#TouhouDanmakufu
#Title[RAN_Non04]
#Text[Starter]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main {

let frame1 = 0;
let frame2 = 0;
let frame3 = 0;
let frame4 = 0;
let frame5 = 0;
let frame6 = 0;
let a1 = 0;
let a2 = 0;
let a3 = 0;
let a4 = 0;
let acc1 = 0;
let acc2 = 0;
let acc3 = 0;
let acc4 = 0;
let acc5 = 0;
let acc6 = 0;
let random1 = 0;

let BossImage = GetCurrentScriptDirectory~"RanSpeed0.png";
let BossImage2 = GetCurrentScriptDirectory~"RanSpin.png";
let MC = GetCurrentScriptDirectory~"magiccircle.png";
let ShotSE = GetCurrentScriptDirectory~"ShotSE.wav";
let ShotSE2 = GetCurrentScriptDirectory~"ShotSE2.wav";
let ShotSE3 = GetCurrentScriptDirectory~"ShotSE3.wav";
let Death = GetCurrentScriptDirectory~"se_enep01.wav";
let Custom = GetCurrentScriptDirectory~"supershot.txt";
let BG = GetCurrentScriptDirectory~"bg2.png";
let BG2 = GetCurrentScriptDirectory~"nobg.png";

    @Initialize {

SetMovePosition02(GetCenterX, GetCenterY - 100, 10);
LoadGraphic(BossImage);
LoadGraphic(BossImage2);
LoadGraphic(BG);
LoadGraphic(BG2);
LoadGraphic(MC);
LoadSE(ShotSE);
LoadSE(ShotSE2);
LoadSE(ShotSE3);
LoadSE(Death);
SetLife(1000);
SetDamageRate(40, 0);
SetTimer(30);
SetInvincibility(120);
SetEnemyMarker(true);
SetShotAutoDeleteClip(50,50,50,50);
    }

    @MainLoop {
SetCollisionA(GetX, GetY, 32);
SetCollisionB(GetX, GetY, 24);
LoadUserShotData(Custom);
        if (frame1 == 50)
        { 
        loop(2)
        {
	acc1 += 0.5;
        loop(5)
        {
            CreateShot01(GetX, GetY, 1 + acc1, a1 + a2, 77, 10);
            CreateShot01(GetX, GetY, 2 + acc1, a1 + a2, 80, 10);
            a1 += 360/5;
        }
	}
        CreateShot01(GetX, GetY, 3, a1 + a2, 229, 25);
        CreateShot01(GetX, GetY, 3.2, a1 + a2, 202, 20);
        CreateShot01(GetX, GetY, 3.4, a1 + a2, 25, 15);
        CreateShot01(GetX, GetY, 3.6, a1 + a2, 158, 10);

        CreateShot01(GetX, GetY, 3, 180+a1 + a2, 230, 25);
        CreateShot01(GetX, GetY, 3.2, 180+a1 + a2, 204, 20);
        CreateShot01(GetX, GetY, 3.4, 180+a1 + a2, 30, 15);
        CreateShot01(GetX, GetY, 3.6, 180+a1 + a2, 160, 10);
	PlaySE(ShotSE2);
	a2 += 33;
	acc1 = 0;
	frame1 = 40;
        }
        frame1++;
	if (frame2 == 130)
        { 
	SetMovePositionRandom01(50,20,5,GetClipMinX()+100,30,GetClipMaxX()-100,100);
	frame2 = 0;
        }
        frame2++;
        frame3++;
        frame4++;
    }

    @DrawLoop {


SetTexture(BG2);
SetRenderState(ALPHA);
SetGraphicAngle(0,0,0);
SetGraphicRect(0, 0, 10000, 10000);
SetGraphicScale(1,1);
SetAlpha(255);
DrawGraphic(GetCenterX, GetCenterY);

SetRenderState(ALPHA);
SetGraphicScale(1,1);
SetAlpha(255);
SetGraphicRect(0, 0, 64, 83);
if (GetSpeedX == 0 && GetSpeedY == 0)
{
SetTexture(BossImage);
SetGraphicAngle(0,0,0);
}
if (GetSpeedX > 0 || GetSpeedY > 0 || GetSpeedX < 0 || GetSpeedY < 0)
{
SetTexture(BossImage2);
SetGraphicAngle(0,0,acc6);
}
DrawGraphic(GetX, GetY);

SetTexture(MC);
SetRenderState(ADD);
SetGraphicAngle(0,0,acc5);
SetGraphicRect(0, 0, 128, 128);
SetGraphicScale(1+acc4,1+acc4);
SetAlpha(255);
DrawGraphic(GetX, GetY);
frame5++;
if (frame5 <= 50)
{
acc4 += 0.01;
}
if (frame5 >= 50)
{
acc4 -= 0.01;
}
if (frame5 == 100)
{
frame5 = 0;
}

acc5 += 13;
acc6 += 23;
    }

    @Finalize {
    }
}
