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

load Whealth
load Wbomb


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
custentity wbomb
spawnframe 1 -20 -10
	 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");

    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(Bombs<30){
          setglobalvar("Bomb", Bombs+1);
        }
      } else {
        setidle(self, openborconstant("ANI_IDLE"));
      }
    }
@end_script
	 loop	1
sound data/sounds/Rearm.wav
	 delay	50
	 offset	30 15
	 frame	data/chars/flagg/Yellow.png
	 frame	data/chars/flagg/Yellow.png
