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&&GetArgument==2) {
            CreateItem(ITEM_SCORE,GetX(),GetY()+22);
            PlaySE(GetCurrentScriptDirectory~"\se\crash16_c.wav");
            if (GetCommonDataDefault("Sign",0)>=2) {
                PlaySE(GetCurrentScriptDirectory~"\se\Baaaan.wav");
                ascent(let tt in 0..30) {
                    CreateShot02(GetX()+(50+rand(-50,20))*cos(tt*12),GetY()+(50+rand(-50,20))*sin(12*tt),0,tt*12,0.1,0,170,1+R/4);
                }
                ascent(let tt in 0..30) {
                    CreateShot02(GetX()+15*cos(tt*12),GetY()+15*sin(12*tt),0,tt*12,0.1,0,170,1+R/8);
                }
            }
            else {
                //ascent(let tt in 0..20){CreateShot02(GetX()+50*cos(90+tt*18),GetY()+50*sin(90+18*tt),0,90+tt*18,0.1,0.8,170,30);}
                //ascent(let tt in 0..20){CreateShot02(GetX()+25*cos(90+tt*18),GetY()+25*sin(90+18*tt),0,90+tt*18,0.1,1.2,170,30);}
                ascent(let tt in 0..16) {
                    CreateShot12(GetX+rand(-4,4),GetY,rand(-2.4,2.4),rand(-0.7,-8.1),0,0,0,0,170,rand(4,15));
                }
            }
        }

        if (BeVanished==false&&GetArgument!=2&&GetArgument<=5) {
            CreateItem(ITEM_SCORE,GetX(),GetY()+22);
            PlaySE(GetCurrentScriptDirectory~"\se\crash16_c.wav");
            if (GetCommonDataDefault("Sign",0)>=2) {
                PlaySE(GetCurrentScriptDirectory~"\se\Baaaan.wav");
                ascent(let tt in 0..30) {
                    CreateShot02(GetX()+(50+rand(-50,20))*cos(tt*12),GetY()+(50+rand(-50,20))*sin(12*tt),0,tt*12,0.1,0,170,1+R/4);
                }
                ascent(let tt in 0..30) {
                    CreateShot02(GetX()+15*cos(tt*12),GetY()+15*sin(12*tt),0,tt*12,0.1,0,170,1+R/8);
                }
            }
            else {
                //ascent(let tt in 0..20){CreateShot02(GetX()+50*cos(tt*18),GetY()+50*sin(18*tt),0,tt*18,0.1,1.1,170,30);}
                //ascent(let tt in 0..20){CreateShot02(GetX()+25*cos(tt*18),GetY()+25*sin(18*tt),0,tt*18,0.1,1.2,170,30);}
                ascent(let tt in 0..16) {
                    CreateShot12(GetX+rand(-4,4),GetY,rand(-2.4,2.4),rand(-0.7,-8.1),0,0,0,0,170,rand(4,15));
                }
            }
        }

        if (BeVanished==false&&GetArgument>5) {
            CreateItem(ITEM_SCORE,GetX(),GetY()+22);
            PlaySE(GetCurrentScriptDirectory~"\se\crash16_c.wav");
            if (GetCommonDataDefault("Sign",0)>=2) {
                PlaySE(GetCurrentScriptDirectory~"\se\Baaaan.wav");
                ascent(let tt in 0..30) {
                    CreateShot02(GetX()+(50+rand(-50,20))*cos(tt*12),GetY()+(50+rand(-50,20))*sin(12*tt),0,tt*12,0.1,0,170,1+R/4);
                }
                ascent(let tt in 0..30) {
                    CreateShot02(GetX()+15*cos(tt*12),GetY()+15*sin(12*tt),0,tt*12,0.1,0,170,1+R/8);
                }
            }
            else {
                ascent(let tt in 0..20) {
                    CreateShot12(GetX+rand(-4,4),GetY,rand(-2.4,2.4),rand(-0.7,-8.1),0,0,0,0,170,rand(4,15));
                }
            }
        }
    }

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(470+(GetArgument==2)*50);
    SetDamageRate(50,0);
    SetScore(2000000);
    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-150+80*(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-160+80*(GetArgument%5)-rand(0,0),120+(GetArgument>=10)*25,cx-160+80*(GetArgument%5)+rand(0,0),120+(GetArgument>=10)*25);
        move=55;
    }
    if (GetArgument<=4) {
        if (count==206) {
            PlaySE(GetCurrentScriptDirectory~"\se\Shot01.wav");
            ascent( let t in 0..6 ) {
                CreateShot02(GetX(),GetY()+2,7,90+t*60+(GetArgument==2)*30,-0.2,4.6,169,20);
            }
        }
        if (count>=208&&count<=350&&count%3==2) {
            PlaySE(GetCurrentScriptDirectory~"\se\Shot00.wav");
            ascent( let t in 0..6 ) {
                CreateShot02(GetX(),GetY()+2,7,90+t*60+(GetArgument==2)*30,-0.2,4.6,196,20);
            }
        }
        if (GetCommonDataDefault("Sign",0)>=2) {
            R+=6;
        }
        if (GetX>=cx-R&&GetX<=cx+R) {
            SetLife(180);
        }
    }
    if (GetArgument>=10) {
        if (count<206) {
            SetDamageRate(0,0);
        }
        if (count==206) {
            PlaySE(GetCurrentScriptDirectory~"\se\Shot01.wav");
            SetDamageRate(150,40);
            ascent( let t in 0..6 ) {
                CreateShot02(GetX(),GetY()+2,7,90+t*60+(GetArgument==12)*30,-0.2,4.6,169,20);
            }
        }
        if (count>=208&&count<=350&&count%3==2) {
            PlaySE(GetCurrentScriptDirectory~"\se\Shot00.wav");
            ascent( let t in 0..6 ) {
                CreateShot02(GetX(),GetY()+2,7,90+t*60+(GetArgument==12)*30,-0.2,4.6,196,20);
            }
        }
        if (count>=208&&count<=350&&count%18==2&&GetCommonDataDefault("ii1",0)<2000) {
            PlaySE(GetCurrentScriptDirectory~"\se\Shot02.wav");
            CreateShot02(GetX(),GetY()+2,5,GetAngleToPlayer,-0.2,4.6,169,20);
        }
        if (count>=208&&count<=350&&count%18==2&&GetCommonDataDefault("ii1",0)>=2000) {
            PlaySE(GetCurrentScriptDirectory~"\se\Shot02.wav");
            CreateShot02(GetX(),GetY()+2,5,GetAngleToPlayer,-0.2,5.6,169,10);
            CreateShot02(GetX(),GetY()+2,5,GetAngleToPlayer+5,-0.2,4.6,169,10);
            CreateShot02(GetX(),GetY()+2,5,GetAngleToPlayer+5,-0.2,4.6,169,10);
        }
        //if(count>=400&&count%4==2&&count%40<27){PlaySE(GetCurrentScriptDirectory~"\se\Shot00.wav");
        //ascent( let t in 0..2 ){CreateShot12(GetX+rand(-4,4),GetY,rand(-0.4,0.4),rand(-0.4,-2.1),0,0.03,0,2.4,196,rand(4,15));}
        //	ascent( let t in 0..2 ){CreateShot12(GetX+rand(-4,4),GetY,-2.6+t*5,0,0,0.02,0,2.4,196,14);}}
        if (count>=400&&count%25==2&&count%40<27) {
            PlaySE(GetCurrentScriptDirectory~"\se\Shot00.wav");
            ascent( let t in 0..2 ) {
                CreateShot12(GetX+rand(-4,4),GetY,rand(-0.4,0.4),rand(-0.4,-2.1),0,0.03,0,2.4,196,rand(4,15));
            }
        }
        if (GetCommonDataDefault("Sign",0)>=2) {
            R+=6;
        }
        if (GetX>=cx-R&&GetX<=cx+R) {
            SetLife(180);
        }
    }
    if (GetArgument>=5&&GetArgument<=9) {
        if (count==206) {
            PlaySE(GetCurrentScriptDirectory~"\se\Shot02.wav");
            ascent( let t in 0..6 ) {
                CreateShot12(GetX,GetY,rand(-3.7,3.7),rand(-0.4,-2.6),0,-0.03,0,-2.4,196,12);
            }
        }
        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
{if (N17<=0) {
    CreateItem(ITEM_SCORE,GetX(),GetY());
    SetColor(155,0,0);
    Explosion01(GetX,GetY,3,0.02,180);
}
}

@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);
    }
}
}
