#東方弾幕風[Single]
#ScriptVersion[3]
#Title["SP6"]
#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-120, 10, 4);
	
	if(GetCommonData("IsStage", false)==false){
	LoadAssets;}
	
	Main;
	end;
} 

@Event { 
	alternative(GetEventType())
	case(EV_REQUEST_LIFE){
		SetScriptResult(5000);
     	}
	case(EV_REQUEST_TIMER){
		SetScriptResult(55);
	}
	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 path = GetCurrentScriptDirectory ~ "./default_system/img/Ingame/cutin.png";
	SpellCard(210, "", [255, 60, 60], path, path, 20, 0.75, "Okina");
	
	
	Shoot;
	loop{
	ascent(j in 0..80){
	let random = truncate(rand(-2, 2));
	let obj = FireShotA2(rand(0, GetStageRight), -10, 5, 90, -0.1, 1.5, RICE_S_PINK_ADD, 10);
	Red(obj, random, j);
	PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/smbullet.wav", 90, 0);
	yield;
	}
	wait(120);
	}
	
	task Red(obj, random, j){
	wait(180-j);
	Angular(obj, 1*random);
	PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/spirit.wav", 90, 0);
	wait(45);
	Angular(obj, 1*random*-1);
	}
	
	task Shoot{
	wait(120*2);
	loop{
	let random = rand(-2, 2);
		ascent(j in 1..12){
		let obj = FireShotA1(BossX, BossY, 3, GetAngleToPlayer(objBoss)+90+j*360/24+random, RICE_S_PURPLE, 10);
		ShotReflect(obj, 0, 1, 0, 0, 1);
		}
	PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/smbullet.wav", 90, 0);
	wait(6);
	}
	}
}

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


