script_enemy_main
{
    let count=0;//抧崠堿梲媴
    let MT=0;
    let mm=0;
    let N15=0;
    let N16=0;
    let N17=0;
    let N18=0;
    let N19=0;
    let N20=0;
    let N21=0;
    let Level=0;
    let life=0;
    let ten=0;

function CreateWayShot02(Way,Gap,PosX,PosY,Dist,Speed,Angle,Accelerate,MaxSpeed,Graphic,Delay) {
    ascent(let i in 0..Way) {
        CreateShot02(PosX+Dist*cos(Angle+Gap*(i+0.5-(Way * 0.5))),PosY+Dist*sin(Angle+Gap*(i+0.5-(Way * 0.5))),Speed,Angle+Gap*(i+0.5-(Way*0.5)),Accelerate,MaxSpeed,Graphic,Delay);
    }
}

function dead {
    SetDamageRate(0,0);

    if (N17==50) {
        if (GetLife>=200) {
            AddScore(3000000);
        }
        PlaySE(GetCurrentScriptDirectory~"\se\bom27_b.wav");
        loop(5) {
            CreateItem(ITEM_SCORE,GetX()+rand(-44,44),GetY()+rand(15,75));
        }
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Servant10.txt",GetX,GetY,0,0,1);
        SetCommonData("ii1",GetCommonDataDefault("ii1",0)+GetCommonDataDefault("ii2",0));
        SetCommonData("ii3",1);
    }

    if (N17<100) {
        N17+=50;
    }
    if (N17>=100) {
        VanishEnemy;
    }
}

@Initialize
{
    SetLife(64);
    SetDamageRate(100,5);
    SetScore(50000);
    Level+=GetPlayerLife();
}


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

    if (GetArgument==9) {//儚乕僾
        if (count==0) {
            SetMovePositionRandom01(0,200,5,GetCenterX,138,GetCenterX,138);
            SetLife(6000);
        }
        if (count==80) {
            SetColor(35,0,35);
            Concentration01(110);
            PlaySE(GetCurrentScriptDirectory~"\se\puu81.wav");
        }
        if (count>760) {
            VanishEnemy;
        }
        if (count<=440) {
            SetDamageRate(70,10);
            if (GetLife<=5520) {
                SetDamageRate(0,0);
            }
        }
        if (count>440) {
            SetDamageRate(220,40);
        }
        if (count<=280) {
            SetDamageRate(5,2);
        }
        if (GetLife>5400) {
            if (count>=120) {
                SetCollisionA(GetX(),GetY(),12);
                SetCollisionB(GetX(),GetY(),14);
            }
            if (count%25==5&&count>250&&count<=260) {
                PlaySE(GetCurrentScriptDirectory~"\se\Shot01.wav");
            }
            if (GetCommonDataDefault("Mode",0)>=2) {
                if (count%25==0) {
                    N15+=rand(12,18);
                }
                ascent( let t in 0..12 ) {
                    if (count%25>11&&count%2==1&&count>250&&count<=560) {
                        PlaySE(GetCurrentScriptDirectory~"\se\Shot06.wav");
                        CreateShot01(GetX()+28*cos(N15+t*30),GetY()+28*sin(N15+t*30),2.9,N15+t*30,69,12);
                    }
                    if (count%25==5&&count>250&&count<=460) {
                        PlaySE(GetCurrentScriptDirectory~"\se\Shot04.wav");
                        CreateWayShot02(7,2,GetX(),GetY(),28,3.9,N15+t*30,0,0,69,12);
                    }
                }
            }
            else {
                if (count%35==0) {
                    N15+=rand(12,18);
                }
                ascent( let t in 0..12 ) {
                    if (count%35>6&&count%5==1&&count>245&&count<=560) {
                        PlaySE(GetCurrentScriptDirectory~"\se\Shot06.wav");
                        CreateShot01(GetX()+28*cos(N15+t*30),GetY()+28*sin(N15+t*30),2.5,N15+t*30,69,12);
                    }
                    if (count%35==5&&count>245&&count<=460) {
                        PlaySE(GetCurrentScriptDirectory~"\se\Shot04.wav");
                        CreateWayShot02(6,3,GetX(),GetY(),28,3.5,N15+t*30,0,0,69,12);
                    }
                }
            }
        }
        if (count>170&&N21<100) {
            N21+=2;
        }
        if (count>440&&N17<100) {
            N17+=2;
        }
        if (count>100&&N18<130) {
            N18+=1.5;
        }
        if (count>200&&N18<250) {
            N18+=0.3;
        }
        if (count>180&&N19<150) {
            N19+=0.2;
        }
        if (count>610) {
            SetSpeed((count-610)*0.08);
            SetAngle(270);
            SetDamageRate(0,0);
        }
        if (GetLife<=5400) {
            SetDamageRate(0,0);
            if (N20==4&&GetLife<=5400) {
                SetCommonData("ii1",GetCommonDataDefault("ii1",0)+GetCommonDataDefault("ii2",0));
                SetCommonData("ii3",1);
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Servant10.txt",GetX,GetY,0,0,4);
                PlaySE(GetCurrentScriptDirectory~"\se\Baaaaaaaan.wav");
                CollectItems;
                Explosion01(GetX,GetY,8,0.3,80);
                loop(50) {
                    CreateItem(ITEM_SCORE,GetX()+rand(-92,92),GetY()+44+rand(-62,78));
                }
            }
            if (N20<60) {
                DeleteEnemyShotToItemInCircle(SHOT,GetX(),GetY(),N20*8);
            }
            if (N20<250) {
                N20+=4;
            }
            if (N20>=250) {
                VanishEnemy;
            }
            if (count%4<=0&&GetLife<=5400&&N20<650) {//Explosion01(GetX+rand(-80,80),GetY+rand(-80,80),24,0.15,20);
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Servant10.txt",GetX+rand(-80,80),GetY+rand(-80,80),0,0,0);
            }
            if (count%7<=0&&GetLife<=5400&&N20<650) {
                PlaySE(GetCurrentScriptDirectory~"\se\Baaaan.wav");
            }
        }
        if (count>200) {
            SetCollisionA(GetX(),GetY(),32);
        }
    }

    if (GetArgument==13) {
        SetDamageRate(0,0);
        if (count>26) {
            VanishEnemy;
        }
    }

    count++;

}

@Finalize
{
}

@DrawLoop
{
    if (GetArgument<=1||GetArgument==11||GetArgument==12) {
        SetTexture(GetCurrentScriptDirectory~"\img\familiar.png");
        if (count>=112) {
            SetColor(211,211,211);
        }
        SetGraphicAngle(0,0,0);
        SetGraphicScale(0.7,0.7);
        SetAlpha(255);
        SetRenderState(ADD);
        SetGraphicRect(0,48,48,96);
        ascent( let t in 1..2 ) {
            ascent( let tt in 0..4 ) {
                DrawGraphic(GetX()+0.2*N16*t*cos(45+tt*90),GetY()+0.2*N16*t*sin(45+tt*90));
            }
        }
    }

    if (GetArgument==9) {
        if (count<=120) {
            SetColor(0,0,0);
        }
        if (count>=120) {
            SetColor((count-120)*10,(count-120)*10,(count-120)*10);
        }
        if (count>=146) {
            SetColor(255,255,255);
        }
        if (count>=420) {
            SetColor(255-(count-420)*5,255-(count-420)*5,255-(count-420)*5);
        }
        if (count>=470) {
            SetColor(0,0,0);
        }
        SetRenderState(SUBTRACT);
        SetTexture(GetCurrentScriptDirectory~"\img\moon3-2.png");
        SetGraphicRect(256,768,512,1024);
        SetGraphicScale(0.05*N19+count%3*0.25,0.05*N19+count%3*0.25);
        DrawGraphic(GetX(),GetY()+4);
        SetGraphicScale(0.01*N18+count%3*0.1,0.01*N18+count%3*0.1);
        DrawGraphic(GetX(),GetY()+4);
        if (count<=270) {
            SetColor(0,0,0);
        }
        if (count>=270) {
            SetColor((count-270)*5,(count-270)*5,(count-270)*5);
        }
        if (count>=320) {
            SetColor(255,255,255);
        }
        if (count>=420) {
            SetColor(255-(count-420)*5,255-(count-420)*5,255-(count-420)*5);
        }
        if (count>=470) {
            SetColor(0,0,0);
        }
        SetGraphicScale(16,16);
        DrawGraphic(GetX(),GetCenterY()+4);
    }

    if (GetArgument!=9) {
        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==4||GetArgument<=1||GetArgument>=8) {
            SetAlpha(255-N20);
        }
        SetGraphicRect(64,0,128,64);
        //if(GetArgument==2||GetArgument==3||GetArgument==4||GetArgument==6||GetArgument==10){SetGraphicRect(192,0,256,64);}
        if (GetArgument==9) {
            SetGraphicRect(64,64,128,128);
        }
        SetRenderState(ALPHA);
        SetColor(225+count%4*30,225+count%4*30,225+count%4*30);
        if (ten==1) {
            SetColor(120,120,160);
        }
        SetGraphicScale(1.12,1.12);
        SetGraphicAngle(0,0,-count*5);
        DrawGraphic(GetX(),GetY());
        SetGraphicScale(0.8,0.8);
        SetGraphicAngle(0,0,count*5);
        DrawGraphic(GetX(),GetY());

        SetGraphicRect(0,0,64,64);
        //if(GetArgument==2||GetArgument==3||GetArgument==4||GetArgument==6||GetArgument==10){SetGraphicRect(128,0,192,64);}
        if (GetArgument==9) {
            SetGraphicRect(0,64,64,128);
        }
        if (ten==1) {
            SetColor(120,120,160);
        }
        SetColor(255,255,255);
        SetGraphicScale(0.65,0.65);
        SetGraphicAngle(0,0,90);
        DrawGraphic(GetX(),GetY());
    }

    if (GetArgument==9) {
        SetTexture(GetCurrentScriptDirectory~"\img\dot-kaze-ti.png");
        if (count<=120) {
            SetAlpha(0);
            SetGraphicRect(320,448,384,512);
        }
        if (count>=120&&count<=170) {
            SetAlpha((count-120)*4);
            SetGraphicRect(320,448,384,512);
        }
        if (count>=170) {
            SetAlpha(255-N20);
            SetGraphicRect(320,448,384,512);
        }
        if (count>=220) {
            SetGraphicRect(256,448,320,512);
        }
        SetRenderState(ALPHA);
        SetColor(255,255,255);
        SetGraphicScale(1,1);
        SetGraphicAngle(0,0,0);
        if (ten==1) {
            SetColor(120,120,160);
        }
        DrawGraphic(GetX(),GetY()+10+3*sin(count*2));
    }

}
}
