#e
#Title[f[^]
#Text[FAnother~AXe[W
Z[uf[^܂]
#Player[FREE]
#ScriptVersion[2]
#BackGround[User()]

script_enemy_main
{
    let count=0;
    let count2=0;
    let count3=0;
    let R=0;
    let R2=0;
    let R3=0;
    let N15=0;
    let get;
    let try;

    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=0;let tame=0;let tame2=0;let c=0;let d=60;
    let ang=0;

    @Initialize()
    {
        MagicCircle(false);
        SetLife(1400);
        CreateCommonDataArea("Spell");
        LoadCommonDataEx("Spell",pass);
        SetDamageRate(25,0);
        SetTimer(9999);
        SetInvincibility(150);
        SetNormPoint(-1);
        LoadGraphic(img);
        SetShotAutoDeleteClip(512,512,512,512);
        SetMovePositionRandom01(0,200,3,cx,138,cx,138);
        LoadGraphic(bg);
        LoadGraphic(bg2);
        LoadGraphic(bg3);
        LoadGraphic(GetCurrentScriptDirectory~"\img\remiria.png");
        LoadGraphic(GetCurrentScriptDirectory~"\img\circle_l.png");
        LoadUserShotData(GetCurrentScriptDirectory~".\shot_All.txt");


    }

    @MainLoop()
    {
        if (count2>=80) {
            count++;
        }count2++;
        if (count2>=60) {
            count3++;
            tame++;
        }
        if (count==10) {
            SetScore(0);
            PlaySE(GetCurrentScriptDirectory~"\se\warp02.wav");
            CutIn(YOUMU,"u^v",GetCurrentScriptDirectory~"img\remiria2.png",0,0,512,512);
        }

        if (count>=440) {
            ClearCommonDataEx("Spell");
            SetCommonDataEx("Spell","HighScore_before",666);
            SaveCommonDataEx("Spell",pass);
        }if (count>=660) {
            SetLife(0);
        }

        c++;
        yield;
    }

    @Finalize()
    {
    }

    @DrawLoop()
    {
        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&&count<=440) {
                SetGraphicScale(0.02*count+0.1*sin(count*3),0.02*count+0.1*sin(count*3));
            }
            if (count>=50&&count<=440) {
                SetGraphicScale(1.0-((count-50)/440)+0.1*sin(count*3),1.0-((count-50)/440)+0.1*sin(count*3));
            }
            if (count>=440) {
                SetGraphicScale(0,0);
            }
            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);
        SetGraphicAngle(0,0,0);
        SetColor(bombalpha,bombalpha,bombalpha);
        SetRenderState(ALPHA);
        SetGraphicScale(1,1);
        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 (int(GetSpeedX())==0&&tame>0) {
            SetGraphicRect(128*4,0,128*5,128);
        }
        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 (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);
        }
        DrawGraphic(GetX(),GetY());

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

        if (count>=440) {
            SetFontColor(255,196,196,255,0,0);
            let posX = 80;
            DrawText("f[^܂B",GetClipMaxX()-125,GetClipMinY()+44,10,196);
        }
    }

    @BackGround()
    {
    }

}

