Unmorphing does not restore player weapon slots

Bugs that have been investigated and resolved somehow.

Moderator: GZDoom Developers

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 Reply
User avatar
AFADoomer
Posts: 1341
Joined: Tue Jul 15, 2003 4:18 pm
Contact:

Unmorphing does not restore player weapon slots

Post by AFADoomer »

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 22 times
Boondorl
Posts: 167
Joined: Wed Jul 11, 2018 10:57 pm

Re: Unmorphing does not restore player weapon slots

Post by Boondorl »

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().
User avatar
AFADoomer
Posts: 1341
Joined: Tue Jul 15, 2003 4:18 pm
Contact:

Re: Unmorphing does not restore player weapon slots

Post by AFADoomer »

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...
Boondorl
Posts: 167
Joined: Wed Jul 11, 2018 10:57 pm

Re: Unmorphing does not restore player weapon slots

Post by Boondorl »

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.
User avatar
AFADoomer
Posts: 1341
Joined: Tue Jul 15, 2003 4:18 pm
Contact:

Re: Unmorphing does not restore player weapon slots

Post by AFADoomer »

Thanks!

I think this is the last thing is keeping Blade of Agony's tanks from working as they used to *whew*.
User avatar
Nash
 
 
Posts: 17496
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: Unmorphing does not restore player weapon slots

Post by Nash »

Closing as fixed
Post Reply

Return to “Closed Bugs [GZDoom]”