Event Handlers – Arma 3 Talk
Killzone Kid (talk | contribs) mNo edit summary |
Fred Gandt (talk | contribs) (Agreed; copy-paste - no specific values (for now). Also more unexpected and frankly bizarre behaviour.) |
||
Line 27: | Line 27: | ||
-- I wouldn't put any definite numbers if I were you. It needs to be tested not only with units and as far as I remember for vehicles you can get EH triggered for damages < 0.5. I personally think copy paste from "Hit" EH where it explains sensitivity would be sufficient. | -- I wouldn't put any definite numbers if I were you. It needs to be tested not only with units and as far as I remember for vehicles you can get EH triggered for damages < 0.5. I personally think copy paste from "Hit" EH where it explains sensitivity would be sufficient. | ||
::I'm not seeing ''Dammage EH'' triggering for less than 0.5 on Pawnees, Hunters and others, but sure, without confirmation (it'll be in the code somewhere), figures are tough to justify. I agree; a copy-paste of the note in ''Hit EH'' would be a start (I noticed that after my last comment here). At least it gives a clue to expect less than obvious behaviour. | |||
::*Speaking of which... | |||
<pre>v addEventHandler ["HandleDamage", { | |||
_v = _this select 0; | |||
if (alive _v) then { | |||
_s = _this select 1; | |||
if (_s == "") then { | |||
_s = "vehicle"; | |||
}; | |||
if (_s == "?") then { | |||
_s = "thingummybob"; | |||
}; | |||
hintSilent format ["Total damage: %1\nHit damage: %2\nSection: The %3", damage _v, _this select 2, _s]; | |||
if (damage _v > 0) then { | |||
_v setDamage 0; | |||
}; | |||
} else { | |||
hintSilent "Something else that doesn't matter out of context."; | |||
}; | |||
}];</pre> | |||
::Assuming ''v'' is a vehicle like a Pawnee in perfect condition, and assuming it just got hit by a 6.5mm round, wouldn't we expect a hint reading something like | |||
<pre>Total damage: 0.000947657 | |||
Hit damage: 0.284657 | |||
Section: The tail rotor</pre> | |||
::And then find that all the damage has been repaired? | |||
::Well we don't! | |||
<pre>if (damage _v > 0) then { | |||
_v setDamage 0; | |||
};</pre> | |||
::does it's job exactly as we should expect, but <pre style="display:inline;margin:0px;padding:3px 3px 2px 5px;">hintSilent format ["Total damage: %1\nHit damage: %2\nSection: The %3", damage _v, _this select 2, _s];</pre> produces something like | |||
<pre>Total damage: 0 | |||
Hit damage: 0.284657 | |||
Section: The tail rotor</pre> | |||
::The hit damage, section and <pre style="display:inline;margin:0px;padding:3px 3px 2px 5px;">_v setDamage 0;</pre> are all as they should be, but somehow the value for <pre style="display:inline;margin:0px;padding:3px 3px 2px 5px;">damage _v</pre> in the hint is zero - even when the <pre style="display:inline;margin:0px;padding:3px 3px 2px 5px;">if (damage _v > 0)</pre> returns true! | |||
::I've tried a dozen different methods (this one is the simplest for demonstration), and none avoid the issue. Even <pre style="display:inline;margin:0px;padding:3px 3px 2px 5px;">_foo = damage _v</pre> and using _foo in the hint, or <pre style="display:inline;margin:0px;padding:3px 3px 2px 5px;">_v setVariable ["foo", damage _v, true]</pre> and getting the value for the hint don't work. | |||
::I even tried spawning scripts, calling functions, waiting until, sleeping, and using two EHs, but nothing. | |||
::Very strange behaviour. [[User:Fred Gandt|Fred Gandt]] ([[User talk:Fred Gandt|talk]]) 13:42, 4 March 2014 (CET) |
Revision as of 13:42, 4 March 2014
Dammaged
Appears to only trigger if the damage is greater than 0.5
Repro:
- Add to player init
player addEventHandler ["Dammaged", {
hint format ["Damage: %1", _this select 2];
}];
- Set elevation to 5 metres.
- Preview.
- Exit.
- Set elevation to 4.5 meters.
- Preview.
You may need to fiddle with those figures a bit, but it's a quick and dirty method to test.
Observe: Only damage above 0.5 is hinted.
Am I wrong, or should this be noted in the documentation?
Fred Gandt (talk) 06:54, 3 March 2014 (CET)
-- Yes, Dammaged EH is less sensitive than HandleDamage, not sure if there is a defined threshold.
- So we should add a note to the documentation? I'm pretty sure a threshold of 0.5 exists, but that obviously needs testing of verification from bistudio to justify an absolute statement. I'd consider any verifiable fact that affects returns to be important to note, even if the fact is imprecise. A note to the effect that "Dammage will not necessarily trigger for < 0.5 damage", would at least save some folk the trouble I had trying to figure out WTF was going on. Fred Gandt (talk) 04:30, 4 March 2014 (CET)
-- I wouldn't put any definite numbers if I were you. It needs to be tested not only with units and as far as I remember for vehicles you can get EH triggered for damages < 0.5. I personally think copy paste from "Hit" EH where it explains sensitivity would be sufficient.
- I'm not seeing Dammage EH triggering for less than 0.5 on Pawnees, Hunters and others, but sure, without confirmation (it'll be in the code somewhere), figures are tough to justify. I agree; a copy-paste of the note in Hit EH would be a start (I noticed that after my last comment here). At least it gives a clue to expect less than obvious behaviour.
- Speaking of which...
- I'm not seeing Dammage EH triggering for less than 0.5 on Pawnees, Hunters and others, but sure, without confirmation (it'll be in the code somewhere), figures are tough to justify. I agree; a copy-paste of the note in Hit EH would be a start (I noticed that after my last comment here). At least it gives a clue to expect less than obvious behaviour.
v addEventHandler ["HandleDamage", { _v = _this select 0; if (alive _v) then { _s = _this select 1; if (_s == "") then { _s = "vehicle"; }; if (_s == "?") then { _s = "thingummybob"; }; hintSilent format ["Total damage: %1\nHit damage: %2\nSection: The %3", damage _v, _this select 2, _s]; if (damage _v > 0) then { _v setDamage 0; }; } else { hintSilent "Something else that doesn't matter out of context."; }; }];
- Assuming v is a vehicle like a Pawnee in perfect condition, and assuming it just got hit by a 6.5mm round, wouldn't we expect a hint reading something like
Total damage: 0.000947657 Hit damage: 0.284657 Section: The tail rotor
- And then find that all the damage has been repaired?
- Well we don't!
if (damage _v > 0) then { _v setDamage 0; };
- does it's job exactly as we should expect, but
hintSilent format ["Total damage: %1\nHit damage: %2\nSection: The %3", damage _v, _this select 2, _s];
produces something like
- does it's job exactly as we should expect, but
Total damage: 0 Hit damage: 0.284657 Section: The tail rotor
- The hit damage, section and
_v setDamage 0;
are all as they should be, but somehow the value fordamage _v
in the hint is zero - even when theif (damage _v > 0)
returns true! - I've tried a dozen different methods (this one is the simplest for demonstration), and none avoid the issue. Even
_foo = damage _v
and using _foo in the hint, or_v setVariable ["foo", damage _v, true]
and getting the value for the hint don't work. - I even tried spawning scripts, calling functions, waiting until, sleeping, and using two EHs, but nothing.
- The hit damage, section and
- Very strange behaviour. Fred Gandt (talk) 13:42, 4 March 2014 (CET)