script_enemy_main
{
    let count=0;
    let count2=0;
    let count3=0;
    let R=0;
    let R2=0;
    let R3=0;
    let R4=0;
    let o=0;
    let N17=0;
    let move=0;
    let Level=0;
    let ten=0;
    let life=0;
    let get;
    let try;
        let tame=0;
        let tame2=0;

        let pass=GetCurrentScriptDirectory~"Spell.dat";

        let bombalpha=255;

        let cx=GetCenterX();

        let mm=0;
        let shot=0;
        let tame=0;
        let tame2=0;
        let c=0;
        let d=60;
        let ang=0;

        function dead {
            SetDamageRate(0,0);

    if (N17==50) {
    if (GetLife>=200) {
            AddScore(1000000);
        }
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Servant10.txt",GetX,GetY,0,0,1);

        if (BeVanished==false) {
            PlaySE(GetCurrentScriptDirectory~"\se\baaaan.wav");
        }
    }

if (N17<100) {
N17+=50;
}
if (N17>=100) {
VanishEnemy;
}
if (count%3<=0) {
Explosion01(GetX+rand(-10,10),GetY+rand(-10,10),24,0.1,20);
}
    }

    @Initialize
{
    SetLife(460);
    SetDamageRate(50,0);
    Level+=GetPlayerLife();
    LoadUserShotData(GetCurrentScriptDirectory~".\shot_All.txt");
}


@MainLoop
{
    if (count2%4==0) {
        life=GetLife();
    }if (ten==1&&count2%4==1) {
        ten=0;
    }
    if (count2%4==3&&GetLife()<life&&GetLife()>0) {
        ten=1;
    }
    if (GetLife<400) {
        dead;
    }
    if (OnBomb==false||OnEnemySpell==false) {
        SetCollisionA(GetX(),GetY()-6,16);
        if (GetCommonDataDefault("Sign",0)<1) {
            SetCollisionB(GetX(),GetY(),6);
        }
    }

    if (count>=225&&count%65==GetArgument%5*11&&rand(0,100)<=92) {
        SetMovePositionRandom01(85,rand(10,40),2,cx-150+80*(GetArgument%5)-rand(0,42),120+count/3,cx-75+40*(GetArgument%5)+rand(0,42),220+count/2.8);
        move=43;
    }
    if (count>=500&&count%65==GetArgument%5*11) {
        SetMovePositionRandom01(85,rand(10,40),2,cx-150+80*(GetArgument%5)-rand(0,12),120+count/3,cx-150+80*(GetArgument%5)+rand(0,12),220+count/2.8);
        move=43;
    }
    if (count%3==0&&GetCommonDataDefault("Sign",0)==1) {
        SetMovePositionRandom01(85,rand(10,30),rand(6,16),cx-150+80*(GetArgument%5)-rand(0,52),120+count/3,cx-150+80*(GetArgument%5)+rand(0,52),220+count/2.8);
        move=5;
    }
    if (move<=12&&GetCommonDataDefault("Sign",0)==2) {
        SetMovePositionRandom01(85,rand(10,40),rand(6,16),cx-150+80*(GetArgument%5)-rand(0,122),120+count/3,cx-150+80*(GetArgument%5)+rand(0,122),220+count/2.7);
        move=128;
    }
    if (count==115) {
        SetMovePositionRandom01(85,rand(10,40),5,cx-100+50*(GetArgument%5)-rand(0,0),120+(GetArgument>=10)*25,cx-100+50*(GetArgument%5)+rand(0,0),120+(GetArgument>=10)*25);
        move=55;
    }
    if (GetArgument<=4) {
        if (GetCommonDataDefault("Sign",0)>=2) {
            R+=6;
        }
        if (GetX>=cx-R&&GetX<=cx+R) {
            SetLife(180);
        }
    }
    if (GetY-55>GetClipMaxY) {
        VanishEnemy;
    }

    count++;
    count2++;
    move--;

}

@Finalize
{
}

@DrawLoop
{
    if (OnEnemySpell==true&&OnBomb==true&&bombalpha>0) {
        bombalpha-=5;
    }
    if (OnEnemySpell==true&&OnBomb==false&&bombalpha<255) {
        bombalpha+=5;
    }

    SetTexture(GetCurrentScriptDirectory~"\img\dot_flandre.png");
    SetAlpha(255);
    SetGraphicAngle(0,0,0);
    SetColor(bombalpha,bombalpha,bombalpha);
    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&&move>0) {
        SetGraphicRect(256,0,384,128);
    }
    if (GetSpeedX()<0&&move>9) {
        SetGraphicRect(256,128,384,256);
    }
    if (GetSpeedX()>=0&&move>0) {
        SetGraphicRect(256,256,384,384);
    }
    if (GetSpeedX()>=0&&move>9) {
        SetGraphicRect(256,384,384,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 (tame>0&&tame2<=0) {
        SetGraphicRect(128*3,0,128*4,128);
    }
    if (tame>32&&tame2<=0) {
        SetGraphicRect(128*3,128,128*4,256);
    }
    if (tame>42&&tame2<=0) {
        SetGraphicRect(128*3,256,128*4,384);
    }
    if (ten==1&&OnBomb==false) {
        SetColor(100,100,180);
    }
    DrawGraphic(GetX(),GetY());

    if (bombalpha<255) {
        SetTexture(GetCurrentScriptDirectory~"\img\dot_flandre.png");
        SetAlpha(255-bombalpha);
        SetGraphicRect(128*6,0,128*7,128);
        SetColor(255,200,200);
        SetGraphicScale(1.1,1.1);
        SetRenderState(ALPHA);
        if (count2/4%4>=0) {
            SetGraphicRect(128*6,0,128*7,128);
        }
        if (count2/4%4>=1) {
            SetGraphicRect(128*6,128,128*7,256);
        }
        if (count2/4%4>=2) {
            SetGraphicRect(128*6,256,128*7,384);
        }
        if (count2/4%4>=3) {
            SetGraphicRect(128*6,384,128*7,512);
        }
        DrawGraphic(GetX(),GetY()+12);
    }
}
}
