
#ScriptVersion[3]
#Title["TsurubamiN3"]
#Text["TsurubamiN3"]
#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(80);
	}
		case(EV_REQUEST_SPELL_SCORE)
	{
		SetScriptResult(35000000);
	}
}

//----------------------------------------------------
task mainTask{
	SetCommonData("ForceLifebar",1);
	StartCountDown;
	ObjMove_SetDestAtWeight(objBoss,stgx,100,10,10);
	SetCommonData("Scroll",1);
	wait(160);
	TShot1;
	SetCommonData("ForceLifebar",0);
	DamageRateAtFrame(70,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;
	PatternTsubakuraNon1;
	
	}



             task PatternBeat2{ 
              loop( 100000 ){
              let angle = rand( 0, 360 );
              let r = 100;
              loop( 20 ){

                                                    let speed1 = 0.8;
                                                    let speed2 = 3;
	                                let way = 13;
                                                    let shote1 = 55;
                                                    let shote2 = 135;
		            let delay = 20;
		            if( GetDistance(GetPlayerX,GetPlayerY,ObjMove_GetX( objBoss ),ObjMove_GetY( objBoss ) ) < 50 ){ r = 0; }
			loop( way ){
                      	                    let sx = ObjMove_GetX( objBoss ) + r*cos( angle );
                        		let sy = ObjMove_GetY( objBoss ) + r*sin( angle );
				
				let sht1 = TShotA2( sx, sy, speed1, angle, 0, speed1, shote2, delay );
				ObjMove_AddPatternA3( sht1, 50, speed1, angle - 30, 0.03, 0, speed2, shote1 );
				ObjMove_AddPatternA3( sht1, 90, speed2, angle - 60, -0.05, -0.4, speed1, shote2 );
				ObjMove_AddPatternA3( sht1, 210, NO_CHANGE, NO_CHANGE, 0, 0, NO_CHANGE, NO_CHANGE );
				NotifyEventAll( EV_USER + 40, [ sht1, delay ] );

				angle -= 360 / way;

			}
			r -= 5;
			angle += 6.5;
			PlaySound("LenenShot1",92,0);

                        if( wait( 5 ) ){ return; }

	}
	wait( 80 );
	TMovement(10,10,2);
                    if( wait( 200 ) ){ return; }

	}

   }

               task PatternTsubakuraNon1{
	      let angle = rand( 0, 360 ); 
              	      while( !Obj_IsDeleted( objBoss )){

	                		let way = 60;
			let shote = 855;
			let delay = 0;

			loop( way ){

			        	let speed = rand( 4, 20 );

				let sx = ObjMove_GetX( objBoss );
				let sy = ObjMove_GetY( objBoss );
				
				let sht1 = TShotA2( sx, sy, speed, angle, 0, speed, shote, delay );
                                			ObjMove_AddPatternA2( sht1, 10, 0, NO_CHANGE, 0, 0, 0 );
				//ObjRender_SetBlendType( sht1, BLEND_ALPHA );
				//ObjRender_SetColor( sht1, 0, 0, 0 );

                                			PatternTsubakura2( sht1 );

                                			ObjShot_SetSpellResist( sht1, true );
				NotifyEventAll( EV_USER + 40, [ sht1, delay ] );
				angle += 360 / way;
			}
                        		angle += 0.15;
			PlaySound("LenenShot1",92,0);
                        		if( wait( 150 ) ){ return; }
	}

   }
              task PatternTsubakura2( sht1 ){
              wait( 40 );
              loop( 1 ){

	                		let way = 1;
			let speed = rand( -4, -3 );
			let shote = 299;
			let delay = 0;
	                		let angle = 90;

			loop( way ){

				let sx = ObjMove_GetX( sht1 );
				let sy = ObjMove_GetY( sht1 );
				
				let sht5 = TShotA2( sx, sy, speed, angle, 0.1, rand( 2, 4 ), shote, delay );
				let sht6 = TShotA2( sx, sy, speed, angle + 45, 0.1, rand( 2, 4 ), shote, delay );
				let sht7 = TShotA2( sx, sy, speed, angle - 45, 0.1, rand( 2, 4 ), shote, delay );
				ObjRender_SetBlendType( sht5, BLEND_ALPHA );
				//ObjRender_SetColor( sht5, 0, 0, 0 );
				ObjRender_SetBlendType( sht6, BLEND_ALPHA );
				//ObjRender_SetColor( sht6, 0, 0, 0 );
				ObjRender_SetBlendType( sht7, BLEND_ALPHA );
				//ObjRender_SetColor( sht7, 0, 0, 0 );

                                			ObjShot_SetSpellResist( sht5, true );
				NotifyEventAll( EV_USER + 40, [ sht5, delay ] );
                                			ObjShot_SetSpellResist( sht6, true );
				NotifyEventAll( EV_USER + 40, [ sht6, delay ] );
                                			ObjShot_SetSpellResist( sht7, true );
				NotifyEventAll( EV_USER + 40, [ sht7, delay ] );

				angle += 360 / way;
			}
			PlaySound("LenenShot1",92,0);

	}
              	Obj_Delete( sht1 );

   }

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