#TouhouDanmakufu[Single]
#ScriptVersion[3]
#Title["NS4"]
#Text["Baaaaaaaaaap"]
#System["./default_system/Default_System.txt"]
#include "./default_system/MS_Index.txt"


let BossX;
let BossY;
let objBoss;
let appear = false; 


@Initialize {
	objBoss = ObjEnemy_Create(OBJ_ENEMY_BOSS);
	ObjEnemy_Regist(objBoss);
	HitSound(objBoss, 75, 450);
	
	if(GetCommonData("IsStage", false)==true){
	SetCommonData("BossAlpha", 0);
	}
	else{
	MagicRing(objBoss,true);
	SetCommonData("BossAlpha", 255);
	StageBackground;
	appear=true;
	}
	
	RenderCharacter(objBoss);
	ObjMove_SetDestAtWeight(objBoss, GetStgFrameWidth/2, GetStgFrameHeight/2-100, 10, 4);
	mainTask;
	end;
} 

@Event { 
	alternative(GetEventType())
	case(EV_REQUEST_LIFE){
		SetScriptResult(4000);
     	}
	case(EV_REQUEST_TIMER){
		SetScriptResult(105);
	}
	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);
	
	yield;
} 

@Finalize {
} 

task mainTask {
	wait(90);
	let count = 0;
	
	PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/charge.wav", 255);
	ascent(i in 0..10){
	Concentrate(BossX, BossY, i*4, 6, 3, 0.8, "Cherry", 150, -2, [255,255,255]);
	Concentrate(BossX, BossY, -i*4, 6, 3, 0.8, "Cherry", 150, 2, [198, 132, 39]);
	wait(6);
	}
	loop{
	let obj = CreateShotA1(GetStgFrameWidth/2+rand(-350,350), 100+rand(-125,125), 0, 90, VORTEX_ORANGE, 10);
	ObjMove_AddPatternA2(obj, 120, rand(3,4), 90+rand(-15,15), -0.05, 0, 1);
	let obj2 = CreateCurveLaserA1(GetStgFrameWidth/2+rand(-350,350), 100+rand(-125,125) ,0, 90, 35, 10, LASER_ORANGE, 10);
	ObjCrLaser_SetTipDecrement(obj2, 0);
	ObjMove_AddPatternA2(obj2, 60, 3, NO_CHANGE, -0.3, rand(-0.2, 0.2), 1);
	ObjMove_AddPatternA2(obj2, 120, NO_CHANGE, NO_CHANGE, 0.3, rand(-0.5, 0.5), 4);
	PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/smbullet.wav", 90);
	Sound;
	wait(3);
	}
	
	task Sound{
	wait(60);
	PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/laser2.wav", 90);
	}
	}

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