diff --git a/src/g_inventory/a_pickups.cpp b/src/g_inventory/a_pickups.cpp index da49bcab9..35fc071bf 100644 --- a/src/g_inventory/a_pickups.cpp +++ b/src/g_inventory/a_pickups.cpp @@ -225,35 +225,6 @@ AInventory *AInventory::NextInv () return item; } -//=========================================================================== -// -// AInventory :: DoRespawn -// -//=========================================================================== - -bool AInventory::DoRespawn () -{ - if (SpawnPointClass != NULL) - { - AActor *spot = NULL; - DSpotState *state = DSpotState::GetSpotState(); - - if (state != NULL) spot = state->GetRandomSpot(SpawnPointClass); - if (spot != NULL) - { - SetOrigin (spot->Pos(), false); - SetZ(floorz); - } - } - return true; -} - -DEFINE_ACTION_FUNCTION(AInventory, DoRespawn) -{ - PARAM_SELF_PROLOGUE(AInventory); - ACTION_RETURN_BOOL(self->DoRespawn()); -} - //=========================================================================== // // AInventory :: CallTryPickup diff --git a/src/g_inventory/a_pickups.h b/src/g_inventory/a_pickups.h index aace9f571..6b5b75486 100644 --- a/src/g_inventory/a_pickups.h +++ b/src/g_inventory/a_pickups.h @@ -75,8 +75,6 @@ public: void DepleteOrDestroy (); // virtual on the script side. - bool DoRespawn(); - AInventory *PrevInv(); // Returns the previous item with IF_INVBAR set. AInventory *NextInv(); // Returns the next item with IF_INVBAR set. diff --git a/src/g_shared/a_specialspot.cpp b/src/g_shared/a_specialspot.cpp index 77292a7dc..511833ff9 100644 --- a/src/g_shared/a_specialspot.cpp +++ b/src/g_shared/a_specialspot.cpp @@ -368,6 +368,13 @@ ASpecialSpot *DSpotState::GetRandomSpot(PClassActor *type, bool onlyonce) return NULL; } +DEFINE_ACTION_FUNCTION(DSpotState, GetRandomSpot) +{ + PARAM_SELF_PROLOGUE(DSpotState); + PARAM_CLASS(type, AActor); + PARAM_BOOL(onlyonce); + ACTION_RETURN_POINTER(self->GetRandomSpot(type, onlyonce)); +} //---------------------------------------------------------------------------- // diff --git a/wadsrc/static/zscript/base.txt b/wadsrc/static/zscript/base.txt index 672088f12..047a15fff 100644 --- a/wadsrc/static/zscript/base.txt +++ b/wadsrc/static/zscript/base.txt @@ -599,6 +599,7 @@ class SpotState : Object native native static SpotState GetSpotState(); native SpecialSpot GetNextInList(class type, int skipcounter); native SpecialSpot GetSpotWithMinMaxDistance(Class type, double x, double y, double mindist, double maxdist); + native SpecialSpot GetRandomSpot(class type, bool onlyonce); } diff --git a/wadsrc/static/zscript/inventory/inventory.txt b/wadsrc/static/zscript/inventory/inventory.txt index c76d7ec9c..2dcd1d857 100644 --- a/wadsrc/static/zscript/inventory/inventory.txt +++ b/wadsrc/static/zscript/inventory/inventory.txt @@ -49,7 +49,6 @@ class Inventory : Actor native Inventory.PickupMessage "$TXT_DEFAULTPICKUPMSG"; } - native bool DoRespawn(); native static void PrintPickupMessage (bool localview, String str); States(Actor) @@ -169,6 +168,29 @@ class Inventory : Actor native } } + //=========================================================================== + // + // AInventory :: DoRespawn + // + //=========================================================================== + + bool DoRespawn () + { + if (SpawnPointClass != NULL) + { + Actor spot = NULL; + let state = SpotState.GetSpotState(); + + if (state != NULL) spot = state.GetRandomSpot(SpawnPointClass, false); + if (spot != NULL) + { + SetOrigin (spot.Pos, false); + SetZ(floorz); + } + } + return true; + } + //=========================================================================== // // AInventory :: Grind