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

let objBoss;
let BossX;
let BossY;

@Initialize {
	AutumnBG;
	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);
	AyaRingus;
	wait(60*4);
	RingusRingus;
}

task RingusRingus{
	loop{
	let random = rand(0,360);
		ascent(j in 0..32){
		FireShotA2(BossX, BossY,7, random+j*360/32, -0.1, 1, KUNAI_RED, 20);
		}
	PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/smbullet.wav", 90, 0);
	wait(45);
	}
}

task AyaRingus{
let random = rand(0,360);
	loop{
	ascent(i in 0..3){
		ascent(j in 0..16){
		FireShotA2(BossX+50*cos(j*360/16), BossY+50*sin(j*360/16), 2, random+i*360/3, 0.05, 10, ORB_L2_ORANGE_ADD, 10);
		}
	}
	PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/smbullet.wav", 90, 0);
	PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/spirit.wav", 90, 0);
	wait(20);
	random+=32;
	}
}

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


