A breakdown of PSprites, weapon states, overlays etc

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
User avatar
Nash
 
 
Posts: 17465
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

A breakdown of PSprites, weapon states, overlays etc

Post by Nash »

Can someone write a clear breakdown of the various components that make up the PSprite system? This has always been hit and miss for me and I always get confused.

I am always confused on whether I should act upon the owner, the invoker. I'm unsure if I should do something to a PSprite or to the weapon itself. Then throw in overlays and it gets even more confusing where do they fit in the picture. :S

I'm sorry if this question is vague - the entire topic is so confusing that I don't even know HOW to ask coherently. :S
User avatar
Rachael
Posts: 13793
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her

Re: A breakdown of PSprites, weapon states, overlays etc

Post by Rachael »

Moved to scripting - honestly, I think it has a better chance of being answered here, anyway.
User avatar
neoworm
Posts: 1748
Joined: Fri Sep 23, 2005 9:17 am
Location: Czech Republic

Re: A breakdown of PSprites, weapon states, overlays etc

Post by neoworm »

I am watching this. I almost lost my mind when I was trying to make my attack buffer functions.
ZippeyKeys12
Posts: 111
Joined: Wed Jun 15, 2016 2:49 pm

Re: A breakdown of PSprites, weapon states, overlays etc

Post by ZippeyKeys12 »

You probably know most of this but I want to be thorough. I'm also probably not the best source but nobody has answered so far.

Scope
Owner is the player, invoker is the weapon.
The weapon would be used for sequences of states which can be changed using PSprites and [wiki=Category:Decorate_Jump_functions]jumps[/wiki]
PSprites can be used to check first state of a state sequence: player.GetPSprite(<LAYER>).CurState
They're also used to set states in action functions such as: A_GunFlash and A_Lower

Overlays
Overlays are a separate simultaneously running set of states for a weapon that act exactly the same as the weapon itself. Special states are not triggered though (Fire, Altfire, Reload, etc). There's [wiki=A_OverlayFlags]flags[/wiki] and [wiki=A_OverlayRenderstyle]renderstyles[/wiki] you can set and it can be offset just like the base weapon layer.
For simultaneous fire and altfire, one would just make two layers for each hand and check the player's button.

PSprites
If you set a PSprite from another Actor it will continue until the state ends, however [wiki=Actor_states#Flow_control]hard-coded state jumps[/wiki] work.
On the other hand, an action function jump will terminate that overlay.
Another effect is that overlays created within the other object (one that state is from) are not created.
This is a thing I made a bit ago using PSprites.
Once I actually finish the system it'll use StateProviders as the source of states, but it works.
A weird quirk I haven't bothered looking into is the fact that hitscans don't leave decals, but projectiles do.
There are a ton more problems with setting the PSP_WEAPON's PSprite manually (for external states), but I don't recommend doing that so I'm not going to list them.

Let me know if there is something else you don't get, maybe I'll be able to help.
Also, it's very late at night so point out anything that doesn't make sense and I'll fix it when I'm more awake.
User avatar
Nash
 
 
Posts: 17465
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

Re: A breakdown of PSprites, weapon states, overlays etc

Post by Nash »

Why is it when attempting to check what state a weapon is currently in (let's say I want to monitor for the weapon's Fire and Reload state) I have to do it on the PSprite, and not the Weapon itself?
User avatar
Arctangent
Posts: 1235
Joined: Thu Nov 06, 2014 1:53 pm

Re: A breakdown of PSprites, weapon states, overlays etc

Post by Arctangent »

Because it's not the Weapon that's running said state, but the PSprite. If the Weapon still exists ( I think this is the case, but I'm not 100% ) then it's just in some sort of "phantom" state that allows its properties and states to be accessed while basically removing itself from the map, while the PSprite is the one actually doing all the stuff and calling all of the Weapon's functions. So if you try to get the Weapon's state, well, it has one, but it won't be the one that's being shown on the player's screen because that's another entity entirely.
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: A breakdown of PSprites, weapon states, overlays etc

Post by Graf Zahl »

To be precise, it is the PLAYER running the weapon sprites. A PSprite is just one display layer for the HUD weapon display. This cannot be part of the player struct because each layer has its own state. The weapon itself is just an item in the inventory which itself does nothing while being owned by the player.

Return to “Scripting”