#東方弾幕風[Stage]
#Title[★おまけステージ０２]
#Text[解放条件：
道中ノーミス（喰らいボム不可）or
道中３０００HIT以上 or
道中１０億点以上取得]
#Player[FREE]
#ScriptVersion[2]
#BackGround[Default]
#BGM[]

script_stage_main
{
    let Z=0;//毎フレーム増える
    let ZZ=0;
    let Z01=0;
    let Z02=0;
    let Z03=0;
    let Z04=0;
    let Z11=0;//雑用
    let Z12=0;
    let gra=0;
    let gra2=0;
    let gra3=0;
    let gra4=0;
    let sco=0;

    let color=0;//色代入用


    let gu1=0;
    let gu2=0;
    let gu3=0;
    let gu4=0;
    let gu5=0;
    let gu6=0;
    let gu7=0;
    let gu8=0;
    let gu9=0;
    let gu10=0;

    let cx=GetCenterX();
    let cy=GetCenterY();
    let AC=0;
    let ac=0;
    let ze=0;
    let col=0;
    let col2=0;
    let count=0;
    let BGstep=0;
    let Yspeed=0;
    let Yspeed2=0;
    let slow=0;
    let slow2=0;
    let sx=0;
    let sy=0;
    let sxs=0;
    let sys=0;
    let sa=0;
    let sas=0;
    let SlowMove=0;
    let BGG00=0;
    let BGG01=0;
    let BGG02=0;
    let BGG03=0;
    let BGG04=0;
    let BGG05=255;
    let BGG06=0;
    let BGG07=0;
    let BGG08=0;
    let BGG09=0;
    let BGG10=0;
    let BGG11=100;
    let BGG12=0;
    let BGG13=0;
    let BGG14=0;
    let BGG15=0;
    let BGG16=0;
    let BGG17=0;
    let BGG19=0;
    let BGG21=0;
    let BGG22=0;
    let BGG23=0;
    let BGG24=0;
    let BGG50=250;
    let BGG25=0;
    let BGG26=0;
    let BGG27=0;
    let BGG28=0;
    let BGG29=255;
    let BGG30=0;
    let BGG31=0;
    let BGG34=0;
    let BGG35=0;
    let BGG36=0;
    let BGG37=0;
    let ura=0;

    let ste_ang=0;
    let ste_ang2=0;
    let ma=0;
    let xUP=250;
    let xBOMB=100000000;
    let pass=GetCurrentScriptDirectory~"Spell.dat";
    let BG=100;
    let stage=0;
    let Dark=0;
    let mo=255;
    let mo2=255;
    let backangle=0;
    let Level=0;
    let Mode=0;
    let uprr=0;
    let borr=0;
    let uprr2=0;
    let borr2=0;
    let uprr3=0;
    let borr3=0;
    let uprrS=0;
    let borrS=0;
    let tile2=0;
    let tile3=255;
    let tile4=255;
    let tile5=0;
    let ut=0;
    let ut2=1;
    let replay=0;
    CompileEnemyFromFile(GetCurrentScriptDirectory~"RemiN01.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"RemiN01+.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"RemiN02.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"RemiN02+.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"RemiN03.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"RemiN03+.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"RemiN04.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"RemiN04+.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"RemiN05.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"RemiN05+.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"RemiN06.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"RemiN06+.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"RemiN07.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"RemiN07+.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"Remi02.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"Remi03.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"Remi04.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"Remi01+.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"Remi02+.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"Remi03+.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"Remi04+.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"Remi06.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"Remi06++.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"Remi07.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"Remi09.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"RemiEvent.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"Enemy01.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"Enemy02.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"Enemy03.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"Enemy04.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"Enemy05.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"Enemy07.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"Enemy08.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"Enemy09.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"Enemy10.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"Enemy11.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"Enemy12.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"Enemy13.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"Enemy14.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"rFraN01.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"rFra02.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"rFra01.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"rFraEvent.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"Servant00.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"Servant01.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"Servant02.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"Servant03a.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"Servant04.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"Servant10.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"Servant102.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"firstEvent.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"firstEvent2.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"firstEvent3.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"Missile.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"Missile2.txt");
    CompileEnemyFromFile(GetCurrentScriptDirectory~"Missiles.txt");

    task combo()
    {
        let alpha = 0;
        let obj = Obj_Create(OBJ_EFFECT);
        Obj_SetX(obj, -69);
        Obj_SetY(obj, 51);
        Obj_SetSpeed(obj, 0);
        ObjEffect_SetTexture(obj, GetCurrentScriptDirectory~"\img\Tiiiiilllll.png");
        ObjEffect_SetRenderState(obj, ALPHA);
        ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
        ObjEffect_SetScale(obj,0.8,1.02);
        ObjEffect_SetAngle(obj,0,0,0);
        ObjEffect_CreateVertex(obj, 4);
        ObjEffect_SetLayer(obj,3);

        //四角形状に各頂点のUV値を設定
        ObjEffect_SetVertexUV(obj,0,140,18);
        ObjEffect_SetVertexUV(obj,1,152,18);
        ObjEffect_SetVertexUV(obj,2,152,78);
        ObjEffect_SetVertexUV(obj,3,140,78);

        while (!Obj_BeDeleted(obj))
        {

            //四角形状に各頂点の座標を設定
            ObjEffect_SetVertexXY(obj,0,152,77-gu2);
            ObjEffect_SetVertexXY(obj,1,140,77-gu2);
            ObjEffect_SetVertexXY(obj,2,152,78);
            ObjEffect_SetVertexXY(obj,3,140,78);

            if (gu2<20) {
                ascent(let t in 0..4) {
                    ObjEffect_SetVertexColor(obj,t,(125+(mo2/2)),155,0,200);
                }
            }

            if (gu2>=20) {
                ascent(let t in 0..4) {
                    ObjEffect_SetVertexColor(obj,t,(125+(mo2/2)),200,0,0);
                }
            }

            if (gu2>=60&&gra>=3) {
                ascent(let t in 0..4) {
                    ObjEffect_SetVertexColor(obj,t,(125+(mo2/2)),230,0,0);
                }
            }

            if (gu2>=60&&count%3<1&&gra>=3) {
                ascent(let t in 0..4) {
                    ObjEffect_SetVertexColor(obj,t,(125+(mo2/2)),255,225,195);
                }
            }

            if (gu4>0) {
                ascent(let t in 0..4) {
                    ObjEffect_SetVertexColor(obj,t,(125+(mo2/2)),145,145,145);
                }
            }

            yield;
        }

    }

    task itemg()
    {
        let alpha = 0;
        let obj = Obj_Create(OBJ_EFFECT);
        Obj_SetX(obj, 605);
        Obj_SetY(obj, 193);
        Obj_SetSpeed(obj, 0);
        ObjEffect_SetTexture(obj, GetCurrentScriptDirectory~"\img\Tiiiiilllll.png");
        ObjEffect_SetRenderState(obj, ALPHA);
        ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
        ObjEffect_SetScale(obj,1,1);
        ObjEffect_SetAngle(obj,0,0,0);
        ObjEffect_CreateVertex(obj, 4);
        ObjEffect_SetLayer(obj,8);

        //四角形状に各頂点のUV値を設定
        ObjEffect_SetVertexUV(obj,0,176,352);
        ObjEffect_SetVertexUV(obj,1,176,384);
        ObjEffect_SetVertexUV(obj,2,192,384);
        ObjEffect_SetVertexUV(obj,3,192,352);

        while (!Obj_BeDeleted(obj))
        {

            //四角形状に各頂点の座標を設定
            ObjEffect_SetVertexXY(obj,0,0,0);
            ObjEffect_SetVertexXY(obj,1,0,32);
            ObjEffect_SetVertexXY(obj,2,16,32);
            ObjEffect_SetVertexXY(obj,3,16,0);

            ascent(let t in 0..4) {
                ObjEffect_SetVertexColor(obj,t,255,255,255,255);
            }

            if (uprr2<=0) {
                Obj_Delete(obj);
            }

            yield;
        }

    }

    task itemg2()
    {
        let alpha = 0;
        let obj = Obj_Create(OBJ_EFFECT);
        Obj_SetX(obj, 629);
        Obj_SetY(obj, 211);
        Obj_SetSpeed(obj, 0);
        ObjEffect_SetTexture(obj, GetCurrentScriptDirectory~"\img\Tiiiiilllll.png");
        ObjEffect_SetRenderState(obj, ALPHA);
        ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
        ObjEffect_SetScale(obj,0.5,0.5);
        ObjEffect_SetAngle(obj,0,0,0);
        ObjEffect_CreateVertex(obj, 4);
        ObjEffect_SetLayer(obj,8);

        while (!Obj_BeDeleted(obj))
        {

            //四角形状に各頂点の座標を設定
            ObjEffect_SetVertexXY(obj,0,-10,-19);
            ObjEffect_SetVertexXY(obj,1,-10,19);
            ObjEffect_SetVertexXY(obj,2,10,-19);
            ObjEffect_SetVertexXY(obj,3,10,19);

            //四角形状に各頂点のUV値を設定
            ObjEffect_SetVertexUV(obj,0,164+24*uprr,128);
            ObjEffect_SetVertexUV(obj,1,164+24*uprr,166);
            ObjEffect_SetVertexUV(obj,2,184+24*uprr,128);
            ObjEffect_SetVertexUV(obj,3,184+24*uprr,166);

            ascent(let t in 0..4) {
                ObjEffect_SetVertexColor(obj,t,255,255,255,255);
            }

            if (uprr2<=0) {
                Obj_Delete(obj);
            }

            yield;
        }

    }

    task bombg()
    {
        let alpha = 0;
        let obj = Obj_Create(OBJ_EFFECT);
        Obj_SetX(obj, 605);
        Obj_SetY(obj, 227);
        Obj_SetSpeed(obj, 0);
        ObjEffect_SetTexture(obj, GetCurrentScriptDirectory~"\img\Tiiiiilllll.png");
        ObjEffect_SetRenderState(obj, ALPHA);
        ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
        ObjEffect_SetScale(obj,1,1);
        ObjEffect_SetAngle(obj,0,0,0);
        ObjEffect_CreateVertex(obj, 4);
        ObjEffect_SetLayer(obj,8);

        //四角形状に各頂点のUV値を設定
        ObjEffect_SetVertexUV(obj,0,176,352);
        ObjEffect_SetVertexUV(obj,1,176,384);
        ObjEffect_SetVertexUV(obj,2,192,384);
        ObjEffect_SetVertexUV(obj,3,192,352);

        while (!Obj_BeDeleted(obj))
        {

            //四角形状に各頂点の座標を設定
            ObjEffect_SetVertexXY(obj,0,0,0);
            ObjEffect_SetVertexXY(obj,1,0,32);
            ObjEffect_SetVertexXY(obj,2,16,32);
            ObjEffect_SetVertexXY(obj,3,16,0);

            ascent(let t in 0..4) {
                ObjEffect_SetVertexColor(obj,t,255,255,255,255);
            }

            if (borr2<=0||borrS!=0) {
                Obj_Delete(obj);
            }

            yield;
        }

    }

    task bombg2()
    {
        let alpha = 0;
        let obj = Obj_Create(OBJ_EFFECT);
        Obj_SetX(obj, 629);
        Obj_SetY(obj, 245);
        Obj_SetSpeed(obj, 0);
        ObjEffect_SetTexture(obj, GetCurrentScriptDirectory~"\img\Tiiiiilllll.png");
        ObjEffect_SetRenderState(obj, ALPHA);
        ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
        ObjEffect_SetScale(obj,0.5,0.5);
        ObjEffect_SetAngle(obj,0,0,0);
        ObjEffect_CreateVertex(obj, 4);
        ObjEffect_SetLayer(obj,8);

        while (!Obj_BeDeleted(obj))
        {

            //四角形状に各頂点の座標を設定
            ObjEffect_SetVertexXY(obj,0,-10,-19);
            ObjEffect_SetVertexXY(obj,1,-10,19);
            ObjEffect_SetVertexXY(obj,2,10,-19);
            ObjEffect_SetVertexXY(obj,3,10,19);

            //四角形状に各頂点のUV値を設定
            ObjEffect_SetVertexUV(obj,0,164+24*borr,128);
            ObjEffect_SetVertexUV(obj,1,164+24*borr,165);
            ObjEffect_SetVertexUV(obj,2,184+24*borr,128);
            ObjEffect_SetVertexUV(obj,3,184+24*borr,165);

            ascent(let t in 0..4) {
                ObjEffect_SetVertexColor(obj,t,255,255,255,255);
            }

            if (borr2<=0||borrS!=0) {
                Obj_Delete(obj);
            }

            yield;
        }

    }

    task mono(m) {
        while (m>51) {
            tile4=255;
            m--;
            yield;
        }while (m<=51&&tile4>0) {
            tile4-=5;
            m--;
        }
    }

    task StageTask
    {
        function Wait(let frame) {
            loop(frame) {
                yield
            };
        }
        function WaitForZeroEnemy() {
            while (GetEnemyNum() != 0) {
                yield;
            }
        }
        task angfix() {
            Wait(520);
            loop(300) {
                Wait(1);
                if (BGG11>0) {
                    BGG11-=0.2;
                }if (BGG11>20) {
                    BGG11-=0.2;
                }if (BGG11>40) {
                    BGG11-=0.2;
                }if (BGG11<0) {
                    BGG11=0;
                }
            }
        }
        task tile22() {
            loop(255) {
                if (tile2>0) {
                    tile2--;
                    yield;
                }
            }
        }
        task tile32() {
            loop(255) {
                if (tile3>0) {
                    tile3--;
                    yield;
                }
            }
        }
        task tile42() {
            loop(255) {
                if (tile4>0) {
                    tile4--;
                    yield;
                }
            }
        }
        task tama1() {
            loop(6) {
                Wait(32);
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy00.txt",cx+32,480,0,0,2);
            }
        }
        task tama2() {
            loop(6) {
                Wait(32);
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy00.txt",cx-32,480,0,0,3);
            }
        }
        task tama3(l,d) {
            loop(l) {
                Wait(15);
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy13.txt",cx-125-d,470,6,280,0);
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy13.txt",cx+125+d,470,6,260,0);
            }
        }
        task tama3a(l,d) {
            loop(l) {
                Wait(15);
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy13.txt",cx-125-d,470,6,280,3);
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy13.txt",cx+125+d,470,6,260,4);
            }
        }
        task tama3b(l,d) {
            loop(l) {
                Wait(15);
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy13.txt",cx-55-d+rand(-65,265),470+rand(-25,155),rand(6,8),280,3);
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy13.txt",cx+55+d+rand(-265,65),470+rand(-25,155),rand(6,8),260,4);
            }
        }
        task tama4(l) {
            loop(l) {
                Wait(13);
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy13.txt",cx+265,310,6.6,180+44,1);
            }
        }
        task tama5(l) {
            loop(l) {
                Wait(13);
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy13.txt",cx-265,310,6.6,0-44,2);
            }
        }

        task tama6(l) {
            loop(l) {
                Wait(25);
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Servant11.txt",cx-23,-22,0,0,5);
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Servant11.txt",cx+26,-22,0,0,5);
            }
        }

        task z3(x,y,a) {
            loop(8) {
                Wait(20);
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy05.txt",cx+x,y,1.5,a,4);
            }
        }
        task hayaokuri(l) {
            loop(l) {
                count++;
                Wait(1);
            }
        }
        task ame{loop(225) {
            BGG31+=1;
            Wait(1);
        }}
        task tuki{loop(800) {
            BGG19++;
            Wait(1);
        }}
        task onmyo() {
            loop(4) {
                Wait(180);
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy07.txt",cx-140*sin(Z),-110+rand(0,-20),0,0,0);
            }
        }
        task tt() {
            loop(1) {
                Wait(15);
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Servant06.txt",cx+rand(-115,-130),-60,0,0,15);
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Servant06.txt",cx+126,-187,0,0,1);
                Wait(15);
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Servant06.txt",cx+rand(115,130),-60,0,0,15);
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Servant06.txt",cx-126,-187,0,0,1);
            }
            loop(4) {
                Wait(30);
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Servant06.txt",cx+rand(-15,-20),-60,0,0,15);
                Wait(30);
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Servant06.txt",cx+rand(15,20),-60,0,0,15);
            }
        }
        task tank(s,l) {
            loop(l) {
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy00.txt",cx+300,s+70,0,0,0);
                Wait(5);
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy00.txt",cx+300,s,0,0,0);
                Wait(16);
            }Wait(60);
            loop(l) {
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy00.txt",cx-300,s+70,0,0,0);
                Wait(5);
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy00.txt",cx-300,s,0,0,0);
                Wait(16);
            }
        }
        task tankl(s,l) {
            loop(l) {
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy00.txt",cx-300,s+70,0,0,0);
                Wait(5);
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy00.txt",cx-300,s,0,0,0);
                Wait(16);
            }Wait(60);
            loop(l) {
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy00.txt",cx+300,s+70,0,0,0);
                Wait(5);
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy00.txt",cx+300,s,0,0,0);
                Wait(16);
            }
        }
        task tank2(s,l) {
            loop(l) {
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy00.txt",cx+300,s+70,0,0,0);
                Wait(5);
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy00.txt",cx+300,s,0,0,0);
                Wait(16);
            }Wait(30);
            loop(l) {
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy00.txt",cx-300,s+70,0,0,0);
                Wait(5);
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy00.txt",cx-300,s,0,0,0);
                Wait(16);
            }
        }
        task tank2l(s,l) {
            loop(l) {
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy00.txt",cx-300,s+70,0,0,0);
                Wait(5);
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy00.txt",cx-300,s,0,0,0);
                Wait(16);
            }Wait(30);
            loop(l) {
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy00.txt",cx+300,s+70,0,0,0);
                Wait(5);
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy00.txt",cx+300,s,0,0,0);
                Wait(16);
            }
        }
        task yousei(s,l,y) {
            loop(l) {
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy04.txt",cx+255,y+rand(10,-10),0,0,7);
                Wait(s);
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy04.txt",cx-255,y+rand(10,-10),0,0,7);
                Wait(s);
            }
        }
        task yousei2(s,l,y,x) {
            loop(l) {
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy04.txt",cx-304-x,y,0,0,8);
                CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy04.txt",cx+304+x,y,0,0,8);
                Wait(s);
            }
        }

        CompileEnemyFromFile(GetCurrentScriptDirectory~"Enemy01.txt");
        CompileEnemyFromFile(GetCurrentScriptDirectory~"Enemy02.txt");
        CompileEnemyFromFile(GetCurrentScriptDirectory~"Enemy03.txt");
        CompileEnemyFromFile(GetCurrentScriptDirectory~"Enemy04.txt");
        CompileEnemyFromFile(GetCurrentScriptDirectory~"Enemy05.txt");
        CompileEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt");
        CompileEnemyFromFile(GetCurrentScriptDirectory~"Enemy07.txt");
        CompileEnemyFromFile(GetCurrentScriptDirectory~"Enemy08.txt");
        CompileEnemyFromFile(GetCurrentScriptDirectory~"Enemy09.txt");
        CompileEnemyFromFile(GetCurrentScriptDirectory~"Enemy10.txt");
        CompileEnemyFromFile(GetCurrentScriptDirectory~"Enemy11.txt");
        CompileEnemyFromFile(GetCurrentScriptDirectory~"Enemy12.txt");
        CompileEnemyFromFile(GetCurrentScriptDirectory~"Enemy13.txt");
        CompileEnemyFromFile(GetCurrentScriptDirectory~"Enemy14.txt");
        CompileEnemyFromFile(GetCurrentScriptDirectory~"rFraN01.txt");
        CompileEnemyFromFile(GetCurrentScriptDirectory~"rFra01.txt");
        CompileEnemyFromFile(GetCurrentScriptDirectory~"RemiN01.txt");
        CompileEnemyFromFile(GetCurrentScriptDirectory~"Servant00.txt");
        CompileEnemyFromFile(GetCurrentScriptDirectory~"Servant01.txt");
        CompileEnemyFromFile(GetCurrentScriptDirectory~"Servant02.txt");
        CompileEnemyFromFile(GetCurrentScriptDirectory~"Servant03.txt");
        CompileEnemyFromFile(GetCurrentScriptDirectory~"Servant04.txt");
        CompileEnemyFromFile(GetCurrentScriptDirectory~"Servant10.txt");
        CompileEnemyFromFile(GetCurrentScriptDirectory~"Servant102.txt");
        CompileEnemyFromFile(GetCurrentScriptDirectory~"firstEvent.txt");
        CompileEnemyFromFile(GetCurrentScriptDirectory~"firstEvent2.txt");
        CompileEnemyFromFile(GetCurrentScriptDirectory~"firstEvent3.txt");
        CompileEnemyFromFile(GetCurrentScriptDirectory~"Missile.txt");
        CompileEnemyFromFile(GetCurrentScriptDirectory~"Missile2.txt");
        CompileEnemyFromFile(GetCurrentScriptDirectory~"Missiles.txt");
        CompileEnemyFromFile(GetCurrentScriptDirectory~"RemiN05.txt");
        CompileEnemyFromFile(GetCurrentScriptDirectory~"RemiN05+.txt");

        Wait(1);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy04.txt",cx+888,-62,0,0,13);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy05.txt",cx+888,-262,0,0,13);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy00.txt",cx+888,-62,0,0,13);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy11.txt",cx+888,-62,0,0,13);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy12.txt",cx+888,-62,0,0,13);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy14.txt",cx+888,600,0,0,0);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Servant02.txt",cx+888,-292,0,0,4);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Servant10.txt",cx+888,-152,0,0,3);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Servant10.txt",cx+888,-152,0,0,4);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Servant102.txt",cx+888,-152,0,0,3);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Missile.txt",cx+888,-152,0,0,2);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Missiles.txt",cx+888,-152,0,0,2);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Missile2.txt",cx+888,-152,0,0,2);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"RemiN05+.txt",cx+888,-388,0,0,0);

        count=0;Z=0;ZZ=0;Z11=0;Z12=0;
        PlaySE(GetCurrentScriptDirectory~"\se\metal.wav");
        //CreateEnemyFromFile(GetCurrentScriptDirectory~"firstEvent.txt",cx,-60,0,0,0);

        //Wait(25);
        SetCommonData("Mode",2);

        WaitForZeroEnemy();

        //Wait(10);
        Z=-90;

        Yspeed2=0.6;

        BGstep=3;
        BGstep=1;Wait(58);

        WaitForZeroEnemy();
        ForbidShot(false);
        ForbidBomb(false);











        WaitForZeroEnemy();

        if (GetCommonDataDefault("Go",0)<=0) {
            SetCommonData("Go",1);
        }
        if (GetPlayerType()==REIMU_A || GetPlayerType()==REIMU_B) {
            if (GetPlayerY()<162) {
                SetCommonData("Go",0);
            }
        }
        else if (GetPlayerType()==MARISA_A || GetPlayerType()==MARISA_B) {
            if (GetPlayerY()<178) {
                SetCommonData("Go",0);
            }
        }
        else {
            if (GetPlayerY()<166) {
                SetCommonData("Go",0);
            }
        }

        if (GetCommonDataDefaultEx("Spell","omake02",0)==0) {
            Wait(100);
            CreateEnemyFromFile(GetCurrentScriptDirectory~"LastEvent3.txt",0,0,0,0,0);
            Wait(300);
            Clear();
        }
        WaitForZeroEnemy();
        PlayMusic(GetCurrentScriptDirectory~"\bgm\bgm3.mp3");
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx+60,-70,0,180,9.7);
        Wait(15);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx+120,-70,0,180,9.7);
        Wait(125);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx-60,-70,0,180,9.7);
        Wait(15);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx-120,-70,0,180,9.7);
        Wait(125);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx,-80,0,180,9.8);
        WaitForZeroEnemy();
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx-140,-40,0,180,9.8);
        Wait(55);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx+140,-40,0,180,9.8);
        Wait(55);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx+1,-70,0,180,9.8);
        WaitForZeroEnemy();
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx-140,-70,0,180,9.7);
        Wait(15);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx+140,-70,0,180,9.7);
        Wait(15);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx,-110,0,180,9.8);
        WaitForZeroEnemy();
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx-160,-70,0,180,9.7);
        Wait(15);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx-120,-70,0,180,9.7);
        Wait(15);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx-80,-70,0,180,9.7);
        Wait(15);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx-30,-70,0,180,9.7);
        Wait(15);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx+30,-70,0,180,9.7);
        Wait(15);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx+80,-70,0,180,9.7);
        Wait(15);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx+120,-70,0,180,9.7);
        Wait(15);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx+160,-70,0,180,9.7);
        Wait(130);
	CreateEnemyBossFromFile(GetCurrentScriptDirectory~"RemiN05+.txt",cx,-30,0,0,0);
        Wait(15);
        WaitForZeroEnemy();
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx-160,-70,0,180,9.8);
        Wait(20);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx-120,-70,0,180,9.8);
        Wait(20);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx-80,-70,0,180,9.8);
        Wait(20);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx-30,-70,0,180,9.8);
        Wait(20);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx+30,-70,0,180,9.8);
        Wait(20);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx+80,-70,0,180,9.8);
        Wait(20);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx+120,-70,0,180,9.8);
        Wait(20);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx+160,-70,0,180,9.8);
        Wait(15);
        WaitForZeroEnemy();
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx+160,-70,0,180,9.8);
        Wait(18);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx+120,-70,0,180,9.8);
        Wait(18);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx+80,-70,0,180,9.8);
        Wait(18);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx+30,-70,0,180,9.8);
        Wait(18);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx-30,-70,0,180,9.8);
        Wait(18);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx-80,-70,0,180,9.8);
        Wait(18);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx-120,-70,0,180,9.8);
        Wait(18);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx-160,-70,0,180,9.8);
        WaitForZeroEnemy();
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx-160,-70,0,180,9.8);
        Wait(15);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx-120,-70,0,180,9.8);
        Wait(15);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx-80,-70,0,180,9.8);
        Wait(15);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx-30,-70,0,180,9.8);
        Wait(15);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx+30,-70,0,180,9.8);
        Wait(15);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx+80,-70,0,180,9.8);
        Wait(15);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx+120,-70,0,180,9.8);
        Wait(15);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx+160,-70,0,180,9.8);
        Wait(97);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx+160,-70,0,180,9.8);
        Wait(15);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx+120,-70,0,180,9.8);
        Wait(15);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx+80,-70,0,180,9.8);
        Wait(15);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx+30,-70,0,180,9.8);
        Wait(15);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx-30,-70,0,180,9.8);
        Wait(15);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx-80,-70,0,180,9.8);
        Wait(15);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx-120,-70,0,180,9.8);
        Wait(15);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx-160,-70,0,180,9.8);
        Wait(77);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx-160,-70,0,180,9.8);
        Wait(15);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx-120,-70,0,180,9.8);
        Wait(15);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx-80,-70,0,180,9.8);
        Wait(15);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx-30,-70,0,180,9.8);
        Wait(15);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx+30,-70,0,180,9.8);
        Wait(15);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx+80,-70,0,180,9.8);
        Wait(15);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx+120,-70,0,180,9.8);
        Wait(15);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx+160,-70,0,180,9.8);
        Wait(155);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx-120,-70,0,180,9.8);
        Wait(15);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx+120,-70,0,180,9.8);
        Wait(15);
        CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy06.txt",cx,-120,0,180,9.8);

        WaitForZeroEnemy();
        FadeOutMusic(GetCurrentScriptDirectory~"\bgm\bgm3.mp3",8);
        Wait(145);
        PlaySE(GetCurrentScriptDirectory~"\se\warp.wav");
        Wait(160);
        PlaySE(GetCurrentScriptDirectory~"\se\warp.wav");
        Wait(200);

        DeleteMusic(GetCurrentScriptDirectory~"\bgm\bgm1.mp3");
        PlayMusic(GetCurrentScriptDirectory~"\bgm\bgm5.mp3");
        SetCommonData("Go",-5);
        PlaySE(GetCurrentScriptDirectory~"\se\warp.wav");
        CreateEnemyBossFromFile(GetCurrentScriptDirectory~"RemiN08.txt",cx,138,0,0,0);
        loop(140) {
            BGG36+=1;
            Wait(1);
        }
        loop(115) {
            BGG36+=1;
            Wait(1);
        }
        while (GetCommonDataDefault("Go",0)<=1) {
            yield;
        }Wait(2);
        FadeOutMusic(GetCurrentScriptDirectory~"\bgm\bgm5.mp3",8);
        Wait(366);
        DeleteMusic(GetCurrentScriptDirectory~"\bgm\bgm5.mp3");




        WaitForZeroEnemy();
        Wait(40);
        Clear();


        Wait(64);

    }

    @MainLoop()
    {
        if (BGG12==1) {
            if (GetKeyState(VK_SHOT)==KEY_PUSH||GetKeyState(VK_SHOT)==KEY_HOLD) {
                ForbidShot(false);
            }
            else {
                ForbidShot(true);
            }
        }

        if (GetPoint>=xUP) {
            PlaySE(GetCurrentScriptDirectory~"\se\power33.wav");
            ExtendPlayer(1);
            xUP+=xUP;
        }

        if (xUP<=4000) {
            SetNormPoint(xUP);
        }

        if (GetScore>=xBOMB) {
            PlaySE(GetCurrentScriptDirectory~"\se\power32.wav");
            AddBomb(1);
            xBOMB+=200000000;
        }


        if (!OnPlayerMissed) {
            if (GetKeyState(VK_SLOWMOVE)==KEY_HOLD&&col==0) {
                if (ma<250) {
                    ma+=10;
                }
            }else {
                if (ma>0) {
                    ma-=10;
                }
            }
        }
        if (OnPlayerMissed) {
            if (ma>0) {
                ma-=10;
            }
        }

        if (ze==0) {
            if (gra3-GetGraze()<0) {
                gra++;
                gra2=18;
            }gra3=GetGraze();
            if (gra>16) {
                gra=16;
            }if (gra>0&&gra2<0) {
                gra--;
                gra2=18;
            }gra2--;
            if (GetCommonDataDefault("ddffffffffrrr",0)>=0&&gra>10&&count%8==0) {
                CollectItems;
            }

            if (count<110) {
                gra=16;
            }if (count==110) {
                gra=0;
            }if (OnBomb==true) {
                gra=12;
            }

            if (gra<11) {
                if (GetPlayerType()==REIMU_A || GetPlayerType()==REIMU_B) {
                    if (GetPlayerY()<162) {
                        gra=11;
                    }
                }
                else if (GetPlayerType()==MARISA_A || GetPlayerType()==MARISA_B) {
                    if (GetPlayerY()<178) {
                        gra=11;
                    }
                }
                else {
                    if (GetPlayerY()<166) {
                        gra=11;
                    }
                }
            }
        }

        if (BGstep==1) {
            if (BGG00<225) {
                BGG00+=1;
            }if (BGG03>0) {
                BGG03-=3;
            }if (BGG08>0) {
                BGG08-=1;
            }if (BGG09>0) {
                BGG09-=1;
            }
        }
        if (BGstep==3) {
            if (BGG03<255) {
                BGG03+=2;
            }
        }
        if (BGstep==4) {
            if (BGG00>0) {
                BGG00-=2;
            }if (BGG01>0) {
                BGG01-=1;
            }if (BGG02>0) {
                BGG02-=1;
            }if (BGG03>0) {
                BGG03-=3;
            }if (BGG05>0) {
                BGG05-=1;
            }if (BGG04<255) {
                BGG04+=1;
            }
            if (BGG06>0) {
                BGG06-=1;
            }if (BGG08>0) {
                BGG08-=1;
            }if (BGG09>0) {
                BGG09-=1;
            }
        }
        if (BGstep==6) {
            if (BGG00>0) {
                BGG00-=1;
            }if (BGG01>0) {
                BGG01-=1;
            }if (BGG02>0) {
                BGG02-=1;
            }if (BGG03>0) {
                BGG03-=3;
            }if (BGG05<255) {
                BGG05+=1;
            }if (BGG08<255) {
                BGG08+=1;
            }if (BGG09<255) {
                BGG09+=1;
            }
        }
        if (BGstep==7||BGstep==8) {
            if (BGG00>0) {
                BGG00-=1;
            }if (BGG01>0) {
                BGG01-=1;
            }if (BGG02>0) {
                BGG02-=1;
            }
            if (BGG09>0) {
                BGG09-=1;
            }
            if (BGG03>0) {
                BGG03-=3;
            }if (BGG05<255) {
                BGG05+=1;
            }if (BGG06>0) {
                BGG06-=1;
            }if (BGG04>0) {
                BGG04-=1;
            }if (BGG10>0) {
                BGG10-=1;
            }
            if (BGstep==8) {
                if (BGG07<255) {
                    BGG07+=1;    //全黒
                }
            }else {
                if (BGG08>0) {
                    BGG08-=5;
                }if (BGG08<0) {
                    BGG08=0;
                }if (BGG07>0) {
                    BGG07-=1;
                }
            }
        }
        if (BGstep==9) {
            if (BGG00>0) {
                BGG00-=2;
            }if (BGG01>0) {
                BGG01-=1;
            }if (BGG02>0) {
                BGG02-=1;
            }if (BGG03>0) {
                BGG03-=3;
            }if (BGG05>0) {
                BGG05-=1;
            }
            if (BGG06>0) {
                BGG06-=1;
            }if (BGG08>0) {
                BGG08-=1;
            }if (BGG09>0) {
                BGG09-=1;
            }if (BGG10<253) {
                BGG10+=2;
            }
        }

        if (OnEnemySpell==true) {
            if (BG>2) {
                BG-=2;
            }SetCommonData("Black",0);
        }else {
            BG=100;
        }

        if (GetEnemyLife<=0) {
            BG=100;
        }

        if (Dark<GetCommonDataDefault("Black",0)&&BGG00<=0) {
            Dark++;
        }
        if (Dark>GetCommonDataDefault("Black",0)&&BGG00<=0) {
            Dark-=5;
        }

        if (0<GetCommonDataDefault("Black",0)&&BGG00>0) {
            mono(GetCommonDataDefault("Black",0));
            SetCommonData("Black",0);
        }


        if (GetCommonDataDefault("flash2",0)>0) {
            SetCommonData("flash2",GetCommonDataDefault("flash2",0)-3);
        }





        if (gu1>=1000&&gu1<2000&&gu10<12) {
            gu10+=2;
        }
        if (gu1>=2000&&gu10<18) {
            gu10+=2;
        }
        if (gu1>=1000&&gu1<2000&&gu10>12) {
            gu10-=2;
        }
        if (gu1<1000&&gu10>0) {
            gu10-=2;
        }

        ac+=Yspeed;

        if (uprrS==0) {
            if (GetPlayerLife()>=8&&uprr<9) {
                uprr3++;
            }
            if (GetPlayerLife()>=8&&uprr3>60) {
                uprr++;
                uprr3=0;
                ExtendPlayer(-1);
                PlaySE(GetCurrentScriptDirectory~"\se\power34.wav");
            }
            if (GetPlayerLife()<7&&uprr>0) {
                uprr--;
                ExtendPlayer(1);
            }
            if (uprr2<=0&&uprr>0) {
                uprr2++;
                itemg;
                itemg2;
            }
            if (uprr2>0&&uprr<=0) {
                uprr2--;
            }
            if (uprr>8) {
                uprr=0;
                uprrS=1;
            }
        }

        if (borrS==0) {
            if (GetPlayerBomb()>=7&&borr<9) {
                borr3++;
            }
            if (GetPlayerBomb()>=7&&borr3>60) {
                borr++;
                borr3=0;
                AddBomb(-1);
                PlaySE(GetCurrentScriptDirectory~"\se\power34.wav");
            }
            if (GetPlayerBomb()<6&&borr>0) {
                borr--;
                AddBomb(1);
            }
            if (borr2<=0&&borr>0) {
                borr2++;
                bombg;
                bombg2;
            }
            if (borr2>0&&borr<=0) {
                borr2--;
            }
            if (borr>8) {
                borr=0;
                borrS=1;
            }
        }



        //この辺でハイスコア判定


        //if (GetScore()>GetCommonDataDefaultEx("Spell","HighScore",0)) {
        //    SetCommonDataEx("Spell","HighScore",GetScore());
        //}

        if (OnPlayerMissed==true&&GetCommonDataDefault("miss",0)==0) {
            SetCommonData("miss",1);
        }

        if (OnBomb==true&&GetCommonDataDefault("bomb",0)==0) {
            SetCommonData("bomb",1);
        }

        sx+=sxs;
        sy+=sys;
        sa+=sas;
        if (sas>0) {
            sas-=0.05;
        }if (sas<0) {
            sas+=0.05;
        }


        if (Yspeed2>Yspeed) {
            Yspeed+=0.01;
        }if (Yspeed2<Yspeed) {
            Yspeed-=0.01;
        }
        count++;
        if (slow2>0) {
            slow2--;
        }Z++;
        ZZ++;
        yield;
    }

    @DrawTopObject() {

        SetGraphicAngle(0, 0, 0);
        if (GetCommonDataDefault("last",false)==false) {
            if (OnBomb==true||OnEnemySpell==true||IsBGStopping==true) {
                Slow(0);
            }
        }

        SetTexture(GetCurrentScriptDirectory~"\img\Tiiiiilllll.png");


        if (GetCommonDataDefault("ddffffffffrrr",0)>=0) {
            if (ze==0) {
                if (gra<=10) {
                    SetGraphicRect(0,32*gra,64,32+32*gra);
                }
                if (gra<=0) {
                    SetGraphicRect(0,0,64,32);
                }
                if (gra>10&&count%8>=0) {
                    SetGraphicRect(0,352,64,384);
                }
                if (gra>10&&count%8>=4) {
                    SetGraphicRect(0,384,64,416);
                }
                SetGraphicScale(1,1);
                SetAlpha(255);
                SetColor(mo,mo,mo);
                if (GetPlayerX()<160&&GetPlayerY()>332) {
                    if (mo>50) {
                        mo-=4;
                    }
                }
                if (GetPlayerX()>=160||GetPlayerY()<=332) {
                    if (mo<255) {
                        mo+=4;
                    }
                }
                SetRenderState(ADD);
                DrawGraphic(74,440);
            }

            if (col==0) {
                SetTexture(GetCurrentScriptDirectory~"shot_all.png");
                SetGraphicRect(0, 290, 28, 317);
                SetGraphicScale(0.42,0.4);
                SetAlpha(255);
                SetColor(255,255,255);
                if (ma<255) {
                    SetAlpha(ma);
                }
                SetRenderState(ALPHA);
                DrawGraphic(GetPlayerX+1,GetPlayerY+0.5);
            }
        }

        if (BGG03>0) {
            SetTexture(GetCurrentScriptDirectory~"\img\Title2.png");
            SetGraphicRect(0,0,512,512);
            SetGraphicScale(1,1);
            SetAlpha(255);
            SetColor(255,255,255);
            if (BGG03<255) {
                SetAlpha(BGG03);
            }
            SetRenderState(ALPHA);
            DrawGraphic(cx,cy);
        }

        if (count<=110) {
            SetTexture(GetCurrentScriptDirectory~"\img\getitemborder.png");
            if (count%8>=0) {
                SetGraphicRect(0,0,512,64);
            }
            if (count%8>=4) {
                SetGraphicRect(0,64,512,128);
            }
            SetGraphicAngle(0,0,0);
            SetGraphicScale(1,1);
            SetAlpha(255);
            SetColor(255,255,255);
            if (count>=80) {
                SetColor(255-(count-80)*8,255-(count-80)*8,255-(count-80)*8);
            }
            if (count<=30) {
                SetColor(count*8,count*8,count*8);
            }
            SetRenderState(ADD);
            if (GetPlayerType()==REIMU_A || GetPlayerType()==REIMU_B) {
                DrawGraphic(cx+5,162);
            }
            else if (GetPlayerType()==MARISA_A || GetPlayerType()==MARISA_B) {
                DrawGraphic(cx+5,178);
            }
            else {
                DrawGraphic(cx+5,166);
            }
        }

        if (GetCommonDataDefault("flash2",0)>0) {
            SetTexture(GetCurrentScriptDirectory~"\img\3a.png");
            SetGraphicRect(0,0,384,448);
            SetRenderState(ADD);
            SetGraphicScale(GetCommonDataDefault("flash2",0)/255,1);
            SetGraphicAngle(0,0,0);
            SetColor(GetCommonDataDefault("flash2",0),0,0);
            SetAlpha(255);
            DrawGraphic(GetCenterX(),GetCenterY());
        }


    }

    @DrawBottomObject() {

        if (BGG05>0) {//ベース・黒
            SetTexture(GetCurrentScriptDirectory~"\img\st00.png");
            SetGraphicRect(0,0,384,448);
            SetRenderState(ALPHA);
            SetGraphicScale(1,1);
            SetGraphicAngle(0,0,0);
            SetColor(255,255,255);
            SetAlpha(BGG05);
            DrawGraphic(GetCenterX(),GetCenterY());
        }

        if (BGG36<255) {
            SetTexture(GetCurrentScriptDirectory~"\img\moon3-2.png");//赤い月
            SetGraphicScale(0.6,0.6);
            SetGraphicRect(0,0,512,512);
            SetGraphicAngle(0,0,0);
            SetAlpha(255);
            color=BGG00/3;
            SetColor(color,color,color);
            SetRenderState(ADD);
            DrawGraphic(cx,124);
            SetTexture(GetCurrentScriptDirectory~"\img\st01.png");
            SetGraphicScale(1,1);
            SetGraphicRect(0,0,384,1464);
            SetAlpha(255);
            SetColor(BGG00,BGG00/3,BGG00/3);
            SetRenderState(ADD);
            DrawGraphic(cx,cy+(ac*7)%488);
            SetTexture(GetCurrentScriptDirectory~"\img\NuclearRing5.png");
            SetGraphicScale(0.7,0.7);
            SetGraphicRect(0+count*5,0-count*12,512+count*5,768-count*12);
            SetAlpha(255);
            SetColor(255*0.3,255*0.1,255*0.1);
            SetRenderState(ADD);
            DrawGraphic(cx,cy);
            SetGraphicScale(0.4,0.4);
            SetGraphicRect(0+count*8,0-count*10,1028+count*8,1156-count*10);
            SetAlpha(255);
            SetColor(255*0.4,255*0.2,255*0.1);
            SetRenderState(ADD);
            DrawGraphic(cx,cy);
        }

        if (BGG36>0) {//ラスト
            SetTexture(GetCurrentScriptDirectory~"\img\rBG05.png");
            color=(BGG36-(BGG36/2)*(count%2<=0))*0.7;
            if (BGG37>0) {
                SetTexture(GetCurrentScriptDirectory~"\img\rBG05a.png");
                color=BGG36-(BGG36/2)*(count%2<=0);
            }
            SetGraphicAngle(0, 0, 0);
            SetGraphicScale(0.5,0.5);
            SetAlpha(BGG36);
            SetRenderState(ALPHA);
            SetColor(0,0,color);
            SetGraphicRect(-128+4000*sin(count*0.3),-count*12,768+4000*sin(count*0.3),976-count*12);
            DrawGraphic(cx,cy);
            SetGraphicRect(-128+4000*sin(count*0.2),count*11,768+4000*sin(count*0.2),976+count*11);
            SetAlpha(BGG36/2);
            DrawGraphic(cx,cy);
        }

    }

    @Initialize()
    {	//CreateDebugWindow();
        if (IsCommonDataAreaExists("Spell")==false) {
            CreateCommonDataArea("Spell");
        }
        if (GetPlayerType()==REIMU_A || GetPlayerType()==REIMU_B || GetPlayerType()==MARISA_A || GetPlayerType()==MARISA_B) {
            BGG12=1;
        }
        LoadCommonDataEx("Spell",pass);
        LoadSE(GetCurrentScriptDirectory~"\se\Shot00.wav");
        LoadSE(GetCurrentScriptDirectory~"\se\Shot01.wav");
        LoadSE(GetCurrentScriptDirectory~"\se\Shot02.wav");
        LoadSE(GetCurrentScriptDirectory~"\se\Shot03.wav");
        LoadSE(GetCurrentScriptDirectory~"\se\Shot04.wav");
        LoadSE(GetCurrentScriptDirectory~"\se\Shot05.wav");
        LoadSE(GetCurrentScriptDirectory~"\se\Shot06.wav");
        LoadSE(GetCurrentScriptDirectory~"\se\Shot07.wav");
        LoadSE(GetCurrentScriptDirectory~"\se\Laser.wav");
        LoadSE(GetCurrentScriptDirectory~"\se\Laser2.wav");
        LoadSE(GetCurrentScriptDirectory~"\se\Laser3.wav");
        LoadSE(GetCurrentScriptDirectory~"\se\Laser5.wav");
        LoadSE(GetCurrentScriptDirectory~"\se\puu81.wav");
        LoadSE(GetCurrentScriptDirectory~"\se\puu811.wav");
        LoadSE(GetCurrentScriptDirectory~"\se\Baaaaaaaan.wav");
        LoadSE(GetCurrentScriptDirectory~"\se\Baaaaaaaan2.wav");
        LoadSE(GetCurrentScriptDirectory~"\se\Baaaan.wav");
        LoadSE(GetCurrentScriptDirectory~"\se\Baaaan2.wav");
        LoadSE(GetCurrentScriptDirectory~"\se\mizu08.wav");
        LoadSE(GetCurrentScriptDirectory~"\se\metal.wav");
        LoadSE(GetCurrentScriptDirectory~"\se\metal37_b.wav");
        LoadSE(GetCurrentScriptDirectory~"\se\powerdown.wav");
        LoadSE(GetCurrentScriptDirectory~"\se\crash16_c.wav");
        LoadSE(GetCurrentScriptDirectory~"\se\bom13.wav");
        LoadSE(GetCurrentScriptDirectory~"\se\beam.wav");
        LoadSE(GetCurrentScriptDirectory~"\se\warp.wav");
        LoadSE(GetCurrentScriptDirectory~"\se\warp_2.wav");
        LoadSE(GetCurrentScriptDirectory~"\se\warp_22.wav");
        LoadSE(GetCurrentScriptDirectory~"\se\se002-0023.wav");
        LoadSE(GetCurrentScriptDirectory~"\se\power32.wav");
        LoadSE(GetCurrentScriptDirectory~"\se\power33.wav");
        LoadSE(GetCurrentScriptDirectory~"\se\power34.wav");
        LoadSE(GetCurrentScriptDirectory~"\se\eco00.wav");
        LoadSE(GetCurrentScriptDirectory~"\se\bom27_b.wav");
        LoadGraphic(GetCurrentScriptDirectory~"shot_all.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\3a.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\ba1.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\ba2.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\ba3.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\ba4.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\circle_l.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\cloud.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\dot_flandre.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\dot_remilia.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\dot_sakuya.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\dot-kaze-ti.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\dot-Other.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\ho.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\familiar.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\getitemborder.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\JUUJI.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\kyozou.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\laserbit.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\last.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\last2.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\moji.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\moon3-1.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\moon3-2.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\moon3-3.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\moon3-21.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\NuclearRing.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\NuclearRing2.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\NuclearRing4.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\NuclearRing5.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\NuclearSpark2.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\NuclearWave2.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\rBG05.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\rBG05a.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\remilia2.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\shadow.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\st00.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\st01.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\st02a.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\st04.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\st04a.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\st04b.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\st05.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\st07.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\Tiiiiilllll.png");
        SetCommonData("ii1",0);
        SetCommonData("ii2",0);
        SetCommonData("ii3",0);
        SetCommonData("x",0);
        SetCommonData("y",0);
        SetCommonData("fs",0);
        SetCommonData("ddffffffffrrr",0);
        SetCommonData("last",false);
        SetCommonData("flash",0);
        SetCommonData("flash2",0);
        SetCommonData("Black",0);
        SetCommonData("Zatsuyou",0);
        SetCommonData("Zatsuyou2",0);
        SetCommonData("Go",0);
        SetCommonData("Mode",0);
        SetCommonData("P01",0);
        SetCommonData("P02",0);
        SetCommonData("P03",0);
        SetCommonData("P04",0);
        SetCommonData("P05",0);
        SetCommonData("bgh",0);
        SetCommonData("miss",0);
        SetCommonData("bomb",0);
        if (GetCommonDataDefaultEx("Spell","omake01",0)==0) {
            SetCommonDataEx("Spell","omake01",0);
        }
        if (GetCommonDataDefaultEx("Spell","omake02",0)==0) {
            SetCommonDataEx("Spell","omake02",0);
        }
        if (GetCommonDataDefaultEx("Spell","omake03",0)==0) {
            SetCommonDataEx("Spell","omake03",0);
        }
        ExpertEx(false,0,3);
        SetRateScoreSystemEnable(false);
        SetShotAutoDeleteClip(32,32,32,32);
        //SetDefaultStatusVisible(false);
        ForbidShot(true);
        ForbidBomb(true);
        StageTask();
    }

    @Finalize()
    {
        Slow(0);
        DeleteSE(GetCurrentScriptDirectory~"\se\Shot00.wav");
        DeleteSE(GetCurrentScriptDirectory~"\se\Shot01.wav");
        DeleteSE(GetCurrentScriptDirectory~"\se\Shot02.wav");
        DeleteSE(GetCurrentScriptDirectory~"\se\Shot03.wav");
        DeleteSE(GetCurrentScriptDirectory~"\se\Shot04.wav");
        DeleteSE(GetCurrentScriptDirectory~"\se\Shot05.wav");
        DeleteSE(GetCurrentScriptDirectory~"\se\Shot06.wav");
        DeleteSE(GetCurrentScriptDirectory~"\se\Shot07.wav");
        DeleteSE(GetCurrentScriptDirectory~"\se\Laser.wav");
        DeleteSE(GetCurrentScriptDirectory~"\se\Laser2.wav");
        DeleteSE(GetCurrentScriptDirectory~"\se\Laser3.wav");
        DeleteSE(GetCurrentScriptDirectory~"\se\Laser5.wav");
        DeleteSE(GetCurrentScriptDirectory~"\se\puu81.wav");
        DeleteSE(GetCurrentScriptDirectory~"\se\puu811.wav");
        DeleteSE(GetCurrentScriptDirectory~"\se\Baaaaaaaan.wav");
        DeleteSE(GetCurrentScriptDirectory~"\se\Baaaan.wav");
        DeleteSE(GetCurrentScriptDirectory~"\se\Baaaan2.wav");
        DeleteSE(GetCurrentScriptDirectory~"\se\mizu08.wav");
        DeleteSE(GetCurrentScriptDirectory~"\se\metal.wav");
        DeleteSE(GetCurrentScriptDirectory~"\se\metal37_b.wav");
        DeleteSE(GetCurrentScriptDirectory~"\se\powerdown.wav");
        DeleteSE(GetCurrentScriptDirectory~"\se\crash16_c.wav");
        DeleteSE(GetCurrentScriptDirectory~"\se\bom13.wav");
        DeleteSE(GetCurrentScriptDirectory~"\se\beam.wav");
        DeleteSE(GetCurrentScriptDirectory~"\se\warp.wav");
        DeleteSE(GetCurrentScriptDirectory~"\se\warp_2.wav");
        DeleteSE(GetCurrentScriptDirectory~"\se\warp_22.wav");
        DeleteSE(GetCurrentScriptDirectory~"\se\se002-0023.wav");
        DeleteSE(GetCurrentScriptDirectory~"\se\power32.wav");
        DeleteSE(GetCurrentScriptDirectory~"\se\power33.wav");
        DeleteSE(GetCurrentScriptDirectory~"\se\power34.wav");
        DeleteSE(GetCurrentScriptDirectory~"\se\eco00.wav");
        DeleteSE(GetCurrentScriptDirectory~"\se\bom27_b.wav");
        DeleteGraphic(GetCurrentScriptDirectory~"shot_all.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\3a.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\ba1.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\ba2.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\ba3.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\ba4.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\circle_l.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\cloud.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\dot_flandre.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\dot_remilia.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\dot_sakuya.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\dot-kaze-ti.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\dot-Other.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\ho.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\familiar.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\getitemborder.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\JUUJI.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\kyozou.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\laserbit.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\last.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\last2.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\moji.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\moon3-1.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\moon3-2.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\moon3-3.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\moon3-21.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\NuclearRing.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\NuclearRing2.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\NuclearRing4.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\NuclearRing5.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\NuclearSpark2.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\NuclearWave2.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\rBG05.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\rBG05a.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\remilia2.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\shadow.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\st00.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\st01.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\st02a.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\st04.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\st04a.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\st04b.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\st05.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\st07.png");
        DeleteGraphic(GetCurrentScriptDirectory~"\img\Tiiiiilllll.png");
        DeleteMusic(GetCurrentScriptDirectory~"\bgm\bgm1.mp3");
        DeleteMusic(GetCurrentScriptDirectory~"\bgm\bgm2.mp3");
        DeleteMusic(GetCurrentScriptDirectory~"\bgm\bgm3.mp3");
        DeleteMusic(GetCurrentScriptDirectory~"\bgm\bgm4.mp3");
        DeleteMusic(GetCurrentScriptDirectory~"\bgm\bgm5.mp3");
        SaveCommonDataEx("Spell",pass);
        DeleteCommonData("ii1");
        DeleteCommonData("ii2");
        DeleteCommonData("ii3");
        DeleteCommonData("x");
        DeleteCommonData("y");
        DeleteCommonData("fs");
        DeleteCommonData("ddffffffffrrr");
        DeleteCommonData("last");
        DeleteCommonData("flash");
        DeleteCommonData("flash2");
        DeleteCommonData("Black");
        DeleteCommonData("Zatsuyou");
        DeleteCommonData("Zatsuyou2");
        DeleteCommonData("Go");
        DeleteCommonData("Mode");
        DeleteCommonData("P01");
        DeleteCommonData("P02");
        DeleteCommonData("P03");
        DeleteCommonData("P04");
        DeleteCommonData("P05");
        DeleteCommonData("bgh");
        DeleteCommonData("miss");
        DeleteCommonData("bomb");
    }

}
