Jump to content
johnnyboy

Fully heal using medkit [solved]

Recommended Posts

I find it annoying that when healing using first aid kit, the player is only 75% healed, which means you have to listen to the player moaning and groaning forever until he can be healed by a medic (by a medkit).

 

A mission maker can solve this for you by using the eventhandler below.  With this eventHandler, player is always healed 100% when healing.   I'm using this in my new mission Last Tango in Tanoa 2: Razing Cane.  Hopefully someone else will find this useful.

 

I can't take credit for this, as I think I found the example somewhere (a post or wiki?), but I don't remember where.  So my apologies to the original author.

player addEventHandler ["HandleHeal", {
	_this spawn {
		params ["_injured","_healer"];
		_damage = damage _injured;
		if (_injured == _healer) then {
			waitUntil {damage _injured != _damage};
			if (damage _injured < _damage) then {
				_injured setDamage 0;
			};
		};
	};
}];

 

  • Like 4

Share this post


Link to post
Share on other sites

Does this work if someone else is healing you?

 

I also read this

Quote

If unit walks away from the healer during healing action, the heal will not finish but there is no way to detect this within "HandleHeal" framework.

So if removing this line if (_injured == _healer) then and adding something like this to the waitUntil, waitUntil {damage _injured != _damage || _healer distance2d _injured > 5};

 

Will it work?

Share this post


Link to post
Share on other sites
1 hour ago, Robustcolor said:

Does this work if someone else is healing you?

 

I also read this

So if removing this line if (_injured == _healer) then and adding something like this to the waitUntil, waitUntil {damage _injured != _damage || _healer distance2d _injured > 5};

 

Will it work?

In your example when a unit finishes healing you, the 100% heal will trigger when damage changes OR distance between you and your healer is more than 5 meters, I assume you want the full heal only when damage is reduced and healer is close. If so,

 

this addEventHandler ["HandleHeal", { 
    _this spawn { 
    params ["_injured", "_healer"]; 
    private _damage = damage _injured;
    waitUntil { ((damage _injured != _damage) && (_healer distance2d _injured < 5))}; 
    if (damage _injured < _damage) then { 
        _injured setDamage 0; 
        }; 
    }; 
}];

will do the job.

  • Like 1

Share this post


Link to post
Share on other sites

Is there something similiar for multiplayer? Since handleheal only triggers for local player and AI interactions, not when healing other players.

Share this post


Link to post
Share on other sites
29 minutes ago, Robustcolor said:

not when healing other players.

 

How did you come to this conclusion? MP is where this discussion started (see source link posted by HazJ above).

Share this post


Link to post
Share on other sites
39 minutes ago, Harzach said:

 

How did you come to this conclusion? MP is where this discussion started (see source link posted by HazJ above).

Well the thing is, handleheal never triggers if someone heals you even if both has the EH. The EH only works for the local player starting a self heal or healing an AI. 

 

There is no effect in MP between players when im testing it, Injured or healer is either the player or an AI, never another pllayer starting healing others. 

 

So my question is, is there a solution for this? 

Share this post


Link to post
Share on other sites
17 minutes ago, Robustcolor said:

when im testing it,

 

Show your code.

Share this post


Link to post
Share on other sites
23 minutes ago, Harzach said:

 

Show your code.

this addEventHandler ["HandleHeal", { 

    _this spawn { 

    params ["_injured", "_healer"]; 

    private _damage = damage _injured;

    waitUntil {(damage _injured != _damage)}; 

    if (damage _injured < _damage) then { 

        _injured setDamage 0; 

        }; 

    }; 

}];

Share this post


Link to post
Share on other sites

You could use the "handleDamage" EH instead, as far as a heal leads to 0.25 remaining damage.
This EH is a little bit more trick. "_damage" parameter is for selection, not overall damage. So, you need to wait for 0.25 overall damage.

Furthermore, this EH can fire multiple times so you  need the skip it for unwanted repeat:
Try:
 

this addEventHandler ["HandleDamage", {
  _this spawn {
    params ["_unit","_sel","_dam"];
    if !(_unit getVariable ["ready4heal",FALSE]) then {
      _unit setVariable ["ready4heal",TRUE];
      waitUntil {damage _unit in [0,0.25,1]};
      if (damage _unit == 0.25) then {_unit setDamage 0};
      _unit setVariable ["ready4heal",FALSE];
    };
  };
  _dam
}];

 

  • 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

×