#東方弾幕風[Single]
#ScriptVersion[3]
#Title["System"]
#Text["A new System is in order"]
#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;
}

@Event { 
	alternative(GetEventType())
	case(EV_REQUEST_LIFE){SetScriptResult(255);}
	case(EV_REQUEST_TIMER){SetScriptResult(45);}
	case(EV_REQUEST_SPELL_SCORE){SetScriptResult(2);}
	//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 { 
loop(120){yield;}
//Attack(60);
//let objScene = GetEnemyBossSceneObjectID();
//ObjEnemyBossScene_StartSpell(objScene);
let path = GetCurrentScriptDirectory ~ "./default_system/img/Par.png";
let path2 = GetCurrentScriptDirectory ~ "./default_system/img/Par2.png";
SpellCard(180, "Green Sign &quot;Green&quot;", [12, 255, 12], path, path2, 50, 200, 0.5);


loop{
Attack(90*2);
PlaySound("chargelong",60,0);
ascent(i in 0..45){
Concentrate(BossX, BossY, i*360/5, 360*sin(i), 5, 150*sin(i*2+90), 4, 0.5, "Cherry", rand(0,360), [25, 255, 25], 7);
loop(2){yield;}
}
PlaySound("charge",60,0);
ascent(i in 0..2){
Vortex(BossX, BossY, 0.1, 0.06+i/50, 255, -3, [0, 255, 12], 6+i);
}
ascent(i in 0..45){
Particle(BossX, BossY, rand(1, 8), rand(0,360), 0.5, rand(0,360), "vortex", [0, 255, 12], 4);
}
ascent(i in 0..5){
Vortex(BossX, BossY, 2+0.5*i, -0.05, 255, -4, [0, 255, 12], 1+i);
}
loop(60){yield;}
PlaySound("explode",70,0);
ascent(i in 0..2){
Vortex(BossX, BossY, 0.1, 0.06+i/50, 255, -3, [0, 255, 12], 6+i);
}
ascent(i in 0..45){
Particle(BossX, BossY, rand(1, 8), rand(0,360), 0.5, rand(0,360), "Cherry", [0, 255, 12], 4);
}
Pattern;
loop(60*5){yield;}
}
}

task Pattern{
	loop(1){
	let ran = rand(0,360);
	ascent(i in 0..32){
		ascent(k in 0..5){
			let a = CreateStraightLaserA1(BossX+i*16, BossY, ran+k*360/5-i*i/5, 500, 15, 60, DS_RICE_M_GREEN, 30+i*5);
			let b = CreateStraightLaserA1(BossX-i*16, BossY, ran+k*360/5+i*i/5, 500, 15, 60, DS_RICE_M_GREEN, 30+i*5);
			Length(a, 500, 60);
			Length(b, 500, 60);
			Colorization(a, 125);
			Colorization(b, 125);
		}
	PlaySound("smbullet",60,30+i*2);
	loop(5){yield;}
	}
	loop(180){yield;}
	}
}

task end{
    while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0){yield;}
	StartSlow(TARGET_ALL, 15);
	PlaySound("death",90,0);
	loop(45){
	Particle(BossX, BossY, rand(1, 20), rand(0,360), 0.7, rand(0,360), "Cherry", [255, 255, 255], 10);
	Particle(BossX, BossY, rand(1, 20), rand(0,360), 0.4, rand(0,360), "Cherry", [25, 255, 25], 10);
	yield;
	}
	StopSlow(TARGET_ALL);
	NotifyEvent(GetStageID, EV_USER_STAGE, [false, false, true, true, true, true]); //smexplosion, smparticles, items, bigexplosion, bigparticles, shake+slow
    Obj_Delete(objBoss);
    DeleteShotAll(TYPE_ALL, TYPE_ITEM);
    SetAutoDeleteObject(true);
    CloseScript(GetOwnScriptID());
} 