Skip to content

Commit

Permalink
Added PSpriteTick virtual
Browse files Browse the repository at this point in the history
  • Loading branch information
Boondorl authored and madame-rachelle committed Apr 21, 2024
1 parent b0137e5 commit c622c63
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
5 changes: 5 additions & 0 deletions wadsrc/static/zscript/actors/actor.zs
Expand Up @@ -509,6 +509,11 @@ class Actor : Thinker native
native clearscope void DisableLocalRendering(uint playerNum, bool disable);
native ui bool ShouldRenderLocally(); // Only clients get to check this, never the playsim.

// Called when the Actor is being used within a PSprite. This happens before potentially changing PSprite
// state so that any custom actions based on things like player input can be done before moving to the next
// state of something like a weapon.
virtual void PSpriteTick(PSprite psp) {}

// Called by inventory items to see if this actor is capable of touching them.
// If true, the item will attempt to be picked up. Useful for things like
// allowing morphs to pick up limited items such as keys while preventing
Expand Down
22 changes: 16 additions & 6 deletions wadsrc/static/zscript/actors/player/player.zs
Expand Up @@ -2708,13 +2708,23 @@ class PSprite : Object native play
{
if (processPending)
{
// drop tic count and possibly change state
if (Tics != -1) // a -1 tic count never changes
if (Caller)
{
Tics--;
// [BC] Apply double firing speed.
if (bPowDouble && Tics && (Owner.mo.FindInventory ("PowerDoubleFiringSpeed", true))) Tics--;
if (!Tics && Caller != null) SetState(CurState.NextState);
Caller.PSpriteTick(self);
if (bDestroyed)
return;
}

if (processPending)
{
// drop tic count and possibly change state
if (Tics != -1) // a -1 tic count never changes
{
Tics--;
// [BC] Apply double firing speed.
if (bPowDouble && Tics && (Owner.mo.FindInventory ("PowerDoubleFiringSpeed", true))) Tics--;
if (!Tics && Caller != null) SetState(CurState.NextState);
}
}
}
}
Expand Down

0 comments on commit c622c63

Please sign in to comment.