diff --git a/src/actor.h b/src/actor.h index 4f37dcf98f..d3a6d94aad 100644 --- a/src/actor.h +++ b/src/actor.h @@ -1259,7 +1259,6 @@ public: void LinkToWorld (FLinkContext *ctx, bool spawningmapthing=false, sector_t *sector = NULL); void UnlinkFromWorld(FLinkContext *ctx); void AdjustFloorClip (); - bool InStateSequence(FState * newstate, FState * basestate); bool IsMapActor(); int GetTics(FState * newstate); bool SetState (FState *newstate, bool nofunction=false); diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 740bcb18ab..e26465e99c 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -425,7 +425,7 @@ AActor &AActor::operator= (const AActor &other) // //========================================================================== -bool AActor::InStateSequence(FState * newstate, FState * basestate) +static int InStateSequence(FState * newstate, FState * basestate) { if (basestate == NULL) return false; @@ -440,12 +440,19 @@ bool AActor::InStateSequence(FState * newstate, FState * basestate) return false; } -DEFINE_ACTION_FUNCTION(AActor, InStateSequence) +DEFINE_ACTION_FUNCTION(AActor, InStateSequence, InStateSequence) { - PARAM_SELF_PROLOGUE(AActor); + PARAM_PROLOGUE; PARAM_POINTER(newstate, FState); PARAM_POINTER(basestate, FState); - ACTION_RETURN_BOOL(self->InStateSequence(newstate, basestate)); + ACTION_RETURN_BOOL(InStateSequence(newstate, basestate)); +} + +DEFINE_ACTION_FUNCTION(FState, InStateSequence, InStateSequence) +{ + PARAM_SELF_STRUCT_PROLOGUE(FState); + PARAM_POINTER(basestate, FState); + ACTION_RETURN_BOOL(InStateSequence(self, basestate)); } diff --git a/wadsrc/static/zscript/actor.txt b/wadsrc/static/zscript/actor.txt index eed1118f4c..6b09698aaa 100644 --- a/wadsrc/static/zscript/actor.txt +++ b/wadsrc/static/zscript/actor.txt @@ -680,7 +680,7 @@ class Actor : Thinker native native void FindFloorCeiling(int flags = 0); native double, double GetFriction(); native bool, Actor TestMobjZ(bool quick = false); - native bool InStateSequence(State newstate, State basestate); + native static bool InStateSequence(State newstate, State basestate); bool TryWalk () { diff --git a/wadsrc/static/zscript/base.txt b/wadsrc/static/zscript/base.txt index 449e8aa09d..466529aeac 100644 --- a/wadsrc/static/zscript/base.txt +++ b/wadsrc/static/zscript/base.txt @@ -747,6 +747,7 @@ struct State native native int DistanceTo(state other); native bool ValidateSpriteFrame(); native TextureID, bool, Vector2 GetSpriteTexture(int rotation, int skin = 0, Vector2 scale = (0,0)); + native bool InStateSequence(State base); } struct F3DFloor native diff --git a/wadsrc/static/zscript/inventory/weapons.txt b/wadsrc/static/zscript/inventory/weapons.txt index 1c2d1d2e92..7eebdf3dc5 100644 --- a/wadsrc/static/zscript/inventory/weapons.txt +++ b/wadsrc/static/zscript/inventory/weapons.txt @@ -811,24 +811,32 @@ class Weapon : StateProvider let player = Owner.player; if (SisterWeapon != NULL && bPowered_Up) { - if (GetReadyState() != SisterWeapon.GetReadyState()) + let ready = GetReadyState(); + if (ready != SisterWeapon.GetReadyState()) { if (player.PendingWeapon == NULL || player.PendingWeapon == WP_NOCHANGE) + { player.PendingWeapon = SisterWeapon; + } + player.WeaponState |= WF_REFIRESWITCHOK; } else { let psp = player.FindPSprite(PSP_WEAPON); - if (psp != null && psp.Caller == player.ReadyWeapon) + if (psp != null && psp.Caller == player.ReadyWeapon && psp.CurState.InStateSequence(ready)) { // If the weapon changes but the state does not, we have to manually change the PSprite's caller here. psp.Caller = SisterWeapon; player.ReadyWeapon = SisterWeapon; } - else + else { - // Something went wrong. Initiate a regular weapon change. - player.PendingWeapon = SisterWeapon; + if (player.PendingWeapon == NULL || player.PendingWeapon == WP_NOCHANGE) + { + // Something went wrong. Initiate a regular weapon change. + player.PendingWeapon = SisterWeapon; + } + player.WeaponState |= WF_REFIRESWITCHOK; } } }