Slay No More 73 Posted November 2, 2021 Hello, I'm trying to make it so all vehicles survive impact damage (from wrecks), but can get killed from everything else. The script works fine on land vehicles, it even de-activates on its own, but helicopters don't seem to abide by the same rules, even after blocking the damage types that they give off during various wrecks, but it almost always seems to be fuel damage or something else still destroying it. I can throw a vehicle with the following setvelocitymodelspace function to enduce a strong wreck, the land vehicles remain alive, the helicopters even if its a soft slide still explode like vanilla. vehicle player setVelocityModelSpace [55, 55, 0]; I wish I understood what to do with the script at this point, Vandeanson assisted me and helped me with his knowledge of eventhandlers and helped me get to this point, which functions as I wanted, but the game seemingly doesn't allow it to work the same for helicopters so I'm stuck at a complete stand still trying to think of some way to protect helicopters as well without the proper knowledge. explosionarray = []; player addEventHandler ["GetInMan",{ params ["_unit", "_role", "_vehicle", "_turret"]; //if (driver _vehicle != _unit) exitwith {}; if (_vehicle getVariable ["alreadyprotectedunderscripts",0] isEqualTo 0) then {//variable check to stop spam maybe _vehicle setVariable ["alreadyprotectedunderscripts",1,true]; _vehicle addEventHandler ["HandleDamage", { params ["_unit", "_selection", "_damage", "_source", "_projectile", "_hitIndex", "_instigator", "_hitPoint"]; explosionarray pushbackunique _projectile; //systemchat _projectile; if (_unit iskindof "air" && _projectile in ["", "HelicopterExploSmall", "FuelExplosion","HelicopterExploBig"]) then {_unit allowdamage false; }; if (!(_unit iskindof "air") && _projectile in ["", "HelicopterExploSmall", "FuelExplosion","HelicopterExploBig"]) then { if (_selection isEqualTo "") then {damage _unit} else {_unit getHit _selection}; }; }]; }; }]; player addEventHandler ["GetOutMan",{ params ["_unit", "_role", "_vehicle", "_turret"]; if (count crew _vehicle isequalto 0) then { _vehicle removeAllEventHandlers "HandleDamage"; _vehicle setVariable ["alreadyprotectedunderscripts",0,true]; }; }]; 1 Share this post Link to post Share on other sites
MuRaZorWitchKING 725 Posted November 3, 2021 Bump 1 Share this post Link to post Share on other sites
Slay No More 73 Posted November 12, 2021 On 11/2/2021 at 9:02 PM, MuRaZorWitchKING said: Bump thanks m8 Share this post Link to post Share on other sites
Slay No More 73 Posted December 25, 2021 Hey @pierremgi or @Rydygier I was wondering if maybe one of you or maybe both of you could assist or help me with a perplexing issue here I ran into with a script I had made, perhaps one or both of you know what's wrong? I've attempted to make a script which disables damage for all vehicles from impact and wrecking and it works for land vehicles in regards to tree impact and vehicle to vehicle impact but the same logic doesn't apply to aircraft. Aircraft explode when coming into the same types of collisions and even when blocking all of the incoming damage which can be viewed when putting _projectile into the console. I've been stumped for months on it, tried asking around to no avail so I'm desperate with a tag, I'd like to add eventhandlers are completely new to me, I used to get the desired effects using while loops and I know now its bad. Share this post Link to post Share on other sites
Gunter Severloh 4068 Posted December 25, 2021 Slay they wont see that the way you tagged it, i'll do it for you. @pierre MGI and @Rydygier Slay had asked me on steam chat about his issue here, idk what to make of it, i suggested him to ask you guys since you know code well, any ideas on what the issue is for what hes asking about? 1 1 Share this post Link to post Share on other sites
Slay No More 73 Posted December 26, 2021 9 hours ago, Gunter Severloh said: Slay they wont see that the way you tagged it, i'll do it for you. @pierre MGI and @Rydygier Slay had asked me on steam chat about his issue here, idk what to make of it, i suggested him to ask you guys since you know code well, any ideas on what the issue is for what hes asking about? Thanks for fixing my whoopsie lmao. Merry Christmas to you and all who reads this. 1 Share this post Link to post Share on other sites
Rydygier 1317 Posted December 26, 2021 Hi there and Merry Christmas! 🙂 On 12/25/2021 at 5:17 AM, Slay No More said: a script which disables damage for all vehicles from impact and wrecking and it works for land vehicles in regards to tree impact and vehicle to vehicle impact but the same logic doesn't apply to aircraft. Is it the same code, you pasted in the first post? Frankly, I do not know anything about any specific ways of being destroyed in simulation, that would ignore HandleDamage EH, for helicopters exclusively or not. Anyhow, best would be to have simple and 100% vanilla repro mission with complete setup, that creates the issue and nothing else. But first... Regarding the above code, it looks, like you try to protect "air" units in different way, that non-air ones. Why? Such difference may perfectly explain your issue, apparently the way, you use for "air" doesn't work, while the way applied to other vehicles is fine. Personally I never tried to apply allowDamage false via HandleDamage EH, but if you do, then question is, where you do allowdamage true back? Otherwise you make the air asset permanently immune to common types of damage that may occur in the simulation. IIRC only most of them, not to all. But also, if this doesn't work (since heli is destroyed), it may be too late to apply it from within HandleDamage to "catch" the damage, which triggered this EH code. Not sure about that, needs testing, just guessing here. Anyway, if this: if (_selection isEqualTo "") then {damage _unit} else {_unit getHit _selection} works for non-air assets, maybe first try to apply same thing to aerial vehicles as well? Simply like this: //systemchat _projectile; if (_projectile in ["", "HelicopterExploSmall", "FuelExplosion","HelicopterExploBig"]) then { if (_selection isEqualTo "") then {damage _unit} else {_unit getHit _selection}; }; so without any "_unit iskindof "air"" differentiation. Just all vehicles get same treatment. Also, in case that would help you anyhow, here's how I implemented HadleDamage EH in order to make an unit fall unconscious instead of dead: _ldr addEventHandler ["HandleDamage", { params ["_unit", "_selection", "_damage", "_source", "_projectile", "_hitIndex", "_instigator", "_hitPoint"]; if ((toLower _selection) in ["arms","hands","legs"]) exitWith { _damage }; if (_damage >= 1) then { _unit setUnconscious true; }; (_damage min 0.99) }]; So, the thing about this EH is, its code should end with some final damage value if you wish to alter default damage. This damage will be applied to the selection, for which EH was triggered. As you can see, if the hit selection was non-vital, I do exitWith with nominal _damage value (probably would be same if left empty). In other cases though, if _damage is 1 or more, I set unconscious state to the unit, but I pass no more, than 0.99 of damage to ensure, unit will not die. Allowdamage false, even if working, as intended, shouldn't be needed for such purposes here. Another example, closer to your implementation, that makes infantry immune to collision-based damage (self-inflicted by falling etc. included): _ix = _x addEventHandler ["HandleDamage", { _this call { _unit = _this select 0; _sel = _this select 1; _damage = _this select 2; _source = _this select 3; _inst = _this select 6; if ((isNull _source) or {(_unit isEqualTo _source) or {(isNull _inst)}}) exitWith {if (_sel isEqualTo "") then {(damage _unit)} else {(_unit getHit _sel)}}; _damage } }]; (_this call thingy is required in order to make it working reliably, but I managed to forget, why exactly). As you can see, all is based on output damage value, no allowDamage false. So, if _source indicates one of mentioned types of damage, new damage is not applied (exitWith previous damage). Otherwise _damage is applied. BTW this: On 11/2/2021 at 7:39 AM, Slay No More said: _vehicle removeAllEventHandlers "HandleDamage"; Is not recommended, if you plan to public your script. This line will remove all EHs on this vehicle, not only your EH. That may break other scripts/mods, that use same event handler for something. Safer is: https://community.bistudio.com/wiki/removeEventHandler Which also can be run from within EH's code itself like this: _x addEventHandler ["HandleDamage", { params ["_unit", "_selection", "_damage", "_source", "_projectile", "_hitIndex", "_instigator", "_hitPoint"]; if (_projectile isEqualTo "") exitWith { if (_damage >= 1) then { _unit removeEventHandler ["HandleDamage",_thisEventHandler]; //deleteVehicle _unit; }; _damage }; (_damage min 0.99) }] But of course also from the outside (addEventhandler return required EH's index). Just in case: https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#HandleDamage and some robust explanations on this EH: 4 Share this post Link to post Share on other sites
Slay No More 73 Posted December 27, 2021 20 hours ago, Rydygier said: Hi there and Merry Christmas! 🙂 Thanks to you as well and thank you for replying to my post / thread! I have prepared a demo mission to sort to give you the same view of things that I have so hopefully you can see how the issues are occurring. I swapped the if statement with your first suggestion. As you can probably see with this demonstration here, the effects work on land vehicles, but not so much with aircraft. I'm hoping you are able to spot something obvious seeing it in action as its intended. Please note, the version I used in this snippet is different from the original first post, below the download URL I will post the tested version.http://uppit.com/awz22wpqv5fz explosionarray = []; player addEventHandler ["GetInMan",{ params ["_unit", "_role", "_vehicle", "_turret"]; //if (driver _vehicle != _unit) exitwith {}; if (_vehicle getVariable ["alreadyprotectedunderscripts",0] isEqualTo 0) then {//variable check to stop spam maybe _vehicle setVariable ["alreadyprotectedunderscripts",1,true]; _vehicle addEventHandler ["HandleDamage", { params ["_unit", "_selection", "_damage", "_source", "_projectile", "_hitIndex", "_instigator", "_hitPoint"]; explosionarray pushbackunique _projectile; //systemchat _projectile; if (_projectile in ["", "HelicopterExploSmall", "FuelExplosion","HelicopterExploBig"]) then { if (_selection isEqualTo "") then {damage _unit} else {_unit getHit _selection}; }; }]; }; }]; player addEventHandler ["GetOutMan",{ params ["_unit", "_role", "_vehicle", "_turret"]; if (count crew _vehicle isequalto 0) then { _vehicle removeAllEventHandlers "HandleDamage"; _vehicle setVariable ["alreadyprotectedunderscripts",0,true]; }; }]; 1 Share this post Link to post Share on other sites
Rydygier 1317 Posted December 27, 2021 All right. So, the mission, you provided is not loading: but don't worry. The scenario anyway was containing other scripting and stuff, that would obscure the testing results with uncertainty as for the cause of observed events. So I took relevant part only and made actual repro mission: https://www.dropbox.com/s/cv381nfurhmlakg/VehProtection_test.Stratis.zip?dl=0 I ran it and was able to reproduce the issue. Here's the recording that helps todocument, what I was doing. Ignore my shitty piloting, besides, the crash was intended... this time. 🙂 Code was suplemented with diag_logs to save interesting data. Here's the SQF used: diag_log "go"; explosionarray = []; player addEventHandler ["GetInMan",{ params ["_unit", "_role", "_vehicle", "_turret"]; diag_log format ["getin: %1",_this]; //if (driver _vehicle != _unit) exitwith {}; if (_vehicle getVariable ["alreadyprotectedunderscripts",0] isEqualTo 0) then {//variable check to stop spam maybe _vehicle setVariable ["alreadyprotectedunderscripts",1,true]; _vehicle addEventHandler ["HandleDamage", { params ["_unit", "_selection", "_damage", "_source", "_projectile", "_hitIndex", "_instigator", "_hitPoint"]; diag_log format ["handledamage [_unit, _selection, _damage, _source, _projectile, _hitIndex, _instigator, _hitPoint]: %1",_this]; explosionarray pushbackunique _projectile; //systemchat _projectile; if (_projectile in ["", "HelicopterExploSmall", "FuelExplosion","HelicopterExploBig"]) then { diag_log format ["protection [_unit,_projectile,_selection]: %1",[_unit,_projectile,_selection]]; if (_selection isEqualTo "") then {damage _unit} else {_unit getHit _selection}; }; }]; }; }]; player addEventHandler ["GetOutMan",{ params ["_unit", "_role", "_vehicle", "_turret"]; diag_log format ["getout: %1",_this]; if (count crew _vehicle isequalto 0) then { _vehicle removeAllEventHandlers "HandleDamage"; _vehicle setVariable ["alreadyprotectedunderscripts",0,true]; }; }]; and here's resulting RPT log reflecting my actions and consequences: https://www.dropbox.com/s/cqngzrgaectl3cl/Arma3_x64_2021-12-27_09-05-50.rpt?dl=0 Conclusions so far: - get in and get out works. - HD EH seems properly triggered. - also for heli each HD EH exec log is accompanied by "protection" log, so each damage event, that triggered this EH damage protection line was executed. - yet, heli exploded. - so either it was destroyed by some damage, that didn't triggered HandleDamage, either the protection code line is for some reason ineffective for such collisions. That's it for now, I'll let you know, if I find more clues. 3 Share this post Link to post Share on other sites
haleks 8212 Posted December 27, 2021 If it helps, the demo missions included in my Remnant mod feature drones that stalk the player, with a working EH that disable collision-induced damage : _this addEventHandler ["HandleDamage", { params ["_unit", "_selection", "_damage", "_source", "_projectile", "_hitIndex", "_instigator", "_hitPoint"]; if (isNull _source) then {0} }]; Note that the code actually "heals" the drone, so you need to replace the numeric value by a proper overwrite with the original damage of the hit selection. Slay's code checks for projectiles such as "HelicopterExploSmall", "FuelExplosion","HelicopterExploBig" - but those occur once the heli is destroyed already, so it's most likely "too late" at this point to overwrite initial damage, I think. 3 Share this post Link to post Share on other sites
Rydygier 1317 Posted December 27, 2021 In further tests started from the simpliest thing. Disabled whole code and instead put this into Heli1 init field: this addEventHandler ["HandleDamage", {0}]; Then tested it with gun fire and satchel charge. Works - damage 0 after satchel explosion. Then piloted the heli1 same manner, as on the footage. Collision made me dead and the heli exploded and was destroyed. So it seems, heli colliding with stuff is destroyed in a way, that ["HandleDamage", {0}] won't prevent. this allowDamage false; prevents that kind of damage though. But it is not selective nor working from inside HD EH, as you tried. Meaning, if you do this in the heli's init field: this addEventHandler ["HandleDamage",{(_this select 0) allowDamage false;}]; then you play, fly and collide - heli's destroyed unless earlier HD EH was triggered with some non-lethal damage (which wouldn't destroy the heli but would execute allowDamage false). Well, at this point I admit, I know no good for your need way to prevent a helicopter from taking collision damage. 3 Share this post Link to post Share on other sites
NightIntruder 710 Posted December 27, 2021 I recommend getting in touch with 10Dozen or Buzzil who both developed a mod called "dzn Vehicle on Fire", available on Steam:https://steamcommunity.com/sharedfiles/filedetails/?id=1352522482 It somehow works with aircraft as far as my tests are concerned, to some extent only tho. On a side note, what you want to achieve might be done from an addon config, I think. The likely class for that is: EPEImpulseDamageCoefhttps://community.bistudio.com/wiki/Config_Properties_Megalist#epeImpulseDamageCoef Consequently, you may try to create a config that alters a value of that class for a specific addon or type of vehicle. By the way, a fireball coming from an aircraft crash isn't always avoidable IRL. It depends on different factors - impact forces (and crash-prevention measures like landing gear absorbers and crew seats), amount of fuel in fuel tanks, destruction of fuel tanks and consequent fuel leaks (even if self-sealing fuel tanks are present), a fire caught from sparks, running engines or hot exhaust pipes, etc. Anyway, fingers crossed! I've been waiting for ages for such a script that would deny an explosion of a helicopter after kinetic impact (especially dynamic rollover during a ground roll) while allowing to damage its subsystems and hurt passengers. 2 Share this post Link to post Share on other sites
haleks 8212 Posted December 27, 2021 2 hours ago, Rydygier said: So it seems, heli colliding with stuff is destroyed in a way, that ["HandleDamage", {0}] won't prevent. Maybe the EH is triggered several times in the same frame? By the way, this doesn't work either : this addEventHandler ["EpeContactStart", { params ["_object1", "_object2", "_selection1", "_selection2", "_force"]; _object1 allowDamage false }]; this addEventHandler ["EpeContactEnd", { params ["_object1", "_object2", "_selection1", "_selection2", "_force"]; _object1 allowDamage true }]; 😕 Might be worth opening a ticket, if there isn't one already. 2 Share this post Link to post Share on other sites
Slay No More 73 Posted December 28, 2021 19 hours ago, NightIntruder said: Anyway, fingers crossed! I've been waiting for ages for such a script that would deny an explosion of a helicopter after kinetic impact (especially dynamic rollover during a ground roll) while allowing to damage its subsystems and hurt passengers. That's basically the goal of these scripts. The idea is to basically avoid all the other damage EXCEPT gun fire and rocket fire, I like vehicles tanky on missions, but allowdamage false is just way too much protection. It makes it un-fun. It's the entire reason hopefully we can get to the bottom of it. Share this post Link to post Share on other sites
Slay No More 73 Posted December 28, 2021 17 hours ago, haleks said: Might be worth opening a ticket, if there isn't one already. I wish I knew how to do that, I've forgotten how to use forums it seems. I've taken too long of a break from any kind of platform like this lmao. Share this post Link to post Share on other sites
EO 11277 Posted December 28, 2021 2 hours ago, Slay No More said: I wish I knew how to do that, I've forgotten how to use forums it seems. I've taken too long of a break from any kind of platform like this lmao. https://feedback.bistudio.com/w/ft_a3_howto/ Share this post Link to post Share on other sites
IIIXJokerXIII 4 Posted August 23 Slay sent me a link on discord to have a look at this. I've not done any testing yet, but at a quick look over I bet the issue is with advanced flight model settings. As these setting have a really big impact on heli's. I would run the same test changing these setting to see if the desired outcome if achieved. 1 Share this post Link to post Share on other sites