
#ScriptVersion[3]
#Title["TsurubamiN7"]
#Text["TsurubamiN7"]
#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
{
SetCommonData("Scroll",0);
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(5000);
	}
	case(EV_REQUEST_TIMER)
	{
		SetScriptResult(85);
	}
		case(EV_REQUEST_SPELL_SCORE)
	{
		SetScriptResult(35000000);
	}
}

//----------------------------------------------------
task mainTask{
	SetCommonData("ForceLifebar",1);
	StartCountDown;
	ObjMove_SetDestAtWeight(objBoss,stgx,120,10,10);
	SetCommonData("Scroll",1);
	wait(160);
	TShot1;
	SetCommonData("ForceLifebar",0);
	DamageRateAtFrame(64,0,0);
	yield;
	}

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

task TShot1
{
	if( ObjEnemy_GetInfo( objBoss, INFO_LIFE ) == 1 ){ DeleteShotAll( TYPE_ALL, TYPE_IMMEDIATE ); }
	let r = 70;
	let angle = rand(0,80);
	let dir = 0;
	let s = 1;
                	PatternMonochrome1;
	
	}

             task PatternMonochrome1{ 
             while( !Obj_IsDeleted( objBoss )){
             	let angle2 = rand( 0, 360 ); 
	let x = rand( 30, 50 );
	loop( 15 ){

			let way = 6;
			let speed = 2.4;
			let shote = 97;
			let delay = 0;
			loop( way ){

				let sx = ObjMove_GetX( objBoss );
				let sy = ObjMove_GetY( objBoss );
				
				EEShot( sx, sy, speed, angle2, shote , delay, x, 30, 6, 0);
				angle2 += 360 / way;
			}
                        		//angle2 -= a;
			//a += 0.1;
			PlaySound("LenenShot1",100,0); 
			wait( 5 );
		}
			wait( 0 );
		}
		
	}

task EEShot(x,y,v,angle,color,delay,value,time, how, count)
{
     let obj = CreateShotA1(x,y,v,angle,color,delay);
     //ObjShot_SetAutoDelete( obj, false );
     //DelayDelete( obj, 600 );
     wait(time);
     if(!Obj_IsDeleted(obj) && count != how)
     {
        count += 2;
        EEShot(ObjMove_GetX(obj),ObjMove_GetY(obj),v,angle+value,color,0,value,time, how, count);
        EEShot(ObjMove_GetX(obj),ObjMove_GetY(obj),v,angle-value,color,0,value,time, how, count);
        Obj_Delete(obj);
     }
}

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

	}






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

task SizeCircle
{
	ascent(i in 0..60)
	{
		SetCommonData("CircleSize",sin(i*1.5));
		yield;
	}
}	

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

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