Home   Help Search Login Register  

Author Topic: Making units tougher  (Read 5178 times)

0 Members and 1 Guest are viewing this topic.

Offline SniperUK

  • Members
  • *
  • I'm a llama!
Making units tougher
« 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.

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: Making units tougher
« Reply #1 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.
"When 900 years YOU reach, look as good you will not!"

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Making units tougher
« Reply #2 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.
« Last Edit: 20 Jul 2007, 16:53:01 by Mr.Peanut »
urp!

Offline SniperUK

  • Members
  • *
  • I'm a llama!
Re: Making units tougher
« Reply #3 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?
« Last Edit: 14 Jul 2007, 15:46:14 by SniperUK »

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: Making units tougher
« Reply #4 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:
« Last Edit: 14 Jul 2007, 17:24:57 by h- »
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline Cheetah

  • Former Staff
  • ****
Re: Making units tougher
« Reply #5 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.
Like missions? Help with Beta Testing! or take a look at the OFPEC Missions Depot for reviewed missions!

Offline jeroenm

  • Members
  • *
Re: Making units tougher
« Reply #6 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.

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: Making units tougher
« Reply #7 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.
"When 900 years YOU reach, look as good you will not!"

Offline JasonO

  • OFPEC Patron
  • ****
  • Oh no...
    • The New Life RPG
Re: Making units tougher
« Reply #8 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.

Offline Cheetah

  • Former Staff
  • ****
Re: Making units tougher
« Reply #9 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
Like missions? Help with Beta Testing! or take a look at the OFPEC Missions Depot for reviewed missions!

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: Making units tougher
« Reply #10 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.

"When 900 years YOU reach, look as good you will not!"

Offline Cheetah

  • Former Staff
  • ****
Re: Making units tougher
« Reply #11 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
« Last Edit: 31 Aug 2007, 14:32:59 by Cheetah »
Like missions? Help with Beta Testing! or take a look at the OFPEC Missions Depot for reviewed missions!