
#ScriptVersion[3]
#Title["KurojiS4"]
#Text["KurojiS4"]
#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",2);
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(80000000);
	}
}

//----------------------------------------------------
task mainTask{
	StartCountDown;
	PlaySound("SpellStart",100,0);
	ObjMove_SetDestAtWeight(objBoss,stgx,130,10,7);
	Cutin("Disaster Card 'End is End'",15,"SHINKI");
	ObjEnemyBossScene_StartSpell(objScene);
	Sound(GCSD ~ "Butterfly.mp3");
	wait(120);
	DamageRateAtFrame(29,5,0);
	TShot1;
	}
//----------------------------------------------------

task TShot1
{
	TheEnd;
	HelpYou;

}


	task HelpYou{
	while( !Obj_IsDeleted( objBoss )){ yield; }
	DeleteShotAll( TYPE_ALL, TYPE_ITEM );
	}

              task TheEnd{ 
              while( !Obj_IsDeleted( objBoss ) ){
                    let speed = 1.6;
              	let angle = rand( 0, 360 );
	loop( 10 ){

			let shote = 300;
	                                	let way = 14;
			let delay = 0;

			loop( way ){

				let sx = ObjMove_GetX( objBoss );
				let sy = ObjMove_GetY( objBoss );
				
				let sht1 = TShotA2( sx, sy, speed, angle, 0, speed, shote, delay );
				ObjShot_SetAutoDelete( sht1, false );
				ObjShot_SetSpellResist( sht1, true );
				Disappear( sht1, 700 );
				ObjMove_AddPatternA3( sht1, 60, 0, 180 + angle, 0, 0, 0, 299 );
				Changeling( 60 );
				ObjMove_AddPatternA3( sht1, 125, 0, NO_CHANGE, rand( 0.006, 0.01 ), 0, rand( 1.6, 2.6 ), 299 );

				angle += 360 / way;
			}
			speed += 0.38;
			angle += 68;
			}
			PlaySound("LenenShot1",92,0);
                        		wait( 472 );

	}
}

	task Changeling( t ){
	wait( t );
	let x1 = GetPlayerX;
	let y1 = GetPlayerY;
	let x2 = ObjMove_GetX( objBoss );
	let y2 = ObjMove_GetY( objBoss );
	yield;
	PlaySound("LenenBulletWave",92,0);	
	ObjMove_SetPosition( objBoss, x1, y1 );
	yield;
	ObjMove_SetPosition( objPlayer, x2, y2 );
	}

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

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