let imgBoss1 = GetCurrentScriptDirectory~"img/AkitsuMaru1.png";
let imgBoss2 = GetCurrentScriptDirectory~"img/AkitsuMaru2.png";

let Aattack=false;
let idle=false;
let move=false;
let returnMov=false;
let beginAtk=false;
let Rika=true;
let Tank=false;
let Eye=false;
let a=0;
let imgeffect1 = GetCurrentScriptDirectory~"img/deck1.png";
let Summon=false;

//------------------------------------------//
//---Coordenates of Lotus Flowers----------//
/*
	TinyLotusUp(-56,-84,bossposcopy); Top Right
	TinyLotusUp(56,-84,bossposcopy); Top Left
	TinyLotusUp(-120,54,bossposcopy); Bottom Right
	TinyLotusUp(120,54,bossposcopy); Bottom Left
*/

function GetAngle(obj){
return NormalizeAngle(ObjMove_GetAngle(obj))
}
function NormalizeAngle(angle){
  angle %= 360;
  if(angle<0){ angle += 360; }

  return angle;

}


task SetAkitsuA(Enemy){
ObjPrim_SetTexture(Enemy,imgBoss1);
ObjSprite2D_SetSourceRect(Enemy,0,0,34,96);
ObjSprite2D_SetDestCenter(Enemy);
Obj_SetRenderPriority(Enemy,0.25);
}

task SetAkitsuB(Enemy){
ObjPrim_SetTexture(Enemy,imgBoss2);
ObjSprite2D_SetSourceRect(Enemy,0,0,65,104);
ObjSprite2D_SetDestCenter(Enemy);
Obj_SetRenderPriority(Enemy,0.25);
}



task CallNormal(){
a=0;
}

task CallKai(){
a=1;
}

task newAnimation(Enemy){
let bossposcopy = ObjPrim_Create(OBJ_SPRITE_2D);
AnimateEnemy(bossposcopy);

let floatcount=0;
let floatf=false;
let fdur=2;
let frac=18;

while(!Obj_IsDeleted(Enemy)){
ObjRender_SetPosition(bossposcopy,ObjMove_GetX(Enemy),ObjMove_GetY(Enemy)+floatcount,0);

if(Summon==true){
Amp(objEnemy,bossposcopy);
Summon=false;
}

if(floatcount<fdur && floatf==false){
floatcount+=fdur/frac;
}
if(floatcount>=fdur){
floatf=true;
}
if(floatf==true && floatcount>-fdur){
floatcount-=fdur/frac;
}
if(floatcount<=-fdur){
floatf=false;
}
yield;
}

Obj_Delete(bossposcopy);

task AnimateEnemy(Enemy){

while(!Obj_IsDeleted(Enemy)){

alternative(a)
case(0){
SetAkitsuA(Enemy);
}
case(1){
SetAkitsuB(Enemy);
}


yield;
}

}

}

task SummonAmp(){
Summon=true;
}

task Amp(objEnemy,bossposcopy){
let path1 = imgeffect1;
let enmx = ObjRender_GetX(bossposcopy);
let enmy = ObjRender_GetY(bossposcopy);
let base = ObjPrim_Create(OBJ_SPRITE_2D);
let duration=60;
let alphaval=255*(2/3);
let maxval=1;
ObjPrim_SetTexture(base, path1);
Obj_SetRenderPriority(base,0.23);
ObjSprite2D_SetSourceRect(base, 0, 0, 440, 94);
ObjRender_SetAlpha(base,alphaval);
ObjRender_SetBlendType(base,BLEND_ALPHA);
ObjRender_SetAngleZ(base,GetAngleToPlayer(objEnemy));

	let grow=0;
	let begin=false;
		ObjRender_SetScaleX(base, 0);
	let flip=1;
	let flipcount=0;

	wait(60);
	se_boon01();
	loop(duration){
		ObjRender_SetX(base, ObjRender_GetX(bossposcopy));
		ObjRender_SetY(base, ObjRender_GetY(bossposcopy));
		ObjSprite2D_SetDestCenter(base);
		ObjRender_SetScaleX(base, grow);
		ObjRender_SetScaleY(base, maxval*(2));
		ObjRender_SetAngleZ(base,GetAngleToPlayer(objEnemy));
		
		grow+=maxval/duration;

			if(grow>=maxval){
			begin=true;
			}

		yield;
	}


while(!Obj_IsDeleted(objEnemy) && begin==true){
enmx = ObjRender_GetX(bossposcopy);
enmy = ObjRender_GetY(bossposcopy);


		ObjRender_SetX(base, ObjRender_GetX(bossposcopy));
		ObjRender_SetY(base, ObjRender_GetY(bossposcopy));
		ObjSprite2D_SetDestCenter(base);
		ObjRender_SetScaleX(base, maxval);
		ObjRender_SetScaleY(base, maxval*(2));
		ObjRender_SetAngleZ(base,GetAngleToPlayer(objEnemy));

		
	if(flipcount>=0 && flipcount<=30){
		flip+= 0.002;
		}
	if(flipcount>=31 && flipcount<=61){
		flip-=0.002;
		}
	if(flipcount==62){
		flipcount = 0;
		}
		flipcount+=1;
		


	
	yield;
	}


}

task StartBG{

let current = GetCurrentScriptDirectory();
let desp=0;
let obj0 = ObjPrim_Create(OBJ_SPRITE_2D);
let obj1 = ObjPrim_Create(OBJ_SPRITE_2D);

let path1 = current ~ "img/bg1.png";
let path2 = current ~ "img/bg2.png";


				
				Obj_SetRenderPriority(obj0, 0.21);
				ObjPrim_SetTexture(obj0, path1);
				ObjSprite2D_SetDestRect(obj0, 0-128, 0, 616-128, GetStgFrameHeight);
				ObjSprite2D_SetSourceRect(obj0, 0, 0, 616, 448);				
				
					
				Obj_SetRenderPriority(obj1, 0.22);
                ObjPrim_SetTexture(obj1, path2);
				ObjRender_SetAlpha(obj1,255*(2/4));
				ObjSprite2D_SetDestRect(obj1, 0, 0, 796, 448); 				
                ObjSprite2D_SetSourceRect(obj1, 0, 0, 256, 448);				


				
				while(ObjEnemyBossScene_GetInfo(objScene,INFO_IS_SPELL)==true){
				ObjSprite2D_SetSourceRect(obj1, 0+desp, 0, 796+desp, 448);	



				desp+=1/2;
				yield;
				}
				Obj_Delete(obj0);
				Obj_Delete(obj1);



}