diff --git a/src/d_player.h b/src/d_player.h index bb0c7676a..c899d8f0d 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -94,7 +94,6 @@ public: bool ResetAirSupply (bool playgasp = true); int GetMaxHealth(bool withupgrades = false) const; - AActor *PickNewWeapon (PClassActor *ammotype); void GiveDeathmatchInventory (); void GiveDefaultInventory (); diff --git a/src/fragglescript/t_func.cpp b/src/fragglescript/t_func.cpp index 3358b390e..6c475c0f8 100644 --- a/src/fragglescript/t_func.cpp +++ b/src/fragglescript/t_func.cpp @@ -49,6 +49,7 @@ #include "g_levellocals.h" #include "actorinlines.h" #include "scriptutil.h" +#include "vm.h" static FRandom pr_script("FScript"); @@ -2550,8 +2551,13 @@ void FParser::SF_PlayerWeapon() if (players[playernum].PendingWeapon==wp) players[playernum].PendingWeapon=WP_NOCHANGE; if (players[playernum].ReadyWeapon==wp) { - players[playernum].ReadyWeapon=NULL; - players[playernum].mo->PickNewWeapon(NULL); + players[playernum].ReadyWeapon=nullptr; + + IFVM(PlayerPawn, PickNewWeapon) + { + VMValue param[] = { players[playernum].mo, (void*)nullptr }; + VMCall(func, param, 2, nullptr, 0); + } } } } diff --git a/src/p_user.cpp b/src/p_user.cpp index 253809a6a..fcd81b686 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -938,29 +938,6 @@ void APlayerPawn::PostBeginPlay() } } -//=========================================================================== -// -// APlayerPawn :: PickNewWeapon -// -// Picks a new weapon for this player. Used mostly for running out of ammo, -// but it also works when an ACS script explicitly takes the ready weapon -// away or the player picks up some ammo they had previously run out of. -// -//=========================================================================== - -AActor *APlayerPawn::PickNewWeapon(PClassActor *ammotype) -{ - AActor *best = nullptr; - IFVM(PlayerPawn, PickNewWeapon) - { - VMValue param[] = { player->mo, ammotype }; - VMReturn ret((void**)&best); - VMCall(func, param, 2, &ret, 1); - } - - return best; -} - //=========================================================================== // // APlayerPawn :: GiveDeathmatchInventory