- scriptified A_SelectWeapon and inlined the last remaining use of APlayerPawn::SelectWeapon.

This commit is contained in:
Christoph Oelckers 2018-12-04 17:41:55 +01:00
parent 44e43c48b5
commit 2459b27895
3 changed files with 8 additions and 26 deletions

View File

@ -94,7 +94,6 @@ public:
bool ResetAirSupply (bool playgasp = true);
int GetMaxHealth(bool withupgrades = false) const;
AActor *PickNewWeapon (PClassActor *ammotype);
void GiveDeathmatchInventory ();
void GiveDefaultInventory ();

View File

@ -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);
}
}
}
}

View File

@ -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