Raised This Month: $32 Target: $400
 8% 

[TF2] Dropped weapons


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
psychonic

BAFFLED
Join Date: May 2008
Old 07-19-2015 , 22:54   [TF2] Dropped weapons
Reply With Quote #1

I did some messing around with the new "dropped" weapons in TF2, and figured I'd share my findings.

Test plugin attached with gamedata. Creating a dropped weapon works fine with zero quirks. (Everything is initialized properly). And picking any dropped weapon entity works as well. You do still have to manually remove/unequip weapons when "dropping" them (else, you're just creating a copy).

glhf
Attached Files
File Type: sp Get Plugin or Get Source (dropped-weapons.sp - 1466 views - 4.0 KB)
File Type: txt dropped-weapons.games.txt (1,023 Bytes, 710 views)
psychonic is offline
Potato Uno
Veteran Member
Join Date: Jan 2014
Location: Atlanta, Georgia
Old 07-20-2015 , 00:15   Re: [TF2] Dropped weapons
Reply With Quote #2

So this actually makes a direct call to the game's drop weapon function? Holy shit, you are the boss. <3

EDIT: Just gonna throw my fail attempt at making a dropped weapon here https://forums.alliedmods.net/showthread.php?t=265850 as it requires no gamedata (temporary alternative if the gamedata ever breaks).

Last edited by Potato Uno; 07-20-2015 at 00:18.
Potato Uno is offline
psychonic

BAFFLED
Join Date: May 2008
Old 07-20-2015 , 06:36   Re: [TF2] Dropped weapons
Reply With Quote #3

Quote:
Originally Posted by Potato Uno View Post
EDIT: Just gonna throw my fail attempt at making a dropped weapon here https://forums.alliedmods.net/showthread.php?t=265850 as it requires no gamedata (temporary alternative if the gamedata ever breaks).
Seeing that is what made me want to toy with this. There's another 30+ variables that get copied over from the original weapon that aren't getting set in that snippet (some of them netprops, and some not), which explains why you said you had some issues with it.

Last edited by psychonic; 07-20-2015 at 06:37.
psychonic is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 07-20-2015 , 10:00   Re: [TF2] Dropped weapons
Reply With Quote #4

Out of curiosity, does CBaseCombatCharacter::Weapon_Detach need to be called somewhere? I'm not sure what it does, but I noticed TF2 uses it internally right before it removes the old weapon when a player swaps their weapon with one on the ground. That is, after the new dropped weapon is created and initialized, but before the one they have equipped is destroyed.

(Side note: It's not called when a player dies and drops a weapon)
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 07-20-2015 at 10:06.
Powerlord is offline
psychonic

BAFFLED
Join Date: May 2008
Old 07-20-2015 , 10:17   Re: [TF2] Dropped weapons
Reply With Quote #5

When using the function for picking up weapons in the plugin on the first post, I believe it automatically handles removing the entity for the existing equipped weapon.

One thing that I forgot to note is that iirc, when picking up a dropped weapon with this method, the dropped one stays on the ground. You would have to manually remove that one.

I didn't test anything with removing current weapon when making a dropped copy of it.
psychonic is offline
Michalplyoutube
Veteran Member
Join Date: Jan 2013
Location: Tank Carrier in Mannhatt
Old 07-20-2015 , 15:49   Re: [TF2] Dropped weapons
Reply With Quote #6

So how we apply attributes?
Easiest would be TF2 Attrib but is there any other way?
__________________
The plugin developer of TF2BWR Reborn
And a TF2 Player
Michalplyoutube is offline
psychonic

BAFFLED
Join Date: May 2008
Old 07-20-2015 , 15:51   Re: [TF2] Dropped weapons
Reply With Quote #7

Quote:
Originally Posted by Michalplyoutube View Post
So how we apply attributes?
Easiest would be TF2 Attrib but is there any other way?
Create a weapon with TF2Items. Use that weapon as the source for the dropped weapon. Then, remove that weapon entity.
psychonic is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 07-20-2015 , 15:52   Re: [TF2] Dropped weapons
Reply With Quote #8

Quote:
Originally Posted by Michalplyoutube View Post
So how we apply attributes?
Easiest would be TF2 Attrib but is there any other way?
If you're using TF2Items, its TF2Items_OnGiveNamedItem is still called when you pick up an item from the ground. I assume CTFPlayer::PickupWeaponFromOther calls OnGiveNamedItem.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 07-20-2015 at 15:52.
Powerlord is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 07-20-2015 , 15:53   Re: [TF2] Dropped weapons
Reply With Quote #9

Quote:
Originally Posted by psychonic View Post
Create a weapon with TF2Items. Use that weapon as the source for the dropped weapon. Then, remove that weapon entity.
Does that work if you pass its weapon with the world as the client?
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
psychonic

BAFFLED
Join Date: May 2008
Old 07-20-2015 , 16:06   Re: [TF2] Dropped weapons
Reply With Quote #10

Quote:
Originally Posted by Powerlord View Post
Does that work if you pass its weapon with the world as the client?
World as client will very likely not work. There's a better chance that INVALID_ENT_REFERENCE would.

Last edited by psychonic; 07-20-2015 at 16:16.
psychonic is offline
Reply



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 11:27.


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