this.GoalType = "REVIVE";
this.DefaultPriority = 1.0;
this.DontSave = true;
this.Radius = 64;
this.DynamicPosition = true;
this.DynamicOrientation = true;
this.Range = 2000; // this matches value for compass icon in SDK

//////////////////////////////////////////////////////////////////////////

this.UpgradeVersion = function(Props)
{
	if(Props.Version == 0)
	{
		// default to disabled, until the entity stops moving.
		this.DisableGoal(true);

		// store the position. velocity check on injured ents is bad
		this.EntPosition = GetEntPosition(this.GetEntity());

		//delete goal if body is on ice
		tr = TraceLine( this.EntPosition, Vec3(this.EntPosition.x, this.EntPosition.y, this.EntPosition.z-90), 0, TRACE.SOLID, -1, false );
		if(tr.surface & SURFACE.SLICK){
			this.SetRemoveFlag(true);
		}
	}
};

//////////////////////////////////////////////////////////////////////////

this.Update = function()
{
	sleep(1); // give it some time to update internally
	goalEnt = this.GetEntity();

	if (!GetEntFlags(goalEnt, ENTFLAG.DEAD) && Util.GetEntHealth(goalEnt) > 0  //check health because ENTFLAG.DEAD does not work if omnibot_flags 16
		|| GetEntFlags(goalEnt, ENTFLAG.LIMBO) )
	{
		this.SetAvailable(0, false);
		this.SetRemoveFlag(true);
	}
	else if(this.IsDisabled())
	{
		entPos = GetEntPosition(goalEnt);
		if (entPos){
			if (DistanceBetween(this.EntPosition,entPos) < 2)
			{
				this.DisableGoal(false);
				// cs: actually can't block here or the goal will never get removed.
				//block(0);
			}
			else
			{
				this.EntPosition = entPos;
			}
		}
	}
};
