Jump to content
Sign in to follow this  
redleouf

Prevent player from dying in basic ace medical

Recommended Posts

Hi,

 

I am actually working on a personnal script to run in singleplayer to simulate a respawn when I should die.

 

What I do is that when I take a sufficient amount of damage, I disable damage, teleport myself to spawn, clean my damage amount and renable damage.

 

It works fine, but the mission also use the ACE and it's basic medical system. I want to keep it that way but if I don't erase all the HandleDamage handlers before putting mine, my script still run but I die anyway when I "respawn" because of ACE.

 

Is there any way I can tell ACE that I do not want to die when taking a certain amount of damage? I tried calling the ace_medical_fnc_treatmentAdvanced_fullHeal function in my script after setting allowDamage to false but it doesn't work.

 

Here is my code so far :

 

SPR_HandleDamage_EH =
{
	private ["_unit", "_killer", "_amountOfDamage"];
	
	_unit = _this select 0;
	_amountOfDamage = _this select 2;
	_killer = _this select 3;

    if (alive _unit && _amountOfDamage >= 0.9) then
	{		
		hint "Respawning";
		_unit allowDamage false;				
		if (hayACE) then
		{
      		[_unit, _unit] call ace_medical_fnc_treatmentAdvanced_fullHeal;
    	}
		_unit setPos(getMarkerPos("respawn_west"));
		_unit setDamage 0;
		_amountOfDamage = 0;
		_unit allowDamage true;
	};
	
	_amountOfDamage
};

[] spawn
{
    waitUntil { !isNull player };
	
	[] spawn SPR_Player_Init;
	hintSilent format["SP Respawn Script Loaded"];
};

SPR_Player_Init =
{
	//player removeAllEventHandlers "HandleDamage";

	player addEventHandler ["HandleDamage", SPR_HandleDamage_EH];
};

 

pastebin

Share this post


Link to post
Share on other sites

Yep, try putting the code under: 

[_unit, _unit] call ace_medical_fnc_treatmentAdvanced_fullHeal;

It should reset a unit's ACE medical state (12).

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
Sign in to follow this  

×