Allow player states for PSprites

Moderator: GZDoom Developers

Jarewill
 
 
Posts: 1821
Joined: Sun Jul 21, 2019 8:54 am

Allow player states for PSprites

Post by Jarewill »

Currently you cannot use states within the player class as PSprites, or at least any layer other than -1.
Trying to do so will print an error stating the state is not flagged for use in weapons.
However if you try to do it on layer -1 (strife burning hands) it will work fine, could this behavior be extended to all other layers?

This will allow modders to define overlays that are independent of the weapon and persist between weapon switching.
This will also fruther deprecate the use of CustomInventory items, as they are the only way of achieving such overlays so far.

Quick player class for testing purposes:

Code: Select all

Class OverlayPlayer : DoomPlayer{
	Override void Tick(){
		Super.Tick();
		//Press the reload key to activate the overlay
		If(player.cmd.buttons&BT_RELOAD&&!(player.oldbuttons&BT_RELOAD)){
			//Layer 2 prints an error, layer -1 works fine
			player.SetPSprite(2,FindState("Gun"));
		}
	}
	States{
	Gun:
		SHTG D 1;
		Loop;
	}
}
User avatar
phantombeta
Posts: 2119
Joined: Thu May 02, 2013 1:27 am
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: Brazil

Re: Allow player states for PSprites

Post by phantombeta »

Already in, you just need to set the correct qualifier on the states block, like so:

Code: Select all

States (Weapon, Overlay) {
    Gun:
        SHTG D 1;
        Loop;
}
Available qualifiers are Actor, Weapon, Item and Overlay. You can also change the default qualifiers like this:

Code: Select all

Default {
    DefaultStateUsage SUF_ACTOR | SUF_WEAPON | SUF_OVERLAY;
}
It's kind of an obscure feature, I couldn't even find any documentation for it on the wiki to link here.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49183
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Allow player states for PSprites

Post by Graf Zahl »

The last one was only exported because the internal base classes need it. Unless you define a new base class that manages non-actor states there won't be any need to change the default. This was mainly meant for backwards compatibility with existing unannotated code.
Jarewill
 
 
Posts: 1821
Joined: Sun Jul 21, 2019 8:54 am

Re: Allow player states for PSprites

Post by Jarewill »

phantombeta wrote: Thu Oct 17, 2024 2:42 pm Already in, you just need to set the correct qualifier on the states block, like so:
Oh.... My bad then, I didn't know.
Thanks phantom!

Return to “Closed Feature Suggestions [GZDoom]”