Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
Sign in to follow this  
aaronhance

Is there a way to prevent damage from slected guns/ammo?

Recommended Posts

maybe this works:

 this addEventHandler ["HandleDamage", {_dmg = _this select 2;if (_this select 3 in ["hgun_P07_F"]) then {_dmg=0;}_dmg;}];

Share this post


Link to post
Share on other sites
 this addEventHandler ["HandleDamage", {if (_this select 3 in ["hgun_P07_F"]) then {[color="#FF0000"]0[/color]}else{ _this select 2}];

Just 0. quoteing the WIKI.

Adding this eventhandler with no return value or with return value 0, replaces damage handling by the engine, making the object invulnerable if damage is not scripted in the eventhandler. If you want default processing to be done, be sure to return _this select 2.
Also _this select 3 does not return the weapon fired but the unit that done the firing, you will need to find another way of discovering the weapon type. Edited by Larrow

Share this post


Link to post
Share on other sites

[/color]

 this addEventHandler ["HandleDamage", {if (_this select 3 in ["hgun_P07_F"]) then {[color="#FF0000"]0[/color]}else{ _this select 2}];

Just 0. quoteing the WIKI. Also _this select 3 does not return the weapon fired but the unit that done the firing, you will need to find another way of discovering the weapon type.

Tried it, but it does not work, :(

Share this post


Link to post
Share on other sites

I only checked the return value was correct first time i looked at your code, I added shortly afterwards that select 3 was wrong for checking the weapon used as it only returns the unit that caused the damage. You will need to use this units current weapon to check against, something like

this addEventHandler ["HandleDamage", {if ((currentWeapon (_this select 3)) in ["hgun_P07_F"]) then {0}else{ _this select 2}];

Share this post


Link to post
Share on other sites
I only checked the return value was correct first time i looked at your code, I added shortly afterwards that select 3 was wrong for checking the weapon used as it only returns the unit that caused the damage. You will need to use this units current weapon to check against, something like
this addEventHandler ["HandleDamage", {if ((currentWeapon (_this select 3)) in ["hgun_P07_F"]) then {0}else{ _this select 2}];

I changed it to _this select 4 and put in the ammo class name.

I've been using this http://forums.bistudio.com/showthread.php?113418-HandleDamage-EH-explained-%28-poor-man-s-getHit%29&highlight=event%20handler

Share this post


Link to post
Share on other sites
Sign in to follow this  

×