jazzer12369   12 Posted August 30, 2018 I'm looking for a way to stop a specific vehicle from being able to be blown up. I want the hull and engine to be invincible, so that the vehicle won't explode when hit, but the wheels should still be vulnerable so that it can still be disabled, just not destroyed/blown up.  I'm looking for this to be achieved within the vehicles init field, or via an external script. The reason I want this to be possible is because I don't want a simple vehicle respawn in my mission like I have now. I want to punish players for getting a vehicle blown up, making them have to airlift the damaged vehicle back to base where it can be repaired (I don't need help with the airlift or repairs I've got that covered, just need help on making the vehicles hull and engine invulnerable.)    Are there any scripts out there which can help me a achieve this? I was looking into the "SetHit" functionality etc but I am a total noob when it comes to scripting. To be completely honest with you I'd love for someone to figure this out for me as I really don't have a lot of time to dedicate to testing and playing about with things myself Share this post Link to post Share on other sites
POLPOX Â Â 778 Posted August 30, 2018 this addEventHandler ["HandleDamage",{(_this#7 in ["hitlfwheel","hitlbwheel","hitlmwheel","hitlf2wheel","hitrfwheel","hitrbwheel","hitrmwheel","hitrf2wheel"])}] The code is showing how to deal with on the Marshall. Change the array to use on other vehicles. Â There are two ways to implement. this addEventHandler ["HandleDamage",{(_this#7 in [/*HitPoints to break*/])}] this addEventHandler ["HandleDamage",{!(_this#7 in [/*HitPoints to protect*/])}] Â 2 1 Share this post Link to post Share on other sites
jazzer12369   12 Posted August 31, 2018 This is fantastic mate thanks for this.  I've got this working for a hunter now simply by changing the wheels in the array like you suggested.  Just a quick question about one of the parameters, what does the "(_this#7" mean? I understand the rest for the most part but I haven't seen this before. I'm quite interested in how it all works. Also, how would this be adapted for a tracked or fixed wing vehicle for example?   Share this post Link to post Share on other sites
HazJ Â Â 1289 Posted September 1, 2018 https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#HandleDamage Quote unit: Object - Object the event handler is assigned to. hitSelection: String - Name of the selection where the unit was damaged. "" for over-all structural damage, "?" for unknown selections. damage: Number - Resulting level of damage for the selection. source: Object - The source unit that caused the damage. projectile: String - Classname of the projectile that caused inflicted the damage. ("" for unknown, such as falling damage.) hitPartIndex: Number - Hit part index of the hit point, -1 otherwise. instigator: Object - Person who pulled the trigger hitPoint: String - hit point Cfg name I think you can disable simulation as well. Note: Once you enable simulation again, the vehicle will be destroyed or whatever damage was dealt before restores. Best approach is HandleDamage EH as @POLPOX said. Share this post Link to post Share on other sites
pierremgi   4850 Posted September 1, 2018 Similar topic and solution. 1 Share this post Link to post Share on other sites
jazzer12369   12 Posted September 2, 2018 @HazJ @pierremgi  This is great stuff ladies thank you very much! @POLPOX nailed exactly what I needed, awesome stuff all round. Share this post Link to post Share on other sites
HazJ   1289 Posted September 2, 2018 3 hours ago, jazzer12369 said: @HazJ @pierremgi  This is great stuff ladies thank you very much! @POLPOX nailed exactly what I needed, awesome stuff all round. Definitely not a "lady" - Yup, just checked! Not sure about @pierremgi though? 1 1 Share this post Link to post Share on other sites
Shadow__   0 Posted June 5, 2021 Hi !  So I'm trying to adapt the code from @POLPOX for other vehicles. Right now, I'm triyng with the RHS M1165A1, and so far I have this : this addEventHandler ["HandleDamage",{(_this#7 in ["hitlfwheel","hitlbwheel","hitrfwheel","hitrbwheel","hitengine"])}] It's working fine for the 4 wheels and the engine, but I wish to make damageable the "turret" and the M2 & M240 mounted on it. I tried with "hitturret" and "hitgun" but that doesn't seem to work. Any idea where I could find the names of these parts ? I looked in the config viewer but I did not find anything. Share this post Link to post Share on other sites
meaty   34 Posted October 2 I've recently been trying to do exactly this so this code is a god send! However as some vehicles have a ton of hitpoints that differ between vehicles (especially modded ones) i'd rather say which ones to protect just to save a ton of work. But i am having an issue where the code for "hit points to protect" doest seem to be working at all and the vehicle just takes damage as normal. Does it need more than just the ! in the line to work?  On 8/30/2018 at 6:11 PM, POLPOX said: this addEventHandler ["HandleDamage",{!(_this#7 in [/*HitPoints to protect*/])}]   thanks  meaty Share this post Link to post Share on other sites
JCataclisma   79 Posted October 2 @meaty "/*HitPoints to protect*/" is NOT what you must use: it's just an example, so you need to add there the names of the hit parts you desire to protect. You can find the specific names of such part by righ-clicking on the vehicle in editor, then looking at its config file. Take a look at Polpox' message again, so you can see what was used: {(_this#7 in ["hitlfwheel","hitlbwheel","hitlmwheel","hitlf2wheel","hitrfwheel","hitrbwheel","hitrmwheel","hitrf2wheel"])} Share this post Link to post Share on other sites
meaty   34 Posted October 3 guess i should have been a little clearer 🙂 I am using the actual hit point names, but it doesn't work.  So for example this code works in that only the tyres, turret, and engine parts get damaged  this addEventHandler ["HandleDamage",{(_this#7 in ["hitlfwheel","hitlbwheel","hitlmwheel","hitlf2wheel","hitrfwheel","hitrbwheel","hitrmwheel","hitrf2wheel","hitturret","hitengine"])}] however if you use this addEventHandler ["HandleDamage",{!(_this#7 in ["hitlfwheel","hitlbwheel","hitlmwheel","hitlf2wheel","hitrfwheel","hitrbwheel","hitrmwheel","hitrf2wheel""hitturret","hitengine"])}] then the vehicle takes damage as it normally would without any code. 1 Share this post Link to post Share on other sites
pierremgi   4850 Posted October 3 That's because your EH code returns true or false depending on each hit. When returning false, there is no damage on part. so: (_this#7 in ["hitlfwheel","hitlbwheel","hitlmwheel","hitlf2wheel","hitrfwheel","hitrbwheel","hitrmwheel","hitrf2wheel","hitturret","hitengine"]) means , for each part (and multiple times): hit point (cfg name) in the array  --> takes damage , not the other ones (hit body, hit hull, hit lights...)  see 1st array of getAllHitPointsDamage cursorObject for example  if you write: !(_this#7 in ["hitlfwheel","hitlbwheel","hitlmwheel","hitlf2wheel","hitrfwheel","hitrbwheel","hitrmwheel","hitrf2wheel","hitturret","hitengine"]) , vehicle will take damage on ALL other parts than those inside the array.  The problem comes from the "hithull" part which should be protected for avoiding a late explosion (hard coded arma engine) and... I can't say why, the empty hit parts ("") you can't grab by getAllHitPointsDamage 1st array, but appearing in selection names (2nd array). I can't explain but you can test:  !(_this#7 in ["hitlfwheel","hitlbwheel","hitlmwheel","hitlf2wheel","hitrfwheel","hitrbwheel","hitrmwheel","hitrf2wheel","hitturret","hitengine","hithull",""])  It seems convoluted for breaking glasses, lights and fuel...  To conclude, don't use a reverse condition: !(cond) but prefer a direct one (cond) each time you can.       1 Share this post Link to post Share on other sites