
script_enemy_main
{
    let count=0;
    let count2=0;
    let count3=0;
    let ten=0;
    let life=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(5000);
        SetDamageRate(225,64);
        SetTimer(39);
        SetInvincibility(0);
        SetNormPoint(-1);
        LoadGraphic(img);
        SetShotAutoDeleteClip(32,32,32,32);
        SetMovePositionRandom01(0,200,3,cx,88,cx,88);
        LoadGraphic(bg);
        LoadGraphic(bg2);
        LoadGraphic(bg3);
        LoadGraphic(GetCurrentScriptDirectory~"\img\circle_l.png");
        LoadUserShotData(GetCurrentScriptDirectory~".\shot_All.txt");

    }

    @MainLoop()
    {
        SetCommonDataEx("Spell","omake01",1);
        if (count==20) {
            SetColor(255,0,0);
            Concentration01(125);
            PlaySE(GetCurrentScriptDirectory~"\se\puu81.wav");
        }
        if (count2%4==0) {
            life=GetLife();
        }if (ten==1&&count2%4==1) {
            ten=0;
        }
        if (count2%4==3&&GetLife()<life&&GetLife()>0) {
            ten=1;
        }
        SetCollisionA(GetX(),GetY()-18,36);
        SetCollisionB(GetX(),GetY(),14);

        SetCommonData("Black",222);

        if (count2>=(115+35*(GetCommonDataDefault("ii1",0)<2000))&&count%90<74&&count%(9+2*(GetCommonDataDefault("ii1",0)<2000))==0&&count%450>=10&&count%450<=420) {
            PlaySE(GetCurrentScriptDirectory~"\se\Shot00.wav");
            ascent( let t in 0..7 ) {
                CreateShot02(GetX(),GetY()-2,4,220+count2*1.4+t*45,-0.1,3.4,49,10);
            }
        }


        if (GetCommonDataDefault("ii1",0)<2000) {
            if (count2>=170&&count%7==0&&count%900>=30&&count%900<=400) {
                PlaySE(GetCurrentScriptDirectory~"\se\Shot02.wav");
                ascent( let t in 0..3 ) {
                    CreateShot02(GetX(),GetY()-2,5,count2*4+t*4,-0.1,2.4-0.05*t+0.5,BLUE01,10);
                }
                ascent( let t in 0..3 ) {
                    CreateShot02(GetX(),GetY()-2,5,count2*4+t*4+180,-0.1,2.4-0.05*t+0.5,BLUE01,10);
                }
            }

            if (count2>=170&&count%7==0&&count%900>=480&&count%900<=850) {
                PlaySE(GetCurrentScriptDirectory~"\se\Shot02.wav");
                ascent( let t in 0..3 ) {
                    CreateShot02(GetX(),GetY()-2,5,count2*4+t*4,-0.1,2.4-0.05*t+0.4,BLUE01,10);
                }
                ascent( let t in 0..3 ) {
                    CreateShot02(GetX(),GetY()-2,5,count2*4+t*4+180,-0.1,2.4-0.05*t+0.4,BLUE01,10);
                }
            }

            if (count2>=145&&count%16==4&&count%450>=10&&count%450<=400) {
                PlaySE(GetCurrentScriptDirectory~"\se\Shot02.wav");
                ascent( let t in 16..24 ) {
                    CreateShot02(GetX(),GetY()-2,5,-count2*3+t*15,-0.1,2.3,46,10);
                }
            }
        }

        else {
            if (count2>=135&&count%7==0&&count%900>=30&&count%900<=400) {
                PlaySE(GetCurrentScriptDirectory~"\se\Shot02.wav");
                ascent( let t in 0..3 ) {
                    CreateShot02(GetX(),GetY()-2,5,count2*4+t*4,-0.1,2.9-0.05*t,BLUE01,10);
                    CreateShot02(GetX(),GetY()-2,5,count2*4+t*4+180,-0.1,2.9-0.05*t,BLUE01,10);
                    CreateShot02(GetX(),GetY()-2,5,count2*4+t*4,-0.1,2.9-0.05*t+0.5,BLUE01,10);
                    CreateShot02(GetX(),GetY()-2,5,count2*4+t*4+180,-0.1,2.9-0.05*t+0.5,BLUE01,10);
                }
            }

            if (count2>=135&&count%7==0&&count%900>=480&&count%900<=850) {
                PlaySE(GetCurrentScriptDirectory~"\se\Shot02.wav");
                ascent( let t in 0..3 ) {
                    CreateShot02(GetX(),GetY()-2,5,count2*4+t*4,-0.1,2.9-0.05*t,BLUE01,10);
                    CreateShot02(GetX(),GetY()-2,5,count2*4+t*4+180,-0.1,2.9-0.05*t,BLUE01,10);
                    CreateShot02(GetX(),GetY()-2,5,count2*4+t*4,-0.1,2.9-0.05*t+0.5,BLUE01,10);
                    CreateShot02(GetX(),GetY()-2,5,count2*4+t*4+180,-0.1,2.9-0.05*t+0.5,BLUE01,10);
                }
            }

            if (count2>=135&&count%16==4&&count%450>=10&&count%450<=400) {
                PlaySE(GetCurrentScriptDirectory~"\se\Shot02.wav");
                ascent( let t in 16..24 ) {
                    CreateShot02(GetX(),GetY()-2,5,-count2*3+t*15,-0.1,2.4,46,10);
                }
            }
        }

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

        if (count2>=165&&count%46==29) {
            SetMovePositionRandom01(rand(24,120),20,0.8,GetClipMinX()+100,80,GetClipMaxX()-100,120);
            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>0&&tame2<12) {
            SetGraphicRect(128*4,128,128*5,256);
        }
        if (ten==1&&OnBomb==false) {
            SetColor(160,160,180);
        }
        DrawGraphic(GetX(),GetY());

    }


}

