
#ScriptVersion[3]
#Title["KurojiN2"]
#Text["KurojiN2"]
#Player[DEFAULT]
#System["./system/Default_System.txt"]
#Background["./BG.txt"]
#include"./Functions/Index.txt"
#include"./SetBoss.txt"
#include"./Shot/AllStarShot_Const.dnh"
#include"./system/Default_Effect.Txt"


let objBoss;
let GCSD=GetCurrentScriptDirectory~"";
let enemy;
let bSpell=false;
let stgx=GetStgFrameWidth()/2;
let stgy=GetStgFrameHeight()/2;
let idle = true;
let atk = false;
let fog = 0;
let objScene=GetEnemyBossSceneObjectID();
let color = [0,0];
@Initialize
{
SetBoss("Doremy",false);
}

@MainLoop
{
	ObjEnemy_SetIntersectionCircleToPlayer(objBoss,ObjMove_GetX(objBoss),ObjMove_GetY(objBoss),18);
	ObjEnemy_SetIntersectionCircleToShot(objBoss,ObjMove_GetX(objBoss),ObjMove_GetY(objBoss),26);
	yield;

}

@Event
{
	alternative(GetEventType())
	case(EV_REQUEST_LIFE)
	{
		SetScriptResult(4200);
	}
	case(EV_REQUEST_TIMER)
	{
		SetScriptResult(55);
	}
		case(EV_REQUEST_SPELL_SCORE)
	{
		SetScriptResult(0);
	}
}

//----------------------------------------------------
task mainTask{
	StartCountDown;
	ObjMove_SetDestAtWeight(objBoss,stgx,120,10,6);
	SetCommonData("Scroll",1);
	SetCommonData("ForceLifebar",1);
	wait(180);
	DamageRateAtFrame(88,5,0);
	TShot1;
	SetCommonData("ForceLifebar",0);
	}

//----------------------------------------------------

task TShot1
{
	while( !Obj_IsDeleted( objBoss )){
	PatternKurojiNon1;	
	wait( 55 );
	PatternKurojiNon1;	
	wait( 18 );
	TMovement( 16, 10, 2 );
	wait( 37 );
	}
}

              task PatternKurojiNon1{ 
              let angle = rand( 0, 360 );
              let r = [ -0.5, 0.5]; 
              let s = r[ round( rand( 0, 1 ))];
              loop( 6 ){

              			let speed = 2.2;
	                                	let way = 4;
                                                	let shote = 55;
			let delay = 0;

			loop( way ){

                      	                	let sx = ObjMove_GetX( objBoss );
                        		let sy = ObjMove_GetY( objBoss );
				
				let sht1 = TShotA2( sx, sy, speed, angle + 24, 0, speed, shote, delay );
				let sht2 = TShotA2( sx, sy, speed, angle + 8, 0, speed, shote, delay );
				let sht3 = TShotA2( sx, sy, speed, angle - 8, 0, speed, shote, delay );
				let sht4 = TShotA2( sx, sy, speed, angle - 24, 0, speed, shote, delay );

				Reflect( sht1, 0, 0, NO_CHANGE );
				Reflect( sht2, 0, 0, NO_CHANGE );
				Reflect( sht3, 0, 0, NO_CHANGE );
				Reflect( sht4, 0, 0, NO_CHANGE );

				angle += 360 / way;

	}
	    PlaySound("LenenShot1",92,0);
	    angle -= s;
                        wait( 3 );

	}

   }

	task Reflect( obj, acceleration, angular, v ){
	while( !Obj_IsDeleted( obj ) && ObjMove_GetX( obj ) > 0 && ObjMove_GetX( obj ) < GetStgFrameWidth && ObjMove_GetY( obj ) > 0 ){ yield; }

   	if(ObjMove_GetX(obj)<0 || ObjMove_GetX(obj)>GetStgFrameWidth)
   	{ ObjMove_AddPatternA2( obj, 0, NO_CHANGE, 180-ObjMove_GetAngle( obj ), acceleration, angular, v ); }

   	if( ObjMove_GetY( obj ) < 0 )
   	{ ObjMove_AddPatternA2( obj, 0, NO_CHANGE, -ObjMove_GetAngle( obj ), acceleration, angular, v ); }


}

	task StartCountDown
	{
		wait((55*60) - (10*60));
		loop(10)
		{
			PlaySound("time",100,0);
			wait(60);
		}

	}	

//----------------------------------------------------

task TEnd{
	while(ObjEnemy_GetInfo(objBoss,INFO_LIFE)>0){yield;}
		EndBoss(0);
		yield;
		CloseScript(GetOwnScriptID());
	}