Jump to content

Recommended Posts

Hi all. I am using the below code, and half the times it works, and the other half not (unit actually dies).  Is there something wrong to prevent death 100% of the time?  Thanks for taking a look.

 

 

 

s01 addEventHandler ["HandleDamage", 
  { 
  _dam = _this select 2; 
  if (_dam > 0.96) then {_dam = 0.96;
	s01 setcaptive true;
	S01 allowdamage false;
	s01 switchmove "Acts_InjuredLyingRifle01";
	["LOOSE",true,true,true] call BIS_fnc_endMission;
	0 = ["DynamicBlur", 400, [10]] spawn {
	params ["_name", "_priority", "_effect", "_handle"];
	while {
		_handle = ppEffectCreate [_name, _priority];
		_handle < 0
	} do {
		_priority = _priority + 1;
	};
	_handle ppEffectEnable true;
	_handle ppEffectAdjust _effect;
	_handle ppEffectCommit 5;
	};
	1 cutText["You have been killed!","PLAIN"];};
  _dam
  }];

 

Share this post


Link to post
Share on other sites

I wanted to add some more info on what it is i am tryi9ng to accomplish. 

 

When unit S01 dies, i want to trigger an END MISSION call rather then going to the death screen in SP.  I do not want to allow for resuming save or ending the mission after being killed (prevent death screen).  Reason is I have a score board come up at the end of the mission with the stats from it.  The goal of this scenario is to count how many completed missions+kills which is saved to profile so that the scenario can be played again to try and beat the score.

 

Hope this makes sense.  The above works (when the EH actually kicks in), but the end result is what i just explained.  So if there are other ways to handle, i am down to look into it.  Thanks again.

Share this post


Link to post
Share on other sites

So i am thinking that the above eventhandler doesn't work when damage is >= 1?  is this correct?  It won't fire since the unit is classified as "DEAD"?  Any tricks for the above scenario?

 

Tried reading a couple of post, and this one here: 

But a bit confused as to what I can do.

Share this post


Link to post
Share on other sites
On 1/18/2017 at 4:55 AM, jcae2798 said:

So i am thinking that the above eventhandler doesn't work when damage is >= 1?  is this correct?

 

Kind of old topic but better late than never :

 

preventing death completely :

_this addEventHandler ["HandleDamage", {0}];   

preventing death with damage dealt :

_this addEventHandler ["HandleDamage", {
	params ["_unit", "_selection", "_damage", "_source", "_projectile", "_hitIndex", "_instigator", "_hitPoint"];
	
	_unit = _this select 0;

	_damage = damage _unit;
	if (_damage > 0.9) then {
	_damage = 0.9;
	[_unit,true] remoteExec ["setUnconscious",_unit];      
	};	
_unit setDamage _damage;
}];

 

  • Like 4

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

×