#東方弾幕風[Single]
#ScriptVersion[3]
#Title["NS2"]
#Text["Time to begin twisting it[r]even more."]
#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(40);}
	//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 {
} 

/*
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);
*/


task Main { 
wait(120);

let a = 1;
	loop{
	Attack(60);
		ascent(i in 0..7){
				ascent(j in 0..32){
				let obj = FireShotA2(BossX, BossY-25, 5-i/3, j*360/32+(i*4*a), -0.06-i*0.001, 0, DS_RICE_S_BLUE, 10);
				ObjMove_AddPatternA2(obj, 90+i*30, 0, j*360/32+(i*4*a), 0.25, 0, 2);
				}
				ascent(j in 0..32){
				let obj = FireShotA2(BossX, BossY-25, 5-i/3, j*360/32+(i*4*a), -0.06-i*0.001, 0, DS_RICE_S_YELLOW, 10);
				ObjMove_AddPatternA2(obj, 90+i*30, 6, j*360/32+(i*4*a)+120, -0.05, 0, 1);
				}
				ascent(j in 0..32){
				let obj = FireShotA2(BossX, BossY-25, 5-i/3, j*360/32+(i*4*a), -0.06-i*0.001, 0, DS_RICE_S_YELLOW, 10);
				ObjMove_AddPatternA2(obj, 90+i*30, 6, j*360/32+(i*4*a)-120, -0.05, 0, 1);
				}
		PlaySound("smbullet", 60, 10);
		PlaySound("spirit", 60, 90+i*30);
		wait(2);
		}
	a = -a;
	wait(60*7);
	}
}

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());
} 