OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: SniperUK on 13 Jul 2007, 09:16:41

Title: Making units tougher
Post by: SniperUK on 13 Jul 2007, 09:16:41
Hi guys, what is the best way to make a unit tougher to kill, i have a few important ai in my mission that die far too easy and are essential to the missions end. I know snypir released a script a while back in ofp and found a post about it on the board but can no longer find it in the editors depot. Any suggestions would be appreciated, thanks.
Title: Re: Making units tougher
Post by: Wolfrug on 13 Jul 2007, 12:24:16
I'll second this - any way to make a unit tougher without making an addon? The reason I'm asking is because when I've tried to script stuff (for instance with eventhandlers), it doesn't seem to quite work.  :dunno:

The basic method is to simply loop the damage done down all the time - in OFP this worked on AI units, since they could easily be brought back to life from 1 or more damage. Now however if you kill an AI unit and retroactively setDamage them, they won't come back to life. They'll sometimes lose the damage textures, but they'll still be dead.

Maybe something to do with the new switchable player functions? (since even in OFP you couldn't really bring back your player unit from the dead -> the death camera would roll even if your avatar was still running about happily).

Anyone else have different experiences with this?

Wolfrug out.
Title: Re: Making units tougher
Post by: Mr.Peanut on 13 Jul 2007, 16:19:03
Code: [Select]
this addEventHandler ["HIT",{(_this select 0) setDamage (0.75 * damage (_this select 0));}];Will multiply a unit's damage by 0.75 every time it gets hit. It will still take damage but be hard to kill. Replace with setDamage 0 if you want it to take no damage.

this addEventHandler("KILLED",{(_this select 0) setDamage 0;}];
Will prevent the unit from being killed.


Even with these enhancements a unit can still get killed by taking a headshot, being blown up by an LGB, crashing, or run over.
Title: Re: Making units tougher
Post by: SniperUK on 13 Jul 2007, 17:37:59
I tried the steps you suggested and put the this addEventHandler["KILLED",{(_this select 0) setDamage 0;}]; in the init line of the unit. However nothing seemed to happen and the unit dies very easily regardless of whether its a leg shot, arm shot etc. Is there any reason for this? i notice when you put down the code, one minute you are using _this and then another 'this'. Is this code called from the init line of the unit, or from a script?
Title: Re: Making units tougher
Post by: h- on 14 Jul 2007, 17:19:51
Quote
Is this code called from the init line of the unit, or from a script?
Init.

this refers to the unit, _this refers to the hardcoded array that is automatically passed into the executed script..

EDIT:
Weirdly enough that "killed" eventhandler 'trick' doesn't seem to work for me either  :dunno:
Title: Re: Making units tougher
Post by: Cheetah on 14 Jul 2007, 19:55:45
Instead of the KILLED eHandler try using the HIT eHandler. As killed means that the unit is already dead, in ArmA if a unit is dead he can't be revived by simply putting setdammage 0.

So if you a soldier to be invincible (expect vs. headshots and stuff mentioned by Peanut), use the HIT eHandler.
Title: Re: Making units tougher
Post by: jeroenm on 29 Aug 2007, 11:52:17
Code: [Select]
this addEventHandler ["HIT",{(_this select 0) setDamage (0.75 * damage (_this select 0));}];Will multiply a unit's damage by 0.75 every time it gets hit. It will still take damage but be hard to kill. Replace with setDamage 0 if you want it to take no damage.

this addEventHandler("KILLED",{(_this select 0) setDamage 0;}];
Will prevent the unit from being killed.


Even with these enhancements a unit can still get killed by taking a headshot, being blown up by an LGB, crashing, or run over.

this addEventHandler ["hit", {[_this select 0] setDamage -5}]

units now survive headshots,grenades etc!
it works only if the first hit that the unit takes is not deadly  


i tested it and it worked.
Title: Re: Making units tougher
Post by: Wolfrug on 29 Aug 2007, 12:53:23
Whoa, hold on a second -> the setdammage command can take NEGATIVE values now?   :scratch: That could reaaaa-he-heally make for some interesting things. Got to test this.  :D

Wolfrug out.
Title: Re: Making units tougher
Post by: JasonO on 30 Aug 2007, 22:25:02
Any Results on this? My new graphics card doesn't arrive until tommorow and ArmA obviously won't start on my mobo's onboard graphics card. Does it make the unit feel more alive?
Didn't something like setdammge -1 make the unit really inaccurate or something... can't remember.
Title: Re: Making units tougher
Post by: Cheetah on 30 Aug 2007, 23:18:34
The only thing that its useful for is to survive things like headshots and chestshots - things that would get you killed normally.

However, after this first shot (in the head, chest, foot - whatever) the next one will get you killed..

Conclusion: only useful if you want a unit not to die from a headshot or chestshot - any explosive (if direct) will kill you even with -10000
Title: Re: Making units tougher
Post by: Wolfrug on 31 Aug 2007, 07:11:04
I did some (fairly extensive) testing on this yesterday. Mes results:

JUST giving the unit a default, init-field "this setdamage -10" (for instance) does not, as Cheetah observes, make them particularly invincible. They will perhaps survive one more shot or so, but as we all know, when the AI shoots, they shoot to kill. A lot. In AI vs AI engangements, this base minus-value to damage did not seem to have much of a difference.

Conclusion: the engine only accepts one "negative value" hit before resetting to its default 0-1 range. (needs further testing)

However, if used in conjunction with the "hit" eventhandler (resetting the damage to a negative one every hit) will produce much more interesting results. Here are my (preliminary) results:

this setdamage -10; this addeventhandler ("hit", {this setdamage -10}]

-> The unit is invulnerable to small arms fire. All of it. Shooting the unit in the head with a SAW for a full clip will yield no results. HOWEVER, the moment the "pain threshold" is overcome (i.e., one shot, one kill) the unit immediately dies. I believe that at -10, the unit could still be killed from headshots from a .50 cal.  :cool2:

this setdamage -5; this addeventhandler ("hit", {this setdamage -5}]

-> Unit still invulnerable to small arms fire, but dies from anything of higher caliber (i.e. .50 cal, explosions). I think they might also buckle under multiple close-range headshots from a 7.62-type weapon ^^

this setdamage -3; this addeventhandler ("hit", {this setdamage -3}]

-> Unit dies from headshots/high calibre shots.

Conclusion: I didn't try it up to really ridiculous lenghts, but even a -100 unit would still die from i.e. a tank shell (lots of damage in one of those, though). Basically though, it's possible with this method to make units invulnerable. This also works on vehicles, BUT! The crew generally dies from the concussive effects nonetheless. :)

Caveat: When applied on many units (squad-sized), the eventhandlers seemed to get a bit overworked and didn't want to work any more. Basically there's a lot of ArmA-randomness going down here, that needs more research.

But, to conclude: if someone made a quick .sqf script that checked for body parts hit (i.e., head-arms-legs) and then either negated the damage or let the unit die, there's a sort-of chance to make SOME kind of body armor out of it. :) :good:

Wolfrug out.

Title: Re: Making units tougher
Post by: Cheetah on 31 Aug 2007, 14:28:31
@Body Armor

Tried doing that yesterday evening, but I couldn't make a easy to use Body Armor thingy. Especially had trouble keeping it somewhat realistic (unit dies sometime).

EDIT:

major problem - as you said the game can't keep up with multiple eventHandlers