Jump to content
Sign in to follow this  
Heeeere's johnny!

Problems with "damage" command

Recommended Posts

Hi everybody,

I stumbled upon this problem regarding the damage of an object. I'm manually executing the following lines in VR after mission start:

[color=#FF8040][color=#1874CD]_car[/color] [color=#8B3E2F][b]=[/b][/color] [color=#191970][b]createVehicle[/b][/color] [color=#8B3E2F][b][[/b][/color][color=#7A7A7A]"C_SUV_01_F"[/color][color=#8B3E2F][b],[/b][/color] [color=#191970][b]screenToWorld[/b][/color] [color=#8B3E2F][b][[/b][/color][color=#FF0000]0.5[/color][color=#8B3E2F][b],[/b][/color][color=#FF0000]0.5[/color][color=#8B3E2F][b]][/b][/color][color=#8B3E2F][b],[/b][/color] [color=#8B3E2F][b][[/b][/color][color=#8B3E2F][b]][/b][/color][color=#8B3E2F][b],[/b][/color] [color=#FF0000]0[/color][color=#8B3E2F][b],[/b][/color] [color=#7A7A7A]"CAN_COLLIDE"[/color][color=#8B3E2F][b]][/b][/color][color=#8B3E2F][b];[/b][/color]
[color=#1874CD]_car[/color] [color=#191970][b]addEventHandler[/b][/color] [color=#8B3E2F][b][[/b][/color][color=#7A7A7A]"HandleDamage"[/color][color=#8B3E2F][b],[/b][/color] [color=#8B3E2F][b]{[/b][/color][color=#191970][b]systemChat[/b][/color] [color=#191970][b]str[/b][/color] [color=#191970][b]damage[/b][/color] [color=#8B3E2F][b]([/b][/color][color=#000000]_this[/color] [color=#191970][b]select[/b][/color] [color=#FF0000]0[/color][color=#8B3E2F][b])[/b][/color][color=#8B3E2F][b];[/b][/color][color=#8B3E2F][b]}[/b][/color][color=#8B3E2F][b]][/b][/color][color=#8B3E2F][b];[/b][/color]
[color=#1874CD]_car[/color] [color=#191970][b]addEventHandler[/b][/color] [color=#8B3E2F][b][[/b][/color][color=#7A7A7A]"HitPart"[/color][color=#8B3E2F][b],[/b][/color] [color=#8B3E2F][b]{[/b][/color][color=#191970][b]hintSilent[/b][/color] [color=#191970][b]str[/b][/color] [color=#191970][b]damage[/b][/color] [color=#8B3E2F][b]([/b][/color][color=#8B3E2F][b]([/b][/color][color=#000000]_this[/color] [color=#191970][b]select[/b][/color] [color=#FF0000]0[/color][color=#8B3E2F][b])[/b][/color] [color=#191970][b]select[/b][/color] [color=#FF0000]0[/color][color=#8B3E2F][b])[/b][/color][color=#8B3E2F][b];[/b][/color][color=#8B3E2F][b]}[/b][/color][color=#8B3E2F][b]][/b][/color][color=#8B3E2F][b];[/b][/color][/color]

Kudos to Killzone_Kid for his SQF to BBCode Converter.

According to the BIKI, the "Hit" EH doesn't always fire when small damage is dealt. But it seems as if a similar effect is falsifying the damage value of the object even without an EH.

Even though I shoot the car with an assault rifle, the value returned by damage is always 0. The only situations it actually changes is setDamage, dealing heavier damage like a granade or heavily crashing the car into something.

Now, the damage value returned by the "Hit" EH is the damage dealt to the hit part, meaning using that value on the whole car on each hit would be falsifying the amount of damage dealt by that bullet resp. damage dealing "thing".

So the question is, what can I do to always get the correct damage value of the vehicle, no matter how low the dealt damage is?

Share this post


Link to post
Share on other sites

I believe its a syntax error, your parenthesis should be captivating damage because you are using a "operator" which is damage, therefor when "str" reads damage it doesn't know what to do

 
_car addEventHandler ["HandleDamage", {systemChat str (damage (_this select 0));}];

Share this post


Link to post
Share on other sites
I believe its a syntax error, your parenthesis should be captivating damage because you are using a "operator" which is damage, therefor when "str" reads damage it doesn't know what to do

 
_car addEventHandler ["HandleDamage", {systemChat str (damage (_this select 0));}];

That is actually not true.

Firstly, if it was a syntax error, such one would have popped up and the interpreter would have not even continued executing the code.

Secondly, as I mentioned the EHs work, but only with greater damage inflicting effort.

And thirdly, "str" and "damage" are both right recursive commands, meaning they proceed when their right side resp. their argument has been processed. Putting the damage part into parantheses doesn't make any difference.

Share this post


Link to post
Share on other sites

tested, the code I have provided works

Edit: oh cars hold fast I will do some testing

Edited by Mr-Blizzard

Share this post


Link to post
Share on other sites

Tried using 'Hit' EH instead of HitPart?

hitPart might need an additional param to be passed, otherwise it won't return.

Too bad I'm too short on time to verify this in-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  

×