I'd like to add Reactive Target dink sound to players who get killed with a headshot while wearing a metal helmet. I know we can get the entity's base protection, but the value you get is dependent on what the player is wearing all over, not only on the bodypart that's getting hit.
Is there a way?
Solved Getting individual body part protection from HitInfo?
Discussion in 'Rust Development' started by rotten, Aug 24, 2017.
-
In HitInfo i believe there is a variable called something like IsHeadshot, might want to use that (nvm, didn't read the question properly)
Last edited by a moderator: Aug 24, 2017 -
-
Besides, you should ideally focus on performance last. Tweaking code as you find there’s an issue. Working around things that you’re not even sure would make a difference would most likely cause more issues in the future than it would by avoiding it now. At least from my experience anyway. Don’t get paranoid on what is laggy and what’s not. If you’re really uncertain add some debug timers. Spawn loads of player models and shoot them all within like 5 seconds. -
I'm pretty sure you can check the players inventory slots. With that you could do something like:
Code:public bool IsWearingHelmet(BasePlayer player) => (player.inventory.containerWear.GetSlot(3).amount == 0) ? false : true;
Code:public int HelmetType(BasePlayer player) { if (player.inventory.containerWear.GetSlot(3).amount == 0) return 0; //Return 0 meaning no helmet. List<int> armored = new List<int>() { 999, 1000, 1001, }; if (armored.Contains(player.inventory.containerWear.GetSlot(3).info.itemid)) return 1; //This will check if his/her helmet is armored, if so return 1 meaning it is armored. else return 2; //Return 2, meaning not armored. The armored list will contains things like facemasks. }
Also, itemSlot 3 might not be right. -
-
Thanks for the info, everyone!
[DOUBLEPOST=1503544630][/DOUBLEPOST]Upon looking further into it, I've found that you can get the damage multiplier by doing the following:
info.damageProperties.GetMultiplier(info.boneArea)
EDIT: God damn it. I'm very wrong.Last edited by a moderator: Aug 24, 2017