#TouhouDanmakufu
#Title[TEN_DESIRES_EX_BOSS_SP_5]
#Text[By Shockman2.]
#Player[FREE]
#BGM[.\mu\bgm.mp3]
#ScriptVersion[2]

script_enemy_main {

let frame1 = 0;
let frame2 = 0;
let frame3 = 0;
let frame4 = 0;
let frame5 = 0;
let frame6 = 0;
let frame7 = 0;
let frame8 = 0;
let frame9 = 0;
let frame10 = 0;
let frame11 = 0;
let anim1 = 0;
let anim2 = 0;
let anim3 = 0;
let anim4 = 0;
let anim5 = 0;
let anim6 = 0;
let a1 = 0;
let a2 = 0;
let a3 = 0;
let a4 = 0;
let a5 = 0;
let a6 = 0;
let a7 = 0;
let a8 = 0;
let acc1 = 0;
let acc2 = 0;
let acc3 = 0;
let acc4 = 0;
let acc5 = 0;
let acc6 = 0;
let acc7 = 0;
let acc8 = 0;
let acc9 = 0;
let acc10 = 0;
let acc11 = 0;
let acc12 = 0;
let random1 = 0;
let random2 = 0;
let random3 = 0;
let random4 = 0;

let SP = GetCurrentScriptDirectory~"sp\sp.png";
let Custom = GetCurrentScriptDirectory~"sup\supershot2.txt";
let MC = GetCurrentScriptDirectory~"ef\MC.png";
let CBG1 = GetCurrentScriptDirectory~"ef\cbg1.png";
let CBG2 = GetCurrentScriptDirectory~"ef\cbg2.png";
let NBG1 = GetCurrentScriptDirectory~"ef\nbg1.png";
let BAR = GetCurrentScriptDirectory~"ef\barrier.png";
let BAR2 = GetCurrentScriptDirectory~"ef\barrier2.png";
let charge = GetCurrentScriptDirectory~"se\Charge2.wav";
let sh1 = GetCurrentScriptDirectory~"se\Shot1.wav";
let sh2 = GetCurrentScriptDirectory~"se\Eff.wav";
let sh3 = GetCurrentScriptDirectory~"se\Shot5.wav";
let sh4 = GetCurrentScriptDirectory~"se\GotBonus.wav";
let Cut = GetCurrentScriptDirectory~"ef\cut.png";
	#include_function ".\function_cutin.txt";
	#include_function ".\maple.txt";

    @Initialize {

SetMovePosition03(GetCenterX, GetCenterY - 150, 10, 10);

LoadUserShotData(Custom);
LoadGraphic(SP);
LoadGraphic(MC);
LoadGraphic(Cut);
LoadGraphic(CBG1);
LoadGraphic(CBG2);
LoadGraphic(NBG1);
LoadGraphic(BAR);
LoadGraphic(BAR2);
LoadSE(charge);
LoadSE(sh1);
LoadSE(sh2);
LoadSE(sh3);
LoadSE(sh4);

SetLife(600);
SetDamageRate(20, 0);
SetTimer(99);
SetInvincibility(120);
SetEnemyMarker(true);
SetShotAutoDeleteClip(128,128,128,128);

cutin("NAZRIN", "Death Awakening - Paralyzation", Cut, 0, 0, 283, 478);
SetScore(50000);
    }

    @MainLoop {
SetCollisionA(GetX, GetY, 32);
SetCollisionB(GetX, GetY, 24);
yield;

if (OnBomb == true){
SetDamageRate(0, 0);
}
if (OnBomb == false){
SetDamageRate(20, 0);
}

task BulletB(x,y,v,angle,graphic,delay) {
     let obj=Obj_Create(OBJ_SHOT);

     Obj_SetPosition(obj, x, y);
     Obj_SetAngle(obj, angle);
     Obj_SetSpeed(obj, v);
     ObjShot_SetGraphic(obj, graphic);
     ObjShot_SetDelay  (obj, delay);
     ObjShot_SetBombResist (obj, false);

     while(Obj_BeDeleted(obj)==false) {
if (frame4 >= 420){
     Obj_SetSpeed(obj, 0);
     ObjShot_SetGraphic(obj, 224);
	frame2 = 190;
ForbidShot(true);
}
if (frame4 < 420){
     Obj_SetSpeed(obj, v);
     ObjShot_SetGraphic(obj, graphic);
ForbidShot(false);
}



             yield;
      }
}
task BulletC(x,y,v,angle,graphic,delay) {
     let obj=Obj_Create(OBJ_SHOT);

     Obj_SetPosition(obj, x, y);
     Obj_SetAngle(obj, angle);
     Obj_SetSpeed(obj, v);
     ObjShot_SetGraphic(obj, graphic);
     ObjShot_SetDelay  (obj, delay);
     ObjShot_SetBombResist (obj, false);

     while(Obj_BeDeleted(obj)==false) {
if (frame4 >= 420){
     Obj_SetSpeed(obj, 0);
     ObjShot_SetGraphic(obj, 58);
	frame2 = 190;
ForbidShot(true);
}
if (frame4 < 420){
     Obj_SetSpeed(obj, v);
     ObjShot_SetGraphic(obj, graphic);
ForbidShot(false);
}



             yield;
      }
}
        if (frame1 == 60)
        { 
	StartMapleConcentrate;
	PlaySE(charge);
        }
        if (frame4 == 340)
        { 
	StartMapleConcentrate;
	PlaySE(charge);
        }
        if (frame4 == 420)
        { 
	PlaySE(sh2);
        }
        if (frame2 == 180)
        { 
        loop(36)
        {
            
            BulletB(GetX+10*cos(a1),GetY+10*sin(a1),1,a1,225,20);
            BulletC(GetX+30*cos(-a1),GetY+30*sin(-a1),2,-a1,60,20);
            a1 += 360/36;
        }
	a1 += 7;
	frame2 = 140;
	PlaySE(sh1);
        }
        if (frame3 == 201)
        { 
SetMovePosition03(GetCenterX + rand(-100,100), GetCenterY - 100 + rand(-50,50), 10, 3); 
frame3 = 100;      
}
if (frame5 == 420){
	loop(5){
        loop(18)
        {
           CreateShot01(GetX,GetY,4+acc12,a2+GetAngleToPlayer,5,20);
	a2 += 360/18;
	PlaySE(sh3);
}
acc12 += 0.2;
}
frame5 = 390;
acc12 = 0;
}
        if (frame4 == 580)
        { 
	PlaySE(sh4);
        }
        if (frame4 == 620)
        { 
	frame2 = 170;
	frame4 = 0;
	frame5 = 0;
        }
acc11 += 1;
        frame1++;
        frame2++;
        frame3++;
        frame4++;
        frame5++;
        frame6++;
    }

    @DrawLoop {
if (frame4 >= 420){
     SetColor(255,0,255);
}
if (frame4 < 420){
     SetColor(255,255,255);
}
SetTexture(CBG1);
SetRenderState(ALPHA);
SetGraphicAngle(0,0,acc7);
SetGraphicScale(1,1);
SetGraphicRect(0, 0, 800, 800);
SetAlpha(255);
DrawGraphic(GetCenterX, GetCenterY);

SetTexture(CBG2);
SetRenderState(ALPHA);
SetGraphicAngle(0,0,-45);
SetGraphicScale(1,1);
SetGraphicRect(0, 0, 256000, 256000);
SetAlpha(80);
DrawGraphic(GetCenterX - acc5, GetCenterY - acc5);

SetTexture(CBG2);
SetRenderState(ALPHA);
SetGraphicAngle(0,0,-45);
SetGraphicScale(1,1);
SetGraphicRect(0, 0, 256000, 256000);
SetAlpha(80);
DrawGraphic(GetCenterX - acc8, GetCenterY - acc6);

SetTexture(MC);
SetRenderState(ADD);
SetGraphicAngle(0,0,acc1);
SetGraphicScale(1+acc3,1+acc3);
SetGraphicRect(0, 0, 128, 128);
SetAlpha(255);
DrawGraphic(GetX, GetY);

if (GetSpeedX == 0){
SetTexture(SP);
SetRenderState(ALPHA);
SetGraphicAngle(0,0,0);
SetGraphicScale(1,1+acc10);
SetGraphicRect(0, 0, 52, 86);
SetAlpha(255);
DrawGraphic(GetX + 2, GetY);
}
if (GetSpeedX > 0){
SetTexture(SP);
SetRenderState(ALPHA);
SetGraphicAngle(0,0,0);
SetGraphicScale(1,1+acc10);
SetGraphicRect(52, 0, 103, 86);
SetAlpha(255);
DrawGraphic(GetX + 10, GetY);
}
if (GetSpeedX < 0){
SetTexture(SP);
SetRenderState(ALPHA);
SetGraphicAngle(0,0,0);
SetGraphicScale(-1,1+acc10);
SetGraphicRect(52, 0, 103, 86);
SetAlpha(255);
DrawGraphic(GetX - 10, GetY);
}

if (OnBomb == true){
SetTexture(BAR);
SetRenderState(ADD);
SetGraphicAngle(0,0,acc1);
SetGraphicScale(1,1);
SetGraphicRect(0, 0, 256, 256);
SetAlpha(100);
DrawGraphic(GetX, GetY);
SetTexture(BAR2);
SetRenderState(ALPHA);
SetGraphicAngle(0,0,acc1);
SetGraphicScale(1,1);
SetGraphicRect(0, 0, 256, 256);
SetAlpha(100);
DrawGraphic(GetX, GetY);
}

acc1 += 8;
acc2++;
anim1++;
anim2++;
anim3++;
if (acc2 <= 40){acc3 += 0.01;}
if (acc2 >= 40){acc3 -= 0.01;}
if (acc2 == 80){acc2 = 0;}

if (acc9 <= 20){acc10 += 0.002;}
if (acc9 >= 20){acc10 -= 0.002;}
if (acc9 == 40){acc9 = 0;}
acc5 += 0.5;
acc6++;
acc7 += 0.2;
acc8 += 1.2;
acc9++;
}
    @Finalize {
     SetColor(255,255,255);
ForbidShot(false);
    }
}
