let playerAngle=GetAngleToPlayer(GetPlayerObjectID);

// Draws the name of the character
function name(text,x,y){
let objText = ObjText_Create();
ObjText_SetText(objText,text);
ObjText_SetFontSize(objText, 10);
ObjText_SetFontBold(objText, true); //Negrita
ObjText_SetFontColorTop(objText, 0, 254, 0); //Color parte arriba
ObjText_SetFontColorBottom(objText, 0, 100, 0); // = parte abajo
ObjText_SetFontBorderType(objText, BORDER_SHADOW); //Borde, los otros son BORDER_FULL y BORDER_SHADOW
ObjText_SetFontBorderColor(objText,0, 0, 0); // color del borde
ObjText_SetFontBorderWidth(objText, 2); // ancho del borde
ObjText_SetMaxWidth(objText,348); //ancho max
ObjText_SetMaxHeight(objText,50); // alto max
Obj_SetRenderPriorityI(objText, 79); //prioridad
ObjRender_SetX(objText, x); //x
ObjRender_SetY(objText, y); //y
//if(ObjEnemy_GetInfo(Enemy,INFO_LIFE) < 0){Obj_Delete(objText);}
}

// Draws the Cutin
    task CutinSpell(text,x,size){
    let Ctxt = ObjText_Create();
    let ymove = 0;
let alfa = 0;
    ObjText_SetText(Ctxt,text);
    ObjText_SetFontSize(Ctxt, size-2);
    ObjText_SetFontBold(Ctxt, true); //Negrita
    ObjText_SetFontColorTop(Ctxt, 254, 254, 254); //Color parte arriba
    ObjText_SetFontColorBottom(Ctxt, 254, 254, 254); // = parte abajo
    ObjText_SetFontBorderType(Ctxt, BORDER_FULL); //Borde, los otros son BORDER_FULL y BORDER_SHADOW
    ObjText_SetFontBorderColor(Ctxt,0, 0, 0); // color del borde
    ObjText_SetFontBorderWidth(Ctxt, 2); // ancho del borde
    ObjText_SetMaxWidth(Ctxt,600); //ancho max
    ObjText_SetMaxHeight(Ctxt,50); // alto max
    Obj_SetRenderPriorityI(Ctxt, 79); //prioridad
ObjRender_SetAlpha(Ctxt,alfa);
    ObjRender_SetX(Ctxt, x); //x
    ObjRender_SetY(Ctxt, 400); //y
BonusText;
loop(60){yield;}
    while(!Obj_IsDeleted(Ctxt)){
if(alfa <= 256){
ObjRender_SetAlpha(Ctxt,alfa);
alfa += 2;
//yield;
}
    if(ymove <= 380){
    ObjRender_SetX(Ctxt, x); //x
    ObjRender_SetY(Ctxt, 400-ymove); //y
    ymove += 5;
    }
     
    yield;
    }
}
task BonusText{
Bonus;
    let Ctxt2 = ObjText_Create();
let alfa2 = 0;
    ObjText_SetFontSize(Ctxt2, 12);
    ObjText_SetFontBold(Ctxt2, true); //Negrita
    ObjText_SetFontColorTop(Ctxt2, 254, 254, 254); //Color parte arriba
    ObjText_SetFontColorBottom(Ctxt2, 254, 254, 254); // = parte abajo
    ObjText_SetFontBorderType(Ctxt2, BORDER_FULL); //Borde, los otros son BORDER_FULL y BORDER_SHADOW
    ObjText_SetFontBorderColor(Ctxt2,0, 0, 0); // color del borde
    ObjText_SetFontBorderWidth(Ctxt2, 2); // ancho del borde
    ObjText_SetMaxWidth(Ctxt2,348); //ancho max
    ObjText_SetMaxHeight(Ctxt2,50); // alto max
    Obj_SetRenderPriorityI(Ctxt2, 79); //prioridad
ObjRender_SetAlpha(Ctxt2,alfa2);
    ObjRender_SetX(Ctxt2, 280); //x
    ObjRender_SetY(Ctxt2, 40); //y
while(!Obj_IsDeleted(Ctxt2)){
if(alfa2 <= 256){
ObjRender_SetAlpha(Ctxt2,alfa2);
alfa2 += 1;
//yield;
}
    if( ObjEnemyBossScene_GetInfo(GetEnemyBossSceneObjectID,INFO_PLAYER_SHOOTDOWN_COUNT)==0 && ObjEnemyBossScene_GetInfo(GetEnemyBossSceneObjectID,INFO_PLAYER_SPELL_COUNT)==0 ){
    ObjText_SetText(Ctxt2,IntToString(ObjEnemyBossScene_GetInfo(GetEnemyBossSceneObjectID,INFO_SPELL_SCORE)));
    }else{
    ObjText_SetText(Ctxt2,"Failed");
    }
yield
}
}
task Bonus{
    let Ctxt2 = ObjText_Create();
let alfa2 = 0;
ObjText_SetText(Ctxt2,"Bonus:");
    ObjText_SetFontSize(Ctxt2, 12);
    ObjText_SetFontBold(Ctxt2, true); //Negrita
    ObjText_SetFontColorTop(Ctxt2, 0, 0, 254); //Color parte arriba
    ObjText_SetFontColorBottom(Ctxt2, 0, 0, 254); // = parte abajo
    ObjText_SetFontBorderType(Ctxt2, BORDER_FULL); //Borde, los otros son BORDER_FULL y BORDER_SHADOW
    ObjText_SetFontBorderColor(Ctxt2,0, 0, 0); // color del borde
    ObjText_SetFontBorderWidth(Ctxt2, 2); // ancho del borde
    ObjText_SetMaxWidth(Ctxt2,348); //ancho max
    ObjText_SetMaxHeight(Ctxt2,50); // alto max
    Obj_SetRenderPriorityI(Ctxt2, 79); //prioridad
ObjRender_SetAlpha(Ctxt2,alfa2);
    ObjRender_SetX(Ctxt2, 200); //x
    ObjRender_SetY(Ctxt2, 40); //y
while(!Obj_IsDeleted(Ctxt2)){
if(alfa2 <= 256){
ObjRender_SetAlpha(Ctxt2,alfa2);
alfa2 += 1;
//yield;
}  
yield;
}
}
//Draws yuyuko's Fan
task Fan(x,y){
let fanobj = ObjPrim_Create(OBJ_SPRITE_2D);
    let fanimg = GetCurrentScriptDirectory ~ "fan.png";
     
    let sbalpha = 0;
     let fangle = 90;
    LoadTexture(fanimg);
    ObjPrim_SetTexture(fanobj,fanimg);
    ObjSprite2D_SetSourceRect(fanobj,0,0,512,300);
    ObjSprite2D_SetDestCenter(fanobj);
    ObjSprite2D_SetDestRect(fanobj,-256,-150,256,150);
    Obj_SetRenderPriorityI(fanobj,20);
    ObjRender_SetPosition(fanobj,x,y,0);
    ObjRender_SetScaleXYZ(fanobj,1,1,1);
     ObjRender_SetAlpha(fanobj,255);
    while(!Obj_IsDeleted(fanobj)){
 ObjRender_SetPosition(fanobj,x,y,0);
    ObjRender_SetAngleXYZ(fanobj,fangle,0,0);
if(fangle <= 90 && fangle > 0){fangle--;}
yield;
    }
}
function getAtanAngle(obj,obj2){
	let angle=atan2(ObjMove_GetY(obj2)-ObjMove_GetY(obj),ObjMove_GetX(obj2)-ObjMove_GetX(obj));
	return angle;
}

/*task SE(dir){
let snd = ObjSound_Create;
if(!Obj_IsDeleted(Enemy)){
ObjSound_Load(snd,dir);
}
ObjSound_SetSoundDivision(snd,SOUND_SE);
ObjSound_Play(snd);
}
*/
// Plays a sound
function SE(file){
LoadSound(file);
PlaySE(file);
}
// Failed Explosion Effect!
task boom(x,y){
circleInv(x,y);
wait(20);
circleInv2(x,y);
}
task circleInv(x,y){
let boomobj = ObjPrim_Create(OBJ_SPRITE_2D);
    let boomimg = GetCurrentScriptDirectory ~ "charge.png";
    let alphalol = 0;
	let scale = 0;
    LoadTexture(boomimg);
    ObjPrim_SetTexture(boomobj,boomimg);
    ObjSprite2D_SetSourceRect(boomobj,0,0,128,128);
    ObjSprite2D_SetDestCenter(boomobj);
    ObjSprite2D_SetDestRect(boomobj,-64,-64,64,64);
    Obj_SetRenderPriorityI(boomobj,78);
    ObjRender_SetPosition(boomobj,x,y,0);
	ObjRender_SetBlendType(boomobj,BLEND_INV_DESTRGB);
     //ObjRender_SetAlpha(boomobj,255);
    while(!Obj_IsDeleted(boomobj)){
 ObjRender_SetPosition(boomobj,x,y,0);
    ObjRender_SetAngleXYZ(boomobj,0,0,0);
ObjRender_SetScaleXYZ(boomobj,scale,scale,scale);
scale += 0.3;
yield;
    }
}
task circleInv2(x,y){
let boomobj = ObjPrim_Create(OBJ_SPRITE_2D);
    let boomimg = GetCurrentScriptDirectory ~ "charge.png";
    let alphalol = 0;
	let scale = 0;
    LoadTexture(boomimg);
    ObjPrim_SetTexture(boomobj,boomimg);
    ObjSprite2D_SetSourceRect(boomobj,0,0,128,128);
    ObjSprite2D_SetDestCenter(boomobj);
    ObjSprite2D_SetDestRect(boomobj,-64,-64,64,64);
    Obj_SetRenderPriorityI(boomobj,79);
    ObjRender_SetPosition(boomobj,x,y,0);
	ObjRender_SetBlendType(boomobj,BLEND_INV_DESTRGB);
     //ObjRender_SetAlpha(boomobj,255);
    while(!Obj_IsDeleted(boomobj)){
 ObjRender_SetPosition(boomobj,x,y,0);
    ObjRender_SetAngleXYZ(boomobj,0,0,0);
ObjRender_SetScaleXYZ(boomobj,scale,scale,scale);
scale += 0.3;
yield;
    }
}

task RedCircle(x,y){
let boomobj = ObjPrim_Create(OBJ_SPRITE_2D);
    let boomimg = GetCurrentScriptDirectory ~ "eff_magicsquare.png";
    let alphalol = 0;
let xyMov = 0;
let zMov = 0;
    LoadTexture(boomimg);
    ObjPrim_SetTexture(boomobj,boomimg);
    ObjSprite2D_SetSourceRect(boomobj,0,0,256,256);
    ObjSprite2D_SetDestCenter(boomobj);
    Obj_SetRenderPriorityI(boomobj,78);
    ObjRender_SetPosition(boomobj,x,y,0);
	ObjRender_SetBlendType(boomobj,BLEND_ALPHA);
     //ObjRender_SetAlpha(boomobj,255);
    while(!Obj_IsDeleted(boomobj)){
 ObjRender_SetPosition(boomobj,x,y,0);
    ObjRender_SetAngleXYZ(boomobj,xyMov,xyMov,zMov);
xyMov += 0.5;
zMov += 0.5;
yield;
    }
}
//Ultima's Delay Shot Functions
       function CreateShotFA1(x,y,s,a,g,d,holdspeed){
              let obj = CreateShotA1(x,y,s,a,g,0);
            if(holdspeed){
                ObjMove_SetSpeed(obj,0);
            }
        ObjShot_SetIntersectionEnable(obj,false);
             fadeinshot(d,obj,s,holdspeed);
              return obj
              }
        task fadeinshot(d,obj,s,holdspeed){
         let alpha = 00;
         let scale = 2.4;
         let a = 255/d;
         let b = 1/d;
         let done = false;
         while(!done){
         alpha+=a;
         scale-=b;
         ObjRender_SetScaleXYZ(obj,scale,scale,1);
         if(scale <1){
         ObjRender_SetScaleXYZ(obj,1,1,1);
         scale = 1;
         }
         if(scale <=1&&alpha>=255){
         done = true;
         }

        // ObjRender_SetScaleXYZ(obj,1,1,1);
         ObjRender_SetAlpha(obj,alpha);
         yield;
         }
                        if(holdspeed){
                ObjMove_SetSpeed(obj,s);

            }
          ObjShot_SetIntersectionEnable(obj,true);

         }


       function CreateShotFA2(x,y,s,a,acc,ms,g,d,holdspeed){
              let obj = CreateShotA2(x,y,s,a,acc,ms,g,0);
            if(holdspeed){
                ObjMove_SetSpeed(obj,0);
                ObjMove_SetAcceleration(obj,0);
                ObjMove_SetMaxSpeed(obj,0);
            }
        ObjShot_SetIntersectionEnable(obj,false);
             fadeinshot2(d,obj,s,acc,ms,holdspeed);
              return obj
              }

         task fadeinshot2(d,obj,s,acc,ms,holdspeed){
         let alpha = 00;
         let scale = 2.4;
         let a = 255/d;
         let b = 1/d;
         let done = false;
         while(!done){
         alpha+=a;
         scale-=b;
         ObjRender_SetScaleXYZ(obj,scale,scale,1);
         if(scale <1){
         ObjRender_SetScaleXYZ(obj,1,1,1);
         scale = 1;
         }
         if(scale <=1&&alpha>=255){
         done = true;
         }

        // ObjRender_SetScaleXYZ(obj,1,1,1);
         ObjRender_SetAlpha(obj,alpha);
         yield;
         }
                        if(holdspeed){
                ObjMove_SetSpeed(obj,s);
                ObjMove_SetAcceleration(obj,acc);
                ObjMove_SetMaxSpeed(obj,ms);
            }
          ObjShot_SetIntersectionEnable(obj,true);

         }

         function GetX{
         return ObjMove_GetX(Enemy)
         }
         function GetY{
         return ObjMove_GetY(Enemy)
         }
         function GetCenterX{
         return GetStgFrameWidth/2
         }
         function GetCenterY{
         return GetStgFrameHeight/2
         }