
#ScriptVersion[3]
#Title["KurojiN1"]
#Text["KurojiN1"]
#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;
	SetCommonData("Scroll",1);
	SetForbidPlayerShot( false );
	SetForbidPlayerSpell( false );
	wait(180);
	DamageRateAtFrame( 178, 5, 0 );
	TShot1;
	SetCommonData("ForceLifebar",0);
	}

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

task TShot1
{
	while( !Obj_IsDeleted( objBoss )){
	PatternKurojiNon1;
	wait( 80 );
	PatternKurojiNon3;
	ObjMove_SetDestAtWeight(objBoss,GetStgFrameWidth / 4 + rand( -10, 10 ),ObjMove_GetY( objBoss ) + rand( -2, 2 ),12,4);
	wait( 80 );
	PatternKurojiNon2;
	wait( 80 );
	PatternKurojiNon3;
	ObjMove_SetDestAtWeight(objBoss,GetStgFrameWidth / 4*3 + rand( -10, 10 ),ObjMove_GetY( objBoss ) + rand( -2, 2 ),12,4);
	wait( 80 );
	}
}

              task PatternKurojiNon1{ 
              let angle2 = 190;
              loop( 8 ){
              let angle = angle2;
              let speed = 4.1;
              loop( 6 ){

	                                	let way = 1;
                                                	let shote = 51;
			let delay = 0;
			if( GetPlayerY < ObjMove_GetY( objBoss )){ angle = GetAngleToPlayer( objBoss ); }

			loop( way ){

                      	                	let sx = ObjMove_GetX( objBoss );
                        		let sy = ObjMove_GetY( objBoss );
				
				let sht1 = TShotA2( sx, sy, speed, angle + 10.5, 0, speed, shote, delay );
				let sht2 = TShotA2( sx, sy, speed, angle + 7, 0, speed, shote, delay );
				let sht3 = TShotA2( sx, sy, speed, angle + 3.5, 0, speed, shote, delay );
				let sht7 = TShotA2( sx, sy, speed, angle, 0, speed, shote, delay );
				let sht4 = TShotA2( sx, sy, speed, angle - 3.5, 0, speed, shote, delay );
				let sht5 = TShotA2( sx, sy, speed, angle - 7, 0, speed, shote, delay );
				let sht6 = TShotA2( sx, sy, speed, angle - 10.5, 0, speed, shote, delay );

				angle += 360 / way;
			
			}
			speed -= 0.42;
			PlaySound("LenenShot1",92,0);

	}
	    angle2 -= 11;
                        wait( 9 );

	}

   }

              task PatternKurojiNon2{ 
              let angle2 = -10;
              loop( 8 ){
              let angle = angle2;
              let speed = 4.5;
              loop( 6 ){

	                                	let way = 1;
                                                	let shote = 51;
			let delay = 0;
			if( GetPlayerY < ObjMove_GetY( objBoss )){ angle = GetAngleToPlayer( objBoss ); }

			loop( way ){

                      	                	let sx = ObjMove_GetX( objBoss );
                        		let sy = ObjMove_GetY( objBoss );
				
				let sht1 = TShotA2( sx, sy, speed, angle + 10.5, 0, speed, shote, delay );
				let sht2 = TShotA2( sx, sy, speed, angle + 7, 0, speed, shote, delay );
				let sht3 = TShotA2( sx, sy, speed, angle + 3.5, 0, speed, shote, delay );
				let sht7 = TShotA2( sx, sy, speed, angle, 0, speed, shote, delay );
				let sht4 = TShotA2( sx, sy, speed, angle - 3.5, 0, speed, shote, delay );
				let sht5 = TShotA2( sx, sy, speed, angle - 7, 0, speed, shote, delay );
				let sht6 = TShotA2( sx, sy, speed, angle - 10.5, 0, speed, shote, delay );

				angle += 360 / way;
			
			}
			speed -= 0.48;
			PlaySound("LenenShot1",92,0);

	}
	    angle2 += 11;
                        wait( 9 );

	}

   }

              task PatternKurojiNon3{ 
              loop( 80 ){

	                                let way = round( rand( 1, 3 ));
                                                    let shote = 39;
		            let delay = 0;

			loop( way ){

              			let angle = rand( 0, 360 );
                                                    	let speed = rand( 2.5, 3.5 );
                      	                	let sx = ObjMove_GetX( objBoss );
                        		let sy = ObjMove_GetY( objBoss );
				
				let sht1 = TShotA2( sx, sy, speed, angle, 0, speed, shote, delay );

				angle += 360 / way;

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

	}

   }	

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

	}