#東方弾幕風[Single]
#ScriptVersion[3]
#Title["NS5"]
#Text["Blep"]
#System["./default_system/Default_System.txt"]
#include "./default_system/MS_Index.txt"

let objBoss;
let BossX;
let BossY;

@Initialize {
	SummerBG;
	SeasonEffect;
	objBoss = ObjEnemy_Create(OBJ_ENEMY_BOSS);
	ObjEnemy_Regist(objBoss);
	
	EnemyMarker(objBoss);
	HitSound(objBoss, 50, 450);
	RenderCharacter(objBoss);
	DamageReduction(objBoss, 120);
	
	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(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 { 
	wait(60*2);
	loop{
		loop(5){
		Ring1;
		PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/smbullet.wav", 90, 0);
		wait(30);
		}
	ObjMove_SetDestAtWeight(objBoss, GetStgFrameWidth/2+rand(-75, 75), GetStgFrameHeight/2-100+rand(-25, 25), 10, 0.5);
	Spiral;
	wait(120);
	Ring2;
	wait(90);
	Ring2;
	wait(90);
	Ring2;
	wait(90);
	}
}

task Ring2{
let random = rand(0,360);
ascent(j in 0..48){
FireShotA1(BossX, BossY, 2.5, j*360/48+random, ORB_S_SKY, 10);
}
PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/smbullet.wav", 90, 0);
wait(10);
ascent(j in 0..64){
let obj = FireShotA2(BossX, BossY, 6, j*360/64+random, -0.1, 0, ICE_SKY, 10);
Red(obj);
}
PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/smbullet.wav", 90, 0);
wait(10);
random = rand(0,360);
ascent(j in 0..48){
FireShotA1(BossX, BossY, 2.5, j*360/48+random, ORB_S_SKY, 10);
}
PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/smbullet.wav", 90, 0);

task Red(obj){
wait(60);
ObjMove_AddPatternA2(obj, 0, 0, GetAngleToPlayer(obj), 0.05, 0, 10);
PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/spirit.wav", 90, 0);
}
}

task Spiral{
let random = rand(0,360);
ascent(i in 0..64){
	ascent(j in 0..5){
	FireShotA1(BossX, BossY, 6-i/15, j*360/5+i*15+random, ICE_BLUE, 10);
	FireShotA2(BossX, BossY, 0, rand(0,360), 0.05, 4, ICE_SKY, 10);
	}
PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/smbullet.wav", 90, 0);
wait(2);
}
}

task Ring1{
let random = rand(0,360);
ascent(j in 0..48){
FireShotA1(BossX, BossY, 2.5, j*360/48+random, ORB_S_SKY, 10);
FireShotA1(BossX, BossY, 3, j*360/48+random, ORB_S_GREEN, 10);
}
}

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


