
#ScriptVersion[3]
#Title["KurojiS5"]
#Text["KurojiS5"]
#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);
}

@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(70);
	}
		case(EV_REQUEST_SPELL_SCORE)
	{
		SetScriptResult(90000000);
	}
}

//----------------------------------------------------
task mainTask{
	SetCommonData("ForceLifebar",1);
	StartCountDown;
	PlaySound("SpellStart",100,0);
	ObjMove_SetDestAtWeight(objBoss,stgx,100,10,7);
	wait( 120 );
	SetCommonData("Scroll",1);
	SetCommonData("ForceLifebar",0);
	Cutin("'The Eight-Head Summer Storm'",15,"SHINKI");
	ObjEnemyBossScene_StartSpell(objScene);
	wait(120);
	DamageRateAtFrame(18,0,0);
	TShot1;
	wait(1200);
	}
//----------------------------------------------------

task TShot1
{
	PatternBlack;

}

		task PatternBlack{ 
		let angle1 = rand( 0, 360 );
		let t = 80;
                                	while( !Obj_IsDeleted( objBoss )){

                                                	let speed1 = 0;
                                                	let speed = 2;
			let acc = 0.1;
			let way = 8;
			let delay = 20;
			let shote = 37;

			loop( way ){

                                                	let r1 = 20*0;
                                                	let r2 = 20*1;
                                                	let r3 = 20*2;
                                                	let r4 = 20*3;
                                                	let r5 = 20*4;
			let r6 = 70;
			let r7 = 65;
                                                
			let sx1 = ObjMove_GetX( objBoss ) + r1*cos( angle1 );
			let sy1 = ObjMove_GetY( objBoss ) + r1*sin( angle1 );
			let sx2 = ObjMove_GetX( objBoss ) + r2*cos( angle1 );
			let sy2 = ObjMove_GetY( objBoss ) + r2*sin( angle1 );
			let sx3 = ObjMove_GetX( objBoss ) + r3*cos( angle1 );
			let sy3 = ObjMove_GetY( objBoss ) + r3*sin( angle1 );
			let sx4 = ObjMove_GetX( objBoss ) + r4*cos( angle1 );
			let sy4 = ObjMove_GetY( objBoss ) + r4*sin( angle1 );
			let sx5 = ObjMove_GetX( objBoss ) + r5*cos( angle1 );
			let sy5 = ObjMove_GetY( objBoss ) + r5*sin( angle1 );

			let sx6 = ObjMove_GetX( objBoss ) + r6*cos( angle1 + 15 );
			let sy6 = ObjMove_GetY( objBoss ) + r6*sin( angle1 + 15 );
			let sx7 = ObjMove_GetX( objBoss ) + r7*cos( angle1 + 33 );
			let sy7 = ObjMove_GetY( objBoss ) + r7*sin( angle1 + 33 );
			let sx8 = ObjMove_GetX( objBoss ) + r6*cos( angle1 - 15 );
			let sy8 = ObjMove_GetY( objBoss ) + r6*sin( angle1 - 15 );
			let sx9 = ObjMove_GetX( objBoss ) + r7*cos( angle1  - 33 );
			let sy9 = ObjMove_GetY( objBoss ) + r7*sin( angle1 - 33 );

			    let sht1 = TShotA2( sx1, sy1, speed1, angle1, acc, speed, shote, delay );
			    let sht2 = TShotA2( sx2, sy2, speed1, angle1, acc, speed, shote, delay );
			    let sht3 = TShotA2( sx3, sy3, speed1, angle1, acc, speed, shote, delay );
			    let sht4 = TShotA2( sx4, sy4, speed1, angle1, acc, speed, shote, delay );
			    let sht5 = TShotA2( sx5, sy5, speed1, angle1, acc, speed, shote, delay );
			    let sht6 = TShotA2( sx6, sy6, speed1, angle1, acc, speed, shote, delay );
			    let sht7 = TShotA2( sx7, sy7, speed1, angle1, acc, speed, shote, delay );
			    let sht8 = TShotA2( sx8, sy8, speed1, angle1, acc, speed, shote, delay );
			    let sht9 = TShotA2( sx9, sy9, speed1, angle1, acc, speed, shote, delay );

			    EdgeWarpingC( sht1, 1 );
			    EdgeWarpingC( sht2, 1 );
			    EdgeWarpingC( sht3, 1 );
			    EdgeWarpingC( sht4, 1 );
			    EdgeWarpingC( sht5, 1 );
			    EdgeWarpingC( sht6, 1 );
			    EdgeWarpingC( sht7, 1 );
			    EdgeWarpingC( sht8, 1 );
			    EdgeWarpingC( sht9, 1 );
				
                                                                ObjShot_SetSpellResist( sht1, true );
                                                                ObjShot_SetSpellResist( sht2, true );
                                                                ObjShot_SetSpellResist( sht3, true );
                                                                ObjShot_SetSpellResist( sht4, true );
                                                                ObjShot_SetSpellResist( sht5, true );
                                                                ObjShot_SetSpellResist( sht6, true );
                                                                ObjShot_SetSpellResist( sht7, true );
                                                                ObjShot_SetSpellResist( sht8, true );
                                                                ObjShot_SetSpellResist( sht9, true );

			    angle1 += 360 / way;

			}
			angle1 += 13.8;
			PlaySound("LenenShot1",92,0);
            			if( wait( 45 ) ){ return; }

	}

   }

task EdgeWarpingC( obj, time )
{
        let count = 0;
        while( !Obj_IsDeleted( obj ))
        {
            if( count == time ){ break; }

            if( ObjMove_GetX( obj ) < 0 ){ ObjMove_SetX(obj, GetStgFrameWidth );
			          ObjShot_SetGraphic( obj, 39 );
			          yield;
			          count++;}

            if( ObjMove_GetX( obj ) > GetStgFrameWidth ){ ObjMove_SetX( obj, 0 );
					      ObjShot_SetGraphic( obj, 35 );
					      yield;
					      count++;}
            yield;
        }
}

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