Jump to content
Sign in to follow this  
wyattwic

Arma 2 - Preventing player damage from reaching 1

Recommended Posts

Hello everyone!

I have a somewhat simple question, in witch I have yet to find a simple solution too.

I am working on a new game mode and I would like players to get heavily injured (0.95) then execute a script. Is there any way to do this without having to rewrite the damage handler for all the body parts?

---------- Post added at 19:49 ---------- Previous post was at 19:41 ----------

After continued research, I found an old thread with some tips that are guiding me towards the lengthy solution.

http://forums.bistudio.com/showthread.php?113418-HandleDamage-EH-explained-%28-poor-man-s-getHit%29

If anyone knows of a simpler method to mess around with handling damage, please let me know.

Share this post


Link to post
Share on other sites

Haven't time to work out all the syntax (could you come back next week? :o) but as individual part damage-levels seem a bit irrelevant at damage >/= 0.95, you might use

_damage = getDammage _unit;

to find how badly injured units are (the mis-spelt command is correct), then

if ((_damage) < 0.95) exitWith {};  //so you don't do any more on less-injured untis

followed by something like

_unit removeAllEventHandlers "HandleDamage";
_unit setDamage (_damage); //not sure that's needed but shouldn't be a problem if it isn't

all wrapped in a forEach loop with your script running at the end.

Edit: hmm, according to Celery (your ref. thread) units die if damage =/> 0.9. I would start with a lower damage level than 0.9 to check the sript works; otherwise if all you see are dead units you won't know if it's your script or a feature pf the game engine.

Edited by Orcinus

Share this post


Link to post
Share on other sites

An issue I see with that, what if I hit the player with a weapon that does 30 points of damage (sabot round) to his face? The code may not have enough time to handle it.

to sum it up, will this loop have priority over the damage handling built into the game mode?

As it stands, I am just going the long way. I think it may be cool to provide a damage modifier option.

Share this post


Link to post
Share on other sites

Example:

this addEventHandler ["HandleDamage", {if (((damage unit1) + (_this select 2)) < 0.9) then {_this select 2} else {0.9}}]

This in the init field of unit1 will make, I hope, so unit will take normal damage as long as its overall damage stays below 0.9. Otherwise will be set to 0.9 (if any higher value you choose - unit will die).

Edited by Rydygier

Share this post


Link to post
Share on other sites

Thanks! I will test that now!

---------- Post added at 19:16 ---------- Previous post was at 19:11 ----------

Does not work. Makes player and AI invincible.

Share this post


Link to post
Share on other sites

Of course. "Preventing player damage from reaching 1" means making him invicible while still can be injured. This will (should, as in my quick tests) allow rising damage up to 0.9, no further, as bigger value will kill the unit. And instead of 0.9 in "else" part you can run any code you wish, as you stated: "I would like players to get heavily injured (0.95) then execute a script. ". Isn't that what you want? If no - sorry for misunderstanding.

Share this post


Link to post
Share on other sites

Sorry, I did not provide the report accurately. Players are not taking any damage.

Tested by firing a minigun to the knee. 1000 rounds.

Share this post


Link to post
Share on other sites

Hmm. Strange. In my case damage is rising up to 0.9. I pasted that code into unit1 init field, set looped silent hint with current damage of unit1, then just shot that unit with the rifle in the legs or torso. After first shot I usualy got about 0.6, after any next - 0.9. I have no idea, why it is not working for you... Here is that mission, if you want - check it, if will work for you.

Share this post


Link to post
Share on other sites

I did some more testing myself and it is allowing damage to the unit, but the unit is not being injured the same as before.

---------- Post added at 22:09 ---------- Previous post was at 22:06 ----------

Broken legs, arms etc.

Share this post


Link to post
Share on other sites

Ah, clear now. Yes, that is true. If you want this, try with such code:

this addEventHandler ["HandleDamage", {if ((((damage unit1) + (_this select 2)) < 0.9) or ((_this select 1) in ["hands","legs"])) then {_this select 2} else {0.9}}]

Share this post


Link to post
Share on other sites

Thanks Rydygier, I will definitely implement this in my game.

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  

×