

script_enemy_main
{
    let count=0;
    let count2=0;
    let count3=0;
    let count4=0;
    let ten=0;
    let life=0;
    let N15=0;
    let N16=0;
    let get;
    let try;

    let move=0;

    let pass=GetCurrentScriptDirectory~"Spell.dat";

    let cx=GetCenterX();
    let cy=GetCenterY();
    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 tame=0;
    let tame2=0;
    let d=70;
    let ang=0;

#include_function ".\BGfx.txt"

    @Initialize()
    {
        MagicCircle(false);
        SetEnemyMarker(true);
        SetShotColor(255,255,255);
        SetLife(3800);
        SetDamageRate(68,10);
        SetTimer(49);
        SetInvincibility(150);
        SetNormPoint(-1);
        LoadGraphic(img);
        SetShotAutoDeleteClip(32,32,32,32);
        SetX(cx);
        SetY(cy);
        SetMovePositionRandom01(0,200,1,cx,128,cx,128);
        LoadGraphic(bg);
        LoadGraphic(bg2);
        LoadGraphic(bg3);
        LoadGraphic(GetCurrentScriptDirectory~"\img\circle_l.png");
        LoadUserShotData(GetCurrentScriptDirectory~".\shot_All.txt");

    }

    @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;
        }
        if (count2<=50) {
            SetCollisionA(GetX(),GetY()-12,2*count2);
        }

        if (count2>=50) {
            SetCollisionA(GetX(),GetY()-12,100);
        }

        if (GetLife()<=0) {
            count3++;
        }

        SetCommonData("Black",128);

        if (count2<530&&count2>=120)
        {
            N16-=6;
        }

        if (count2<=466&&count2>120&&count%1==0)
        {
            N15=0;
            N15+=rand(-1,1);
            PlaySE(GetCurrentScriptDirectory~"\se\Shot02.wav");
            ascent( let t in 0..1 ) {
                CreateShot01(GetX()+110*cos(-count*8.3+N15),GetY()+110*sin(-count*8.3+N15),6.3+t*0.42-1.2*(GetCommonDataDefault("ii1",0)<2000),180-count*8.3+N15,169,16);
            }
            ascent( let t in 0..1 ) {
                CreateShot01(GetX()+110*cos(180-count*8.3+N15),GetY()+110*sin(180-count*8.3+N15),6.3+t*0.42-1.2*(GetCommonDataDefault("ii1",0)<2000),-count*8.3+N15,169,16);
            }
        }
        if (count2>=180&&count2<500) {
            SetAngle(180);
            SetSpeed(sin(count2-90)/2);
        }
        if (count2>=861) {
            SetAngle(180);
            SetSpeed(sin(count2-770)/2);
        }

        if (count2<850&&count2>=500)
        {
            N16-=6;
        }

        if (count2<=806&&count2>560&&count%2==0)
        {
            N15=0;
            N15+=rand(-1,1);
            PlaySE(GetCurrentScriptDirectory~"\se\Shot02.wav");
            CreateShot01(GetX()+30*cos(-count*4.3+N15),GetY()+30*sin(-count*4.3+N15),2.6-0.5*(GetCommonDataDefault("ii1",0)<2000),-count*4.3+N15,169,16);
            CreateShot01(GetX()+30*cos(180-count*4.3+N15),GetY()+30*sin(180-count*4.3+N15),2.6-0.5*(GetCommonDataDefault("ii1",0)<2000),180-count*4.3+N15,169,16);
            ascent( let t in 0..2 ) {
                CreateShot01(GetX()+60*cos(t-count*4.3+N15),GetY()+60*sin(t-count*4.3+N15),1.4-0.2*(GetCommonDataDefault("ii1",0)<2000),t-count*4.3+N15+180,49,16);
            }
            CreateShot01(GetX()+60*cos(90-count*7.3+N15),GetY()+60*sin(90-count*7.3+N15),1.6-0.2*(GetCommonDataDefault("ii1",0)<2000),-count*7.3+N15+180,33,16);
        }
        if (count2==500) {
            SetMovePosition02(cx,18,40);
        }
        if (count2==540) {
            SetMovePosition02(cx+220,18,40);
        }
        if (count2==580) {
            SetMovePosition02(cx+220,470,80);
        }
        if (count2==660) {
            SetMovePosition02(cx-220,470,60);
        }
        if (count2==720) {
            SetMovePosition02(cx-220,18,80);
        }
        if (count2==800) {
            SetMovePosition02(cx,18,40);
        }
        if (count2==840) {
            SetMovePosition02(cx,128,20);
        }

        if (count2==860&&count4<120)
        {
            count2--;
            count4++;
        }

        if (count4==1||count4==45)
        {
            PlaySE(GetCurrentScriptDirectory~"\se\Shot04.wav");
            ascent( let t in 0..30 ) {
                CreateShotA(N15,GetX(),GetY(),26);
                SetShotDataA(N15,0,1.7-0.6*(GetCommonDataDefault("ii1",0)<2000),GetAngleToPlayer+t*12,0,0,0,49);
                SetShotDataA(N15,20,NULL,NULL,0,0.05,12,49);
                FireShot(N15);
            }
            ascent( let t in 0..30 ) {
                CreateShotA(N15,GetX(),GetY(),26);
                SetShotDataA(N15,0,2.2-0.6*(GetCommonDataDefault("ii1",0)<2000),GetAngleToPlayer+t*12,0,0,0,169);
                SetShotDataA(N15,20,NULL,NULL,0,0.05,12,169);
                FireShot(N15);
            }
        }

        if (count2<984&&count2>860&&count%2==1)
        {
            PlaySE(GetCurrentScriptDirectory~"\se\Shot00.wav");
            if (count2<934) {
                ascent( let t in 0..8 ) {
                    CreateShot02(GetX()+100*cos(count*3+t*45),GetY()+100*sin(count*3+t*45),5-1.2*(GetCommonDataDefault("ii1",0)<2000),count*3+t*45,-0.5,2.8,196,26);
                }
            }
            if (count%36<=20) {
                ascent( let t in 0..8 ) {
                    CreateShot02(GetX()+100*cos(-count*0.3+t*45),GetY()+100*sin(-count*0.3+t*45),5,12-count*0.3+t*45,-0.5,4.0,169,26);
                }
            }
        }

        if (count2<1114&&count2>994&&count%2==1)
        {
            PlaySE(GetCurrentScriptDirectory~"\se\Shot00.wav");
            if (count2<1104) {
                ascent( let t in 0..8 ) {
                    CreateShot02(GetX()+100*cos(count*3+t*45),GetY()+100*sin(count*3+t*45),5-1.2*(GetCommonDataDefault("ii1",0)<2000),count*3+t*45,-0.5,2.8,196,26);
                }
            }
            if (count%36<=20) {
                ascent( let t in 0..8 ) {
                    CreateShot02(GetX()+100*cos(count*0.6+t*45),GetY()+100*sin(count*0.6+t*45),5,12+count*0.6+t*45,-0.5,4.0,169,26);
                }
            }
        }

        if (count2<1437&&count2>1164&&count%2==1)
        {
            PlaySE(GetCurrentScriptDirectory~"\se\Shot00.wav");
            if (count2<1374) {
                ascent( let t in 0..8 ) {
                    CreateShot02(GetX()+100*cos(count*3+t*45),GetY()+100*sin(count*3+t*45),5-1.2*(GetCommonDataDefault("ii1",0)<2000),count*3+t*45,-0.5,2.8,196,26);
                }
            }
            if (count%36<=20) {
                ascent( let t in 0..8 ) {
                    CreateShot02(GetX()+100*cos(-count*0.5+t*45),GetY()+100*sin(-count*0.5+t*45),5,6-count*0.5+t*45,-0.5,4.6,169,26);
                }
            }
        }

        if (count2>=1520)
        {
            N16-=6;
        }

        if (count2>1500&&count%2==1)
        {
            PlaySE(GetCurrentScriptDirectory~"\se\Shot00.wav");
            ascent( let t in 0..6 ) {
                //CreateShot02(GetX()+100*cos(-count*3+t*45),GetY()+100*sin(-count*3+t*45),5.5,180-count*3+t*45,0.03,6,169,26);
                CreateShotA(N15,GetX()+100*cos(-count*3+t*60),GetY()+100*sin(-count*3+t*60),26);
                SetShotDataA(N15,0,6.2,180-count*3+t*60,0,0,0,169);
                SetShotDataA(N15,22,NULL,NULL,0.2*sin(count2),0,6,169);
                FireShot(N15);
            }
        }

        if (count2>=60) {
            count++;
        }count2++;
        count3++;
        move--;
        if (count2==40) {
            SetColor(255,0,0);
            Concentration01(100);
            PlaySE(GetCurrentScriptDirectory~"\se\puu811.wav");
        }

        yield;
    }

    @Finalize()
    {
        ascent( let t in 0..50 ) {
            CreateItem(ITEM_SCORE,GetX()+150*cos(t*7.2),GetY()+20+150*sin(t*7.2));
        }
        ascent( let t in 0..50 ) {
            CreateItem(ITEM_SCORE,GetX()+100*cos(3.6+t*7.2),GetY()+20+100*sin(3.6+t*7.2));
        }
    }

    @DrawLoop()
    {
        if (N16>6&&count2>=1500)
        {
            N16-=6;
        }

        SetTexture(GetCurrentScriptDirectory~"img\dot_remilia.png");
        SetAlpha(255);
        SetGraphicRect(128*6,0,128*7,128);
        SetGraphicAngle(0,0,0);
        SetColor(255,220,250);
        SetGraphicScale(1.1,1.1);
        SetRenderState(ALPHA);
        if (count3/2%4>=0) {
            SetGraphicRect(128*6,0,128*7,128);
        }
        if (count3/2%4>=1) {
            SetGraphicRect(128*6,128,128*7,256);
        }
        if (count3/2%4>=2) {
            SetGraphicRect(128*6,256,128*7,384);
        }
        if (count3/2%4>=3) {
            SetGraphicRect(128*6,384,128*7,512);
        }
        DrawGraphic(GetX()+15*cos(count3*1),GetY()+30*cos(count3*2));
        if (count3/2%4>=0) {
            SetGraphicRect(128*6,384,128*7,512);
        }
        if (count3/2%4>=1) {
            SetGraphicRect(128*6,0,128*7,128);
        }
        if (count3/2%4>=2) {
            SetGraphicRect(128*6,128,128*7,256);
        }
        if (count3/2%4>=3) {
            SetGraphicRect(128*6,256,128*7,384);
        }
        DrawGraphic(GetX()-30*cos(count3*3),GetY()-15*cos(count3*4));
        if (count3/2%4>=0) {
            SetGraphicRect(128*6,256,128*7,384);
        }
        if (count3/2%4>=1) {
            SetGraphicRect(128*6,384,128*7,512);
        }
        if (count3/2%4>=2) {
            SetGraphicRect(128*6,0,128*7,128);
        }
        if (count3/2%4>=3) {
            SetGraphicRect(128*6,128,128*7,256);
        }
        DrawGraphic(GetX()+24*cos(count3*3),GetY()-40*cos(count3*3));
        if (count3/2%4>=0) {
            SetGraphicRect(128*6,128,128*7,256);
        }
        if (count3/2%4>=1) {
            SetGraphicRect(128*6,256,128*7,384);
        }
        if (count3/2%4>=2) {
            SetGraphicRect(128*6,384,128*7,512);
        }
        if (count3/2%4>=3) {
            SetGraphicRect(128*6,0,128*7,128);
        }
        DrawGraphic(GetX()-44*cos(count3*2),GetY()+20*cos(count3*1));
        if (count3/2%4>=0) {
            SetGraphicRect(128*6,256,128*7,384);
        }
        if (count3/2%4>=1) {
            SetGraphicRect(128*6,384,128*7,512);
        }
        if (count3/2%4>=2) {
            SetGraphicRect(128*6,0,128*7,128);
        }
        if (count3/2%4>=3) {
            SetGraphicRect(128*6,128,128*7,256);
        }
        DrawGraphic(GetX()+54*cos(count3*4),GetY()-60*cos(count3*3));
        if (count3/2%4>=0) {
            SetGraphicRect(128*6,256,128*7,384);
        }
        if (count3/2%4>=1) {
            SetGraphicRect(128*6,384,128*7,512);
        }
        if (count3/2%4>=2) {
            SetGraphicRect(128*6,0,128*7,128);
        }
        if (count3/2%4>=3) {
            SetGraphicRect(128*6,128,128*7,256);
        }
        DrawGraphic(GetX()+54*cos(count3*3),GetY()-60*cos(count3/5));
        if (count3/2%4>=0) {
            SetGraphicRect(128*6,384,128*7,512);
        }
        if (count3/2%4>=1) {
            SetGraphicRect(128*6,0,128*7,128);
        }
        if (count3/2%4>=2) {
            SetGraphicRect(128*6,128,128*7,256);
        }
        if (count3/2%4>=3) {
            SetGraphicRect(128*6,256,128*7,384);
        }
        DrawGraphic(GetX()-60*cos(count3*1),GetY()-65*cos(count3*1));

        SetTexture(GetCurrentScriptDirectory~"\img\circle_l.png");
        SetGraphicAngle(0,0,N16);
        SetGraphicRect(0,256,256,512);
        SetAlpha(255);
        SetRenderState(ADD);
        SetColor(255,255,255);
        if (count2<=1) {
            SetGraphicScale(0,0);
        }
        if (count2>1) {
            SetGraphicScale(0.015*count2,0.015*count2);
        }
        if (count2>=100) {
            SetGraphicScale(1.5,1.5);
        }
        if (ten==1&&OnBomb==false) {
            SetColor(160,160,180);
        }
        DrawGraphic(GetX(),GetY());
    }


}

