script_enemy_main
{
    let cx=GetCenterX();
    let img=GetCurrentScriptDirectory~"img\dot_flandre.png";
    let mm=0;
    let shot=0;
    let tame=0;
    let tame2=0;
    let c=0;
    let d=50;
    let ang=0;
    let angW=0;
    let MT=0;
    let ss=100;
    let count=0;
    let count2=0;
    let count4=0;
    let move=0;
    let move2=0;
    let ten=0;
    let life=0;
    let cx=GetCenterX();//STGシーンの中心x座標を取得
    let sh00=GetCurrentScriptDirectory~"\se\Shot00.wav";
    let ang=0;
    @Initialize
{
    MagicCircle(false);
    SetEnemyMarker(true);
    SetLife(3000);
    SetDamageRate(100,50);
    SetTimer(34);
    SetNormPoint(-1);
    LoadGraphic(img);
    SetShotAutoDeleteClip(32,64,32,32);
    SetMovePositionRandom01(0,200,8,cx,154,cx,154);
    LoadGraphic(GetCurrentScriptDirectory~"\img\dot_flandre.png");
    LoadGraphic(GetCurrentScriptDirectory~"\img\circle_l.png");
    LoadGraphic(GetCurrentScriptDirectory~"\img\familiar.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==40) {
        PlaySE(GetCurrentScriptDirectory~"\se\puu811.wav");
        SetColor(255,0,0);
        Concentration01(243);
    }
    if (count>=50&&count%3<=1&&count4<=1)
    {
        PlaySE(sh00);
        ss+=sin(count);
        CreateShot02(GetX()+ss*cos(ang+count*3+0),GetY()-6+ss*sin(ang+count*3+0),-3,170+count*2.4+rand(-5,3),0.1,1.8+0.2*cos(count*2.7),69,20);
        CreateShot02(GetX()+ss*cos(ang+count*3+90),GetY()-6+ss*sin(ang+count*3+90),-3,180-count*2.2+rand(-5,3),0.1,0.8+0.4*cos(count*2),69,20);
        CreateShot02(GetX()+ss*cos(ang+count*3+180),GetY()-6+ss*sin(ang+count*3+180),-3,360+count*2.7+rand(-5,3),0.1,1.8+0.3*cos(count*7.4),69,20);
        CreateShot02(GetX()+ss*cos(ang+count*3+270),GetY()-6+ss*sin(ang+count*3+270),-3,330-count*2.9+rand(-5,3),0.1,0.8+0.5*cos(count*4),69,20);
    }

    //if(count>=50&&count%2==0)
    //{
    //	if(count>=100)
    //	{CreateLaser01(GetX()+38*sin(ang+count*3+90),GetY()-6+38*cos(ang+count*3+90),3,-ang+count*3+91,255,8,41,0);}
    //}

    //if(count>=50&&count%2==0)
    //{
    //	if(count>=100)
    //	{CreateLaser01(GetX()-38*sin(-ang-count*3+90),GetY()-6-38*cos(-ang-count*3+90),3,-ang-count*3+89,255,8,47,0);}
    //}
    SetCollisionA(GetX(),GetY()-12,34);//当たり判定(自弾)登録
    SetCollisionB(GetX(),GetY(),12);//当たり判定(体当たり)登録

    if (GetLife<15) {
        SetDamageRate(0,0);
        count4++;
        move2-=1;
    }

    if (count4<15&&GetLife<5) {
        AddLife(6);
    }

    if (count4>0) {
        DeleteEnemyShotInCircle(ALL,GetX,GetY,(count4)*4.2);
    }

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

    if (count4>110) {
        AddLife(-400);
    }

    if (count%160==69&&count>180) {
        SetMovePositionRandom01(rand(50,80),20,5,GetClipMinX()+100,110,GetClipMaxX()-100,150);
        move=80;
    }

    count2++;
    if (count2>=90) {
        count++;
    }if (count2>=117) {
        tame++;
    }if (count2<100) {
        move2++;
    }
}

@Finalize
{//読みこんだファイルを削除
    SetEnemyMarker(false);
}

@DrawLoop
{//描画

    if (move2>=2) {
        SetTexture(GetCurrentScriptDirectory~"\img\familiar.png");
        SetColor(0,0,0);
        if (count2>0&&count2<5) {
            SetColor(count2*50,count2*50,count2*50);
        }
        if (count2>=5) {
            SetColor(255*(move2/100),255*(move2/100),255*(move2/100));
        }
        SetGraphicAngle(0,0,count2*8);
        SetAlpha(255);
        SetGraphicScale(1,1);
        SetRenderState(ADD);
        SetGraphicRect(48,48,96,96);
        ascent( let t in 0..4 ) {
            DrawGraphic(GetX()+(ss*(move2/100))*cos(ang+count*3+90*t),GetY()+(ss*(move2/100))*sin(ang+count*3+90*t));
        }
    }

    SetTexture(GetCurrentScriptDirectory~"\img\dot_flandre.png");
    SetAlpha(255);
    SetGraphicAngle(0,0,0);
    SetColor(255,255,255);
    SetRenderState(ALPHA);
    SetGraphicScale(1,1);
    SetGraphicRect(0,0,128,128);
    if (int(GetSpeedX())==0&&count2/7%4>=0) {
        SetGraphicRect(0,0,128,128);
    }
    if (int(GetSpeedX())==0&&count2/7%4>=1) {
        SetGraphicRect(0,128,128,256);
    }
    if (int(GetSpeedX())==0&&count2/7%4>=2) {
        SetGraphicRect(0,256,128,384);
    }
    if (int(GetSpeedX())==0&&count2/7%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 (int(GetSpeedX())==0&&tame>0) {
        SetGraphicRect(128*4,0,128*5,128);
    }
    if (int(GetSpeedX())==0&&tame>8) {
        SetGraphicRect(128*4,128,128*5,256);
    }
    if (int(GetSpeedX())==0&&tame>16) {
        SetGraphicRect(128*4,256,128*5,384);
    }
    if (ten==1&&OnBomb==false) {
        SetColor(160,160,180);
    }
    DrawGraphic(GetX(),GetY());

}
}
