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

    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 sh00=GetCurrentScriptDirectory~"\se\Shot00.wav";
    let mm=5;
    let shot=0;
    let tame=0;
    let tame2=0;
    let d=70;
    let ang=0;

    @Initialize()
    {
        MagicCircle(false);
        SetEnemyMarker(true);
        SetLife(4800);
        SetDamageRate(240,94);
        SetTimer(49);
        SetInvincibility(150);
        SetNormPoint(-1);
        LoadGraphic(img);
        SetShotAutoDeleteClip(32,32,32,32);
        SetMovePositionRandom01(0,200,3,cx-1,108,cx-1,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",188);

        if (count>=21&&count%7==0&&count%160>=80) {
            PlaySE(GetCurrentScriptDirectory~"\se\Shot02.wav");
            ascent( let t in 0..18 ) {
                CreateShotA(shot,GetX(),GetY(),15);
                SetShotDataA(shot,0,2.5,mm-count*6+t*20,0,0,3,46);
                SetShotDataA(shot,15,NULL,NULL,-0.3,-0.04,0.5,46);
                SetShotDataA(shot,85,NULL,NULL,0.3,0.04,5,46);
                FireShot(shot);
            }
        }
        if (count>=21&&count%7==0&&count%160<80) {
            PlaySE(GetCurrentScriptDirectory~"\se\Shot02.wav");
            ascent( let t in 0..18 ) {
                CreateShotA(shot,GetX(),GetY(),15);
                SetShotDataA(shot,0,2.5,mm+count*6+t*20,0,0,3,46);
                SetShotDataA(shot,15,NULL,NULL,0.3,-0.04,0.5,46);
                SetShotDataA(shot,85,NULL,NULL,-0.3,0.04,5,46);
                FireShot(shot);
            }
        }
        if (count>=21&&count%4==0&&count%160>30&&count%160<60) {
            let i=0;
            while (i>-360) {
                CreateShot02(GetX(),GetY(),12-count/20,i+count3,-0.4,4.2,196,0);
                i-=5;
                PlaySE(sh00);
            }
        }
        if (count>=21&&count%4==0&&count%160>110&&count%160<140) {
            let i=0;
            while (i<360) {
                CreateShot02(GetX(),GetY(),12-count/20,i-count3,-0.4,4.2,196,0);
                i+=5;
                PlaySE(sh00);
            }
        }
        if (count%160==159) {
            mm+=GetPlayerX();
        }
        if (count2>=60) {
            count++;
        }count2++;
        if (count>=10) {
            count3++;
        }

    }

    @Finalize()
    {
        if (!OnBomb) {
            CreateItem(ITEM_1UP,0,440);
        }
    }

    @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 (int(GetSpeedX())==0&&tame>0) {
            SetGraphicRect(128*4,0,128*5,128);
        }
        if (int(GetSpeedX())==0&&tame>0&&tame2<12) {
            SetGraphicRect(128*4,128,128*5,256);
        }
        DrawGraphic(GetX(),GetY());

    }

}

