fimpen 1 Posted July 5, 2018 Hello! What would be the easiest way to emulate losing your vest when getting hit? I've been looking around for a simple solution. The gist of it would be: Check if player has a vest on him If player gets hit (if possible; if hit in the body and not arms, legs, etc.) 1 in 20 chance that the vest is "destroyed" and removed from player. Would be nice if there is a simple way of making different chances of this happening for different kinds of vests. For example: a "heavy" vest might be more durable than a lighter one. Thus, harder to lose. Any ideas? 1 Share this post Link to post Share on other sites
fimpen 1 Posted July 5, 2018 OK, just found there's an event handler for this kind of thing, at least to detect a hit. Quote this addEventHandler ["HitPart", {this execVM "script.sqf"}]; So there might be a way of detecting if the player is hit in the body I suppose. But I cannot figure this one out. The wiki isn't too clear on the subject IMO. Share this post Link to post Share on other sites
Grumpy Old Man 3546 Posted July 5, 2018 3 minutes ago, fimpen said: OK, just found there's an event handler for this kind of thing, at least to detect a hit. So there might be a way of detecting if the player is hit in the body I suppose. But I cannot figure this one out. The wiki isn't too clear on the subject IMO. I'm sure the folks editing the wiki would appreciate any suggestions on how to make the wiki more 'clear'. Cheers 1 Share this post Link to post Share on other sites
fimpen 1 Posted July 5, 2018 1 hour ago, Grumpy Old Man said: I'm sure the folks editing the wiki would appreciate any suggestions on how to make the wiki more 'clear'. Cheers I'm sure they would. I'll make sure to contact them. Share this post Link to post Share on other sites
gokitty1199 225 Posted July 5, 2018 id love to be able to edit the wiki but i asked Dwarden a month ago and hes responded once but not since then so i guess no wiki account for me :( anyways is this what your looking for? checks if the player has a best when shot, if he does then check if he was hit in the chest, if he was hit in the chest then it has a 20 percent chance of him loosing the vest player addEventHandler ["HitPart", { params ["_unit", "_shooter", "_bullet", "_pos", "_vel", "_hitLoc"]; if ((vest _unit) != "") then { { if (_x == "HitChest" && 20 > random 100) then { removeVest _unit; }; } forEach _hitLoc; }; }]; 2 Share this post Link to post Share on other sites
fimpen 1 Posted July 10, 2018 On 7/5/2018 at 9:57 PM, gokitty1199 said: id love to be able to edit the wiki but i asked Dwarden a month ago and hes responded once but not since then so i guess no wiki account for me :( anyways is this what your looking for? checks if the player has a best when shot, if he does then check if he was hit in the chest, if he was hit in the chest then it has a 20 percent chance of him loosing the vest player addEventHandler ["HitPart", { params ["_unit", "_shooter", "_bullet", "_pos", "_vel", "_hitLoc"]; if ((vest _unit) != "") then { { if (_x == "HitChest" && 20 > random 100) then { removeVest _unit; }; } forEach _hitLoc; }; }]; Hey, thank you for the answer man! Although I cannot get this one to work. Do I need to set the Player as _unit in the parameters? Or maybe use _this as Player? Share this post Link to post Share on other sites
fimpen 1 Posted July 10, 2018 21 minutes ago, fimpen said: '...tLoc"]; _unit = (_this select 0); if ((|#|vest _unit) != "") then { { if (_x == "H....' Error vest: Type Array, expected Object This is the error I'm getting. Share this post Link to post Share on other sites
pierremgi 4890 Posted July 10, 2018 replace params ["_target", "_shooter", "_bullet", "_pos", "_vel", "_hitLoc"]; by (_this select 0) params ["_target", "_shooter", "_bullet", "_pos", "_vel", "_hitLoc"]; 1 1 Share this post Link to post Share on other sites
gokitty1199 225 Posted July 10, 2018 2 hours ago, pierremgi said: replace params ["_target", "_shooter", "_bullet", "_pos", "_vel", "_hitLoc"]; by (_this select 0) params ["_target", "_shooter", "_bullet", "_pos", "_vel", "_hitLoc"]; derp thank you Share this post Link to post Share on other sites
fimpen 1 Posted July 10, 2018 Thanks! So, would it be possible to change "vest" to an array of classnames? Share this post Link to post Share on other sites
gokitty1199 225 Posted July 10, 2018 1 hour ago, fimpen said: Thanks! So, would it be possible to change "vest" to an array of classnames? do you mean like get all the vests that are in the game? what are you trying to do with the array Share this post Link to post Share on other sites
fimpen 1 Posted July 10, 2018 17 minutes ago, gokitty1199 said: do you mean like get all the vests that are in the game? what are you trying to do with the array Nope. Like having an array of specific types of vests, i.e. using their classnames. Btw, still cannot get this script to work. I'm beginning to wonder if it has something to do with Arma's hit detection. Seems like different body parts are hit more or less at random sometimes. Or more likely: it's a conflict with using ACE, I guess they handle damage and hit locations differently. Might have to dig into ACE and see what I can find. Share this post Link to post Share on other sites
gokitty1199 225 Posted July 10, 2018 21 minutes ago, fimpen said: Nope. Like having an array of specific types of vests, i.e. using their classnames. Btw, still cannot get this script to work. I'm beginning to wonder if it has something to do with Arma's hit detection. Seems like different body parts are hit more or less at random sometimes. Or more likely: it's a conflict with using ACE, I guess they handle damage and hit locations differently. Might have to dig into ACE and see what I can find. ah. yea you can but you would need to modify the script to work along side it because as of right now it works with any vest. change if (_x == "HitChest" && 20 > random 100) to if (_x == "HitChest") and see if it works, remember its a random chance that it will remove the vest Share this post Link to post Share on other sites
pierremgi 4890 Posted July 11, 2018 Just for fun (shoot small caliber at head of "yourUnit"): yourUnit addEventHandler ["handledamage", { if ((_this select 1) == "head" && headgear (_this select 0) != "") exitWith { _h = headgear (_this select 0); removeHeadgear (_this select 0); _g = goggles (_this select 0); removeGoggles (_this select 0); _nv = ((assignedItems (_this select 0)) select {_x find "NV" > -1}) select 0; (_this select 0) unlinkItem _nv; _w = createVehicle ["WeaponHolderSimulated",ASLtoATL eyePos (_this select 0),[],0,"CAN_COLLIDE"]; _w addItemCargoGlobal [_h,1]; _w addItemCargoGlobal [_g,1]; _w addItemCargoGlobal [_nv,1]; _w setVelocity [5 * sin ((_this select 3) getdir (_this select 0)), 5 * cos ((_this select 3) getDir (_this select 0)), 0.3]; _w addTorque [random 0.02, random .02, random .02]; 0 } }]; 3 Share this post Link to post Share on other sites
fimpen 1 Posted July 11, 2018 9 hours ago, pierremgi said: Just for fun (shoot small caliber at head of "yourUnit"): yourUnit addEventHandler ["handledamage", { if ((_this select 1) == "head" && headgear (_this select 0) != "") exitWith { _h = headgear (_this select 0); removeHeadgear (_this select 0); _g = goggles (_this select 0); removeGoggles (_this select 0); _nv = ((assignedItems (_this select 0)) select {_x find "NV" > -1}) select 0; (_this select 0) unlinkItem _nv; _w = createVehicle ["WeaponHolderSimulated",ASLtoATL eyePos (_this select 0),[],0,"CAN_COLLIDE"]; _w addItemCargoGlobal [_h,1]; _w addItemCargoGlobal [_g,1]; _w addItemCargoGlobal [_nv,1]; _w setVelocity [5 * sin ((_this select 3) getdir (_this select 0)), 5 * cos ((_this select 3) getDir (_this select 0)), 0.3]; _w addTorque [random 0.02, random .02, random .02]; 0 } }]; I can already tell what it does from looking at it :D Nice one. I opened up Goko's Ballistics mod to look at at how he did it. Though I couldn't get it to work with vests (even without the other features). So, is "handledamage" if a unit/object receives actual damage? That might be a better way of doing what I'm thinking about. Share this post Link to post Share on other sites
fimpen 1 Posted July 11, 2018 Well, I've got no luck getting this to work even without ACE. Something I found out is that "Chest" doesn't seem to be a HitPart (at least not in game). All hits on the "chest" are actually body hits according to the game. Can't seem to find any chest location. The script doesn't work even if you switch out "HitChest" to "HitBody" though. Share this post Link to post Share on other sites
gokitty1199 225 Posted July 11, 2018 3 hours ago, fimpen said: Well, I've got no luck getting this to work even without ACE. Something I found out is that "Chest" doesn't seem to be a HitPart (at least not in game). All hits on the "chest" are actually body hits according to the game. Can't seem to find any chest location. The script doesn't work even if you switch out "HitChest" to "HitBody" though. fixed. used the hitPart event handler to see what the part of the body was actually called and the chest area is spine1/spine3(couldnt find spine2 if it exists) but its tested and working player addEventHandler ["HitPart", { (_this select 0) params ["_unit", "_shooter", "_bullet", "_pos", "_vel", "_hitLoc"]; if ((vest _unit) != "") then { { if (_x == "spine1" || _x == "spine2" || _x == "spine3" && 20 > random 100) then { removeVest _unit; }; } forEach _hitLoc; }; }]; Share this post Link to post Share on other sites
pierremgi 4890 Posted July 12, 2018 coming from getAllHitPointsDamage player (in debug console), the selection names are: ["face_hub","neck","head","pelvis","spine1","spine2","spine3","body","arms","hands","legs","body"] Yes, there are 2 "body"... Compared with the hit parts: ["hitface","hitneck","hithead","hitpelvis","hitabdomen","hitdiaphragm","hitchest","hitbody","hitarms","hithands","hitlegs","incapacitated"] the second selection name "body" seems to be linked with "incapacitated" hit part (as far as this is a part, rather a patch for some unconscious flag...Who knows?) Anyway, your selections are, imho: ["pelvis","spine1","spine2","spine3","body"] Share this post Link to post Share on other sites
gokitty1199 225 Posted July 12, 2018 8 minutes ago, pierremgi said: coming from getAllHitPointsDamage player (in debug console), the selection names are: ["face_hub","neck","head","pelvis","spine1","spine2","spine3","body","arms","hands","legs","body"] Yes, there are 2 "body"... Compared with the hit parts: ["hitface","hitneck","hithead","hitpelvis","hitabdomen","hitdiaphragm","hitchest","hitbody","hitarms","hithands","hitlegs","incapacitated"] the second selection name "body" seems to be linked with "incapacitated" hit part (as far as this is a part, rather a patch for some unconscious flag...Who knows?) Anyway, your selections are, imho: ["pelvis","spine1","spine2","spine3","body"] i noticed with the hitpart EH, in the area that is covered by most of the vests it just triggers the spine, couldnt get body hits Share this post Link to post Share on other sites