#東方弾幕風[Single]
#ScriptVersion[3]
#Title["SP2"]
#Text["Cannot find good theme[r]This'll have to do."]
#System["./default_system/Default_System.txt"]
#Background["./default_System/Default_Background.txt"]
#include"./default_system/Default_ShotConst.txt"
#include"./default_system/Default_Index.txt"

let objBoss;
let BossX;
let BossY;

@Initialize {
	SetPlayerClip(126, 12, 510, 468);
	objBoss = ObjEnemy_Create(OBJ_ENEMY_BOSS);
	ObjEnemy_Regist(objBoss);

	ObjMove_SetDestAtWeight(objBoss, GetStgFrameWidth/2, GetStgFrameHeight/2-100, 5, 4);

	Initialization;
	
	Main;
	end;
} 

task Initialization{
	RenderCharacter(objBoss);
	MagicRing(objBoss);
	WaveCircle(true, false, true, 156);
	HitSound(objBoss,60,500);
	TimerCountdown;
	SetArmor(objBoss, [90, 80], 180);
	EnemyMarker(objBoss);
}

@Event { 
	alternative(GetEventType())
	case(EV_REQUEST_LIFE){SetScriptResult(3000);}
	case(EV_REQUEST_TIMER){SetScriptResult(60);}
	case(EV_REQUEST_SPELL_SCORE){SetScriptResult(10000);}
	//case(EV_REQUEST_IS_DURABLE_SPELL){SetScriptResult(true);}
	//case(EV_REQUEST_IS_LAST_SPELL){SetScriptResult(true);}
} 

@MainLoop {
	BossX = ObjMove_GetX(objBoss);
	BossY = ObjMove_GetY(objBoss);
	SetCommonData("BossX", BossX);
	SetCommonData("BossY", BossY);
	ObjEnemy_SetIntersectionCircleToShot(objBoss,ObjMove_GetX(objBoss),ObjMove_GetY(objBoss),21);
	ObjEnemy_SetIntersectionCircleToPlayer(objBoss,ObjMove_GetX(objBoss),ObjMove_GetY(objBoss),24);
	yield;
} 

@Finalize {
} 
task Main { 
wait(90);
let path = GetCurrentScriptDirectory ~ "./default_system/img/Par.png";
let path2 = GetCurrentScriptDirectory ~ "./default_system/img/Par2.png";
SpellCard(180, "Jealousy &quot;Banished to the Depths&quot;", [12, 255, 12], path, path2, 50, 200, 0.5);

ascent(j in 0..6){
let obj = FireShotA1(BossX, BossY, 1, j*360/6, DS_BALL_M_PURPLE, 10);
Trial(obj);
}
PlaySound("labullet", 60, 10);
wait(60*9);
	loop{
		ascent(j in 0..5){
		let obj = FireShotA1(BossX, BossY, 2, j*360/5+GetAngleToPlayer(objBoss), DS_BALL_M_PURPLE, 10);
		Trial(obj);
		}
		PlaySound("labullet", 60, 10);
		wait(60*3);
	}
}

task Trial(obj){
let a = 0;
while(!Obj_IsDeleted(obj)){
ascent(i in 0..4){
FireShotA2(GetX(obj), GetY(obj), 4, ObjMove_GetAngle(obj)+10+a, -0.04, 2, DS_ICE_BLUE, 10+i*5);
FireShotA2(GetX(obj), GetY(obj), 4, ObjMove_GetAngle(obj)-10-a, -0.04, 2, DS_ICE_BLUE, 10+i*5);
PlaySound("spirit", 60, 10+i*5);
}
a+=21;
wait(15);
if(GetY(obj) > GetStageDown){
ascent(i in 0..40){
CreateShotB2(GetX(obj), GetY(obj), rand(-1, 1), rand(-1, -6), 0, 0.04, 10, 10, DS_FIRE_BLUE, 10);
}
PlaySound("labullet", 80, 5);
Obj_Delete(obj);
}
}
}

task end{
    while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0){yield;}
	NotifyEvent(GetStageID, EV_USER_STAGE, [true, true, true, false, false, false]); //smexplosion, smparticles, items, bigexplosion, bigparticles, shake+slow
    Obj_Delete(objBoss);
    DeleteShotAll(TYPE_ALL, TYPE_ITEM);
    SetAutoDeleteObject(true);
    CloseScript(GetOwnScriptID());
} 