script_enemy_main
{
    let count=0;
    let MT=0;
    let mm=0;
    let cc=0;
    let N15=0;
    let Level=0;
    let N17=0;
    let life=0;
    let ten=0;

function dead {
    SetDamageRate(0,0);
    if (N17==50) {
        if (GetArgument<=1) {
            if (BeVanished==false) {
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Servant10.txt",GetX,GetY,0,0,3);
                PlaySE(GetCurrentScriptDirectory~"\se\Baaaan2.wav");
                SetCommonData("ii1",GetCommonDataDefault("ii1",0)+GetCommonDataDefault("ii2",0));
                SetCommonData("ii3",1);

                DeleteEnemyShotToItemInCircle(ALL,GetX(),GetY(),400);
                loop(10) {
                    CreateItem(ITEM_SCORE,GetX()+rand(-32,32),GetY()+rand(18,64));
                }
                if (GetArgument==1) {
                    CollectItems;
                    Explosion01(GetX,GetY,6,0.3,80);
                    loop(10) {
                        CreateItem(ITEM_SCORE,GetX()+rand(-32,32),GetY()+rand(18,64));
                    }
                    PlaySE(GetCurrentScriptDirectory~"\se\Baaaaaaaan.wav");
                    PlaySE(GetCurrentScriptDirectory~"\se\powerdown.wav");
                    loop(20) {
                        CreateItem(ITEM_SCORE,GetX()+rand(-102,102),GetY()+rand(-58,74));
                    }CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy07.txt",GetX(),GetY(),0,0,2);
                }
            }
        }
        if (GetArgument==2&&BeVanished==false&&OnBomb==false) {
            PlaySE(GetCurrentScriptDirectory~"\se\crash16_c.wav");
            AddScore(5000000);
            CreateItem(ITEM_1UP,GetX(),GetY()+12);
            CreateEnemyFromFile(GetCurrentScriptDirectory~"Servant10.txt",GetX,GetY,0,0,4);
            SetCommonData("ii1",GetCommonDataDefault("ii1",0)+GetCommonDataDefault("ii2",0));
            SetCommonData("ii3",1);
        }
        if (GetArgument==2&&BeVanished==false&&OnBomb==true) {
            PlaySE(GetCurrentScriptDirectory~"\se\Baaaan.wav");
            CreateEnemyFromFile(GetCurrentScriptDirectory~"Servant10.txt",GetX,GetY,0,0,3);
            SetCommonData("ii1",GetCommonDataDefault("ii1",0)+GetCommonDataDefault("ii2",0));
            SetCommonData("ii3",1);
        }
    }
    if (GetArgument==8&&N17<20) {
        DeleteEnemyShotToItemInCircle(CHILD,GetX(),GetY(),500);
    }
    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(5430);
}


@MainLoop
{
    if (count%5==0) {
        life=GetLife();
    }if (ten==1&&count%5==1) {
        ten=0;
    }
    if (count%5==4&&GetLife()<life&&GetLife()>200) {
        ten=1;
    }

    if (GetArgument==0) {
        SetAngle(90);
        SetSpeed(5.2-count*0.06);
        SetDamageRate(100,32);
        if (count<100) {
            SetLife(5430);
        }
        if (count==0) {
            SetScore(55000);
            N15=90;
            CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy08.txt",GetX(),GetY()+35,0,0,0);
        }
        if (GetLife<5400) {
            dead;
        }
        else {
            if (count>=10) {
                SetCollisionA(GetX(),GetY(),19);
                SetCollisionB(GetX(),GetY(),5);
            }
        }
        if (count>400) {
            VanishEnemy;
        }if (count>80) {
            SetSpeed(0);
        }if (count>350) {
            SetCollisionA(GetX(),GetY(),40);
            SetSpeed(-(count-350)*0.2);
        }
        if (count>360) {
            SetLife(6028);
        }
        if (count>=80&&count<=89) {
            N15-=4;
        }if (count>89&&count<=140) {
            N15-=1;
        }if (count%70==0) {
            cc=0;
            cc+=GetAngleToPlayer;
        }
        if (count>140&&count<280&&count%4==0&&count%70<50&&GetLife>5400) {
            PlaySE(GetCurrentScriptDirectory~"\se\Shot01.wav");
            CreateShot02(GetX()-35,GetY(),2,cc-3*(GetCommonDataDefault("Mode",0)>=3)+5*(GetCommonDataDefault("Mode",0)<2),0.1,3,67,10);
            CreateShot02(GetX()+35,GetY(),2,cc+3*(GetCommonDataDefault("Mode",0)>=3)-5*(GetCommonDataDefault("Mode",0)<2),0.1,3,67,10);
        }
    }

    if (GetArgument==1) {
        if (count==0) {
            SetScore(55000);
            N15=90;
            SetLife(6005);
            CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy08.txt",GetX(),GetY()+35,0,0,0);
        }
        SetAngle(90);
        SetSpeed(5.2-count*0.06);
        SetDamageRate(100,3);
        if (GetLife<5400) {
            dead;
        }
        else {
            if (count>=10) {
                SetCollisionA(GetX(),GetY(),28);
                SetCollisionB(GetX(),GetY(),5);
            }
        }
        if (count>750) {
            VanishEnemy;
        }if (count>80) {
            SetSpeed(0);
        }if (count>620) {
            SetCollisionA(GetX(),GetY(),36);
            SetLife(6428);
            SetSpeed(-(count-620)*0.05);
        }
        if (count>=80&&count<=89) {
            N15-=4;
        }if (count>89&&count<=140) {
            N15-=1;
        }if (count%70==0) {
            cc=0;
            cc+=GetAngleToPlayer;
        }
        if (count>140&&count<420&&count%4==0) {
            PlaySE(GetCurrentScriptDirectory~"\se\Shot01.wav");
            CreateShot02(GetX()-35,GetY(),2,cc,0.1,3+1*(GetPlayerLife>5),67,10);
            CreateShot02(GetX()+35,GetY(),2,cc,0.1,3+1*(GetPlayerLife>5),67,10);
            CreateShot02(GetX()-35,GetY(),2,cc+15,0.1,3+1*(GetPlayerLife>5),67,10);
            CreateShot02(GetX()+35,GetY(),2,cc-15,0.1,3+1*(GetPlayerLife>5),67,10);
            CreateShot02(GetX()-35,GetY(),2,cc+30,0.1,3+1*(GetPlayerLife>5),67,10);
            CreateShot02(GetX()+35,GetY(),2,cc-30,0.1,3+1*(GetPlayerLife>5),67,10);
        }
    }

    if (GetArgument==2) {
        if (count==0) {
            SetScore(55000);
            N15=90;
            SetLife(5800);
        }SetSpeed(0.1);
        SetDamageRate(50,10);
        SetAngle(270);
        if (count>50) {
            SetDamageRate(100,20);
        }
        if (count>130) {
            SetAngle(340+rand(-50,50));
            SetSpeed((count-130)*0.023);
        }
        if (GetLife<5400) {
            dead;
        }
        else {
            SetCollisionA(GetX(),GetY(),18);
            SetCollisionB(GetX(),GetY(),7);
        }
        if (count>330) {
            VanishEnemy;
        }
    }

    if (GetArgument>=3) {
        if (count>80) {
            VanishEnemy;
        }
    }

    count++;
    yield;

}

@Finalize
{
}

@DrawLoop
{

    if (GetArgument<=1) {
        SetTexture(GetCurrentScriptDirectory~"\img\familiar.png");
        SetColor(211,211,211);
        SetGraphicAngle(0,0,0);
        SetGraphicScale(1.2,1.2);
        SetAlpha(255);
        SetRenderState(ADD);
        SetGraphicRect(144,48,192,96);
        DrawGraphic(GetX(),GetY()-5);
        SetGraphicScale(1,1);
        SetGraphicAngle(0,0,count*5);
        DrawGraphic(GetX()+35*cos(N15),GetY()+35*sin(N15)+N15/3);
        SetGraphicAngle(0,0,-count*5);
        DrawGraphic(GetX()-35*cos(N15),GetY()+35*sin(N15)+N15/3);

        if (GetArgument==1) {
            SetGraphicScale(1.5,1.5);
            SetGraphicAngle(0,0,count*5);
            DrawGraphic(GetX()+45,GetY()-35);
            SetGraphicAngle(0,0,-count*5);
            DrawGraphic(GetX()-45,GetY()-35);
        }
    }

    if (GetArgument<=0) {
        SetTexture(GetCurrentScriptDirectory~"\img\dot-kaze-ti.png");
        if (count<=50) {
            SetAlpha(0);
        }
        if (count>=50&&count<=112) {
            SetAlpha((count-50)*4);
        }
        if (count>=112||GetArgument==0) {
            SetAlpha(255);
        }if (GetArgument==2) {
            SetAlpha(255);
        }
        SetGraphicRect(64,0,128,64);//if(GetArgument==2){SetGraphicRect(192,0,256,64);}
        SetRenderState(ALPHA);
        SetColor(225+count%4*30,225+count%4*30,225+count%4*30);
        if (ten==1) {
            SetColor(0,0,140);
        }
        SetGraphicScale(1.12,1.12);
        SetGraphicAngle(0,0,-count*5);
        DrawGraphic(GetX(),GetY());

        SetGraphicRect(64,0,128,64);//if(GetArgument==2){SetGraphicRect(192,0,256,64);}
        SetRenderState(ALPHA);
        SetColor(225+count%4*30,225+count%4*30,225+count%4*30);
        SetGraphicScale(0.8,0.8);
        SetGraphicAngle(0,0,count*5);
        if (ten==1) {
            SetColor(0,0,140);
        }
        DrawGraphic(GetX(),GetY());

        SetGraphicRect(0,0,64,64);//if(GetArgument==2){SetGraphicRect(128,0,192,64);}
        SetColor(255,255,255);
        SetGraphicScale(0.65,0.65);
        SetGraphicAngle(0,0,90);
        if (ten==1) {
            SetColor(0,0,140);
        }
        DrawGraphic(GetX(),GetY());
    }

    if (GetArgument==1) {
        SetTexture(GetCurrentScriptDirectory~"\img\dot-kaze-ti.png");
        SetGraphicRect(256,448,320,512);
        SetRenderState(ALPHA);
        SetColor(255,255,255);
        SetGraphicScale(1,1);
        SetGraphicAngle(0,0,0);
        if (ten==1) {
            SetColor(0,0,140);
        }
        DrawGraphic(GetX(),GetY()+4+3*sin(count*2));
    }

    if (GetArgument==2) {
        SetTexture(GetCurrentScriptDirectory~"\img\dot-kaze-ti.png");
        SetGraphicRect(384,448,448,512);
        SetRenderState(ALPHA);
        SetColor(255,255,255);
        SetGraphicScale(1,1);
        SetGraphicAngle(0,0,0+count*17*(count<126));
        if (ten==1) {
            SetColor(0,0,140);
        }
        DrawGraphic(GetX()+rand(-2,2)*(count<126),GetY()+6+3*sin(count*2)+rand(-4,4)*(count<126));
    }

    if (GetArgument==0&&count>330) {
        SetTexture(GetCurrentScriptDirectory~"\img\familiar.png");
        if (count>=330&&count<358) {
            SetColor((count-330)*4,(count-330)*4,(count-330)*4);
        }
        if (count>=358) {
            SetColor(155,155,155);
        }
        SetGraphicScale(1.6,1.6);
        SetAlpha(255);
        SetRenderState(ADD);
        SetGraphicRect(144,48,192,96);
        SetGraphicAngle(0,0,-count*5);
        DrawGraphic(GetX(),GetY());
        SetGraphicAngle(0,0,+count*5);
        DrawGraphic(GetX(),GetY());
    }
    if (GetArgument==1&&count>580) {
        SetTexture(GetCurrentScriptDirectory~"\img\familiar.png");
        if (count>=580&&count<595) {
            SetColor((count-580)*10,(count-580)*10,(count-580)*10);
        }
        if (count>=595) {
            SetColor(155,155,155);
        }
        SetGraphicScale(1.6,1.6);
        SetAlpha(255);
        SetRenderState(ADD);
        SetGraphicRect(144,48,192,96);
        SetGraphicAngle(0,0,-count*5);
        DrawGraphic(GetX(),GetY());
        SetGraphicAngle(0,0,+count*5);
        DrawGraphic(GetX(),GetY());
    }

}
}

