diff --git a/src/g_hexen/a_fighteraxe.cpp b/src/g_hexen/a_fighteraxe.cpp index fde3a9c18a..7036def950 100644 --- a/src/g_hexen/a_fighteraxe.cpp +++ b/src/g_hexen/a_fighteraxe.cpp @@ -21,38 +21,6 @@ static FRandom pr_axeatk ("FAxeAtk"); // The Fighter's Axe -------------------------------------------------------- -class AFWeapAxe : public AFighterWeapon -{ - DECLARE_CLASS (AFWeapAxe, AFighterWeapon) -public: - FState *GetUpState (); - FState *GetDownState (); - FState *GetReadyState (); - FState *GetAtkState (bool hold); -}; - -IMPLEMENT_CLASS(AFWeapAxe, false, false) - -FState *AFWeapAxe::GetUpState () -{ - return Ammo1->Amount ? FindState ("SelectGlow") : Super::GetUpState(); -} - -FState *AFWeapAxe::GetDownState () -{ - return Ammo1->Amount ? FindState ("DeselectGlow") : Super::GetDownState(); -} - -FState *AFWeapAxe::GetReadyState () -{ - return Ammo1->Amount ? FindState ("ReadyGlow") : Super::GetReadyState(); -} - -FState *AFWeapAxe::GetAtkState (bool hold) -{ - return Ammo1->Amount ? FindState ("FireGlow") : Super::GetAtkState(hold); -} - //============================================================================ // // A_FAxeCheckReady diff --git a/src/g_shared/a_pickups.h b/src/g_shared/a_pickups.h index bd252437d6..bc83199316 100644 --- a/src/g_shared/a_pickups.h +++ b/src/g_shared/a_pickups.h @@ -335,12 +335,12 @@ public: virtual bool Use (bool pickup); virtual void Destroy() override; - virtual FState *GetUpState (); - virtual FState *GetDownState (); - virtual FState *GetReadyState (); - virtual FState *GetAtkState (bool hold); - virtual FState *GetAltAtkState (bool hold); - virtual FState *GetStateForButtonName (FName button); + FState *GetUpState (); + FState *GetDownState (); + FState *GetReadyState (); + FState *GetAtkState (bool hold); + FState *GetAltAtkState (bool hold); + FState *GetStateForButtonName (FName button); virtual void PostMorphWeapon (); virtual void EndPowerup (); diff --git a/src/g_shared/a_weapons.cpp b/src/g_shared/a_weapons.cpp index 02cd19fa6d..e9d931520e 100644 --- a/src/g_shared/a_weapons.cpp +++ b/src/g_shared/a_weapons.cpp @@ -818,7 +818,16 @@ void AWeapon::CallEndPowerup() FState *AWeapon::GetUpState () { - return FindState(NAME_Select); + IFVIRTUAL(AWeapon, GetUpState) + { + VMValue params[1] = { (DObject*)this }; + VMReturn ret; + VMFrameStack stack; + FState *retval; + ret.PointerAt((void**)&retval); + stack.Call(func, params, 1, &ret, 1, nullptr); + return retval; + } } //=========================================================================== @@ -829,7 +838,16 @@ FState *AWeapon::GetUpState () FState *AWeapon::GetDownState () { - return FindState(NAME_Deselect); + IFVIRTUAL(AWeapon, GetDownState) + { + VMValue params[1] = { (DObject*)this }; + VMReturn ret; + VMFrameStack stack; + FState *retval; + ret.PointerAt((void**)&retval); + stack.Call(func, params, 1, &ret, 1, nullptr); + return retval; + } } //=========================================================================== @@ -840,7 +858,16 @@ FState *AWeapon::GetDownState () FState *AWeapon::GetReadyState () { - return FindState(NAME_Ready); + IFVIRTUAL(AWeapon, GetReadyState) + { + VMValue params[1] = { (DObject*)this }; + VMReturn ret; + VMFrameStack stack; + FState *retval; + ret.PointerAt((void**)&retval); + stack.Call(func, params, 1, &ret, 1, nullptr); + return retval; + } } //=========================================================================== @@ -851,11 +878,16 @@ FState *AWeapon::GetReadyState () FState *AWeapon::GetAtkState (bool hold) { - FState * state=NULL; - - if (hold) state = FindState(NAME_Hold); - if (state == NULL) state = FindState(NAME_Fire); - return state; + IFVIRTUAL(AWeapon, GetAtkState) + { + VMValue params[2] = { (DObject*)this, hold }; + VMReturn ret; + VMFrameStack stack; + FState *retval; + ret.PointerAt((void**)&retval); + stack.Call(func, params, 2, &ret, 1, nullptr); + return retval; + } } //=========================================================================== @@ -866,11 +898,16 @@ FState *AWeapon::GetAtkState (bool hold) FState *AWeapon::GetAltAtkState (bool hold) { - FState * state=NULL; - - if (hold) state = FindState(NAME_AltHold); - if (state == NULL) state = FindState(NAME_AltFire); - return state; + IFVIRTUAL(AWeapon, GetAltAtkState) + { + VMValue params[2] = { (DObject*)this, hold }; + VMReturn ret; + VMFrameStack stack; + FState *retval; + ret.PointerAt((void**)&retval); + stack.Call(func, params, 2, &ret, 1, nullptr); + return retval; + } } //=========================================================================== diff --git a/wadsrc/static/zscript/hexen/fighteraxe.txt b/wadsrc/static/zscript/hexen/fighteraxe.txt index 30b235192d..35049ab9a0 100644 --- a/wadsrc/static/zscript/hexen/fighteraxe.txt +++ b/wadsrc/static/zscript/hexen/fighteraxe.txt @@ -1,7 +1,7 @@ // The Fighter's Axe -------------------------------------------------------- -class FWeapAxe : FighterWeapon native +class FWeapAxe : FighterWeapon { Default { @@ -79,6 +79,28 @@ class FWeapAxe : FighterWeapon native FAXE A 1; Goto ReadyGlow; } + + override State GetUpState () + { + return Ammo1.Amount ? FindState ("SelectGlow") : Super.GetUpState(); + } + + override State GetDownState () + { + return Ammo1.Amount ? FindState ("DeselectGlow") : Super.GetDownState(); + } + + override State GetReadyState () + { + return Ammo1.Amount ? FindState ("ReadyGlow") : Super.GetReadyState(); + } + + override State GetAtkState (bool hold) + { + return Ammo1.Amount ? FindState ("FireGlow") : Super.GetAtkState(hold); + } + + } // Axe Puff ----------------------------------------------------------------- diff --git a/wadsrc/static/zscript/shared/inventory.txt b/wadsrc/static/zscript/shared/inventory.txt index f87331470c..f6c95f8bd6 100644 --- a/wadsrc/static/zscript/shared/inventory.txt +++ b/wadsrc/static/zscript/shared/inventory.txt @@ -580,6 +580,31 @@ class Weapon : StateProvider native return FindState('Ready'); } + virtual State GetUpState () + { + return FindState('Select'); + } + + virtual State GetDownState () + { + return FindState('Deselect'); + } + + virtual State GetAtkState (bool hold) + { + State s = null; + if (hold) s = FindState('Hold'); + if (s == null) s = FindState('Fire'); + return s; + } + + virtual State GetAltAtkState (bool hold) + { + State s = null; + if (hold) s = FindState('AltHold'); + if (s == null) s = FindState('AltFire'); + return s; + } native action void A_ZoomFactor(double scale = 1, int flags = 0); native action void A_SetCrosshair(int xhair);