#東方弾幕風[Single]
#ScriptVersion[3]
#Title["NS1"]
#Text["Blep"]
#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, 50, 450);
	RenderCharacter(objBoss);
	DamageReduction(objBoss, 120);
	
	SetCommonData("ForceLifebar", 1);
	
	ObjMove_SetPosition(objBoss, GetStgFrameWidth/2, GetStgFrameHeight/2-100);
	
	if(GetCommonData("IsStage", false)==false){
	LoadAssets;}
	
	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);
	ObjEnemy_SetIntersectionCircleToShot(objBoss,ObjMove_GetX(objBoss),ObjMove_GetY(objBoss),21);
	ObjEnemy_SetIntersectionCircleToPlayer(objBoss,ObjMove_GetX(objBoss),ObjMove_GetY(objBoss),24);
	yield;
} 

@Finalize {
} 

task Main { 
	let door = Door(GetStgFrameWidth/2, GetStgFrameHeight/2-100);
	wait(120);
	Obj_SetValue(door, "Open", 1);
	PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/creak.wav", 90, 0);
	EnemyMarker(objBoss);
	wait(120);
	SetCommonData("ForceLifebar", 0);
	wait(120*2);
	loop{
	ascent(j in 0..64){
		FireShotA2(BossX+45, BossY+45, 1, 270+j*6, 0.01, 10, KUNAI_GREEN, 20);
		FireShotA2(BossX+45, BossY+45, 1, 270-j*6, 0.01, 10, KUNAI_GREEN, 20);
		FireShotA2(BossX-45, BossY-45, 1, 270+j*6, 0.01, 10, KUNAI_SKY, 20);
		FireShotA2(BossX-45, BossY-45, 1, 270-j*6, 0.01, 10, KUNAI_SKY, 20);
		FireShotA2(BossX-45, BossY+45, 1, 270+j*6, 0.01, 10, KUNAI_ORANGE, 20);
		FireShotA2(BossX-45, BossY+45, 1, 270-j*6, 0.01, 10, KUNAI_ORANGE, 20);
		FireShotA2(BossX+45, BossY-45, 1, 270+j*6, 0.01, 10, KUNAI_PURPLE, 20);
		FireShotA2(BossX+45, BossY-45, 1, 270-j*6, 0.01, 10, KUNAI_PURPLE, 20);
		PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/smbullet.wav", 90, 0);
		wait(3);
	}
	wait(60);
	ascent(i in 0..32){
		ascent(j in 0..6){
		FireShotA2(BossX, BossY, 1, i*6+j*360/6, 0.05, 10, KUNAI_WHITE, 15);
		}
	PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/smbullet.wav", 90, 0);
	wait(2);
	}
	wait(30);
	ascent(i in 0..32){
		ascent(j in 0..6){
		FireShotA2(BossX, BossY, 1, -i*6+j*360/6, 0.05, 10, KUNAI_WHITE, 15);
		}
	PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/smbullet.wav", 90, 0);
	wait(2);
	}
	ObjMove_SetDestAtWeight(objBoss, GetStgFrameWidth/2+rand(-75, 75), GetStgFrameHeight/2-100+rand(-25, 25), 10, 0.5);
	}
}

task end{
    while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0){yield;}
    Obj_Delete(objBoss);
    DeleteShotAll(TYPE_ALL, TYPE_ITEM);
    SetAutoDeleteObject(true);
    CloseScript(GetOwnScriptID());
} 


