Jump to content

Recommended Posts

The HandleHeal event handler fires when healing starts, not finishes. Has anyone figured out an elegant way to tell when a unit is actually healed?

 

This is code I'm using to increment a variable every time an agent gets healed, but it isn't good because it fires when healing starts, not when the unit is healed. If the unit or the healer walk away mid-heal, the increment breaks (conceptually). Thanks.

 

{
  (agent _x) addEventHandler ["HandleHeal", {
	params ["_unit", "_healer", "_isMedic"];
    //code that does stuff
  }];
} forEach agents;

 

Share this post


Link to post
Share on other sites

{

  (agent _x) addEventHandler ["HandleHeal", {
    _this spawn {

      params ["_unit", "_healer", "_isMedic"];
      waitUntil { damage _unit in [0.25,0]};
      // code

    };

  }];

} forEach agents;

Not tested.

Share this post


Link to post
Share on other sites

Thanks, I didn't know about waitUntil.

 

I had to Spawn it to get it to work, and I simplified it. Now the Hint doesn't fire until the heal is complete.

 

{
  (agent _x) addEventHandler ["HandleHeal", {
	params ["_unit", "_healer", "_isMedic"];
    0 = _unit spawn {
      params ["_thisUnit"];
      waitUntil { (damage _thisUnit) < .5 };
      hint "healed";
    };
  }];
} forEach agents;

 

Share this post


Link to post
Share on other sites

When a unit is healed, the damage is set to 0.25 (first aid kit, no medic) or 0 (medikit, medic)

Your solution is not valid if you abort a heal on a unit suffering damage less than 0.5.

The reason why I focused on 0 and 0.25 which are standard values for healed units (and statistically never exactly reached by wounds).

 

  • Thanks 1

Share this post


Link to post
Share on other sites

Got it, I'll change it up. I had actually scripted .8 damage to the units, but your way is universally better.

 

"Your way is universally better" should be a t-shirt. 🤔

  • Like 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×