name		Yellow
type		none
gfxshadow	1
setlayer	2
subject_to_gravity 0
offscreenkill	10000


anim idle
@script
    void self = getlocalvar("self");
    float x = getentityproperty(self, "x");
    float y = getentityproperty(self, "a");
    void P1 = getplayerproperty(0, "entity");

    if(P1){
      float Px = getentityproperty(P1, "x");
      float Py = getentityproperty(P1, "a");
      float PVx = getentityproperty(P1, "xdir");

      if(x>=Px-35 && x<=Px+35 && y>=Py && y<=Py+20 && PVx==0){
        performattack(self, openborconstant("ANI_FOLLOW1"));
      }
    }
@end_script
	 loop	1
	 delay	5
	 offset	30 15
	 frame	data/chars/flagg/Yellow.png
	 frame	data/chars/flagg/Yellow.png

anim follow1
@script
    void self = getlocalvar("self");
    float x = getentityproperty(self, "x");
    float y = getentityproperty(self, "a");
    void P1 = getplayerproperty(0, "entity");
    int TPhase1 = getentityvar(self, 0);
    int TPhase2 = getentityvar(self, 1);
    int SFX1 = loadsample("data/sounds/refuel.wav");
    int SFX2 = loadsample("data/sounds/reload.wav");

    if(P1){
      float Px = getentityproperty(P1, "x");
      float Py = getentityproperty(P1, "a");
      float PVx = getentityproperty(P1, "xdir");
      int PHealth = getentityproperty(P1, "health");
      int Bombs = getglobalvar("Bomb");

      if(x>=Px-35 && x<=Px+35 && y>=Py && y<=Py+20 && PVx==0){
        if(PHealth<100){
          changeentityproperty(P1, "health", PHealth+5);
          if(TPhase1 != NULL() && TPhase1 <= openborvariant("elapsed_time") - 320){
            setentityvar(self, 0, NULL());
            TPhase1 = NULL();
          }
          if (TPhase1 == NULL()){
            playsample(SFX1, 0, 120, 120, 100, 0);
          }
        }
        if(Bombs<30){
          setglobalvar("Bomb", Bombs+1);
          if(TPhase2 != NULL() && TPhase2 <= openborvariant("elapsed_time") - 120){
            setentityvar(self, 1, NULL());
            TPhase2 = NULL();
          }
          if (TPhase2 == NULL()){
            playsample(SFX2, 0, 120, 120, 100, 0);
          }
        }
      } else {
        setidle(self, openborconstant("ANI_IDLE"));
      }
    }
@end_script
	 loop	1
	 delay	50
	 offset	30 15
	 frame	data/chars/flagg/Yellow.png
	 frame	data/chars/flagg/Yellow.png
