Home   Help Search Login Register  

Author Topic: reduce damage taken  (Read 2885 times)

0 Members and 1 Guest are viewing this topic.

Offline Surdus Priest

  • Members
  • *
  • Only I can Forgive You!
reduce damage taken
« on: 15 Sep 2007, 15:24:43 »
i need a way to make a unit godmode to everthing but headshots or direct explosive impacts

or better yet a way to make a unit die after a set number of hits

surdus
Campaigns are hard, I'll stick with scripting for now!

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: reduce damage taken
« Reply #1 on: 15 Sep 2007, 16:55:22 »
This has been asked soooo many times....

Code: [Select]
this addEventhandler ["HIT",{_this select 0 setDamage 0}];
Will make an infantry unit almost invulnerable. If you want a unit to die after so many hits using only event handlers(recommended) you will need something like:
Code: [Select]
this setVariable ["nHits",0] ; this addEventhandler ["HIT",{_nhits = getVariable (_this select 0) ; _nhits = _nhits + 1 ; if (_nhits > 5) then {_this select 0 setDamage 1 ; _this select 0 removeAllEventHandlers "HIT";} else {_this select 0 setVariable ["nHits", _nhits];}];
What a mouthful that was! Of course you could use a looping script to count the hits or a trigger, but this way is probably the best.

urp!

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: reduce damage taken
« Reply #2 on: 15 Sep 2007, 18:11:03 »
Actually the eventhandler-hit-setdamage 0 no longer works in ArmA. Not sure why, but it doesn't (it never worked for the Player character in OFP either, anyway). Or, well -> it WORKS, as in whenever you're hit it sets your damage to 0, however if you're hit and KILLED (headshot, close-range torso shot, high caliber weaponry) you won't be revived.

To make it work, use a very high negative number, such as -100 instead of 0. That will make the unit nigh invincible. However, anything capable of doing more damage than "-100" in one shot will still kill the unit (I think for instance a direct hit from a SABOT will sometimes kill the soldier etc).

It's an ArmA thing.  :dunno:

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

Offline Surdus Priest

  • Members
  • *
  • Only I can Forgive You!
Re: reduce damage taken
« Reply #3 on: 15 Sep 2007, 19:59:06 »
so would this work in the initiation of the unit:

this setdamage -100

then use a looping script or repeating trigger such as:

Condition: unit damage > -100
Activation: unit setdamage -100

would that work?
Campaigns are hard, I'll stick with scripting for now!

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: reduce damage taken
« Reply #4 on: 16 Sep 2007, 03:23:49 »
If you search recent threads for setDamage I believe someone claimed that using a negative value only works the first time.
urp!

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: reduce damage taken
« Reply #5 on: 16 Sep 2007, 14:39:25 »
Actually, no. You can't check negative damage values using "damage" or "getdamage" -> if you set the damage to, say, -100, it will still show up as 0. As to a looping script: I'm sure that'd work, why not. But the "hit" eventHandler also works.

However be advised it IS buggy. Here's the thread where it was previously discussed:

Making units tougher

In my testing I came to the conclusion that this is not really a viable solution because:

a) the "hit" eventhandler isn't handled well by many units at a time
b) quick, consecutive and high-damage hits are sometimes too fast for the game to keep up with, and once the magical threshold of "damage == 1" is passed, the unit can by no means be revived.  :(

But for one unit that needs to be invincible for whatever reason: sure, why not? :)

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

Offline Surdus Priest

  • Members
  • *
  • Only I can Forgive You!
Re: reduce damage taken
« Reply #6 on: 16 Sep 2007, 16:09:18 »
this seems to work:

Code: [Select]
;v = unit

_number = -1000

#loop

?((damage v) > 0):_number = _number +100

v setdamage _number
~0.1

goto "loop"

with the health value set to -1000 the unit can survive any standard bullets such as assault rifles.

however heavy machine guns or close proxy explosions or sniper shots will kill him.

?((damage v) > 0):_number = _number +100;  this line means that the unit can survive up to 10 of these shots.  so with this under the right conditions, it could possiblly make a fight with a unit into a boss battle, even better if the unit is a tank.

i'd still like to know how to make the damage done not matter and no matter what attacks are made, the unit would survive..
Campaigns are hard, I'll stick with scripting for now!

Offline SgtWolf

  • Members
  • *
Re: reduce damage taken
« Reply #7 on: 24 Sep 2007, 22:01:59 »
Can I ask why do you use eventhandlers when for the desired result of a unit being "invincible" basically can just involve having setdamage 0 looping in a script?  ???

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re: reduce damage taken
« Reply #8 on: 24 Sep 2007, 23:13:59 »
cuz it seems in ArmA when unit dies it cant b revived like in OFP so even if we have a loopin setdamage unit dat got hit in da head will stay dead...  :no: or at least... so i heard... never bothered 2 check dat :P ;)

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline Cheetah

  • Former Staff
  • ****
Re: reduce damage taken
« Reply #9 on: 24 Sep 2007, 23:17:28 »
If you take the loop time really really short, it should work. However, the hit eventhandler is failsafe, the looping script isn't as far as I know. For example, a MG fires a lot of bullets per minute which may lead to your looping script not healing the unit fast enough. And you need a negative setdammage to handle headshots.
Like missions? Help with Beta Testing! or take a look at the OFPEC Missions Depot for reviewed missions!

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: reduce damage taken
« Reply #10 on: 25 Sep 2007, 16:45:02 »
eventHandler also beats looping scripts performance wise, eventhandler is not a looping condition check..
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.