#TouhouDanmakufu
#Title[TEN_DESIRES_EX_MIN_SP_1]
#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\supershot.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 charge = GetCurrentScriptDirectory~"se\Charge2.wav";
let sh1 = GetCurrentScriptDirectory~"se\Shot1.wav";
let sh2 = GetCurrentScriptDirectory~"se\BulletWave.wav";
let sh3 = GetCurrentScriptDirectory~"se\Laser1.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);
LoadSE(charge);
LoadSE(sh1);
LoadSE(sh2);
LoadSE(sh3);

SetLife(800);
SetDamageRate(20, 20);
SetTimer(60);
SetInvincibility(120);
SetEnemyMarker(true);
SetShotAutoDeleteClip(128,128,128,128);

cutin("NAZRIN", "Spirit Sign - Soul Eater", Cut, 0, 0, 238, 480);
SetScore(50000);
    }

    @MainLoop {
SetCollisionA(GetX, GetY, 32);
SetCollisionB(GetX, GetY, 24);
yield;
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, true);

     while(Obj_BeDeleted(obj)==false) {

             if(Obj_GetY(obj) >= GetCenterY) {
		loop(1){
BulletC(Obj_GetX(obj), Obj_GetY(obj), 2, angle, graphic + 1, 0);
}
Obj_Delete(obj);
             }

             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, true);

     while(Obj_BeDeleted(obj)==false) {

             if(Obj_GetY(obj) >= GetCenterY + 100 + acc5) {
		loop(1){
CreateShot01(Obj_GetX(obj), Obj_GetY(obj), 5, rand(0,180), graphic + 1, 0);
}
Obj_Delete(obj);
             }

             yield;
      }
}
        if (frame1 == 60)
        { 
	StartMapleConcentrate;
	PlaySE(charge);
        }
        if (frame1 == 150)
        { 
        random1 = rand(-40,40);
        random2 = rand(-40,40);
	loop(3){
        loop(18)
        {
            CreateShotA(1,GetX + random1,GetY + random2,10);
	    SetShotDataA(1,0,5,a1 + acc4,0,-0.2,0.1,74);
	    SetShotDataA(1,100,NULL,NULL,0,0.015,10,74);
	    FireShot(1);
            a1 += 360/18;
        }
	acc4++;
	}
	acc4 = 0;
        a1 += 7;
	PlaySE(sh1);
	frame1 = 130;
        }
        if (frame3 == 150)
        { 
        loop(10)
        {
            CreateLaserC(2,GetX,GetY,10,40,4,0);
	    SetLaserDataC(2,0,5,a2,1.1,0,0);
	    FireShot(2);
            CreateLaserC(3,GetX,GetY,10,40,4,30);
	    SetLaserDataC(3,0,5,-a2,-1.1,0,0);
	    FireShot(3);
            a2 += 360/10;
        }
	SetMovePosition03(GetCenterX + rand(-50,50), GetCenterY - rand(100,150), 10, 2);
	a2 += 27;
	PlaySE(sh3);
	frame3 = -100;
        }
        if (frame2 == 250)
        { 
	PlaySE(sh2);
	frame2 = 230;
        }
        frame1++;
        frame2++;
        frame3++;
        frame4++;
    }

    @DrawLoop {
SetTexture(CBG1);
SetRenderState(ALPHA);
SetGraphicAngle(0,0,0);
SetGraphicScale(1,1);
SetGraphicRect(0, 0, 384, 448);
SetAlpha(255);
DrawGraphic(GetCenterX, GetCenterY);

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

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

if (anim1 < 10 && GetSpeedX == 0){
SetTexture(SP);
SetRenderState(ALPHA);
SetGraphicAngle(0,0,0);
SetGraphicScale(1,1);
SetGraphicRect(0, 0, 50, 81);
SetAlpha(255);
DrawGraphic(GetX + 2, GetY);
}
if (anim1 >= 10 && anim1 < 20 && GetSpeedX == 0){
SetTexture(SP);
SetRenderState(ALPHA);
SetGraphicAngle(0,0,0);
SetGraphicScale(1,1);
SetGraphicRect(0, 0, 50, 81);
SetAlpha(255);
DrawGraphic(GetX + 3, GetY);
}
if (anim1 >= 20 && anim1 < 30 && GetSpeedX == 0){
SetTexture(SP);
SetRenderState(ALPHA);
SetGraphicAngle(0,0,0);
SetGraphicScale(1,1);
SetGraphicRect(50, 0, 100, 81);
SetAlpha(255);
DrawGraphic(GetX + 4, GetY);
}
if (anim1 >= 30 && anim1 < 40 && GetSpeedX == 0){
SetTexture(SP);
SetRenderState(ALPHA);
SetGraphicAngle(0,0,0);
SetGraphicScale(1,1);
SetGraphicRect(100, 0, 150, 81);
SetAlpha(255);
DrawGraphic(GetX + 5, GetY);
}
if (anim1 >= 40 && anim1 < 50 && GetSpeedX == 0){
SetTexture(SP);
SetRenderState(ALPHA);
SetGraphicAngle(0,0,0);
SetGraphicScale(1,1);
SetGraphicRect(150, 0, 200, 81);
SetAlpha(255);
DrawGraphic(GetX + 6, GetY);
}
if (anim1 >= 50 && anim1 <= 60 && GetSpeedX == 0){
SetTexture(SP);
SetRenderState(ALPHA);
SetGraphicAngle(0,0,0);
SetGraphicScale(1,1);
SetGraphicRect(200, 0, 250, 81);
SetAlpha(255);
DrawGraphic(GetX + 7, GetY);
}
if (anim1 == 60){
anim1 = 0;
}
if (GetSpeedX > 0){
SetTexture(SP);
SetRenderState(ALPHA);
SetGraphicAngle(0,0,0);
SetGraphicScale(1,1);
SetGraphicRect(200, 81, 250, 160);
SetAlpha(255);
DrawGraphic(GetX + 10, GetY);
}
if (GetSpeedX < 0){
SetTexture(SP);
SetRenderState(ALPHA);
SetGraphicAngle(0,0,0);
SetGraphicScale(-1,1);
SetGraphicRect(200, 81, 250, 160);
SetAlpha(255);
DrawGraphic(GetX - 10, GetY);
}
acc1 += 8;
acc2++;
anim1++;
anim2++;
anim3++;
if (acc2 <= 40){acc3 += 0.01;}
if (acc2 >= 40){acc3 -= 0.01;}
if (acc2 == 80){acc2 = 0;}
acc5++;
}
    @Finalize {
    }
}
