
script_enemy_main
{
    let count=0;
    let count2=0;
    let count3=0;
    let get;
    let try;

    let move=0;

    let pass=GetCurrentScriptDirectory~"Spell.dat";

    let cx=GetCenterX();
    let img=GetCurrentScriptDirectory~"img\dot_remilia.png";
    let bg=GetCurrentScriptDirectory~"img\st00.png";
    let bg2=GetCurrentScriptDirectory~"img\moon3-1.png";
    let bg3=GetCurrentScriptDirectory~"img\cloud.png";

    let WALL_TOP = 8;
    let WALL_LEFT = 4;
    let WALL_RIGHT = 2;
    let WALL_BOTTOM = 1;

    let mm=0;
    let shot=0;
    let tame=0;
    let tame2=0;
    let d=70;
    let ang=0;

#include_function ".\BGfx.txt"

    @Initialize()
    {
        MagicCircle(false);
        SetEnemyMarker(true);
        SetLife(3750);
        SetDamageRate(188,64);
        SetTimer(49);
        SetInvincibility(150);
        SetNormPoint(-1);
        LoadGraphic(img);
        SetShotAutoDeleteClip(32,32,32,32);
        SetMovePositionRandom01(0,200,3,cx,108,cx,108);
        LoadGraphic(bg);
        LoadGraphic(bg2);
        LoadGraphic(bg3);
        LoadGraphic(GetCurrentScriptDirectory~"\img\circle_l.png");
        LoadUserShotData(GetCurrentScriptDirectory~".\shot_All.txt");

    }

    @MainLoop()
    {
        SetCollisionA(GetX(),GetY()-16,28);
        SetCollisionB(GetX(),GetY(),14);

        SetCommonData("Black",100);

        if (count>=21&&count%280==25) {
            PlaySE(GetCurrentScriptDirectory~"\se\Shot01.wav");
            ang=0;
            ang+=GetAngleToPlayer();
            ascent( let t in 0..58 ) {
                CreateReflectShot02(GetX(),GetY()-2,12,GetAngleToPlayer()+9+6*t,-0.2,3,RED32,10,6,1,130);
            }
            ascent( let t in 0..58 ) {
                CreateReflectShot02(GetX(),GetY()-2,12,GetAngleToPlayer()+9+6*t,-0.2,2,RED32,10,6,1,130);
            }
            ascent( let t in 0..58 ) {
                CreateReflectShot02(GetX(),GetY()-2,12,GetAngleToPlayer()+9+6*t,-0.2,1,RED32,10,6,1,130);
            }
            CreateShotA(shot,GetX(),GetY(),0);
            SetShotDataA(shot,0,5,GetAngleToPlayer(),0,-0.1,0.6,49);
            SetShotDataA(shot,120,NULL,NULL,0,0.01,1.2,49);
            FireShot(shot);
        }

        if (count>=21&&count%280>=125&&count%280<220&&count%6==0) {
            PlaySE(GetCurrentScriptDirectory~"\se\Shot01.wav");
            ascent( let t in 0..58 ) {
                CreateReflectShot02(GetX(),GetY()-2,18,ang+9+6*t,-0.1,4.2,170,10,6,1,0);
            }
        }

        if (count2>=150) {
            count++;
        }
	count2++;
	move--;
        if (count>=10) {
            count3++;
        }

        if (count%280>=5) {
            tame++;
        }

        if (count%280>=220) {
            tame=0;
        }

        if (count%280==220) {
            SetMovePositionRandom01(90,50,6,GetClipMinX()+100,80,GetClipMaxX()-100,160);
            move=80;
        }

        yield;
    }

    @Finalize()
    {}

    @DrawLoop()
    {
        SetTexture(img);
        SetAlpha(255);
        SetGraphicAngle(0,0,0);
        SetColor(255,255,255);
        SetRenderState(ALPHA);
        SetGraphicScale(1,1);
        SetGraphicRect(0,0,128,128);
        if (int(GetSpeedX())==0&&count2/12%4>=0) {
            SetGraphicRect(0,0,128,128);
        }
        if (int(GetSpeedX())==0&&count2/12%4>=1) {
            SetGraphicRect(0,128,128,256);
        }
        if (int(GetSpeedX())==0&&count2/12%4>=2) {
            SetGraphicRect(0,256,128,384);
        }
        if (int(GetSpeedX())==0&&count2/12%4>=3) {
            SetGraphicRect(0,384,128,512);
        }
        if (GetSpeedX()<0&&count2<=d) {
            SetGraphicRect(256,0,384,128);
        }
        if (GetSpeedX()<0&&count2<=d-8) {
            SetGraphicRect(256,128,384,256);
        }
        if (GetSpeedX()>=0&&count2<=d) {
            SetGraphicRect(256,256,384,384);
        }
        if (GetSpeedX()>=0&&count2<=d-8) {
            SetGraphicRect(256,384,384,512);
        }
        if (GetSpeedX()<0&&move>0) {
            SetGraphicRect(256,0,384,128);
        }
        if (GetSpeedX()<0&&move>8) {
            SetGraphicRect(256,128,384,256);
        }
        if (GetSpeedX()>=0&&move>0) {
            SetGraphicRect(256,256,384,384);
        }
        if (GetSpeedX()>=0&&move>8) {
            SetGraphicRect(256,384,384,512);
        }
        if (int(GetSpeedX())==0&&tame>0) {
            SetGraphicRect(128*4,0,128*5,128);
        }
        if (int(GetSpeedX())==0&&tame>12) {
            SetGraphicRect(128*4,128,128*5,256);
        }
        DrawGraphic(GetX(),GetY());

    }


}

