
script_enemy_main
{
    let count=0;
    let count2=0;
    let count3=0;
    let count4=0;
    let ye=0;
    let ye2=0;
    let get;
    let try;
    let alp=255;
    let falp=0;
    let la=0;
    let sca=100;
    let life=0;
    let item=0;
    let N15=80;
    let N16=0;
    let N17=0;
    let N21=0;
    let xs=0;
    let ys=0;
    let mX=0;
    let mY=0;
    let Xloop=0.5;
    let Yloop=0.3;
    let chara=100;

    let i=0;
    let c=0;
    let c2=0;

    let move=0;
    let h=255;

    let pass=GetCurrentScriptDirectory~"Spell.dat";

    let cx=GetCenterX();
    let mm=0;
    let shot=0;
    let tame=0;
    let tame2=0;
    let pat=1;
    let d=70;
    let ten=0;
    let damage=0;

    task CreateShot021(let x, let y, let speed, let angle, let Accelerate, let MaxSpeed, let grf, let delay)
    {
        let obj = Obj_Create(OBJ_SHOT);
        let N15 = 0;
        Obj_SetX(obj, x);
        Obj_SetY(obj, y);
        Obj_SetSpeed(obj, speed);
        Obj_SetAngle(obj, angle);
        ObjShot_SetGraphic(obj, grf);
        ObjShot_SetDelay(obj, delay);
        ObjShot_SetBombResist(obj,true);
        if (Accelerate<0) {
            N15=1;
        }
        if (Accelerate>0) {
            N15=2;
        }
        while ( !Obj_BeDeleted(obj) )
        {
            if (speed>MaxSpeed&&N15==1) {
                Obj_SetSpeed(obj, speed+Accelerate);
            }
            if (speed<MaxSpeed&&N15==1) {
                Obj_SetSpeed(obj, MaxSpeed);
            }
            if (speed<MaxSpeed&&N15==2) {
                Obj_SetSpeed(obj, speed+Accelerate);
            }
            if (speed>MaxSpeed&&N15==2) {
                Obj_SetSpeed(obj, MaxSpeed);
            }
            yield;
        }
    }

    task CreateShot0211(let x, let y, let speed, let angle, let Accelerate, let MaxSpeed, let grf, let delay)
    {
        let obj = Obj_Create(OBJ_SHOT);
        let N15 = 0;
        Obj_SetX(obj, x);
        Obj_SetY(obj, y);
        Obj_SetSpeed(obj, speed);
        Obj_SetAngle(obj, angle);
        ObjShot_SetGraphic(obj, grf);
        ObjShot_SetDelay(obj, delay);
        ObjShot_SetBombResist(obj,true);
        while ( !Obj_BeDeleted(obj) )
        {
            N15++;
            if (N15<=16) {
                Obj_SetAngle(obj, angle+N21/5);
            }
            if (N15==16) {
                Obj_SetSpeed(obj, 3);
                Obj_SetAngle(obj, angle+N21);
            }
            yield;
        }
    }

    task Homing(let x, let y, let speed, let angle, let delay)
    {
        //e^XN
        let count = 0;
        let obj = Obj_Create(OBJ_SHOT);//eIuWFNg쐬
        Obj_SetX(obj, x);//xWݒ
        Obj_SetY(obj, y);//yWݒ;
        Obj_SetSpeed(obj, speed);//xݒ
        Obj_SetAngle(obj, angle);//ړpxݒ
        ObjShot_SetGraphic(obj, 100);//摜ݒ
        ObjShot_SetDelay(obj, delay);//xԐݒ
        let dAngle=2;

        while ( !Obj_BeDeleted(obj) )
        {
            //z[~O
            let toAngle=atan2(GetPlayerY()-Obj_GetY(obj), GetPlayerX()-Obj_GetX(obj));
            if (toAngle>=360) {
                toAngle-=360;
            }
            if (toAngle<0) {
                toAngle+=360;
            }
            let ret=toAngle-angle;
            if ((ret>0&&ret<=180)||(ret<=0&&ret<=-180)) {
                angle+=dAngle;
            }
            if ((ret>0&&ret>180)||(ret<=0&&ret>-180)) {
                angle-=dAngle;
            }
            if (angle>=360) {
                angle-=360;    //360ȏȂ0`360ɕ␳
            }
            if (angle<0) {
                angle+=360;    //0Ȃ0`360ɕ␳
            }
            Obj_SetAngle(obj, angle);
            Obj_SetSpeed(obj, speed);
            ObjShot_SetBombResist(obj,true);
            if (count>=9&&dAngle>0.2) {
                dAngle-=0.1;
                speed-=0.2;
            }
            if (count>=9&&dAngle<=0.2) {
                dAngle=0;
            }
            if (count>=120) {
                speed+=0.005;
            }
            count++;
            yield;
        }
    }

    task Laser(ang,type,w)
    {
        let obj = Obj_Create(OBJ_LASER);
        let c = 0;
        let l = 0;
        w=11;
        Obj_SetX(obj,GetX+40*cos(ang));
        Obj_SetY(obj,GetY-52-40*sin(ang));
        Obj_SetAngle(obj,ang);
        ObjShot_SetGraphic(obj,41);
        ObjShot_SetDelay(obj,0);
        ObjLaser_SetLength(obj,0);
        ObjLaser_SetWidth(obj,w);
        ObjShot_SetBombResist(obj,true);
        ObjShot_ToItem(obj,false);
        ObjLaser_SetSource(obj,false);
        PlaySE(GetCurrentScriptDirectory~"\se\Laser2.wav");

        while (c<200&&GetEnemyLife>0)
        {
            c++;
            Obj_SetX(obj,GetX+40*cos(ang));
            Obj_SetY(obj,GetY-52-40*sin(ang));
            if (type==1) {
                ang+=2;
            }
            if (type==2) {
                ang-=2;
            }
            if (c>102) {
                Obj_Delete(obj);
            }
            else if (GetEnemyLife<=20000) {
                Obj_Delete(obj);
            }
            Obj_SetAngle(obj,ang);

            if (c>80) {
                w-=0.5;
            }
            if (c<40) {
                l+=6;
            }
            if (c>=60) {
                l-=6;
            }

            ObjLaser_SetLength(obj,l);
            ObjLaser_SetWidth(obj,w);
            yield;
        }

    }


    function CreateWayShot02(Way,Gap,PosX,PosY,Dist,Speed,Angle,Accelerate,MaxSpeed,Graphic,Delay) {
        if (Graphic==100||Graphic==211) {
            ascent(let i in 0..Way) {
                CreateShot021(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);
            }
        }
        else {
            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 CreateWayShot022(Way,Gap,PosX,PosY,Dist,Speed,Angle,Accelerate,MaxSpeed,Graphic,Delay) {
        if (Graphic==169||Graphic==196||Graphic==170) {
            ascent(let i in 0..Way) {
                CreateShot0211(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);
            }
        }
        else {
            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);
            }
        }
    }

#include_function ".\BGfx.txt"

    @Initialize()
    {
        MagicCircle(false);
        SetEnemyMarker(true);
        SetCommonData("P01",0);
        SetCommonData("P02",0);
        SetCommonData("P03",0);
        SetCommonData("P04",0);
        SetCommonData("Go",0);
        SetLife(5000000);
        SetDamageRate(20,20);
        SetTimer(20000);
        SetNormPoint(-1);
        SetShotAutoDeleteClip(32,32,32,32);
        SetMovePositionRandom01(0,200,8,cx,120,cx,120);
        LoadUserShotData(GetCurrentScriptDirectory~".\shot_All.txt");
        i=228;

    }

    @MainLoop()
    {
        //if(count2==40){PlaySE(GetCurrentScriptDirectory~"\se\puu81.wav");}

        if (count%4==0) {
            life=GetLife();
        }
        if (GetLife()>=30000) {
            if (count%4==3&&GetLife()<life&&25000<life) {
                AddLife(-8000);
                ten=1;
            }
            if (count%4==3&&GetLife()<life&&25000<life&&GetPlayerY-GetY>=-50&&GetPlayerY-GetY<=50&&GetPlayerX-GetX>=-50&&GetPlayerX-GetX<=50) {
                AddLife(-8000);
            }
            if (ten==1&&count%4==1) {
                ten=0;
            }
        }

        if (OnBomb==true||GetTimeOfPlayerInvincibility>0&&OnPlayerMissed==false&&h<250) {
            h+=10;
        }

        if (h>0) {
            h-=5;
        }



        N21=-33+66*(count%120<60);

        if (pat==1)//Q
        {
            SetCommonDataEx("Spell","omake03",1);
            if (count4==0) {
                if (GetPlayerType()==REIMU_A || GetPlayerType()==REIMU_B||GetPlayerType()==MARISA_A || GetPlayerType()==MARISA_B) {
                    chara=180;
                }
                mm=0;
                mm+=GetAngleToPlayer();
                tame=0;
                tame+=rand(5,15);
                SetInvincibility(120);
                SetSpeed(0);
                SetMovePositionRandom01(45,0,0.8,GetX(),GetY-20,GetX(),GetY-20);
                DeleteEnemyShotToItemInCircle(CHILD,GetX(),GetY(),500);
                PlaySE(GetCurrentScriptDirectory~"\se\Baaaaaaaan.wav");
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Servant10.txt",GetX,GetY,0,0,4);
            }

            if (count4==160) {
                SetColor(255,0,0);
                Concentration01(180);
                PlaySE(GetCurrentScriptDirectory~"\se\puu811.wav");
            }

            if (count4>=20&&count4<300&&count4%10==0) {
                SetSpeed(0);
                SetMovePositionRandom01(rand(20,70),rand(62,84),count4*0.002,GetPlayerX()-24,GetPlayerY()-24,GetPlayerX()+24,GetPlayerY()+24);
            }

            if (count4>=320&&count4<2200&&count4%160==0) {
                SetSpeed(0);
                SetMovePositionRandom01(rand(20,70),rand(2,44),0.2,GetCenterX()-94,68,GetCenterX()+94,148);
            }

            if (count4>=150&&count4<550&&count4%11==4)
            {
                mm=0;
                mm+=GetAngleToPlayer();
                tame=0;
                tame+=rand(2,13);
            }

            if (count4>335&&count4<570&&count4%3==0) {
                PlaySE(GetCurrentScriptDirectory~"\se\Shot04.wav");
                PlaySE(GetCurrentScriptDirectory~"\se\Beam.wav");
                CreateWayShot02(21,10,GetX+10,GetY+8,0,7.2+count4%15*0.03,mm+tame+180,0,8,196,4);
                CreateWayShot02(21,10,GetX-10,GetY+8,0,7.2+count4%15*0.03,mm-tame+180,0,8,196,4);
                CreateWayShot02(8,15,GetX+10,GetY+8,0,7.8+count4%15*0.03,mm+tame,0,8,196,4);
                CreateWayShot02(8,15,GetX-10,GetY+8,0,7.8+count4%15*0.03,mm-tame,0,8,196,4);
                CreateWayShot02(8,15,GetX+10,GetY+8,0,7.8+count4%15*0.03,mm+tame,0,8,100,4);
                CreateWayShot02(8,15,GetX-10,GetY+8,0,7.8+count4%15*0.03,mm-tame,0,8,100,4);
                CreateWayShot02(8,15,GetX+13,GetY+8,0,7.8+count4%15*0.03,mm+tame,0,8,196,4);
                CreateWayShot02(8,15,GetX-13,GetY+8,0,7.8+count4%15*0.03,mm-tame,0,8,196,4);
                CreateWayShot02(8,15,GetX+13,GetY+8,0,7.8+count4%15*0.03,mm+tame,0,8,100,4);
                CreateWayShot02(8,15,GetX-13,GetY+8,0,7.8+count4%15*0.03,mm-tame,0,8,100,4);
            }

            if (count4==570||count4==680||count4==790||count4==1480||count4==1550||count4==1620||count4==1690||count4==1800) {
                SetColor(255,0,0);
                Concentration01(60);
                mm=0;
                mm+=GetAngleToPlayer();
                tame=0;
                tame+=rand(2,13);
            }

            if (count4>635&&count4<680&&count4%3==0) {
                PlaySE(GetCurrentScriptDirectory~"\se\Shot04.wav");
                PlaySE(GetCurrentScriptDirectory~"\se\Beam.wav");
                CreateWayShot02(4,20,GetX+10,GetY+8,0,4,mm+tame,0,8,100,12);
                CreateWayShot02(10,20,GetX+10,GetY+8,0,10.2+count4%15*0.03,mm+tame+180,0,8,196,4);
                CreateWayShot02(10,20,GetX-10,GetY+8,0,10.2+count4%15*0.03,mm-tame+180,0,8,196,4);
                CreateWayShot02(7,17,GetX+10,GetY+8,0,8.8+count4%15*0.03,mm+tame,0,8,196,4);
                CreateWayShot02(7,17,GetX-10,GetY+8,0,8.8+count4%15*0.03,mm-tame,0,8,196,4);
                CreateWayShot02(7,17,GetX+10,GetY+8,0,8.8+count4%15*0.03,mm+tame,0,8,100,4);
                CreateWayShot02(7,17,GetX-10,GetY+8,0,8.8+count4%15*0.03,mm-tame,0,8,100,4);
                CreateWayShot02(7,17,GetX+13,GetY+8,0,8.8+count4%15*0.03,mm+tame,0,8,196,4);
                CreateWayShot02(7,17,GetX-13,GetY+8,0,8.8+count4%15*0.03,mm-tame,0,8,196,4);
                CreateWayShot02(7,17,GetX+13,GetY+8,0,8.8+count4%15*0.03,mm+tame,0,8,100,4);
                CreateWayShot02(7,17,GetX-13,GetY+8,0,8.8+count4%15*0.03,mm-tame,0,8,100,4);
            }

            if (count4>745&&count4<790&&count4%3==0) {
                PlaySE(GetCurrentScriptDirectory~"\se\Shot04.wav");
                PlaySE(GetCurrentScriptDirectory~"\se\Beam.wav");
                CreateWayShot02(5,16,GetX-10,GetY+8,0,4,mm+tame,0,8,100,12);
                CreateWayShot02(10,20,GetX+10,GetY+8,0,10.2+count4%15*0.03,mm+tame+180,0,8,196,4);
                CreateWayShot02(10,20,GetX-10,GetY+8,0,10.2+count4%15*0.03,mm-tame+180,0,8,196,4);
                CreateWayShot02(8,14,GetX+10,GetY+8,0,8.8+count4%15*0.03,mm+tame,0,8,196,4);
                CreateWayShot02(8,14,GetX-10,GetY+8,0,8.8+count4%15*0.03,mm-tame,0,8,196,4);
                CreateWayShot02(8,14,GetX+10,GetY+8,0,8.8+count4%15*0.03,mm+tame,0,8,100,4);
                CreateWayShot02(8,14,GetX-10,GetY+8,0,8.8+count4%15*0.03,mm-tame,0,8,100,4);
                CreateWayShot02(8,14,GetX+13,GetY+8,0,8.8+count4%15*0.03,mm+tame,0,8,196,4);
                CreateWayShot02(8,14,GetX-13,GetY+8,0,8.8+count4%15*0.03,mm-tame,0,8,196,4);
                CreateWayShot02(8,14,GetX+13,GetY+8,0,8.8+count4%15*0.03,mm+tame,0,8,100,4);
                CreateWayShot02(8,14,GetX-13,GetY+8,0,8.8+count4%15*0.03,mm-tame,0,8,100,4);
            }

            if (count4>855&&count4<1020&&count4%7==0) {
                CreateWayShot02(10,8,GetX+10,GetY+8,0,3.5,mm+tame,0,8,100,12);
                CreateWayShot02(10,8,GetX-10,GetY+8,0,3.5,mm+tame,0,8,100,12);
            }

            if (count4>855&&count4<1020&&count4%3==0) {
                PlaySE(GetCurrentScriptDirectory~"\se\Shot04.wav");
                PlaySE(GetCurrentScriptDirectory~"\se\Beam.wav");
                CreateWayShot02(6,20,GetX+10,GetY+8,0,4+count4%45*0.01,mm+tame-44,0,8,100,12);
                CreateWayShot02(6,20,GetX-10,GetY+8,0,4+count4%45*0.01,mm+tame+44,0,8,100,12);
                CreateWayShot02(10,20,GetX+10,GetY+8,0,12.2+count4%15*0.03,mm+tame+180,0,8,196,4);
                CreateWayShot02(10,20,GetX-10,GetY+8,0,12.2+count4%15*0.03,mm-tame+180,0,8,196,4);
                CreateWayShot02(9,12,GetX+10,GetY+8,0,10.8+count4%15*0.03,mm+tame,0,8,196,4);
                CreateWayShot02(9,12,GetX-10,GetY+8,0,10.8+count4%15*0.03,mm-tame,0,8,196,4);
                CreateWayShot02(9,12,GetX+10,GetY+8,0,10.8+count4%15*0.03,mm+tame,0,8,100,4);
                CreateWayShot02(9,12,GetX-10,GetY+8,0,10.8+count4%15*0.03,mm-tame,0,8,100,4);
                CreateWayShot02(9,12,GetX+13,GetY+8,0,10.8+count4%15*0.03,mm+tame,0,8,196,4);
                CreateWayShot02(9,12,GetX-13,GetY+8,0,10.8+count4%15*0.03,mm-tame,0,8,196,4);
                CreateWayShot02(9,12,GetX+13,GetY+8,0,10.8+count4%15*0.03,mm+tame,0,8,100,4);
                CreateWayShot02(9,12,GetX-13,GetY+8,0,10.8+count4%15*0.03,mm-tame,0,8,100,4);
            }

            if (count4>1055&&count4<1420&&count4%3==0) {
                PlaySE(GetCurrentScriptDirectory~"\se\Shot04.wav");
                ascent( let t in 0..10 ) {
                    CreateShot02(GetX,GetY+8,1+t*0.6,(-count*2.5)+22*sin(count*3)+t*2,0,8,169,12);
                    CreateShot02(GetX,GetY+8,1+t*0.5,(-count*2.5)+22*sin(count*3)+t*2+180,0,8,169,12);
                    CreateShot02(GetX,GetY+8,1+t*0.6,(-count*2.5)+22*sin(count*3)+t*2,0,8,196,12);
                    CreateShot02(GetX,GetY+8,1+t*0.5,(-count*2.5)+22*sin(count*3)+t*2+180,0,8,196,12);
                }
            }

            if (count4>1480&&count4<1540&&count4%3==0) {
                PlaySE(GetCurrentScriptDirectory~"\se\Shot04.wav");
                PlaySE(GetCurrentScriptDirectory~"\se\Beam.wav");
                CreateWayShot02(12,7,GetX-10,GetY+8,0,8.2+count4%15*0.03,mm-tame,0,8,196,4);
                CreateWayShot02(12,7,GetX-10,GetY+8,0,8.2+count4%15*0.03,mm-tame,0,8,100,4);
            }

            if (count4>1550&&count4<1610&&count4%3==0) {
                PlaySE(GetCurrentScriptDirectory~"\se\Shot04.wav");
                PlaySE(GetCurrentScriptDirectory~"\se\Beam.wav");
                CreateWayShot02(13,7,GetX+10,GetY+8,0,8.4+count4%15*0.03,mm-tame,0,8,196,4);
                CreateWayShot02(13,7,GetX+10,GetY+8,0,8.4+count4%15*0.03,mm-tame,0,8,100,4);
            }

            if (count4>1620&&count4<1680&&count4%3==0) {
                PlaySE(GetCurrentScriptDirectory~"\se\Shot04.wav");
                PlaySE(GetCurrentScriptDirectory~"\se\Beam.wav");
                CreateWayShot02(14,12,GetX-10,GetY+8,0,8.6+count4%15*0.03,mm-tame,0,8,196,4);
                CreateWayShot02(14,12,GetX-10,GetY+8,0,8.6+count4%15*0.03,mm-tame,0,8,100,4);
            }

            if (count4>1690&&count4<1750&&count4%3==0) {
                PlaySE(GetCurrentScriptDirectory~"\se\Shot04.wav");
                PlaySE(GetCurrentScriptDirectory~"\se\Beam.wav");
                CreateWayShot02(14,4,GetX+10,GetY+8,0,8.6+count4%15*0.03,mm-tame,0,8,196,4);
                CreateWayShot02(14,4,GetX+10,GetY+8,0,8.6+count4%15*0.03,mm-tame,0,8,100,4);
            }

            if (count4>1800&&count4<1850&&count4%3==0) {
                PlaySE(GetCurrentScriptDirectory~"\se\Shot04.wav");
                PlaySE(GetCurrentScriptDirectory~"\se\Beam.wav");
                CreateWayShot02(12,9,GetX-10,GetY+8,0,3.8+count4%15*0.03,mm-tame,0,8,196,4);
                CreateWayShot02(12,9,GetX-10,GetY+8,0,3.8+count4%15*0.03,mm-tame,0,8,100,4);
                CreateWayShot02(17,11,GetX+10,GetY+8,0,8.8+count4%15*0.03,mm-tame,0,8,196,4);
                CreateWayShot02(17,11,GetX+10,GetY+8,0,8.8+count4%15*0.03,mm-tame,0,8,100,4);
            }

            if (count4>=1850&&count4<1930&&count4%3==0) {
                PlaySE(GetCurrentScriptDirectory~"\se\Shot04.wav");
                PlaySE(GetCurrentScriptDirectory~"\se\Beam.wav");
                CreateWayShot02(12,5,GetX-10,GetY+8,0,1.8+count4%15*0.15,mm-tame,0,8,196,4);
                CreateWayShot02(12,5,GetX-10,GetY+8,0,1.8+count4%15*0.15,mm-tame,0,8,100,4);
                CreateWayShot02(17,11,GetX+10,GetY+8,0,8.8+count4%15*0.03,mm-tame,0,8,196,4);
                CreateWayShot02(17,11,GetX+10,GetY+8,0,8.8+count4%15*0.03,mm-tame,0,8,100,4);
            }

            if (count4>=1930) {
                count4=140;
                mm=0;
                mm+=GetAngleToPlayer();
                tame=0;
                tame+=rand(5,15);
            }

            if (h<=chara) {
                SetCollisionA(GetX(),GetY(),36);
                SetCollisionB(GetX(),GetY(),12);
            }

            if (life<2500000&&count4>290) {
                pat=3;
                count4=0;
            }

        }






        if (pat==3)//
        {
            if (count4==0) {
                DeleteEnemyShotToItemInCircle(CHILD,GetX(),GetY(),500);
            }

            if (count4%160==0) {
                SetSpeed(0);
                SetMovePositionRandom01(rand(20,70),rand(2,44),0.2,GetCenterX()-24,100,GetCenterX()+24,200);
            }

            if (count4>=104&&count4%11==0) {
                Laser(270,1,11);
                Laser(270,2,11);
            }

            if (count4>=422&&count4%3==0) {
                SetCollisionB(GetX(),GetY(),36);
                PlaySE(GetCurrentScriptDirectory~"\se\Shot04.wav");
                PlaySE(GetCurrentScriptDirectory~"\se\Beam.wav");
                CreateWayShot022(6,35+24*sin(count/2),GetX,GetY,40,7,count*2,0,8,169,4);
                CreateWayShot022(6,35+24*sin(count/2),GetX,GetY,40,7,count*2,0,8,196,4);
            }
            if (count4>=422&&count4%5==0) {
                PlaySE(GetCurrentScriptDirectory~"\se\Shot04.wav");
                PlaySE(GetCurrentScriptDirectory~"\se\Beam.wav");
                CreateWayShot022(12,35-22*sin(count/3),GetX,GetY,40,2,count*-1.2,0,8,169,4);
                CreateWayShot022(12,35-22*sin(count/3),GetX,GetY,40,2,count*-1.2,0,8,196,4);
            }
            if (count4>=220&&count4%7==0) {
                PlaySE(GetCurrentScriptDirectory~"\se\Shot04.wav");
                CreateWayShot02(30,12,GetX,GetY,40,2.5,(count*1.5)*(count%180>=90)+(count*-1.5)*(count%180<90),0,8,255,4);
            }

            if (h<=chara) {
                SetCollisionA(GetX(),GetY(),36);
                SetCollisionB(GetX(),GetY(),12);
            }

            if (GetLife()<30000&&count4>290) {
                pat=5;
                count4=0;
            }

        }


        if (count2==45000&&pat!=5) {
            count2=46000;
            pat=5;
            count4=0;
            SetLife(10000);
        }


        if (pat==5)//
        {
            SetCommonData("x",GetX);
            SetCommonData("y",GetY);
            SetInvincibility(20);

            if (count4==0) {
                MagicCircle(false);
                SetEnemyMarker(false);
                Explosion01(GetX,GetY,6,0.3,80);
                SetInvincibility(280);
                AddLife(-GetLife+20);
                SetSpeed(0);
                SetMovePositionRandom01(45,0,8,GetX(),GetY-60,GetX(),GetY-60);
                PlaySE(GetCurrentScriptDirectory~"\se\Baaaaaaaan.wav");
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Servant10.txt",GetX,GetY,0,0,4);
            }

            if (count4==220) {
                Explosion01(GetX,GetY,6,0.3,80);
                PlaySE(GetCurrentScriptDirectory~"\se\Baaaaaaaan.wav");
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Servant10.txt",GetX,GetY,0,0,4);
            }

            if (count4>=110&&count4<=146&&count%3==0) {
                PlaySE(GetCurrentScriptDirectory~"\se\Baaaan2.wav");
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Servant102.txt",GetX+100*cos(count*10),GetY+100*sin(count*10),0,0,2);
            }

            if (count4>=0&&count4<110) {
                DeleteEnemyShotToItemInCircle(CHILD,GetX(),GetY(),count4*14);
                N17-=2.6;
                c=c-0.05
              }

            if (count4>=30&&count4<=160&&count%6==0&&rand(0,4)>=2) {
                PlaySE(GetCurrentScriptDirectory~"\se\Baaaaaaaan.wav");
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Servant102.txt",GetX+rand(-23,23),GetY+rand(-23,23),0,0,2);
            }

            if (count4>=30&&count%16==0&&sca>0.2) {
                PlaySE(GetCurrentScriptDirectory~"\se\Baaaan.wav");
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Servant10.txt",GetX+rand(-83,83),GetY+rand(-83,83),0,0,2);
            }

            if (count4>=50&&count4<220&&count4%25==0) {
                SetSpeed(0);
                SetMovePositionRandom01(rand(20,70),rand(2,44),0.8,GetCenterX()-54,128,GetCenterX()+54,158);
            }

            if (count4==230) {
                SetSpeed(0);
                SetMovePositionRandom01(rand(20,40),rand(20,40),0.8,GetCenterX()-88,108,GetCenterX()+88,158);
            }

            if (count4>=160&&count%20==0&&rand(0,4)>=2&&sca>0.2) {
                PlaySE(GetCurrentScriptDirectory~"\se\Baaaan.wav");
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Servant10.txt",GetX+rand(-33,33),GetY+rand(-33,33),0,0,2);
            }

            if (count4==470) {
                PlaySE(GetCurrentScriptDirectory~"\se\bom13.wav");
                SetCommonData("flash2",255);
                if (count2<=45555) {
                    AddScore(100000000);
                }falp=-1;
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Servant10.txt",GetX,GetY,0,0,4);
            }

            if (count4==480) {
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Servant10.txt",GetX+65,GetY-32,0,0,3);
            }

            if (count4==490) {
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Servant10.txt",GetX-65,GetY+12,0,0,3);
            }

            if (count4==500) {
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Servant10.txt",GetX,GetY-11,0,0,3);
            }

            if (count4>=440&&count4<=450&&count%4==0) {
                PlaySE(GetCurrentScriptDirectory~"\se\Baaaan2.wav");
                SetSpeed(0);
                SetMovePositionRandom01(rand(120,140),rand(120,140),8.8,GetCenterX()-88,308,GetCenterX()+88,358);
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Servant102.txt",GetX+rand(-33,33),GetY+rand(-33,33),0,0,5);
            }

            if (count4>=700) {
                MagicCircle(false);
                SetEnemyMarker(false);
                VanishEnemy;
            }

            if (count4==130) {
                PlaySE(GetCurrentScriptDirectory~"\se\Baaaaaaaan.wav");
                la++;
                SetSpeed(0);
                SetMovePositionRandom01(45,0,10,GetX()-64,GetY-38,GetX()-64,GetY-38);
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Servant10.txt",GetX,GetY,0,0,4);
            }

            if (count4>=250&&sca>0) {
                sca-=0.5;
            }

            if (count4>200&&alp>0) {
                alp-=1;
            }
            h=0;

        }

        count++;
        count4++;
        count2++;
        move--;
        ye2--;
        if (ye>0) {
            ye-=4;
        }
        if (ye<0) {
            ye=0;
        }
        if (ye2>0&&ye<244) {
            ye+=6;
        }

        c2+=c;

        yield;
    }

    @Finalize()
    {
        MagicCircle(false);
        SetEnemyMarker(false);
    }

    @DrawLoop()
    {

        if (falp>=0) {
            SetAlpha(255);
            SetGraphicAngle(0,0,0);
            SetColor(255,255,255);
            SetTexture(GetCurrentScriptDirectory~"\img\ho.png");
            SetGraphicScale(0.26+count%3*0.05,0.26+count%3*0.05);
            SetRenderState(ADD);
            if (count2/1%4>=0) {
                SetGraphicRect(256,0,512,256);
            }
            if (count2/1%4>=1) {
                SetGraphicRect(0,0,256,256);
            }
            if (count2/1%4>=2) {
                SetGraphicRect(256,256,512,512);
            }
            if (count2/1%4>=3) {
                SetGraphicRect(0,256,256,512);
            }
            DrawGraphic(GetX()+4,GetY()-8);
            SetTexture(GetCurrentScriptDirectory~"\img\dot_remilia.png");
            SetAlpha(alp);
            SetColor(255,255,0);
            SetGraphicScale(0.95,0.95);
            SetRenderState(ALPHA);
            SetGraphicRect(160,288,224,352);
            if (count2/3%2>=0) {
                SetGraphicRect(160,288,224,352);
            }
            if (count2/3%2>=1) {
                SetGraphicRect(160,416,224,479);
            }
            if (ten==1&&OnBomb==false) {
                SetColor(255,255,255);
            }
            DrawGraphic(GetX(),GetY());

            SetTexture(GetCurrentScriptDirectory~"\img\kyozou.png");
            SetRenderState(ADD);
            SetAlpha(255*(count%2==0));
            SetColor(h,h,h);
            SetGraphicScale(1.2+0.1*(count%3),1+0.1*(count%3));
            SetGraphicRect(0,0,256,256);
            SetGraphicAngle(0,0,0);
            DrawGraphic(GetX(),GetY()+12);
        }

    }


}

