Raised This Month: $ Target: $400
 0% 

Solved [L4D2] Find entities/models attached to survivors?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Qtheman
Junior Member
Join Date: Oct 2010
Old 10-19-2020 , 03:52   [L4D2] Find entities/models attached to survivors?
Reply With Quote #1

Okay, how to explain this...

Well, I posted my Weapon Skin Manager plugin a few days ago, and as I mentioned in the post, there's a bug I'm aware of with defibrillators - namely, the defib-sans-paddles model doesn't get the correct skin, it just resets to the default when equipped.

I don't know if that makes sense, so to explain: if there's a defib with skin 1 on the ground and a survivor picks it up, then it'll have skin 1 applied while on their back (holstered), or if they drop it in exchange for a first aid kit or whatever. However, when they actually equip it, the model on their back resets to skin 0 (the default), while the paddles they hold use skin 1 as they're supposed to.
As far as I'm aware, this bug only applies to the defibrillator. I suspect there might be a somewhat similar bug with ammo upgrades using their default skin when deployed, but I haven't had much chance to look into that yet (and even then, I have an idea as to how I might go about fixing it).

I will admit up-front that I don't know if it's the best approach, or even a good one, but the way I was hoping to fix this was by first saving each client's current defib skin to an array, and then, when a defib is brought out, to find the back (paddle-less) model via modelname, get its owner's/parent's (whatever the term would be here) client ID, and use that to select which array entry to use for its skin.

Of course, this was before I realized I can't figure out how to find entities by their modelname, or if it's even possible...
Is there some method I could use to do that? Or, alternatively, is there a way to get information on the models attached to a survivor's body? I assume there's both the "defibrillator weapon" entity and an "attachment" entity at work in this scenario, seeing as there are two distinct models when a player has the defib out, but I'm not sure where to start looking.

Thanks.
__________________
KyuuGryphon

Last edited by Qtheman; 10-20-2020 at 22:18. Reason: problem solved, thanks everyone :)
Qtheman is offline
cravenge
Veteran Member
Join Date: Nov 2015
Location: Middle of Nowhere
Old 10-19-2020 , 07:43   Re: [L4D2] Find entities/models attached to survivors?
Reply With Quote #2

You could try doing the GetPlayerWeaponSlot approach and reapplying the skin if necessary. I don't know if there's a better and even easier method at the moment but that's the only that comes in mind for now.
__________________
cravenge is offline
Qtheman
Junior Member
Join Date: Oct 2010
Old 10-19-2020 , 16:44   Re: [L4D2] Find entities/models attached to survivors?
Reply With Quote #3

I tried looking into that, but no dice. Thanks, though.

The thing is, the defibrillator weapon - the paddles the player holds in first-person/when they've got the defib out - keeps the correct skin value, as it should. The defib on the player's back when they don't have it out also has the correct skin, so the skin's getting saved with the weapon data as it should be. Other than the model attached to the player's back when they've got the paddles out, it seems to work perfectly fine.

I could've sworn I saw something somewhere in the netprops or something that sounded like it was about models attached to survivors, but I can't remember what it was now, and I didn't have the foresight to write it down.
__________________
KyuuGryphon
Qtheman is offline
Qtheman
Junior Member
Join Date: Oct 2010
Old 10-19-2020 , 19:40   Re: [L4D2] Find entities/models attached to survivors?
Reply With Quote #4

Apologies for the double-post.

Okay, I did some poking around now, and I came across m_iAddonBits. Google suggests that in CS:S, this is used to spawn client-side models for equipment attached to players, and from poking around a bit, I strongly suspect L4D/2 uses this as well - having the/a pistol(s) equipped and holstered, for instance, seems to add 2 to the value, for instance (or rather, it sets the second-lowest bit).

From poking around a bit, I think having the defib paddles out sets the second-highest bit, while having them on your back sets the fourth bit from the right (adding 64 or 8, respectively).

This is a start, because it at least gives me something I can start looking into - which I guess means, my question now is: Is there anything I can do from the server to client-side entities using SourceMod, or am I out of luck here?

Thanks again.

EDIT: Okay, did some more playing around by making a quick and dirty plugin to find entities by their model name - the entity the defib uses on the player's back without the paddles attached does not show up in the server's entity list when searched for, which seems to me to be confirmation that it's a client-side entity only.
__________________
KyuuGryphon

Last edited by Qtheman; 10-19-2020 at 20:23.
Qtheman is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 10-19-2020 , 22:14   Re: [L4D2] Find entities/models attached to survivors?
Reply With Quote #5

AFAIK the m_iAddonBits is just an attachment that doesn't represent a real entity, if you manipulate the values you can see that you can add at to your body some equipment that you don't have, like the gascan (from hardrain)

I think they added weapon skins to the game but wasn't implemented 100%

Maybe you will have to change some files through a vpk to achieve that.
__________________
Marttt is offline
Qtheman
Junior Member
Join Date: Oct 2010
Old 10-20-2020 , 01:17   Re: [L4D2] Find entities/models attached to survivors?
Reply With Quote #6

Oof... I tried poking around on a listen server for comparison, and unless client-side entities go unreported/undetected even on a listen server, then yeah, I guess there's no entity behind it... I guess that means it's all handled by the player entity, somehow?

I did a bit more playing around with m_iAddonBits, and I've at least determined that 64 is what makes the defib-sans-paddle model attach to the player's back, but it doesn't seem like I can do much with that knowledge...

I guess I'm going to have to approach this the hard way, then. When I was Googling to see if I could find anything useful, I stumbled upon this post. I figured it wouldn't hurt to give this a shot in-game using cheats, so I did, and:



It's a start, at least. I guess that makes my next question something a bit more simple: Can I add an offset to an entity's angles via a plugin? I'd certainly assume so, but vectors aren't something I've really tried touching yet.
__________________
KyuuGryphon
Qtheman is offline
Crasher_3637
AlliedModders Donor
Join Date: May 2012
Old 10-20-2020 , 05:08   Re: [L4D2] Find entities/models attached to survivors?
Reply With Quote #7

Quote:
Originally Posted by Qtheman View Post
Can I add an offset to an entity's angles via a plugin? I'd certainly assume so, but vectors aren't something I've really tried touching yet.
Yes, you can find numerous plugins that attach entities to certain objects (i.e. players) with offsets to adjust their position/angles. You can use SetEntPropVector or TeleportEntity, depending on your use case, to set the new position/angles of an entity.
__________________
AFK like JFK
Crasher_3637 is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 10-20-2020 , 10:49   Re: [L4D2] Find entities/models attached to survivors?
Reply With Quote #8

You can use this plugin as a base sample, it used to add melee on the back before LS update (now is deprecated).

https://forums.alliedmods.net/showthread.php?p=2324503
__________________

Last edited by Marttt; 10-21-2020 at 10:33.
Marttt is offline
Qtheman
Junior Member
Join Date: Oct 2010
Old 10-20-2020 , 22:18   Re: [L4D2] Find entities/models attached to survivors?
Reply With Quote #9

Ah, great! Thanks a ton, both of you!



I'll admit, this isn't the method I was hoping I'd have to use to get this working, but I'm very happy that it does! Just have to figure out the client transmit stuff to keep it from doing... well, this, but that's the biggest hurdle out of the way, I think.

Thanks again!
__________________
KyuuGryphon
Qtheman is offline
cravenge
Veteran Member
Join Date: Nov 2015
Location: Middle of Nowhere
Old 10-21-2020 , 07:12   Re: [L4D2] Find entities/models attached to survivors?
Reply With Quote #10

Turn the attached entity's index into a reference and save it in a global variable then check in SetTransmit whether said entity reference belongs to the client themselves or not, If so, then return Plugin_Handled.
__________________
cravenge is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 00:27.


Powered by vBulletin®
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Theme made by Freecode