
#ScriptVersion[3]
#Title["TsurubamiN4"]
#Text["TsurubamiN4"]
#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,110,10,10);
	SetCommonData("Scroll",1);
	wait(160);
	TShot1;
	SetCommonData("ForceLifebar",0);
	DamageRateAtFrame(66,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{ 
             let Wait = 90;
             while( !Obj_IsDeleted( objBoss )){
             let a = 45;
             loop( 3 ){
             loop( 1 ){

		            let angle = GetAngleToPlayer( objBoss ) + a;
                                                    let speed = 40;
	                                let way = 1;
                                                    let shote = 129;
		            let delay = 0;

			loop( way ){

                      	                    let sx = ObjMove_GetX( objBoss );
                        		let sy = ObjMove_GetY( objBoss );
				
				let sht1 = CreateLooseLaserA1( sx, sy, speed, angle, 150, 18, shote, delay );
				ObjRender_SetBlendType( sht1, BLEND_ALPHA );
				ObjRender_SetColor( sht1, 0, 0, 0 );
				NotifyEventAll( EV_USER + 40, [ sht1, delay ] );

				PatternMonochrome2( sht1 );

				angle += 360 / way;

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

	}
	
             loop( 1 ){

		            let angle = GetAngleToPlayer( objBoss ) - a;
                                                    let speed = 40;
	                                let way = 1;
                                                    let shote = 129;
		            let delay = 0;

			loop( way ){

                      	                    let sx = ObjMove_GetX( objBoss );
                        		let sy = ObjMove_GetY( objBoss );
				
				let sht1 = CreateLooseLaserA1( sx, sy, speed, angle, 150, 18, shote, delay );
				ObjRender_SetBlendType( sht1, BLEND_ALPHA );
				ObjRender_SetColor( sht1, 0, 0, 0 );
				NotifyEventAll( EV_USER + 40, [ sht1, delay ] );

				PatternMonochrome2( sht1 );

				angle += 360 / way;

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

	}
	a -= 10;
	wait( 15 );
	}
	wait( Wait );
	}

   }

              task PatternMonochrome2( obj ){ 
              while( !Obj_IsDeleted( obj )){

	                                let way = 5;
                                                    let shote = 64;
		            let delay = 0;

			loop( way ){
			
                                                    	let speed = rand( 0.8, 1.5 );
			let angle = rand( 0, 360 );
                      	                    let sx = ObjMove_GetX( obj );
                        		let sy = ObjMove_GetY( obj );
				
				let sht1 = TShotA2( sx, sy, speed, angle, 0, speed, shote, delay );
				ObjRender_SetBlendType( sht1, BLEND_ALPHA );
				ObjRender_SetColor( sht1, 0, 0, 0 );
				NotifyEventAll( EV_USER + 40, [ sht1, delay ] );

				angle -= 360 / way;

			}
			PlaySound("LenenShot1",92,0);
                        		if( wait( 2 ) ){ return; }

	}

   }

	task ReflectAndChange(obj, acceleration, angular, v)
{
   while(!Obj_IsDeleted(obj) && ObjMove_GetX(obj)>0 && ObjMove_GetX(obj)<GetStgFrameWidth && ObjMove_GetY(obj)>0  && ObjMove_GetY(obj)<GetStgFrameHeight){yield;}
   if(ObjMove_GetX(obj)<0 || ObjMove_GetX(obj)>GetStgFrameWidth)
   {ObjMove_AddPatternA2( obj, 0, NO_CHANGE, ObjMove_GetAngle( obj ), acceleration, angular, v );}
   if(ObjMove_GetY(obj)<0 || ObjMove_GetY(obj)>GetStgFrameHeight)
   {ObjMove_AddPatternA2( obj, 0, NO_CHANGE, -ObjMove_GetAngle( obj ), acceleration, angular, v );}

PlaySound("BulletWave",60,0);

}

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