AlliedModders (
-   TF2Items (
-   -   Missing weapons when overwriting in OGNI (

nosoop 03-22-2019 05:58

Missing weapons when overwriting in OGNI
1 Attachment(s)
Been having trouble for the longest time trying to replace weapons in the TF2Items_OnGiveNamedItem forward. I want to believe it's user error, but nothing obvious stands out to me.

Tested the attached plugin against the following on a fresh Linux server (requires Econ Data):
  • MM:S 1.11.0-git1125
  • SM 1.9.0-git6275
  • TF2Items 1.6.4-hg279

The expected outcome is that the bots (and player) spawn with replacement items, but the bots usually end up equipped with either one stock item or no items at all, though the debugging messages indicate that the item selection process was successful.

Powerlord 04-06-2019 03:43

Re: Missing weapons when overwriting in OGNI
I can make some guesses:

You can't change the item class of a weapon in a TF2Items_OnGiveNamedItem callback. If you try, the game will reject your change and end up giving them nothing in that slot.

What you can do is block the item, then give them a different weapon a frame later.

nosoop 04-07-2019 14:26

Re: Missing weapons when overwriting in OGNI
1 Attachment(s)

Originally Posted by Powerlord (Post 2646514)
What you can do is block the item, [...].

Thanks; might just have to do that. The guess is reasonable enough.

At the very least, that solution avoids having the unnecessary stock weapon spawn since it'll be replaced 100% of the time.

The other issue which I neglected to mention was that I was also looking to bypass spawning the dropped item altogether and recreating the weapon every time a bot touches the resupply cabinet (which, as it currently works, I have to additionally manage things like copying back the Ubercharge meter and killing said dropped weapons).

I'm looking into solutions for that (I believe it's somewhere within CTFPlayer::ManageRegularWeapons(), could also refer to STT's implementation, worst case I can call CTFPlayer::PickupWeaponFromOther() after I figure out what weapons were just dropped).

That's another discussion altogether though -- this one is specifically to verify whether I'm hitting a (TF2Items / PEBKAC / non-) issue in TF2Items' OGNI forward.


New info before I hit the bed: I've narrowed it down even further by making it only affect Soldier primaries (turning them all into copies of the Black Box). While it spawns correctly on my client, it doesn't seem to work with bot players at all. Bots only have their secondary and melee weapons available, but only the melee can be seen in the inspect panel.

New, even shorter test case attached.

All times are GMT -4. The time now is 01:16.

Powered by vBulletin®
Copyright ©2000 - 2021, vBulletin Solutions, Inc.