#東方弾幕風[Single]
#ScriptVersion[3]
#Title["And something else."]
#Text["bep!"]
#System["./default_system/Default_System.txt"]
#include "./default_system/MS_Index.txt"

let objBoss;
let BossX;
let BossY;

@Initialize {
	objBoss = ObjEnemy_Create(OBJ_ENEMY_BOSS);
	ObjEnemy_Regist(objBoss);
	
	HitSound(objBoss, 80, 450);
	RenderCharacter(objBoss);
	DamageReduction(objBoss, 120);
	EnemyMarker(objBoss);
	Aura(objBoss, [0, 0, 0]);
	
	SetCommonData("ForceLifebar", 0);
	
	ObjMove_SetDestAtWeight(objBoss, GetStgFrameWidth/2, GetStgFrameHeight/2-150, 5, 4);
	
	if(GetCommonData("IsStage", false)==false){
	OxigenController;
	WorldBG;
	LoadAssets;}
	
	SetPlayerLife(0);
	SetPlayerSpell(0);
	
	Main;
	end;
} 

@Event { 
	alternative(GetEventType())
	case(EV_REQUEST_LIFE){
		SetScriptResult(4000);
     	}
	case(EV_REQUEST_TIMER){
		SetScriptResult(45);
	}
	/*case(EV_REQUEST_SPELL_SCORE){
		SetScriptResult(1000000);
	}*/
} 

@MainLoop {
	BossX = ObjMove_GetX(objBoss);
	BossY = ObjMove_GetY(objBoss);
	if(GetCommonData("Start", false) == true){
	ObjEnemy_SetIntersectionCircleToShot(objBoss,ObjMove_GetX(objBoss),ObjMove_GetY(objBoss),21);
	ObjEnemy_SetIntersectionCircleToPlayer(objBoss,ObjMove_GetX(objBoss),ObjMove_GetY(objBoss),24);
	}
	yield;
} 

@Finalize {
} 

let gAng = 90;

task Main { 
wait(90);
let obj = Bubble(GetPlayerX, GetPlayerY, 1);
PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/bubble.wav", 90, 45);
Destroy(obj);
wait(90);
let path = GetCurrentScriptDirectory ~ "./default_system/img/Ingame/meg.png";
let path2 = GetCurrentScriptDirectory ~ "./default_system/img/Ingame/meg2.png";
SpellCard(210, "Deadly Dance &quot;Fun is Infinite&quot;", [5, 5, 5], path, path2, 25, 100, 1, "Megumi");
wait(60);
Shooting;
Drown;
}

task Drown{
PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/drowningmusic.wav", 80, 0);
loop{
SetCommonData("Stacks",GetCommonData("Stacks",0)-0.590);
yield;
}
}

task Shooting{
wait(50);
let a = 24;
let b = 0;
loop(8*5){
let random = rand(-75, 75);
let random2 = rand(-75, 75);
let random3 = rand(0,360);
	ascent(i in 0..32){
	FireShotA2(BossX+0*cos(random3+i*360/32)+random, BossY+0*sin(random3+i*360/32)+random2, 3, random3+i*360/32, 0.05, 10, FIREBALL_BLACK_ADD, 10);
	}
b++;
if(b == 8){a-=6;}
if(b == 16){a-=2;}
if(b == 24){a-=2;}
PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/smbullet.wav", 35, 0);
wait(a);
}
ascent(i in 0..128){	
FireShotA2(BossX, BossY, 3, i*360/128, 0.05, 10, FIREBALL_BLACK_ADD, 10);
}
}

task Destroy(obj){
wait(210+90+60);
let rad = 1*100;
let random = rand(0,360);
ascent(k in 0..8){
	ascent(i in 0..(32*1*1.5)){
	FireShotA2(GetX(obj)+rad*cos(random+i*360/(32*1*1.5)), GetY(obj)+rad*sin(random+i*360/(32*1*1.5)), 0, random+1+i*360/(32*1*1.5), 0.01+0.01*k, 10, 1107+k, 10);
	}
PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/labullet.wav", 90, 10);
}
Obj_Delete(obj);
}

task end{

    while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0){yield;}
	SetCommonData("bossx", BossX);
	SetCommonData("bossy", BossY);
	SetCommonData("RipNon", 1);
    Obj_Delete(objBoss);
    DeleteShotAll(TYPE_ALL, TYPE_ITEM);
    SetAutoDeleteObject(true);
    CloseScript(GetOwnScriptID());
	
} 


