HUD models always reference ReadyWeapon

Wed Dec 23, 2020 12:21 pm

This is a bit of a personal gripe due to some hackery I do with psprites belonging to different callers. I am readily aware that what I'm asking for may open up a whole can of worms with how things are currently set up.

psprites that are set to use states from callers that are not the player's current weapon will still use the same model as that weapon. This is because functions like RenderHUDModel will always fetch model frames for the ReadyWeapon's class, rather than the caller's (which in 99.9% of cases is the ReadyWeapon anyway).

I've personally done some changes to RenderHUDModel, PreparePlayerSprites and IsHUDModelForPlayerAvailable that should fix this and I'm currently testing if anything breaks. If this turns out to be acceptable I'll open a PR for it. The main change is merely swapping player->ReadyWeapon->GetClass() with psp->Caller->GetClass() in calls to FindModelFrame. It works as I'd expect, but I can't guarantee nothing will break, hence all the testing.

Edit: Now, I know well that this could be simply worked around by adding those sprites to the MODELDEF of the weapon... but they would have to be added to ALL weapons to account for all potential combinations, which is honestly counter-intuitive.

PS: I've also changed IsHUDModelForPlayerAvailable so it checks for PSP_STRIFEHANDS too, mainly so those can be modelled too.

Re: HUD models always reference ReadyWeapon

Wed Dec 23, 2020 1:49 pm

I support this! When I write my Onslaught! TC I ran into this issue when I wanted to have differnent shields as overlays along with any melee weapon. I had to put all the shield MODELDEFS inside the entries of all the weapons which seemed really odd and also a nightmare if something has to be changed (because it would have to be changed for all weapon entries even though it's always the same shield).

Re: HUD models always reference ReadyWeapon

Thu Dec 24, 2020 10:02 am

I'd say this seems to be working fine, so once I've crafted an example wad I'll send in the pull request.