#東方弾幕風[Single]
#ScriptVersion[3]
#Title["SP1"]
#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);
	
	EnemyMarker(objBoss);
	HitSound(objBoss, 50, 450);
	RenderCharacter(objBoss);
	DamageReduction(objBoss, 320);
	
	ObjMove_SetDestAtWeight(objBoss, GetStgFrameWidth/2, GetStgFrameHeight/2-100, 10, 4);
	
	if(GetCommonData("IsStage", false)==false){
	LoadAssets;}
	
	Main;
	end;
} 

@Event { 
	alternative(GetEventType())
	case(EV_REQUEST_LIFE){
		SetScriptResult(5000);
     	}
	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 { 
	wait(120);
	let path = GetCurrentScriptDirectory ~ "./default_system/img/Ingame/cutin.png";
	SpellCard(210, "", [255, 60, 60], path, path, 20, 0.75, "Okina");
	loop{
	ascent(j in 0..32){
		ascent(i in 0..4){
			ascent(k in 0..4){
			FireShotA2(BossX+75*cos(j*5+i*360/4), BossY+75*sin(j*5+i*360/4), 2.5, j*7+k*360/4, -0.01, 0.75, kunai[i], 10);
			}
		}
	PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/smbullet.wav", 90, 0);
	wait(2);
	}
	wait(60);
	ascent(k in 0..22){
	FireShotA1(BossX, BossY, 1, GetAngleToPlayer(objBoss)+k*360/22, ORB_L2_WHITE_ADD, 20);
	}
	PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/spirit.wav", 90, 0);
	wait(60);
	ascent(j in 0..32){
		ascent(i in 0..4){
			ascent(k in 0..4){
			FireShotA2(BossX+75*cos(-j*5+i*360/4), BossY+75*sin(-j*5+i*360/4), 2.5, -j*7+k*360/4, -0.01, 0.75,  kunai[i], 10);
			}
		}
	PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/smbullet.wav", 90, 0);
	wait(2);
	}
	wait(60);
	ascent(k in 0..22){
	FireShotA1(BossX, BossY, 1.5, GetAngleToPlayer(objBoss)+k*360/22, ORB_L2_WHITE_ADD, 20);
	}
	PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/spirit.wav", 90, 0);
	wait(60);
	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());
} 


