#東方弾幕風[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);
	EnemyMarker(objBoss);
	
	SetCommonData("ForceLifebar", 1);
	SetCommonData("RenderTimer", 0);
	

	ObjMove_SetPosition(objBoss, 0, 0);
	ObjMove_SetDestAtWeight(objBoss, GetCenterX, GetCenterY, 5, 4);
	
	if(GetCommonData("IsStage", false)==false){
	WorldBG;
	LoadAssets;}
	
	Main;
	end;
} 

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

@MainLoop {
	BossX = ObjMove_GetX(objBoss);
	BossY = ObjMove_GetY(objBoss);
	yield;
} 

@Finalize {
}

task Main{
wait(30);
ObjEnemy_SetLife(objBoss, 0);
} 

task end{
    while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0){yield;}
	SetCommonData("BossAlpha",255);
	SetCommonData("ForceLifebar", 0);
	StartSlow(TARGET_ALL, 15);
	PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/death.ogg", 90, 0);
	loop(45){
	ParticleT(BossX, BossY, rand(1, 20), rand(0,360), 1, rand(0,360), "Cherry", [255, 10, 10], 10);
	ParticleT(BossX, BossY, rand(1, 20), rand(0,360), 1, rand(0,360), "Cherry", [155, 10, 155], 10);
	yield;
	}
	SetCommonData("bossx", BossX);
	SetCommonData("bossy", BossY);
	SetCommonData("BossIsDed", 1);
	StopSlow(TARGET_ALL);
    Obj_Delete(objBoss);
    DeleteShotAll(TYPE_ALL, TYPE_ITEM);
    SetAutoDeleteObject(true);
    CloseScript(GetOwnScriptID());
	
} 


