Allow player states for PSprites

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: Allow player states for PSprites

Re: Allow player states for PSprites

by Jarewill » Fri Oct 18, 2024 2:38 pm

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!

Re: Allow player states for PSprites

by Graf Zahl » Thu Oct 17, 2024 3:00 pm

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.

Re: Allow player states for PSprites

by phantombeta » Thu Oct 17, 2024 2:42 pm

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.

Allow player states for PSprites

by Jarewill » Thu Oct 17, 2024 11:35 am

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;
	}
}

Top