
script_enemy_main
{
    let count=0;
    let count2=0;
    let count3=0;
    let mm=0;
    let mm2=0;
    let get;
    let try;

    let move=0;

    let pass=GetCurrentScriptDirectory~"Spell.dat";

    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 WALL_TOP = 8;
    let WALL_LEFT = 4;
    let WALL_RIGHT = 2;
    let WALL_BOTTOM = 1;

    let mm=0;
    let shot=0;
    let ang=0;
    let MT=0;

    task Shot10(let x, let y, let speed, let angle, let grf, let delay)
    {
        //e^XN
        let obj = Obj_Create(OBJ_SHOT);//eIuWFNg쐬
        let N16 = 0;
        Obj_SetX(obj, x);//xWݒ
        Obj_SetY(obj, y);//yWݒ;
        Obj_SetSpeed(obj, speed);//xݒ
        Obj_SetAngle(obj, angle);//ړpxݒ
        ObjShot_SetGraphic(obj, grf);//摜ݒ
        ObjShot_SetDelay(obj, delay);//xԐݒ
        ObjShot_SetBombResist(obj,true);

        while ( !Obj_BeDeleted(obj) )
        {
            yield;
        }
    }

    @Initialize()
    {
        SetLife(5000);
        MagicCircle(false);
        SetEnemyMarker(true);
        SetDamageRate(136,60);
        SetTimer(39);
        SetInvincibility(190);
        LoadGraphic(img);
        SetShotAutoDeleteClip(12,12,12,12);
        SetMovePositionRandom01(0,200,13,cx,GetCenterY()-44,cx,GetCenterY()-44);
        LoadGraphic(GetCurrentScriptDirectory~"\img\circle_l.png");
        LoadUserShotData(GetCurrentScriptDirectory~".\shot_All.txt");

    }

    @MainLoop()
    {
        SetCommonData("Black",244);

        if (count2%13==0) {
            PlaySE(GetCurrentScriptDirectory~"\se\Shot02.wav");
            ascent(let tt in 0..ang) {
                ascent(let t in 0..8) {
                    CreateShot02(GetX()+(16*tt)*cos(112.5+t*45)+rand(-12,12),GetY()+(16*tt)*sin(112.5+t*45)+rand(-12,12),0,112.5+t*45+rand(-ang/2,ang/2),0.02,2.5,RED04,20)
                }
            }
        }

        SetShotDirectionType(PLAYER);

        if (count>120&&count%50==0&&count%1200<650) {
            PlaySE(GetCurrentScriptDirectory~"\se\Shot02.wav");
            ascent(let t in 0..7) {
                CreateShot02(GetX()+150,GetY()+60,2,-60+t*20,-0.1,2,RED01,20)
            }
        }

        if (count>120&&count%50==10&&count%1200<650) {
            PlaySE(GetCurrentScriptDirectory~"\se\Shot02.wav");
            ascent(let t in 0..7) {
                CreateShot02(GetX()-150,GetY()+60,2,-60+t*20,-0.1,2,RED01,20)
            }
        }

        if (count>550&&count%50==30&&count%1200>=0&&count%1200<350) {
            PlaySE(GetCurrentScriptDirectory~"\se\Shot04.wav");
            ascent(let t in 0..7) {
                CreateShot02(GetX()+150,GetY()-60,5.5,0,0,5,RED02,0+t*4)
            }
        }

        if (count>550&&count%50==30&&count%1200>=0&&count%1200<350) {
            PlaySE(GetCurrentScriptDirectory~"\se\Shot04.wav");
            ascent(let t in 0..7) {
                CreateShot02(GetX()-150,GetY()-60,5.5,0,0,5,RED02,0+t*4)
            }
        }

        if (count>250&&count%10==0&&count%600>=450&&count%600<570) {
            PlaySE(GetCurrentScriptDirectory~"\se\Shot04.wav");
            ascent(let t in 0..7) {
                CreateShot02(GetX()+150,GetY()-60,5.5,-60+t*20,0,5,RED02,0)
            }
        }

        if (count>250&&count%10==0&&count%600>=450&&count%600<570) {
            PlaySE(GetCurrentScriptDirectory~"\se\Shot04.wav");
            ascent(let t in 0..7) {
                CreateShot02(GetX()-150,GetY()-60,5.5,-60+t*20,0,5,RED02,0)
            }
        }

        if (count>250&&count%50==30&&count%1200>=650&&count%1200<950) {
            PlaySE(GetCurrentScriptDirectory~"\se\Shot04.wav");
            ascent(let t in 0..7) {
                CreateShot02(GetX()+150,GetY()-60,5.5,0,0,5,RED02,0+t*4)
            }
        }

        if (count>250&&count%50==30&&count%1200>=650&&count%1200<950) {
            PlaySE(GetCurrentScriptDirectory~"\se\Shot04.wav");
            ascent(let t in 0..7) {
                CreateShot02(GetX()-150,GetY()-60,5.5,0,0,5,RED02,0+t*4)
            }
        }

        if (count>600&&count%50==40&&count%600<350) {
            PlaySE(GetCurrentScriptDirectory~"\se\Shot04.wav");
            ascent(let t in 0..7) {
                CreateShot02(GetX(),GetY()+20*sin(GetAngleToPlayer()-60+t*20),3.7,-60+t*20,0,2,33,2)
            }
            ascent(let t in 0..7) {
                CreateShot02(GetX(),GetY()+20*sin(GetAngleToPlayer()-60+t*20),3.0,-60+t*20,0,2,33,2)
            }
        }

        SetShotDirectionType(ABSOLUTE);

        if (count>630&&count%2==0&&(count*2)%360<=180) {
            PlaySE(GetCurrentScriptDirectory~"\se\Shot00.wav");
            CreateShot02(GetX()+60,GetY()-150,1.8,count*2,0,2,196,8);
        }

        if (count>630&&count%2==0&&(count*2)%360>=180) {
            PlaySE(GetCurrentScriptDirectory~"\se\Shot00.wav");
            CreateShot02(GetX()-60,GetY()-150,1.8,-count*2,0,2,196,8);
        }

        if (count<=25) {
            SetCollisionA(GetX(),GetY()-12,8+count);
        }

        if (count>=25) {
            SetCollisionA(GetX(),GetY()-12,32);
            SetCollisionB(GetX(),GetY(),14);
        }

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

        if (count2>=2&&count2%12==0&&ang<10) {
            ang++;
        }

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

        if (count%360==245) {
            SetColor(255,0,0);
            Concentration01(125);
            PlaySE(GetCurrentScriptDirectory~"\se\puu81.wav");
        }

        if (count%1200==260) {
            SetColor(255,0,0);
            Concentration01(185);
            PlaySE(GetCurrentScriptDirectory~"\se\puu81.wav");
        }

        if (MT>0) {
            SetLife(0);
        }

        if (GetLife<=30) {
            DeleteEnemyShotImmediatelyInCircle(SHOT,GetX,GetY,127);
            MT=1;
            ascent(let tt in 0..ang-2) {
                ascent(let t in 0..8) {
                    CreateShot02(GetX()+(24*tt)*cos(112.5+t*45)+rand(-12,12),GetY()+(24*tt)*sin(112.5+t*45)+rand(-12,12),0,112.5+t*45+rand(-ang/2,ang/2),0.02,2.5,RED04,2)
                }
            }
        }

        yield;
    }

    @Finalize()
    {}

    @DrawLoop()
    {
        if (GetEnemyLife>0) {
            SetTexture(GetCurrentScriptDirectory~"\img\circle_l.png");
            SetGraphicAngle(0,0,0);
            SetGraphicRect(0,256,256,512);
            SetAlpha(255);
            SetRenderState(ADD);
            SetColor(255,255,255);
            if (count<=1) {
                SetGraphicScale(0,0);
            }
            if (count>1) {
                SetGraphicScale(0.02*count+0.1*sin(count*3),0.02*count+0.1*sin(count*3));
            }
            if (count>=50) {
                SetGraphicScale(1.0+0.1*sin((count-120)*3),1.0+0.1*sin((count-120)*3));
            }
            DrawGraphic(GetX(),GetY());
        }

    }


}

