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

let objBoss;
let BossX;
let BossY;

@Initialize {
	SummerBG;
	SeasonEffect;
	let door = DoorTransition(GetStgFrameWidth/2, GetStgFrameHeight/2);
	Obj_SetValue(door, "Open", 1);	
	
	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(20);
	PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/gate.wav", 90, 0);
	PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/release.wav", 90, 0);
	wait(60*2);
	Fire;
	loop{
		loop(2){
		let random = rand(0,360);
		let a = 1000;
		let b = 0;
			ascent(j in 0..60*100){
				ascent(i in 0..12){
				FireShotA1(BossX, BossY, 4, i*360/12+(100*sin(a*5)), kunai[0], 10);
				}
			a++;
			PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/smbullet.wav", 90, 0);
			wait(3);
			}
		}
	}
}

	task Fire{
		loop{
		Fire2; ObjMove_SetDestAtWeight(objBoss, GetStgFrameWidth/2+rand(-75, 75), GetStgFrameHeight/2-100+rand(-25, 25), 10, 0.5);
		wait(60*3);
		Fire3; ObjMove_SetDestAtWeight(objBoss, GetStgFrameWidth/2+rand(-75, 75), GetStgFrameHeight/2-100+rand(-25, 25), 10, 0.5);
		wait(60*3);
		}
	}
	
	task Fire2{
	let random = rand(0,360);
		ascent(i in 0..30){
			ascent(j in 0..3){
				ascent(k in 0..3){
				FireShotA1(BossX+50*cos(random+j*360/3+i*9), BossY+50*sin(random+j*360/3+i*9), 1.5, random+j*360/3+i*9, ball[0], 10+7*k);
				}
			}
		PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/smbullet.wav", 90, 0);
		wait(6);
		}
	}
	task Fire3{
	let random = rand(0,360);
		ascent(i in 0..30){
			ascent(j in 0..3){
				ascent(k in 0..3){
				FireShotA1(BossX+50*cos(random+j*360/3-i*9), BossY+50*sin(random+j*360/3-i*9), 1.5, random+j*360/3-i*9, ball[0], 10+7*k);
				}
			}
		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());
} 


