
#ScriptVersion[3]
#Title["TsurubamiS3"]
#Text["TsurubamiS3"]
#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",1);
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(2200);
	}
	case(EV_REQUEST_TIMER)
	{
		SetScriptResult(90);
	}
		case(EV_REQUEST_SPELL_SCORE)
	{
		SetScriptResult(30000000);
	}
}

//----------------------------------------------------
task mainTask{
	StartCountDown;
	PlaySound("SpellStart",100,0);
	ObjMove_SetDestAtWeight(objBoss,stgx,110,10,7);
	Cutin("'Monochrome King'",15,"SHINKI");
	ObjEnemyBossScene_StartSpell(objScene);
	wait( 160 );
	TShot1;
	}
//----------------------------------------------------

task TShot1
{
	try;
	PatternStorm;
	wait( 280 );
	DamageRateAtFrame(60,0,0);
	PatternBlack;
}

	task try{
	while( ObjEnemy_GetInfo( objBoss, INFO_LIFE ) > 1 ){ yield; }
	DeleteShotAll( TYPE_ALL, TYPE_IMMEDIATE );
	}

	task PatternBlack1( angle ){
	loop( 1 ){

                                                    		let shote = 275;
		            		let delay = 0;

		            		let speed = 2.4;
                      	                    	let sx = ObjMove_GetX( objBoss );
                        			let sy = ObjMove_GetY( objBoss );
				
				let sht1 = TShotA2( sx, sy, speed, angle, 0, speed, shote, delay );
				PlaySound("LenenShot1",80,0);
				wait( 10 );

				let sht2 = TShotA2( sx, sy, speed, angle + 5, 0, speed, shote, delay );
				let sht3 = TShotA2( sx, sy, speed, angle, 0, speed, shote, delay );
				let sht4 = TShotA2( sx, sy, speed, angle - 5, 0, speed, shote, delay );
				PlaySound("LenenShot1",80,0);
				wait( 10 );

				let sht5 = TShotA2( sx, sy, speed, angle + 10, 0, speed, shote, delay );
				let sht6 = TShotA2( sx, sy, speed, angle + 5, 0, speed, shote, delay );
				let sht7 = TShotA2( sx, sy, speed, angle, 0, speed, shote, delay );
				let sht8 = TShotA2( sx, sy, speed, angle - 5, 0, speed, shote, delay );
				let sht9 = TShotA2( sx, sy, speed, angle - 10, 0, speed, shote, delay );
				PlaySound("LenenShot1",80,0);
				wait( 10 );

				let sht10 = TShotA2( sx, sy, speed, angle + 5, 0, speed, shote, delay );
				let sht11 = TShotA2( sx, sy, speed, angle, 0, speed, shote, delay );
				let sht12 = TShotA2( sx, sy, speed, angle - 5, 0, speed, shote, delay );
				PlaySound("LenenShot1",80,0);
				wait( 10 );

				let sht13 = TShotA2( sx, sy, speed, angle, 0, speed, shote, delay );
				PlaySound("LenenShot1",80,0);

		}
	}

	task PatternBlack{
	let angle = 90;
	while( !Obj_IsDeleted( objBoss )){
		let way = 8;
		loop( way ){
			PatternBlack1( angle );
			angle += 360/way;
			}
		angle += 45/2;
		wait( 50 );
		}
	}

             task PatternStorm{
	while( !Obj_IsDeleted( objBoss )){
             PlaySound("monostart",92,0);
             MapleExplode2(ObjMove_GetX( objBoss ),ObjMove_GetY( objBoss ),1,"WHITE");
             wait( 1 );
             PlaySound("monodeclare",92,0);
             let angle1 = 0;
             let angle2 = 180;
             DelaySoundPlay2( 100 );
             DelaySoundPlay( 160 );
             loop( 60 ){

                                                    let speed = 30;
	                                let way = 5;
                                                    let shote = 807;
		            let delay = 0;

			loop( way ){

                      	                    let sx = ObjMove_GetX( objBoss );
                        		let sy = ObjMove_GetY( objBoss );
			
				let sht1 = CreateLooseLaserA1( sx, sy, speed, angle1, 120, 20, shote, delay );
				ObjRender_SetBlendType( sht1, BLEND_ALPHA );
				ObjRender_SetColor( sht1, 0, 0, 0 );
				ObjMove_AddPatternA2( sht1, 5, 0, NO_CHANGE, 0, 0, 0 );
				SetAngle( sht1, 160, 20 );
				ObjShot_SetIntersectionEnable( sht1, false );
				NotifyEventAll( EV_USER + 40, [ sht1, delay ] );

				let sht2 = CreateLooseLaserA1( sx, sy, speed, angle2, 120, 20, shote, delay );
				ObjMove_AddPatternA2( sht2, 5, 0, NO_CHANGE, 0, 0, 0 );
				SetAngle( sht2, 160, 20 );
				ObjShot_SetIntersectionEnable( sht2, false );
				NotifyEventAll( EV_USER + 40, [ sht2, delay ] );

				let sht3 = TShotA2( sx, sy, speed, angle1, 0, speed, 724, 0 );
				ObjRender_SetAlpha( sht3, 0 );
				ObjMove_AddPatternA2( sht3, 5, 0, NO_CHANGE, 0, 0, 0 );
				SetAngle( sht3, 160, 20 );
				ObjShot_SetSpellResist( sht3, true );
				NotifyEventAll( EV_USER + 40, [ sht3, delay ] );

				let sht4 = TShotA2( sx, sy, speed, angle2, 0, speed, 724, 0 );
				ObjRender_SetAlpha( sht4, 0 );
				ObjMove_AddPatternA2( sht4, 5, 0, NO_CHANGE, 0, 0, 0 );
				SetAngle( sht4, 160, 20 );
				ObjShot_SetSpellResist( sht3, true );
				NotifyEventAll( EV_USER + 40, [ sht4, delay ] );

				angle1 += 360 / way;
				angle2 += 360 / way;

			}
			angle1 += 7;
			angle2 -= 7;
			PlaySound("LenenShot1",92,0);
                    		if( wait( 2 ) ){ return; }

	}
                    		if( wait( 320 ) ){ return; }

	}
	}
	task SetAngle( obj, t, speed ){
	wait( t );
	ObjLaser_SetLength( obj, 200 );
	ObjMove_AddPatternA2( obj, 0, speed, GetAngleToPlayer( obj ), 0, 0, speed );
	}

	task DelaySoundPlay( t ){
	wait( t );
	PlaySound("mono",100,0);
	wait( 50 );
	PlaySound("mono",100,0);
	}

	task DelaySoundPlay2( t ){
	wait( t );
	maple4( objBoss );
	PlaySound("monocharge",100,0);
	wait( 25 );
	maple4( objBoss );
	PlaySound("monocharge",100,0);
	}

	task StartCountDown
	{
		wait((90*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());
	}