Classes:PSprite
PSprites, often referred to as overlays by functions, are what store information about the sprites currently being drawn on the player's screen e.g. weapons. They have their own coordinate system compared to the HUD and are drawn underneath it. Unlike HUD elements, world lighting can directly affect PSprites. Players support multiple layers of PSprites denoted by their id. They are also ordered by id meaning layers with greater ids are drawn on top of other layers. For this reason what id you give you a PSprite should be considered carefully when adding overlays. PSprites can be created via PlayerInfo's GetPSprite(), SetPSprite(), and SetSafeFlash() functions. PSprites with an id of 0 are invalid and cannot be created.
Certain rules are preserved when players are ticking their PSprites:
- If the Caller is null, the PSprite is destroyed.
- If the Caller is an Inventory item and its owner is not the same as the PSprite's owner, the PSprite is destroyed.
- If the Caller is a Weapon and it's not the PSprite owner's current ReadyWeapon, the PSprite is destroyed.
These rules can be changed by creating a custom player class that overrides TickPSprites().
Functions that are intended to be called from a PSprite (e.g. a function in a weapon's state) should have the action
keyword. This allows the PSprite to properly set up the self, invoker, and stateInfo parameters to pass to it.
There are a few default layer ids that should be noted:
- PSP_STRIFEHANDS (-1) - Used for displaying the player's hand in Strife. This has special caller and state functionality and should be avoided entirely.
- PSP_WEAPON (1) - Displays the player's current ReadyWeapon.
- PSP_FLASH (1000) - Displays the muzzle flash when firing a weapon.
- PSP_TARGETCENTER (0x7FFFFFFF - 2) - Displays the center of the targeting powerup reticle from Strife. This should be avoided unless using from the appropriate powerup.
- PSP_TARGETLEFT (0x7FFFFFFF - 1) - Displays the left-hand side of the targeting powerup reticle from Strife. This should be avoided unless using from the appropriate powerup.
- PSP_TARGETRIGHT (0x7FFFFFFF) - Displays the right-hand side of the targeting powerup reticle from Strife. This should be avoided unless using from the appropriate powerup.
Fields
- readonly State CurState - State data for the PSprite's current state.
- Actor Caller - The Actor that owns the state this PSprite is using.
- readonly PSprite Next - A pointer to the next PSprite in the linked list. The head of the list is stored in a player's player field as psprites.
- readonly PlayerInfo Owner - The player that owns this PSprite.
- SpriteID Sprite - The current sprite being displayed by the PSprite. This is the same as GetSpriteIndex("SPRT").
- int Frame - The current frame of the sprite being displayed by the PSprite. In this case A = 0, B = 1, etc.
- readonly int ID - The ID given to the PSprite on creation.
- bool processPending - If set to false, the PSprite will not Tick(). Usually only relevant when first creating a PSprite so it does not tick on the same frame.
- double x - The current x offset from the center of the screen. Negative values shift left.
- double y - The current y offset from the center of the screen. Positive values shift down.
- double oldx - The x offset on the previous frame. Used for interpolation.
- double oldy - The y offset on the previous frame. Used for interpolation.
- Vector2 baseScale - The base scalar to apply to the PSprite before any other transformations. Used by the Weapon.WeaponScaleX/Y properties.
- Vector2 pivot - The pivot point to transform the PSprite about. This is relative to the PSprite's alignment. If bPivotPercent is set to true, this acts instead like a scalar of the sprite's texture size.
- Vector2 scale - The x and y scalars. This scales about the PSprite's pivot point.
- double rotation - The angle the PSprite it rotated by. This rotates it around its pivot point. Positive values rotate counter-clockwise.
- int HAlign - The horizontal alignment of the PSprite.
- PSPA_LEFT - Align to the leftmost part of the sprite's texture.
- PSPA_CENTER - Align to the sprite texture's horizontal center.
- PSPA_RIGHT - Align to the rightmost part of the sprite's texture.
- int VAlign - The vertical alignment of the PSprite.
- PSPA_TOP - Align to the top of the sprite's texture.
- PSPA_CENTER - Align to the sprite texture's vertical center.
- PSPA_BOTTOM - Align to the bottom of the sprite's texture.
- Vector2 Coord0 - The offset for the top left coordinate of the sprite's texture.
- Vector2 Coord1 - The offset for the bottom left coordinate of the sprite's texture.
- Vector2 Coord2 - The offset for the top right coordinate of the sprite's texture.
- Vector2 Coord3 - The offset for the bottom right coordinate of the sprite's texture.
- double alpha - The current transparency. The PSprite must have a render style set that can use it.
- bool firstTic - Denotes that it's the first tic of the PSprite. This is used to disable interpolation.
- bool InterpolateTic - All transformations of this PSprite should be interpolated for this tic only.
- int Tics - The number of tics remaining in the current state.
- uint Translation - The translation to apply to the sprite.
- bool bAddWeapon - Apply the weapon layer's offsets to this PSprite.
- bool bAddBob - Weapon bobbing offsets apply to this PSprite.
- bool bPowDouble - Allow the duration of all states to be cut in half if the owner has the powerup.
- bool bCVarFast - Allow the sv_fastweapons cheat to apply to this PSprite.
- bool bFlip - The sprite is mirrored across the y axis.
- bool bMirror - The offsets for the PSprite are mirrored across the y axis.
- bool bPlayerTranslated - Applies the same translation rules as the player to the PSprite.
- bool bPivotPercent - If true, the pivot field is read as a scale of the sprite's texture size instead of a coordinate offset.
- bool bInterpolate - If true, all actions are interpolated (offsetting, rotating, scaling).
Methods
Non-static
- void SetState(State newstate, bool pending = false)
- void Tick()
- void ResetInterpolation()
Related PlayerInfo Fields
Non-static
- PSprite FindPSprite(int id)
- PSprite GetPSprite(int id)
- void SetPSprite(int id, State stat, bool pending = false)
- void SetSafeFlash(Weapon weap, State flashstate, int index)