
#ScriptVersion[3]
#Title["KurojiS3"]
#Text["KurojiS3"]
#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 action = false;
let objScene=GetEnemyBossSceneObjectID();
let color = [276,277,278];
let color2 = [51,53,55];
let dcolor = [308,309,310];
@Initialize
{
SetBoss("Doremy",true);
SetCommonData("Life",3);
SetCommonData("Bomb",1);
}

@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(1250);
	}
	case(EV_REQUEST_TIMER)
	{
		SetScriptResult(60);
	}
		case(EV_REQUEST_SPELL_SCORE)
	{
		SetScriptResult(70000000);
	}
}

//----------------------------------------------------
task mainTask{
	StartCountDown;
	PlaySound("SpellStart",100,0);
	ObjMove_SetDestAtWeight(objBoss,stgx,140,10,7);
	Cutin("Return 'Maelstorm of Reconsideration'",15,"SHINKI");
	ObjEnemyBossScene_StartSpell(objScene);
	wait(120);
	DamageRateAtFrame(23,5,0);
	TShot1;
	}
//----------------------------------------------------

task TShot1
{
	Boomerang1;
	wait( 120 );
	Boomerang2;
	wait( 300 );
	Boomerang3;
}

             task TWarnShotA1( sx, sy, angle, length, delay ){ 
	Warning( sx, sy, angle, length, delay );
	wait( delay );
	PatternDelayKnife( sx, sy, angle );
	}

             task PatternDelayKnife( sx, sy, angle ){ 
             loop( 1 ){

                                                    let speed = 12.5;
	                                let way = 1;
                                                    let shote = 300;
		            let delay = 0;

			loop( way ){
				
				let sht1 = TShotA2( sx, sy, speed, angle, 0, speed, shote, delay );
				ObjShot_SetSpellResist( sht1, true );

				angle += 360 / way;

			}
			PlaySound("LenenShot1",92,0);
	}
	}

	task Warning( sx, sy, angle, length, delay ){
	let sht0 = CreateStraightLaserA1( sx, sy, angle, length, 4, delay, 1003, 0 );
	ObjShot_SetIntersectionEnable( sht0, false );
	wait( delay );
	ObjShot_SetIntersectionEnable( sht0, false );
	descent( i in 0..4 ){
	ObjLaser_SetRenderWidth( sht0, i );
	wait( 2 );
	}
	Obj_Delete( sht0 );
	}

              task Boomerang3{ 
              while( !Obj_IsDeleted( objBoss ) ){
              let sx1 = ObjMove_GetX( objBoss );
              let sy1 = ObjMove_GetY( objBoss );
              let angle1 = rand( 0, 360 );
              let angle2 = angle1;
              PlaySound("LenenLaserDelayShort",92,0);
              loop( 5 ){

	                                	let way = 5;
			let delay = 90;
			let length = 550; 

			loop( way ){
				
				TWarnShotA1( sx1, sy1, angle1, length, delay );
				TWarnShotA1( sx1, sy1, angle2, length, delay );

				angle1 += 360 / way;
				angle2 += 360 / way;
			}
			angle1 += 3.8;
			angle2 -= 3.8;
                        		wait( 4 );

	}
	wait( 180 );
	}
}

              task Boomerang1{ 
              while( !Obj_IsDeleted( objBoss ) ){

			let shote = 302;
	                                	let way = 27;
			let delay = 20;
                                                	let speed = 1.5;
              			let angle = rand( 0, 360 );

			loop( way ){

				let sx = ObjMove_GetX( objBoss );
				let sy = ObjMove_GetY( objBoss );
				
				let sht1 = TShotA2( sx, sy, speed + 10, angle, -0.8, speed, shote, delay );
				ObjShot_SetSpellResist( sht1, true );
				ObjShot_SetAutoDelete( sht1, false );
				Ang( sht1, 0.55, 550 );
				Boom( sht1, 6 );
				Disappear( sht1, 1100 );


				angle += 360 / way;
			}

			TMovement( 60, 10, 4 );
			PlaySound("LenenShot1",92,0);
                        		wait( 240 );

	}
}

              	task Boomerang2{               
	while( !Obj_IsDeleted( objBoss ) ){
			let shote = 301;
	                                	let way = 27;
			let delay = 20;
                                                	let speed = 1.5;
              			let angle = rand( 0, 360 );

			loop( way ){

				let sx = ObjMove_GetX( objBoss );
				let sy = ObjMove_GetY( objBoss );
				
				let sht1 = TShotA2( sx, sy, speed + 10, angle, -0.8, speed, shote, delay );
				ObjShot_SetSpellResist( sht1, true );
				ObjShot_SetAutoDelete( sht1, false );
				Ang( sht1, -0.55, 550 );
				Boom( sht1, -6 );
				Disappear( sht1, 1100 );

				angle += 360 / way;
			}
			TMovement( 60, 10, 4 );
			PlaySound("LenenShot1",92,0);
                        		wait( 240 );

	}
}

task Disappear( obj, t ){
wait( t );
Obj_Delete( obj );
}

task Ang( obj, acc, time ){
ObjMove_SetAngularVelocity( obj, acc );
wait( time );
ObjMove_SetAngularVelocity( obj, 0 );
}

task Boom( obj, rate ){
let b = 0;
while( !Obj_IsDeleted( obj )){
ObjRender_SetAngleZ( obj, ObjMove_GetAngle( obj ) + b );
b+= rate;
yield;
}
}

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

	}

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

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