#ϋe
#Title[`LastSpell`uυίΜΆz­v]
#Text[]
#Player[FREE]
#ScriptVersion[2]
#BackGround[User()]
script_enemy_main
{
    let count=0;
    let count2=0;
    let count3=0;
    let count4=0;
    let R=0;
    let R2=0;
    let R3=0;
    let R4=0;
    let ten=0;
    let life=0;
    let xr=0;
    let yr=0;
    let N15=0;
    let B=0;
    let Bo=0;
    let Bx=0;
    let By=0;
    let get;
    let try;

    let move=0;
    let move2=0;

    let ls=0;

    let pass=GetCurrentScriptDirectory~"Spell.dat";

    let bombalpha=255;

    let cx=GetCenterX();
    let img=GetCurrentScriptDirectory~"img\dot_remilia.png";
    let bg=GetCurrentScriptDirectory~"img\st00.png";
    let bg2=GetCurrentScriptDirectory~"img\moon3-1.png";
    let bg3=GetCurrentScriptDirectory~"img\cloud.png";
    let sh00=GetCurrentScriptDirectory~"\se\Shot00.wav";
    let mm=0;
    let shot=120;
    let tame=0;
    let tame2=0;
    let c=0;
    let d=60;
    let ang=0;
    let ang2=0;
    let cir=0;
    let MT=0;

    function IntToString(num) {
        let retStr = "";//ίθl
        let numStr = ToString(num);

        let i = 0;
        while (i < length(numStr)) {
            let tmp = numStr[i];
            if (tmp == '.') {	//¬_ΕIΉ
                break;
            }
            retStr = retStr ~ [tmp];
            i++;
        }
        return retStr;
    }

    function load() {
        LoadCommonDataEx("Spell",pass);
    }

    function save() {
        SaveCommonDataEx("Spell",pass);
    }

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

    task Laser(x,y,s,a,l,w,g,d)
    {
        let obj = Obj_Create(OBJ_LASER);
        let c = 0;
        Obj_SetX(obj,x);
        Obj_SetY(obj,y);
        Obj_SetAngle(obj,a);
        ObjShot_SetGraphic(obj,g);
        ObjShot_SetDelay(obj,d);
        //Obj_SetSpeed(obj,s);
        ObjLaser_SetLength(obj,l);
        ObjLaser_SetWidth(obj,w);
        ObjShot_SetBombResist(obj,true);
        ObjLaser_SetSource(obj,false);
        while ( c<200 )
        {
            ObjLaser_SetLength(obj,l);
            l+=5.2;
            c++;
            Obj_SetX(obj,GetX+rand(-2,2));
            Obj_SetY(obj,GetY+rand(-2,2));
            Obj_SetCollisionToPlayer(obj,false);
            if (c==85) {
                CreateLaser01(Obj_GetX(obj),Obj_GetY(obj),28,a,720,98,41,0);
                PlaySE(GetCurrentScriptDirectory~"\se\Baaaaaaaan2.wav");
                Bo=1;
                Bx=GetX;
                By=GetY;
            }
            if (c>=85) {
                CreateShot01(GetX()+(c-85)*6.3*cos(a)+rand(-43,43),GetY()+(c-85)*6.3*sin(a)+rand(-43,43),512,90,194,22);
            }
            if (c>=95&&c%2==0) {
                Obj_SetX(obj,GetX);
                Obj_SetY(obj,GetY);
            }
            if (c>=132) {
                w=w/1.2;
                ObjLaser_SetWidth(obj,w);
            }
            if (c==142) {
                Obj_Delete(obj);
            }
            yield;
        }
    }

    task Laser2(x,y,s,a,l,w,g,d)
    {
        let obj = Obj_Create(OBJ_LASER);
        let c = 0;
        Obj_SetX(obj,x);
        Obj_SetY(obj,y);
        Obj_SetAngle(obj,a);
        ObjShot_SetGraphic(obj,g);
        ObjShot_SetDelay(obj,d);
        //Obj_SetSpeed(obj,s);
        ObjLaser_SetLength(obj,l);
        ObjLaser_SetWidth(obj,w);
        ObjShot_SetBombResist(obj,true);
        ObjLaser_SetSource(obj,false);
        while ( c<200 )
        {
            ObjLaser_SetLength(obj,l);
            l+=7.2;
            c++;
            Obj_SetX(obj,GetX+rand(-2,2));
            Obj_SetY(obj,GetY+rand(-2,2));
            Obj_SetCollisionToPlayer(obj,false);
            if (c==85) {
                CreateLaser01(Obj_GetX(obj),Obj_GetY(obj),28,a,720,100,41,0);
                PlaySE(GetCurrentScriptDirectory~"\se\Baaaaaaaan.wav");
                Bo=1;
                Bx=GetX;
                By=GetY;
            }
            if (c>=85) {
                CreateShot01(GetX()+(c-85)*6.3*cos(a)+rand(-43,43),GetY()+(c-85)*6.3*sin(a)+rand(-43,43),512,90,194,22);
            }
            if (c>=95&&c%2==0) {
                Obj_SetX(obj,GetX);
                Obj_SetY(obj,GetY);
            }
            if (c>=132) {
                w=w/1.2;
                ObjLaser_SetWidth(obj,w);
            }
            if (c==142) {
                Obj_Delete(obj);
            }
            yield;
        }
    }

    @Initialize()
    {
        MagicCircle(false);
        SetEnemyMarker(true);
        if (IsCommonDataAreaExists("Spell")==false) {
            CreateCommonDataArea("Spell");
        }
        load();
        SetLife(8000);
        SetDamageRate(160,0);
        SetTimer(150);
        SetInvincibility(300);
        SetNormPoint(-1);
        LoadGraphic(img);
        SetShotAutoDeleteClip(52,32,32,32);
        SetX(cx);
        SetY(152);
        SetEffectForZeroLife(195,152,1);
        LoadGraphic(bg);
        LoadGraphic(bg2);
        LoadGraphic(GetCurrentScriptDirectory~"\img\remiria.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\JUUJI.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\circle_l.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\NuclearWave2.png");
        LoadUserShotData(GetCurrentScriptDirectory~".\shot_All.txt");

        get=GetCommonDataDefaultEx("Spell","1no9get",0);
        try=GetCommonDataDefaultEx("Spell","1no9try",0);
        try++;
        SetCommonDataEx("Spell","1no9try",try);
        save();

    }

    @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;
        }
        SetCommonData("Black",244);

        ang=count4*6.8;

        if (count2==30) {
            SetColor(255,0,0);
            Concentration01(465);
            PlaySE(GetCurrentScriptDirectory~"\se\puu811.wav");
        }

        if (count2==100) {
            SetColor(255,0,0);
            Concentration01(385);
            PlaySE(GetCurrentScriptDirectory~"\se\puu81.wav");
        }

        if (count2==170) {
            SetColor(155,0,0);
            Concentration01(18000);
            PlaySE(GetCurrentScriptDirectory~"\se\puu811.wav");
            MotionBlurEx(ALL,310,155,ALPHA);
        }

        if (count2==210) {
            PlaySE(GetCurrentScriptDirectory~"\se\puu81.wav");
        }

        if (count4==70) {
            SetColor(255,0,0);
            Concentration01(185);
            PlaySE(GetCurrentScriptDirectory~"\se\puu81.wav");
        }


        if (count4>60&&count4<160&&count%4==0)
        {
            ascent( let t in 0..12 ) {
                CreateShot12(GetX()+(80-(count4-60))*cos(ang+t*45+0.5*rand(-(count4-60),(count4-60))),GetY()+(160-(count4-60)*6.5)*sin(ang+t*45),rand(-1.2,1.2),rand(1.4,-1.2),0,-0.03,0,-5.4,170,28);
            }
        }

        if (count4>60&&count4<160&&count%4==1)
        {
            ascent( let t in 0..12 ) {
                CreateShot12(GetX()+(160-(count4-60)*6.5)*cos(ang+t*45),GetY()+(80-(count4-60))*sin(ang+t*45+0.5*rand(-(count4-60),(count4-60))),rand(-1.2,1.2),rand(1.4,-1.2),0,-0.03,0,-5.4,170,28);
            }
        }

        if (count4>60&&count4<160&&count%3==0)
        {
            ascent( let t in 0..7 ) {
                CreateShot02(GetX()+(80-(count4-60))*cos(ang+t*45+0.5*rand(-(count4-60),(count4-60))),GetY()+(160-(count4-60)*6.5)*sin(ang+t*45),(count4-60)*0.001,90*rand_int(1,4),0.04,1.8-(count4-60)*0.01,196,28);
            }
        }

        if (count4>60&&count4<160&&count%3==1)
        {
            ascent( let t in 0..7 ) {
                CreateShot02(GetX()+(160-(count4-60)*6.5)*cos(ang+t*45),GetY()+(80-(count4-60))*sin(ang+t*45+0.5*rand(-(count4-60),(count4-60))),(count4-60)*0.05,rand(260,280),0.06+(count4-60)*0.005,2.2+(count4-60)*0.02,196,28);
            }
        }

        if (count4>60&&count4<220&&count%2==0)
        {
            PlaySE(GetCurrentScriptDirectory~"\se\Shot00.wav");
        }

        if (count4==70&&GetLife()<=10000&&GetLife()>=2000)
        {
            ascent( let t in 0..16 ) {
                Laser2(GetX(),GetY(),5,GetAngleToPlayer()+t*(360/16),0,15,185,86);
            }
        }//MotionBlurEx(ALL,130,150,ALPHA);}

        if (count4==70&&GetLife()<2000&&GetLife()>0)
        {
            ascent( let t in 0..16 ) {
                Laser2(GetX(),GetY(),5,GetAngleToPlayer()+t*(360/16),0,15,185,86);
            }
        }//MotionBlurEx(ALL,350,130,ALPHA);}


        if (R4==0) {

            if (count4>180&&count4<280&&count4%7==0&&GetLife()>6000) {
                SetDamageRate(220,0);
                if (count>=35) {
                    PlaySE(GetCurrentScriptDirectory~"\se\Shot04.wav");
                    ascent( let t in 0..4 ) {
                        CreateShot01(GetX()+65*cos(GetAngleToPlayer()+shot),GetY()+2+65*sin(GetAngleToPlayer()+shot),rand(2.2,4.5),GetAngleToPlayer()+135+220*sin(count4)+rand(-3,3),33,0);
                    }
                    ascent( let t in 0..10 ) {
                        CreateShot01(GetX()+65*cos(GetAngleToPlayer()+shot),GetY()+2+65*sin(GetAngleToPlayer()+shot),rand(1.2,3.8),GetAngleToPlayer()+135+220*sin(count4)+rand(-18,18),196,0);
                    }
                    CreateShot02(GetX()+65*cos(GetAngleToPlayer()+shot),GetY()+2+65*sin(GetAngleToPlayer()+shot),7,GetAngleToPlayer()+135+220*sin(count4),-0.2,4.4,49,0);
                    CreateShot01(GetX()+65*cos(GetAngleToPlayer()+shot),GetY()+2+65*sin(GetAngleToPlayer()+shot),512,GetAngleToPlayer()+shot,194,28);
                }
            }

            if (count4>170&&count4<280&&count4%5==0&&GetLife()>4000&&GetLife()<=6000) {
                SetDamageRate(220,0);
                if (count>=35) {
                    PlaySE(GetCurrentScriptDirectory~"\se\Shot04.wav");
                    ascent( let t in 0..4 ) {
                        CreateShot01(GetX()+65*cos(GetAngleToPlayer()+shot),GetY()+2+65*sin(GetAngleToPlayer()+shot),rand(3.6,4.5),GetAngleToPlayer()+235+320*sin(count4)+rand(-3,3),33,0);
                    }
                    ascent( let t in 0..10 ) {
                        CreateShot01(GetX()+65*cos(GetAngleToPlayer()+shot),GetY()+2+65*sin(GetAngleToPlayer()+shot),rand(1.2,3.8),GetAngleToPlayer()+235+320*sin(count4)+rand(-16,16),196,0);
                    }
                    CreateShot02(GetX()+65*cos(GetAngleToPlayer()+shot),GetY()+2+65*sin(GetAngleToPlayer()+shot),7,GetAngleToPlayer()+235+320*sin(count4),-0.2,4.4,49,0);
                    CreateShot01(GetX()+65*cos(GetAngleToPlayer()+shot),GetY()+2+65*sin(GetAngleToPlayer()+shot),512,GetAngleToPlayer()+shot,194,28);
                }
            }

            if (count4>170&&count4<280&&count4%8==0&&GetLife()>1000&&GetLife()<=4000) {
                SetDamageRate(200,0);
                if (count>=35) {
                    PlaySE(GetCurrentScriptDirectory~"\se\Shot04.wav");
                    ascent( let t in 0..3 ) {
                        CreateShot01(GetX()+65*cos(GetAngleToPlayer()+shot),GetY()+2+65*sin(GetAngleToPlayer()+shot),rand(3.6,4.5),GetAngleToPlayer()+235+320*sin(count4)+rand(-2,2),33,0);
                    }
                    ascent( let t in 0..8 ) {
                        CreateShot01(GetX()+65*cos(GetAngleToPlayer()+shot),GetY()+2+65*sin(GetAngleToPlayer()+shot),rand(2.5,4.5),GetAngleToPlayer()+235+320*sin(count4)+rand(-6,6),196,0);
                    }
                    CreateShot02(GetX()+65*cos(GetAngleToPlayer()+shot),GetY()+2+65*sin(GetAngleToPlayer()+shot),7,GetAngleToPlayer()+235+320*sin(count4),-0.2,4.4,49,0);
                    CreateShot01(GetX()+65*cos(GetAngleToPlayer()+shot),GetY()+2+65*sin(GetAngleToPlayer()+shot),512,GetAngleToPlayer()+shot,194,28);
                }
            }

            if (count4>170&&count4<280&&count4%8==2&&GetLife()>1&&GetLife()<=1000) {
                SetDamageRate(140,0);
                if (count>=35) {
                    PlaySE(GetCurrentScriptDirectory~"\se\Shot04.wav");
                    ascent( let t in 0..3 ) {
                        CreateShot01(GetX()+65*cos(GetAngleToPlayer()+shot),GetY()+2+65*sin(GetAngleToPlayer()+shot),rand(3.6,4.5),GetAngleToPlayer()+245+320*sin(count4)+rand(-2,2),33,0);
                    }
                    ascent( let t in 0..6 ) {
                        CreateShot01(GetX()+65*cos(GetAngleToPlayer()+shot),GetY()+2+65*sin(GetAngleToPlayer()+shot),rand(2.5,4.5),GetAngleToPlayer()+245+320*sin(count4)+rand(-6,6),196,0);
                    }
                    CreateShot02(GetX()+65*cos(GetAngleToPlayer()+shot),GetY()+2+65*sin(GetAngleToPlayer()+shot),7,GetAngleToPlayer()+245+320*sin(count4),-0.2,4.4,49,0);
                    ascent( let t in 0..3 ) {
                        CreateShot01(GetX()+65*cos(GetAngleToPlayer()+shot),GetY()+2+65*sin(GetAngleToPlayer()+shot),rand(3.6,4.5),GetAngleToPlayer()+55+320*sin(count4)+rand(-2,2),33,0);
                    }
                    ascent( let t in 0..8 ) {
                        CreateShot01(GetX()+65*cos(GetAngleToPlayer()+shot),GetY()+2+65*sin(GetAngleToPlayer()+shot),rand(2.5,4.5),GetAngleToPlayer()+55+320*sin(count4)+rand(-6,6),196,0);
                    }
                    CreateShot02(GetX()+65*cos(GetAngleToPlayer()+shot),GetY()+2+65*sin(GetAngleToPlayer()+shot),7,GetAngleToPlayer()+55+320*sin(count4),-0.2,4.4,49,0);
                    CreateShot01(GetX()+65*cos(GetAngleToPlayer()+shot),GetY()+2+65*sin(GetAngleToPlayer()+shot),512,GetAngleToPlayer()+shot,194,28);
                }
            }

        }

        else {

            if (count4>180&&count4<280&&count4%7==0&&GetLife()>6000) {
                SetDamageRate(220,0);
                if (count>=35) {
                    PlaySE(GetCurrentScriptDirectory~"\se\Shot04.wav");
                    ascent( let t in 0..4 ) {
                        CreateShot01(GetX()+65*cos(GetAngleToPlayer()+shot),GetY()+2+65*sin(GetAngleToPlayer()+shot),rand(2.2,4.5),GetAngleToPlayer()-135-220*sin(count4)+rand(-3,3),33,0);
                    }
                    ascent( let t in 0..12 ) {
                        CreateShot01(GetX()+65*cos(GetAngleToPlayer()+shot),GetY()+2+65*sin(GetAngleToPlayer()+shot),rand(1.2,3.8),GetAngleToPlayer()-135-220*sin(count4)+rand(-32,32),196,0);
                    }
                    CreateShot02(GetX()+65*cos(GetAngleToPlayer()+shot),GetY()+2+65*sin(GetAngleToPlayer()+shot),7,GetAngleToPlayer()-135-220*sin(count4),-0.2,4.4,49,0);
                    CreateShot01(GetX()+65*cos(GetAngleToPlayer()+shot),GetY()+2+65*sin(GetAngleToPlayer()+shot),512,GetAngleToPlayer()+shot,194,28);
                }
            }

            if (count4>170&&count4<280&&count4%5==0&&GetLife()>4000&&GetLife()<=6000) {
                SetDamageRate(200,0);
                if (count>=35) {
                    PlaySE(GetCurrentScriptDirectory~"\se\Shot04.wav");
                    ascent( let t in 0..4 ) {
                        CreateShot01(GetX()+65*cos(GetAngleToPlayer()+shot),GetY()+2+65*sin(GetAngleToPlayer()+shot),rand(3.6,4.5),GetAngleToPlayer()-235-320*sin(count4)+rand(-3,3),33,0);
                    }
                    ascent( let t in 0..12 ) {
                        CreateShot01(GetX()+65*cos(GetAngleToPlayer()+shot),GetY()+2+65*sin(GetAngleToPlayer()+shot),rand(1.2,3.8),GetAngleToPlayer()-235-320*sin(count4)+rand(-16,16),196,0);
                    }
                    CreateShot02(GetX()+65*cos(GetAngleToPlayer()+shot),GetY()+2+65*sin(GetAngleToPlayer()+shot),7,GetAngleToPlayer()-235-320*sin(count4),-0.2,4.4,49,0);
                    CreateShot01(GetX()+65*cos(GetAngleToPlayer()+shot),GetY()+2+65*sin(GetAngleToPlayer()+shot),512,GetAngleToPlayer()+shot,194,28);
                }
            }

            if (count4>170&&count4<280&&count4%8==0&&GetLife()>1&&GetLife()<=4000) {
                SetDamageRate(140,0);
                if (count>=35) {
                    PlaySE(GetCurrentScriptDirectory~"\se\Shot04.wav");
                    ascent( let t in 0..3 ) {
                        CreateShot01(GetX()+65*cos(GetAngleToPlayer()+shot),GetY()+2+65*sin(GetAngleToPlayer()+shot),rand(3.6,4.5),GetAngleToPlayer()-235-320*sin(count4)+rand(-2,2),33,0);
                    }
                    ascent( let t in 0..8 ) {
                        CreateShot01(GetX()+65*cos(GetAngleToPlayer()+shot),GetY()+2+65*sin(GetAngleToPlayer()+shot),rand(2.5,4.5),GetAngleToPlayer()-235-320*sin(count4)+rand(-4,4),196,0);
                    }
                    CreateShot02(GetX()+65*cos(GetAngleToPlayer()+shot),GetY()+2+65*sin(GetAngleToPlayer()+shot),7,GetAngleToPlayer()-235-320*sin(count4),-0.2,4.4,49,0);
                    ascent( let t in 0..3 ) {
                        CreateShot01(GetX()+65*cos(GetAngleToPlayer()+shot),GetY()+2+65*sin(GetAngleToPlayer()+shot),rand(3.6,4.5),GetAngleToPlayer()-55-320*sin(count4)+rand(-2,2),33,0);
                    }
                    ascent( let t in 0..8 ) {
                        CreateShot01(GetX()+65*cos(GetAngleToPlayer()+shot),GetY()+2+65*sin(GetAngleToPlayer()+shot),rand(2.5,4.5),GetAngleToPlayer()-55-320*sin(count4)+rand(-4,4),196,0);
                    }
                    CreateShot02(GetX()+65*cos(GetAngleToPlayer()+shot),GetY()+2+65*sin(GetAngleToPlayer()+shot),7,GetAngleToPlayer()-55-320*sin(count4),-0.2,4.4,49,0);
                    CreateShot01(GetX()+65*cos(GetAngleToPlayer()+shot),GetY()+2+65*sin(GetAngleToPlayer()+shot),512,GetAngleToPlayer()+shot,194,28);
                }
            }

        }

        if (rand(0,90)<85&&count4%16==0&&GetLife()<=4000&&GetLife()>3000) {
            SetShotAutoDeleteClip(32,32,32,32);
            SetDamageRate(220,0);
            if (count>=35) {
                PlaySE(GetCurrentScriptDirectory~"\se\Shot04.wav");
                //ascent( let t in 0..8 ){CreateShot01(GetX()+65*cos(GetAngleToPlayer()+shot),GetY()+2+65*sin(GetAngleToPlayer()+shot),rand(1.4,2.4),GetAngleToPlayer()+shot+rand(-5,5),169,5);}
                //CreateShot02(GetX()+65*cos(GetAngleToPlayer()+shot),GetY()+2+65*sin(GetAngleToPlayer()+shot),3,GetAngleToPlayer()+shot,-0.2,2.1,55,5);
                CreateShot01(GetX()+65*cos(GetAngleToPlayer()+shot),GetY()+2+65*sin(GetAngleToPlayer()+shot),512,GetAngleToPlayer()+shot,194,28);
                CreateWayShot02(8,15,GetX()+65*cos(GetAngleToPlayer()+shot),GetY()+2+65*sin(GetAngleToPlayer()+shot),25,1,GetAngleToPlayer()+shot,0,5,170,10);
            }shot+=33;
        }

        if (rand(0,90)<75&&count4%11==0&&GetLife()<=3000&&GetLife()>2000) {
            SetDamageRate(200,0);
            if (count>=35) {
                PlaySE(GetCurrentScriptDirectory~"\se\Shot04.wav");
                //ascent( let t in 0..8 ){CreateShot01(GetX()+65*cos(GetAngleToPlayer()+shot),GetY()+2+65*sin(GetAngleToPlayer()+shot),rand(1.6,2.4),GetAngleToPlayer()+shot+rand(-5,5),169,5);}
                //CreateShot02(GetX()+65*cos(GetAngleToPlayer()+shot),GetY()+2+65*sin(GetAngleToPlayer()+shot),3,GetAngleToPlayer()+shot,-0.2,2.1,55,5);
                CreateShot01(GetX()+65*cos(GetAngleToPlayer()+shot),GetY()+2+65*sin(GetAngleToPlayer()+shot),512,GetAngleToPlayer()+shot,194,28);
                CreateWayShot02(4,15,GetX()+65*cos(GetAngleToPlayer()+shot),GetY()+2+65*sin(GetAngleToPlayer()+shot),25,1.3,GetAngleToPlayer()+shot,0,5,170,10);
                CreateWayShot02(4,15,GetX()+65*cos(GetAngleToPlayer()+shot),GetY()+2+65*sin(GetAngleToPlayer()+shot),25,0.7,GetAngleToPlayer()+shot,0,5,170,10);
            }shot+=26;
        }

        if (rand(0,90)<65&&count4%6==0&&GetLife()<=2000&&GetLife()>0) {
            SetDamageRate(140,0);
            if (count>=35) {
                PlaySE(GetCurrentScriptDirectory~"\se\Shot04.wav");
                //ascent( let t in 0..8 ){CreateShot01(GetX()+65*cos(GetAngleToPlayer()+shot),GetY()+2+65*sin(GetAngleToPlayer()+shot),rand(1.7,2.2),GetAngleToPlayer()+shot+rand(-4,4),169,5);}
                //CreateShot02(GetX()+65*cos(GetAngleToPlayer()+shot),GetY()+2+65*sin(GetAngleToPlayer()+shot),3,GetAngleToPlayer()+shot,-0.2,2.1,55,5);
                CreateShot01(GetX()+65*cos(GetAngleToPlayer()+shot),GetY()+2+65*sin(GetAngleToPlayer()+shot),512,GetAngleToPlayer()+shot,194,28);
                CreateWayShot02(3,18,GetX()+65*cos(GetAngleToPlayer()+shot),GetY()+2+65*sin(GetAngleToPlayer()+shot),25,1.5,GetAngleToPlayer()+shot,0,5,170,10);
                CreateWayShot02(3,18,GetX()+65*cos(GetAngleToPlayer()+shot),GetY()+2+65*sin(GetAngleToPlayer()+shot),25,0.9,GetAngleToPlayer()+shot,0,5,170,10);
            }shot+=45+rand(-10,10);
        }

        if (count4>=252&&rand(0,90)<5)
        {
            SetMovePositionRandom01(85,rand(50,150),5,GetPlayerX(),108,GetPlayerX(),170);
            move=70;
            move2=12;
        }
        if (count4==300)
        {
            SetMovePositionRandom01(85,rand(50,150),5,GetPlayerX(),108,GetPlayerX(),170);
            move=70;
            move2=12;
        }

        if (GetX-GetPlayerX<-48&&GetX-GetPlayerX>48) {
            SetDamageRate(40,0);
        }

        if (count4>=320&&rand(0,90)>84&&GetLife()>3000) {
            count4=60;
            if (R4==0) {
                R4+=1;
            }else {
                R4=0;
            }
        }
        if (count4>=320&&rand(0,90)>55&&GetLife()<=3000) {
            count4=60;
            if (R4==0) {
                R4+=1;
            }else {
                R4=0;
            }
        }

        if (OnBomb==false&&count2>540) {
            SetCollisionA(GetX(),GetY(),22);
            SetCollisionB(GetX(),GetY(),14);
        }

        if (count2==310) {
            PlaySE(GetCurrentScriptDirectory~"\se\warp02.wav");
            SetScore(16000000);
            CutIn(YOUMU,"`LastSpell`uυίΜΆz­v",GetCurrentScriptDirectory~"img\remiria2.png",0,0,512,512);
        }

        if (count2>=320) {
            count++;
        }if (count>=75) {
            count4++;
        }count2++;
        if (count2>=10) {
            count3++;
        }move--;

        c+=12;
        move2--;
        xr=0;
        xr+=rand(-5,5);
        yr=0;
        yr+=rand(-5,5);

        if (GetEnemyLife>0&&(GetSpeedX())>=0.1&&ang2<44&&move2>0) {
            ang2+=2.5;
        }
        if (GetEnemyLife>0&&(GetSpeedX())<=-0.1&&ang2>-44&&move2>0) {
            ang2-=2.5;
        }
        if (move2<=0&&ang2<0) {
            ang2+=0.8;
        }
        if (move2<=0&&ang2>0) {
            ang2-=0.8;
        }

        if (count4==140) {
            cir=15;
            PlaySE(GetCurrentScriptDirectory~"\se\Laser2.wav");
        }cir--;

        if (GetEnemyLife<=0) {
            if (ls<172) {
                CreateShot12(GetX+rand(-4,4),GetY,rand(-1.4,1.4),rand(1.4,-1.2),0,-0.03,0,-5.4,196,rand(4,15));
            }
            if (count%40==0) {
                PlaySE(GetCurrentScriptDirectory~"\se\Baaaaaaaan.wav");
            }
            if (MT==0) {
                SetCommonData("last",true);
                SetPlayerInvincibility(200);
                MT++;
                return;
            }ls++;
        }

        if (Bo>0) {
            Bo++;
        }
        SetCommonData("x",GetX);
        SetCommonData("y",GetY);
        yield;
    }

    @Finalize()
    {
        if (GotSpellCardBonus()==true) {
            get++;
            SetCommonDataEx("Spell","1no9get",get);
        }
        save();

        SetShotAutoDeleteClip(32,32,32,32);
        SetCommonData("last",false);

    }

    @DrawLoop()
    {
        SetTexture(GetCurrentScriptDirectory~"\img\JUUJI.png");
        SetGraphicRect(0,0,256,256);
        SetRenderState(ALPHA);
        SetGraphicScale(2,2);
        SetGraphicAngle(0,0,ang2);
        if (count<=1) {
            SetAlpha(0);
            SetColor(0,0,0);
        }
        if (count>1) {
            SetAlpha(count*2.5);
            SetColor(count*1.2,0,0);
        }
        if (count>=100) {
            SetAlpha(255);
            SetColor(125+120*sin(count*2),0,0);
        }
        if (GetEnemyLife<=0) {
            SetAlpha(255-255*(ls/200))
        }
        DrawGraphic(GetX(),GetY());


        if (Bo>0)
        {
            SetTexture(GetCurrentScriptDirectory~"\img\NuclearWave2.png");
            SetGraphicAngle(0,0,225+count*2);
            SetGraphicRect(0,768,256,1024);
            SetAlpha(255);
            SetRenderState(ADD);
            if (Bo>0) {
                SetColor(255,255,255);
                SetGraphicScale(Bo*0.1,Bo*0.1);
            }
            if (Bo>25) {
                SetColor(255-Bo*2,255-Bo*2,255-Bo*2);
                SetGraphicScale(25*0.09+Bo*0.003,25*0.09+Bo*0.003);
            }
            if (Bo*2>=255) {
                SetColor(0,0,0);
                Bo=0;
            }
            DrawGraphic(Bx-12,By);
        }

        if (GetEnemyLife>0) {
            SetTexture(GetCurrentScriptDirectory~"\img\circle_l.png");
            SetGraphicAngle(0,0,-c);
            SetGraphicRect(0,0,256,256);
            SetAlpha(255);
            SetRenderState(ADD);
            SetColor(160+20*sin(c),160+20*sin(c),160+20*sin(c));
            if (count<=1) {
                SetGraphicScale(0,0);
            }
            if (count>1) {
                SetGraphicScale(0.0085*count+0.1*sin(count*3),0.0085*count+0.1*sin(count*3));
            }
            if (count>=100) {
                SetGraphicScale(0.85+0.05*sin((count-120)*3),0.85+0.05*sin((count-120)*3));
            }
            DrawGraphic(GetX()+xr,GetY()+yr);
            if (count<=1) {
                SetGraphicScale(0,0);
            }SetGraphicAngle(0,0,c);
            if (count>1) {
                SetGraphicScale(0.005*count+0.1*sin(count2*3),0.005*count+0.1*sin(count2*3));
            }
            if (count>=50) {
                SetGraphicScale(0.25+0.1*sin((count2-120)*3),0.25+0.1*sin((count2-120)*3));
            }
            DrawGraphic(GetX()+65*cos(GetAngleToPlayer()+shot),GetY()+2+65*sin(GetAngleToPlayer()+shot));

            SetTexture(GetCurrentScriptDirectory~"\img\circle_l.png");
            SetGraphicRect(0,0,256,256);
            SetColor(182,182,182);
            if (count==0&&GetAngle()>=120) {
                N15=-3;
            }
            if (count==0&&GetAngle()<=60) {
                N15=3;
            }
            SetGraphicAngle(0,0,c);
            if (count2<=480) {
                SetGraphicScale(0,0);
            }
            if (count2>480) {
                SetGraphicScale(0.01*(count2-480),0.01*(count2-480));
            }
            if (count2>=530) {
                SetGraphicScale(0.5+0.05*sin((count2-120)*3),0.5+0.05*sin((count2-120)*3));
            }
            SetRenderState(ADD);
            SetGraphicRect(0,0,256,256);
            DrawGraphic(GetX()+55*cos(GetAngleToPlayer()+shot),GetY()+2+55*sin(GetAngleToPlayer()+shot));
            if (cir>0) {
                if (cir>20) {
                    SetColor(155-(cir-20)*15,0,0);
                }else {
                    SetColor(155,0,0);
                }
                SetAlpha(255);
                SetGraphicAngle(0,0,count2*18);
                SetGraphicScale(cir*0.15,cir*0.15);
                DrawGraphic(GetX(),GetY());
            }


        }

        if (OnEnemySpell==true&&OnBomb==true&&bombalpha>0) {
            bombalpha-=5;
        }
        if (OnEnemySpell==true&&OnBomb==false&&bombalpha<255) {
            bombalpha+=5;
        }

        SetTexture(img);
        SetAlpha(255);
        if (count2<=490) {
            SetAlpha(0);
        }
        if (count2>490&&count2<=540) {
            SetAlpha((count2-490)*5);
        }
        SetGraphicAngle(0,0,0);
        SetRenderState(ALPHA);
        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&&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 (GetSpeedX()<0&&move>0) {
            SetGraphicRect(256,0,384,128);
        }
        if (GetSpeedX()<0&&move>8) {
            SetGraphicRect(256,128,384,256);
        }
        if (GetSpeedX()>=0&&move>0) {
            SetGraphicRect(256,256,384,384);
        }
        if (GetSpeedX()>=0&&move>8) {
            SetGraphicRect(256,384,384,512);
        }
        if (tame>0) {
            SetGraphicRect(128*3,0,128*4,128);
        }
        if (tame>32) {
            SetGraphicRect(128*3,128,128*4,256);
        }
        if (tame>42) {
            SetGraphicRect(128*3,256,128*4,384);
        }
        //SetColor(bombalpha,0,0);
        //SetGraphicScale(1.2+count%3*0.2,1.2+count%3*0.2);
        //DrawGraphic(GetX()+rand(-2,2),GetY()+rand(-3,3));
        SetColor(bombalpha,bombalpha,bombalpha);
        SetGraphicScale(1,1);
        if (ten==1&&OnBomb==false) {
            SetColor(160,160,180);
        }
        DrawGraphic(GetX(),GetY());

        if (OnEnemySpell==true&&OnBomb==true&&bombalpha>0) {
            bombalpha-=5;
        }
        if (OnEnemySpell==true&&OnBomb==false&&bombalpha<255) {
            bombalpha+=5;
        }

        if (bombalpha<255) {
            SetTexture(img);
            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()+15*cos(count2*28),GetY()+30*cos(count2*18));
            if (count2/4%4>=1) {
                SetGraphicRect(128*6,0,128*7,128);
            }
            if (count2/4%4>=2) {
                SetGraphicRect(128*6,128,128*7,256);
            }
            if (count2/4%4>=3) {
                SetGraphicRect(128*6,256,128*7,384);
            }
            if (count2/4%4>=0) {
                SetGraphicRect(128*6,384,128*7,512);
            }
            DrawGraphic(GetX()-30*cos(count2*18),GetY()-15*cos(count2*28));
            if (count2/4%4>=2) {
                SetGraphicRect(128*6,0,128*7,128);
            }
            if (count2/4%4>=3) {
                SetGraphicRect(128*6,128,128*7,256);
            }
            if (count2/4%4>=0) {
                SetGraphicRect(128*6,256,128*7,384);
            }
            if (count2/4%4>=1) {
                SetGraphicRect(128*6,384,128*7,512);
            }
            DrawGraphic(GetX()+24*cos(count2*46),GetY()-40*cos(count2*58));
            if (count2/4%4>=3) {
                SetGraphicRect(128*6,0,128*7,128);
            }
            if (count2/4%4>=0) {
                SetGraphicRect(128*6,128,128*7,256);
            }
            if (count2/4%4>=1) {
                SetGraphicRect(128*6,256,128*7,384);
            }
            if (count2/4%4>=2) {
                SetGraphicRect(128*6,384,128*7,512);
            }
            DrawGraphic(GetX()-44*cos(count2*46),GetY()+20*cos(count2*58));
        }

        if (count>=10) {
            SetFontColor(255,196,196,255,0,0);
            let posX = 80;
            if (try>=1000) {
                posX+=21;
            }if (try>=100) {
                posX+=14;
            }else if (try>=10) {
                posX+=7;
            }
            if (get>=1000) {
                posX+=15;
            }if (get>=100) {
                posX+=10;
            }else if (get>=10) {
                posX+=5;
            }
            DrawText("Score "~IntToString(get)~" / "~IntToString(try)~"",GetClipMaxX()-posX,GetClipMinY()+44,10,196);
        }
    }

    @BackGround()
    {
        SetTexture(bg);
        SetGraphicRect(0,0,384,448);
        SetRenderState(ALPHA);
        SetGraphicScale(1,1);
        SetGraphicAngle(0,0,0);
        SetColor(255,255,255);
        if (count3<=1) {
            SetAlpha(0);
        }
        if (count3>1) {
            SetAlpha(count3*5);
        }
        if (count3>=51) {
            SetAlpha(255);
        }
        DrawGraphic(GetCenterX(),GetCenterY());

        SetTexture(bg2);
        SetRenderState(ADD);
        SetGraphicAngle(0,0,-count2);
        if (count2<=1) {
            SetColor(0,0,0);
        }
        if (count2>1) {
            SetColor(count2,count2,count2);
        }
        if (count2>=128) {
            SetColor(128,128,128);
        }
        DrawGraphic(GetCenterX(),GetCenterY()-30);
        SetGraphicScale(1.9,1.9);
        SetGraphicAngle(0,0,count2);
        DrawGraphic(GetCenterX(),GetCenterY()-30);

        SetTexture(bg3);
        SetGraphicAngle(0,0,0);
        SetGraphicRect(-count2,512,1028-count2,768);
        SetGraphicScale(1,1);
        SetAlpha(255);
        if (count2<=1) {
            SetColor(0,0,0);
        }
        if (count2>1) {
            SetColor(count2*2,count2*2,count2*2);
        }
        if (count2>=128) {
            SetColor(255,255,255);
        }
        SetRenderState(SUBTRACT);
        DrawGraphic(GetCenterX(),GetCenterY()+100);
        DrawGraphic(GetCenterX(),GetCenterY()+100);
    }

}

