Unmorphing does not restore player weapon slots

Forum rules
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: Unmorphing does not restore player weapon slots

Re: Unmorphing does not restore player weapon slots

by Nash » Sun Apr 28, 2024 7:44 pm

Closing as fixed

Re: Unmorphing does not restore player weapon slots

by AFADoomer » Sun Apr 28, 2024 11:37 am

Thanks!

I think this is the last thing is keeping Blade of Agony's tanks from working as they used to *whew*.

Re: Unmorphing does not restore player weapon slots

by Boondorl » Sat Apr 27, 2024 7:58 pm

I've PR'd a fix to re-add the behavior back in. This is probably something that should be baked into MorphInto directly since it's very important but for now I'll go with a simple fix until I can get a more robust solution. I guess my only advice for people overriding the player unmorph function is to make sure not to miss it.

Re: Unmorphing does not restore player weapon slots

by AFADoomer » Sat Apr 27, 2024 4:58 pm

Yeah, I don't think weapon slots were intended to work, and this really is a mod-side bug - but this didn't happen in older versions, and really needs to be handled gracefully. Plus I'm running into problems in Blade of Agony where the player doesn't get their proper weapon selection ability back even if there aren't weapon slots defined in the morph PlayerPawn actors.

I can restore the proper weapon slot behavior by, in the PowerMorph descendant actor, saving a pointer to the alternative (original) actor, unmorphing, then calling WeaponSlots.SetupWeaponSlots(<saved alternative actor>).

I think the only time that the weapon slots get set is in PlayerPawn's PostBeginPlay and in the savegame code (call to WeaponSlots.SetupWeaponSlots(self);) - so I'm not sure why this is necessary, but...

Re: Unmorphing does not restore player weapon slots

by Boondorl » Sat Apr 27, 2024 4:16 pm

Interesting, I remember seeing a comment in the code about weapon slots on morphed Actors being unimplemented. Is this a new bug? I didn't really touch anything related to this part of the code but I wonder if I accidentally missed something the engine was doing while cleaning up the pointer substitution (though both morphing and player pawn substitution used the same code so it seems unlikely it'd mess with the weapon slots). Will have to look further to see what exactly it's doing here since I'm not sure how it's even updating the weapon slot to begin with.

Edit: Yeah, found the culprit. Unmorph in particular called SetupWeaponSlots. Seems it's not called while morphing because that's handled in the pawn's PostBeginPlay().

Unmorphing does not restore player weapon slots

by AFADoomer » Sat Apr 27, 2024 3:08 pm

This is a continuation of my earlier thread, but I've figured out what's actually happening.

If a player is morphed into a class that has weapon slots defined, the player's original weapon slots are not properly restored on unmorph.

Demo attached; use 'give morphtest' at the console, and you'll be morphed into a doomguy with a BFG assigned to weaponslot 1. Once the morph runs out (in 10 seconds), you'll be back to normal, but if you use 'give all', you'll see that pressing 1 will select the BFG still, not the chainsaw or fist.
Spoiler: The player class:
Attachments
MorphTestWeapons.pk3
(581 Bytes) Downloaded 24 times

Top