
#ScriptVersion[3]
#Title["TsubakuraS5"]
#Text["TsubakuraS5"]
#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",2);
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(1250);
	}
	case(EV_REQUEST_TIMER)
	{
		SetScriptResult(90);
	}
		case(EV_REQUEST_SPELL_SCORE)
	{
		SetScriptResult(50000000);
	}
}

//----------------------------------------------------
task mainTask{
	StartCountDown;
	PlaySound("SpellStart",100,0);
	BlindBackground;
	ObjMove_SetDestAtWeight(objBoss,stgx,120,10,7);
	Cutin("Conceal Card 'Monochrome Chameleon'",15,"SHINKI");
	ObjEnemyBossScene_StartSpell(objScene);
	wait( 160 );
	TShot1;
	DamageRateAtFrame(15,0,0);
	}
//----------------------------------------------------

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;
	PatternBlack;
	PatternWhite;
}

let blind = GCSD~"img/Blind.png";

task BlindBackground(){ 
	let value = 0;
	let obj=ObjPrim_Create(OBJ_SPRITE_2D);
	Obj_SetRenderPriorityI(obj,25);
	ObjPrim_SetTexture(obj,blind);
	ObjSprite2D_SetSourceRect(obj,0,0,384,448);
	ObjSprite2D_SetDestRect(obj,-384,-448,384,448);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetScaleXYZ(obj,1,1,0);
	ObjRender_SetBlendType(obj,BLEND_ALPHA);
	ObjRender_SetPosition(obj,384/2,448/2,0);
	dDelete( obj );
	while( !Obj_IsDeleted(objBoss) && bSpell == false){
	descent( x in 0..255 ){
	ObjRender_SetColor(obj,x,x,x);
	yield;
	}
	wait( 30 );
	ascent( x in 0..255 ){
	ObjRender_SetColor(obj,x,x,x);
	yield;
	}
	wait( 30 );
	}
	Obj_Delete(obj);
}
	task dDelete( obj ){
	while( !Obj_IsDeleted( objBoss )){ yield; }
	Obj_Delete( obj );
	}

              task PatternBlack{ 
              while( !Obj_IsDeleted( objBoss )){
              let angle = rand( 0, 360 );
              loop( 5 ){
              let speed = 2.2;
              loop( 10 ){

	                                	let way = 7;
                                                	let shote = 307;
			let delay = 0;

			loop( way ){

                      	                	let sx = ObjMove_GetX( objBoss );
                        		let sy = ObjMove_GetY( objBoss );
				
				let sht1 = TShotA2( sx, sy, speed, angle, 0, speed, shote, delay );
				ObjShot_SetSpellResist( sht1, true );
				ObjRender_SetBlendType( sht1, BLEND_ALPHA );
				ObjRender_SetColor( sht1, 0, 0, 0 );

				angle += 360 / way;

			}
			angle += 1.3;
			speed += 0.15;
			PlaySound("LenenShot1",92,0);
                        		if( wait( 2 ) ){ return; }
		}
			wait( 0 );
	}
              loop( 5 ){
              let speed = 2.2;
              loop( 10 ){

	                                	let way = 7;
                                                	let shote = 307;
			let delay = 0;

			loop( way ){

                      	                	let sx = ObjMove_GetX( objBoss );
                        		let sy = ObjMove_GetY( objBoss );
				
				let sht1 = TShotA2( sx, sy, speed, angle, 0, speed, shote, delay );
				ObjShot_SetSpellResist( sht1, true );
				ObjRender_SetBlendType( sht1, BLEND_ALPHA );
				ObjRender_SetColor( sht1, 0, 0, 0 );

				angle += 360 / way;

			}
			angle -= 1.3;
			speed += 0.15;
			PlaySound("LenenShot1",92,0);
                        		if( wait( 2 ) ){ return; }
		}
			wait( 0 );
	}
	}
   }

              task PatternWhite{ 
              while( !Obj_IsDeleted( objBoss )){

              			let angle = rand( 0, 360 );
	                                	let way = 4;
                                                	let shote = 532;
			let delay = 0;

			loop( way ){

              			let speed = rand( 1.5, 3 );
                      	                	let sx = ObjMove_GetX( objBoss );
                        		let sy = ObjMove_GetY( objBoss );
				
				let sht1 = TShotA2( sx, sy, speed, angle, 0, speed, shote, delay );
				ObjShot_SetSpellResist( sht1, true );

				angle += 360 / way;

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

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