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

script_enemy_main {

let frame1 = -30;
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 col = 0;

let SP = GetCurrentScriptDirectory~"sp\Sprite.png";
let Custom = GetCurrentScriptDirectory~"sup\supershot.txt";
let MC = GetCurrentScriptDirectory~"ef\NMC.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 timer = GetTimer;
let time1 = GetCurrentScriptDirectory~"sfx\time1.wav";
let time2 = GetCurrentScriptDirectory~"sfx\time2.wav";
let Cut = GetCurrentScriptDirectory~"ef\Cut.png";
	#include_function ".\blossom.txt";

    @Initialize {
	LoadSE(time1);
LoadSE(time2);

SetMovePosition03(GetCenterX, GetCenterY - 100, 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(1000);
SetDamageRate(40, 40);
SetTimer(32);
SetInvincibility(120);
SetEnemyMarker(true);
SetShotAutoDeleteClip(128,128,128,128);
    }

    @MainLoop {
if(GetTimer!=timer && (GetTimer < 10 && GetTimer>3)){
	PlaySE(time1);
	}

	if(GetTimer!=timer && GetTimer < 4){
	PlaySE(time2);
	

	
}
timer = GetTimer;

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 == 80)
        { 
	SetMovePosition02(GetCenterX + rand(-50,50), GetCenterY - rand(100,150), 40);
        }
        if (frame1 == 120 || frame1 == 125 || frame1 == 130 || frame1 == 135 || frame1 == 140)
        { 
	a2 = rand(-0.9,0.9);
	a3 = rand(-0.9,0.9);
	random1 = rand(-10,10);
	random2 = rand(-20,20);
        loop(18)
        { 
            CreateShotA(1,GetX+20,GetY-30,20);
	    SetShotDataA(1,0,5,a4,a2,-0.2,0.1,98+col);
	    SetShotDataA(1,40,NULL,NULL,0,0.054,3,NULL);
	    FireShot(1);
            CreateShotA(1,GetX+20,GetY-30,20);
	    SetShotDataA(1,0,5,a4,a3,-0.2,0.5,98+col);
	    SetShotDataA(1,40,NULL,NULL,0,0.01,5,NULL);
	    FireShot(1);
	 CreateShotA(1,GetX+20,GetY-30,20);
	    SetShotDataA(1,0,5,-a4,-a2,-0.2,0.1,98+col);
	    SetShotDataA(1,20,NULL,NULL,0,-0.054,-2,NULL);
	    FireShot(1);
            CreateShotA(1,GetX+20,GetY-30,20);
	    SetShotDataA(1,0,5,a4,a3,-0.2,0.5,98+col);
	    SetShotDataA(1,40,NULL,NULL,0,0.01,3,NULL);
	    FireShot(1);
	 CreateShotA(1,GetX+20,GetY-30,20);
	    SetShotDataA(1,0,5,a4,a2,-0.2,0.1,98+col);
	    SetShotDataA(1,40,NULL,NULL,0,0.054,2,NULL);
	    FireShot(1);
            CreateShotA(1,GetX+20,GetY-30,20);
	    SetShotDataA(1,0,5,a4,a3,-0.2,0.5,98+col);
	    SetShotDataA(1,40,NULL,NULL,0,0.01,5,NULL);
	    FireShot(1);
            a4 += 360/18;
        }
	PlaySE(sh2);
	a4+=0.7*cos(a3*7);
        }
        if (frame1 == 160)
        { 
	col++;
	if(col==9){col=0; }
	frame1 = 61;
        }
        frame1++;
        frame2++;
        frame3++;
        frame4++;
    }

    @DrawLoop {

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

if (GetSpeedX == 0){
SetTexture(SP);
SetRenderState(ALPHA);
SetGraphicAngle(0,0,0);
SetGraphicScale(1,1);
SetGraphicRect(0, 0, 96, 128);
SetAlpha(255);
DrawGraphic(GetX+5, GetY+3*sin(anim1));
}
if (GetSpeedX > 0){
SetTexture(SP);
SetRenderState(ALPHA);
SetGraphicAngle(0,0,0);
SetGraphicScale(1,1);
SetGraphicRect(285, 136, 380, 264);
SetAlpha(255);
DrawGraphic(GetX, GetY+3*sin(anim1));
}
if (GetSpeedX < 0){
SetTexture(SP);
SetRenderState(ALPHA);
SetGraphicAngle(0,0,0);
SetGraphicScale(1,1);
SetGraphicRect(285, 258, 380, 386);
SetAlpha(255);
DrawGraphic(GetX - 10, GetY+3*sin(anim1));
}
acc1 += 8;
acc2 += 2;
anim1 += 7;
anim2 += 0.4;
anim3++;
acc5 += 2;
acc3 = 0.3*cos(acc2);
}
    @Finalize {
    }
}
