script_enemy_main
{
    let count=0;
    let N15=0;
    let N16=0;
    let N17=0;
    let N18=0;

    @Initialize
{
    SetLife(900);
    SetScore(0);
    SetDamageRate(0,0);
}


@MainLoop
{
    if (GetArgument==1||GetArgument==2) {
        if (GetLife<=400) {
            SetDamageRate(0,0);
            if (N18==2) {
                PlaySE(GetCurrentScriptDirectory~"\se\Baaaaaaaan.wav");
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Servant10.txt",GetX()+22,GetY(),0,0,4);
                loop(40) {
                    CreateItem(ITEM_SCORE,GetX()+rand(-128,128),GetY()-4+rand(-85,105));
                }
                loop(20) {
                    CreateItem(ITEM_SCORE,GetX()+rand(-102,102),GetY()-4+rand(-58,74));
                }
                SetCommonData("ii1",GetCommonDataDefault("ii1",0)+GetCommonDataDefault("ii2",0));
                SetCommonData("ii3",1);
            }
            if (N18>=100) {
                VanishEnemy;
            }
            if (N18<100) {
                N18+=2;
            }
        }
        if (count>520) {
            VanishEnemy;
        }
        if (count==0) {
            SetAngle(270);
            SetSpeed(1.5);
        }
        if (count==60) {
            SetSpeed(0.8);
        }
        if (GetArgument==1) {
            if (count>=350) {
                SetAngle(305);
                SetSpeed(0.5+(count-350)*0.06);
            }
            if (count<=390&&count%3==0&&GetCommonDataDefault("miss",0)==0&&GetLife>400) {
                PlaySE(GetCurrentScriptDirectory~"\se\Shot00.wav");
                CreateShot12(GetX-108,GetY-125,-8,-0.8,0,0,0,0,196,0);
                CreateShot12(GetX-108,GetY-125,-7,0,0,0,0,0,196,0);
                CreateShot12(GetX-108,GetY-125,-6,0.8,0,0,0,0,196,0);
                CreateShot12(GetX-108,GetY-125,-5,1.6,0,0,0,0,196,0);
                CreateShot12(GetX-108,GetY-125,-4,2.6,0,0,0,0,196,0);
                CreateShot12(GetX-108,GetY-129,999,0,0,0,0,0.0,194,20);
            }
            if (count<=360&&count%4==0&&GetCommonDataDefault("miss",0)!=0&&GetLife>400) {
                CreateShot12(GetX-108+rand(-11,11),GetY-116,rand(-0.1,0.1),-1.6+rand(0,1),0,0.07,0,2,196,0);
            }
            if (count<=560&&count%3==0&&GetCommonDataDefault("miss",0)!=0&&GetLife>400) {
                PlaySE(GetCurrentScriptDirectory~"\se\Shot00.wav");
                CreateShot12(GetX-108,GetY-129,999,0,0,0,0,0.0,194,20);
            }
        }
        if (GetArgument==2) {
            if (count>=350) {
                SetAngle(235);
                SetSpeed(0.5+(count-350)*0.06);
            }
            if (count<=390&&count%3==0&&GetCommonDataDefault("miss",0)==0&&GetLife>400) {
                PlaySE(GetCurrentScriptDirectory~"\se\Shot00.wav");
                CreateShot12(GetX+108,GetY-125,9,-0.8,0,0,0,0,196,0);
                CreateShot12(GetX+108,GetY-125,7,0,0,0,0,0,196,0);
                CreateShot12(GetX+108,GetY-125,6,0.8,0,0,0,0,196,0);
                CreateShot12(GetX+108,GetY-125,5,1.6,0,0,0,0,196,0);
                CreateShot12(GetX+108,GetY-125,4,2.6,0,0,0,0,196,0);
                CreateShot12(GetX+108,GetY-129,999,0,0,0,0,0.0,194,20);
            }
            if (count<=360&&count%4==0&&GetCommonDataDefault("miss",0)!=0&&GetLife>400) {
                CreateShot12(GetX+108+rand(-11,11),GetY-116,rand(-0.1,0.1),-1.6+rand(0,1),0,0.07,0,2,196,0);
            }
            if (count<=560&&count%3==0&&GetCommonDataDefault("miss",0)!=0&&GetLife>400) {
                PlaySE(GetCurrentScriptDirectory~"\se\Shot00.wav");
                CreateShot12(GetX+108,GetY-129,999,0,0,0,0,0.0,194,20);
            }
        }
    }

    if (GetArgument==4) {
        SetDamageRate(0,0);
        if (count>=40) {
            VanishEnemy;
        }
    }

    count++;

}

@Finalize
{
    if (BeVanished==false) {
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Servant10.txt",GetX,GetY,0,0,1);
        loop(40) {
            CreateItem(ITEM_SCORE,GetX()+rand(-128,128),GetY()+rand(-85,105));
        }
        if (GetArgument==0) {
            PlaySE(GetCurrentScriptDirectory~"\se\bom13.wav");
            DeleteAllEnemyWithoutBoss();
            DeleteEnemyShotToItemInCircle(ALL,GetX(),GetY(),400);
            loop(20) {
                CreateItem(ITEM_SCORE,GetX()+rand(-102,102),GetY()+rand(-58,74));
            }
        }
    }
}

@DrawLoop
{
    if (GetArgument==1||GetArgument==2) {
        SetTexture(GetCurrentScriptDirectory~"\img\kyozou.png");
        if (count<=100) {
            SetColor(5*(count-50),5*(count-50),5*(count-50));
        }
        if (count<=50) {
            SetColor(0,0,0);
        }
        if (count>100) {
            SetColor(255*((100-N18)/100),255*((100-N18)/100),255*((100-N18)/100));
        }
        SetAlpha(155);
        SetGraphicRect(224,256,464,448);
        SetRenderState(ADD);
        SetGraphicScale(2,2);
        if (GetArgument==1) {
            SetGraphicAngle(0,0,0);
        }
        if (GetArgument==2) {
            SetGraphicAngle(180,0,0);
        }
        DrawGraphic(GetX(),GetY());
        DrawGraphic(GetX(),GetY());
    }

}
}
