nosoop / SM-TFCustomWeaponsX

SourceMod plugin that allows players to use custom TF2 items.
GNU General Public License v3.0
21 stars 11 forks source link

Prevent "Refund Upgrades" button in MvM from removing custom attributes until respawn #15

Closed SoulBlast35 closed 3 years ago

SoulBlast35 commented 3 years ago

Self-explanatory. Custom Weapons 3 does this natively, and its just a little improvement I thought of

nosoop commented 3 years ago

The issue appears to happen because the game wipes runtime attributes matching the name of the upgrade; any attribute that isn't associated with an upgrade is preserved (such as attach particle effect, <attribute> HIDDEN variations).

The easiest fix for a server operator would be to use one of the alternate attribute names with the same class (if any exists) for that attribute in the CWX item config so it doesn't get wiped in the first place. Bonus benefit of not displaying the upgrade as purchased in that case.

I don't do much modding for MvM; any idea if there are undesirable side effects that could happen if the player was regranted the item when respeccing?

SoulBlast35 commented 3 years ago

I generally do try to use non-conflicting upgrades, I think it might be due to how CWX handles Weapon Permanence whereas CW3 refreshed the weapon if you did anything that updated it. Basically, every single time you bought an upgrade on a weapon, CW3 would regrant the weapon but it would have the bought upgrade. Dont quote me on this, but I think the reason why it worked is because when you clicked "Refund Upgrades", the game refunds them and respawns you. My theory is CW3 took this opportunity upon respawn to regrant the weapon to you, thereby placing the correct attributes back on the weapon. But for some reason, CWX doesnt do this. Is it possible to create a special case to regrant currently equipped weapons upon clicking "Refund Upgrades"?

As for side effects, the only one I had is that manually removing upgrades with the "-" buttons did not work at all. The point would be removed and the money count on the upgrade menu itself would update, but the "ching" sound did not play and the actual HUD money counter did not increase, and exiting the Upgrade menu basically just caused the upgrade points to come back.

nosoop commented 3 years ago

CW3 always refreshes the weapon once the game has (re)spawned weapons as necessary based on ownership / inventory, yes. The game happens to reapply upgrades at some point after CW3 inserts its own weapons, though I'm not sure at which point.

Is it possible to create a special case to regrant currently equipped weapons upon clicking "Refund Upgrades"?

That's the plan; it looks like the least invasive approach.

nosoop commented 3 years ago

Just pushed out the change for it as of the rr-36 build; please give it a test and let me know if that resolves the issue.

SoulBlast35 commented 3 years ago

Works fine from what I can tell. The only noticeable thing is that theres a very slight freeze after you hit the Refund button just before the plugin respawns you with your weapon. Other than that, works great. EDIT: Okay, the slight freeze I believe is due to the plugin possibly reloading a custom model. (I was testing it on the Force-Ten-Miniguns lol)