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

let objBoss;
let BossX;
let BossY;

@Initialize {
	SpringBG;
	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{
	Ring1;
	Ring2;
	Spread;
	ObjMove_SetDestAtWeight(objBoss, GetStgFrameWidth/2+rand(-125, 125), GetStgFrameHeight/2-150+rand(-25, 25), 10, 0.5);
	wait(60*4);
	Spread2;
	Ring3;
	Shoot;
	wait(60*2);
	Ring4;
	wait(60);
	}
}

task Shoot{
ascent(j in 0..12){
FireShotA1(BossX, BossY, 0.5+j/4, GetAngleToPlayer(objBoss), ORB_L2_PINK_ADD, 10);
}
PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/labullet.wav", 90, 0);
}

task Spread2{
ascent(k in 0..3){
	ascent(j in 0..16){
	FireShotA1(BossX, BossY, 5-j/4, GetAngleToPlayer(objBoss)+j*(4+k), AMULET_PINK, 10);
	}
	PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/spirit.wav", 90, 0);
	wait(12);
	ascent(j in 0..16){
	FireShotA1(BossX, BossY, 5-j/4, GetAngleToPlayer(objBoss)-j*(4+k), AMULET_PINK, 10);
	}
	PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/spirit.wav", 90, 0);
	wait(12);
}
}

task Spread{
ascent(i in 0..64){
let random = rand(0,360);
	ascent(j in 0..5){
	FireShotA2(BossX, BossY, 4-i/25+rand(-3, 2), j*360/5+i*15+random, 0.01, 10, RICE_S_PINK, 10);
	}
PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/smbullet.wav", 90, 0);
wait(2);
}
}

task Ring1{
ascent(j in 0..4){
ascent(i in 0..64){
FireShotA1(BossX, BossY, 2+j/3, i*360/64, AMULET_PINK, 10);
}
}
PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/spirit.wav", 90, 0);
}

task Ring2{
ascent(j in 0..4){
ascent(i in 0..42){
FireShotA1(BossX, BossY, 1+j/15, i*360/42+j*2, AMULET_WHITE, 10);
}
}
PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/spirit.wav", 90, 0);
}

task Ring3{
ascent(j in 0..4){
ascent(i in 0..32){
FireShotA1(BossX, BossY, 2+j/3, i*360/32, RICE_S_WHITE, 10);
}
}
PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/smbullet.wav", 90, 0);
}

task Ring4{
ascent(j in 0..6){
ascent(i in 0..64){
FireShotA1(BossX, BossY, 2+j/3, i*360/64+j*360/128, RICE_S_PINK, 10);
}
}
PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/smbullet.wav", 90, 0);
}

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


