#東方弾幕風[Single]
#ScriptVersion[3]
#Title["SP4"]
#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");
	
	Wave;
	loop{
	wait(60*4);
	Shooting(1);
	wait(60*4);
	Shooting(-1);
	}
}

task Shooting(mult){
let random = rand(0,360);
ascent(i in 0..4){
	ascent(j in 0..24){
	FireShotA1(BossX, BossY, 1.5, random+j*360/24+(i*12*mult), ORB_L2_RED_ADD, 10);
	}
PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/labullet.wav", 90, 0);
wait(20);
}
}

task Wave{
let a = 90;
let b = 0;
loop{
let random = rand(0,360);
ascent(j in 0..1){
let obj = FireShotA2(GetPlayerX+(85+20*sin(b))*cos(j*360/36+random), GetPlayerY+(85+20*sin(b))*sin(j*360/36+random), 0.2, a, 0.05, 10, FIREBALL_RED_ADD, 15);
}
PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/smbullet.wav", 90, 0);
wait(3);
a+=2;
b++;
}
}

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


