#TouhouDanmakufu[Single]
#ScriptVersion[3]
#Title["NS1"]
#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("ForceLifebar", 1);
	ObjEnemy_SetDamageRate(objBoss, 0, 0);
	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);
	SetCommonData("MusicProgress", 1);
	wait(90);
	SetCommonData("ForceLifebar", 0);
	ObjEnemy_SetDamageRate(objBoss, 100, 100);
	wait(90);
	loop{
	PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/charge.wav", 255);
	attack = true;
	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);
	}
	wait(30);
	PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/laser2.wav", 90);
	ascent(i in 0..6){
	let obj = CreateCurveLaserA1(BossX, BossY ,3, 270-i*16, 35, 10, LASER_ORANGE, 10);
	ObjCrLaser_SetTipDecrement(obj, 0);
	ObjMove_AddPatternA2(obj, 20, NO_CHANGE, NO_CHANGE, -0.3, -2, 1);
	ObjMove_AddPatternA2(obj, 100, NO_CHANGE, NO_CHANGE, 0.3, -0.2, 4);
	}
	wait(60);
	PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/laser2.wav", 90);
	ascent(i in 0..6){
	let obj = CreateCurveLaserA1(BossX, BossY ,3, 270+i*16, 35, 10, LASER_ORANGE, 10);
	ObjCrLaser_SetTipDecrement(obj, 0);
	ObjMove_AddPatternA2(obj, 20, NO_CHANGE, NO_CHANGE, -0.3, 2, 1);
	ObjMove_AddPatternA2(obj, 100, NO_CHANGE, NO_CHANGE, 0.3, 0.2, 4);
	}
	wait(60);
	PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/laser2.wav", 90);
	ascent(i in 0..8){
	let obj = CreateCurveLaserA1(BossX, BossY ,3, 270+i*360/8, 25, 10, LASER_ORANGE, 10);
	ObjCrLaser_SetTipDecrement(obj, 0);
	ObjMove_AddPatternA2(obj, 20, NO_CHANGE, NO_CHANGE, -0.3, 2, 1);
	ObjMove_AddPatternA2(obj, 100, NO_CHANGE, NO_CHANGE, 0.3, 0.2, 4);
	let obj2 = CreateCurveLaserA1(BossX, BossY ,3, 270+i*360/8, 25, 10, LASER_ORANGE, 10);
	ObjCrLaser_SetTipDecrement(obj2, 0);
	ObjMove_AddPatternA2(obj2, 20, NO_CHANGE, NO_CHANGE, -0.3, -2, 1);
	ObjMove_AddPatternA2(obj2, 100, NO_CHANGE, NO_CHANGE, 0.3, -0.2, 4);
	}
	
	ascent(i in 0..32){
	let obj = CreateShotA1(GetPlayerX+rand(-125,125), 100+rand(-125,125), 0, 90, VORTEX_YELLOW, 10);
	let obj2 = CreateShotA1(GetPlayerX+rand(-125,125), 100+rand(-125,125), 0, 90, BALL_M_YELLOW, 10);
	ObjMove_AddPatternA2(obj, 60, rand(3,4), NO_CHANGE, -0.05, 0, 1);
	ObjMove_AddPatternA2(obj2, 60, rand(3,4), NO_CHANGE, -0.05, 0, 1);
	PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/smbullet.wav", 90);
	yield;
	}
	wait(160/2);
	attack = false;
	ObjMove_SetDestAtWeight(objBoss, GetStgFrameWidth/2+rand(-75, 75), GetStgFrameHeight/2-100, 10, 4);
	wait(160/2);
	}
}

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());
} 