- scriptified P_BringUpWeapon because this was the only native function still referencing AWeapon::GetReadyState.

This commit is contained in:
Christoph Oelckers 2018-11-24 17:22:59 +01:00
parent b4c272ddff
commit 9584e3bc53
6 changed files with 65 additions and 84 deletions

View File

@ -267,27 +267,6 @@ FState *AWeapon::GetDownState ()
return nullptr;
}
//===========================================================================
//
// AWeapon :: GetReadyState
//
//===========================================================================
FState *AWeapon::GetReadyState ()
{
IFVIRTUAL(AWeapon, GetReadyState)
{
VMValue params[1] = { (DObject*)this };
VMReturn ret;
FState *retval;
ret.PointerAt((void**)&retval);
VMCall(func, params, 1, &ret, 1);
return retval;
}
return nullptr;
}
/* Weapon slots ***********************************************************/
//===========================================================================

View File

@ -131,7 +131,6 @@ public:
// scripted virtuals.
FState *GetUpState ();
FState *GetDownState ();
FState *GetReadyState ();
enum
{

View File

@ -556,56 +556,11 @@ DEFINE_ACTION_FUNCTION(DPSprite, SetState)
void P_BringUpWeapon (player_t *player)
{
AWeapon *weapon;
if (player->PendingWeapon == WP_NOCHANGE)
IFVM(PlayerPawn, BringUpWeapon)
{
if (player->ReadyWeapon != nullptr)
{
player->GetPSprite(PSP_WEAPON)->y = WEAPONTOP;
P_SetPsprite(player, PSP_WEAPON, player->ReadyWeapon->GetReadyState());
}
return;
VMValue param = player->mo;
VMCall(func, &param, 1, nullptr, 0);
}
weapon = player->PendingWeapon;
// If the player has a tome of power, use this weapon's powered up
// version, if one is available.
if (weapon != nullptr &&
weapon->SisterWeapon &&
weapon->SisterWeapon->WeaponFlags & WIF_POWERED_UP &&
player->mo->FindInventory (PClass::FindActor(NAME_PowerWeaponLevel2), true))
{
weapon = weapon->SisterWeapon;
}
player->PendingWeapon = WP_NOCHANGE;
player->ReadyWeapon = weapon;
player->mo->weaponspecial = 0;
if (weapon != nullptr)
{
if (weapon->UpSound)
{
S_Sound (player->mo, CHAN_WEAPON, weapon->UpSound, 1, ATTN_NORM);
}
player->refire = 0;
player->GetPSprite(PSP_WEAPON)->y = player->cheats & CF_INSTANTWEAPSWITCH
? WEAPONTOP : WEAPONBOTTOM;
// make sure that the previous weapon's flash state is terminated.
// When coming here from a weapon drop it may still be active.
P_SetPsprite(player, PSP_FLASH, nullptr);
P_SetPsprite(player, PSP_WEAPON, weapon->GetUpState());
}
}
DEFINE_ACTION_FUNCTION(_PlayerInfo, BringUpWeapon)
{
PARAM_SELF_STRUCT_PROLOGUE(player_t);
P_BringUpWeapon(self);
return 0;
}
//---------------------------------------------------------------------------

View File

@ -678,15 +678,7 @@ FString FStringFormat(VM_ARGS, int offset = 0);
#define IFVM(cls, funcname) \
static VMFunction * func = nullptr; \
if (func == nullptr) { \
func = dyn_cast<PFunction>(RUNTIME_CLASS(cls)->FindSymbol(#funcname, false)); \
assert(func); \
} \
if (func != nullptr)
#define IFVMNAME(cls, funcname) \
static VMFunction * func = nullptr; \
if (func == nullptr) { \
func = dyn_cast<PFunction>(PClass::FindClass(cls)->FindSymbol(#funcname, false)); \
PClass::FindFunction(&func, #cls, #funcname); \
assert(func); \
} \
if (func != nullptr)

View File

@ -109,6 +109,14 @@ class Weapon : StateProvider native
return s;
}
virtual void PlayUpSound(Actor origin)
{
if (UpSound)
{
origin.A_PlaySound(UpSound, CHAN_WEAPON);
}
}
override String GetObituary(Actor victim, Actor inflictor, Name mod, bool playerattack)
{
// Weapons may never return HitObituary by default. Override this if it is needed.
@ -165,7 +173,7 @@ class Weapon : StateProvider native
}
if (null == player.ReadyWeapon)
{
player.BringUpWeapon();
player.mo.BringUpWeapon();
return;
}
let psp = player.GetPSprite(PSP_WEAPON);
@ -190,7 +198,7 @@ class Weapon : StateProvider native
}
// [RH] Clear the flash state. Only needed for Strife.
player.SetPsprite(PSP_FLASH, null);
player.BringUpWeapon ();
player.mo.BringUpWeapon ();
return;
}

View File

@ -421,7 +421,7 @@ class PlayerPawn : Actor native
if (player.ReadyWeapon == null)
{
if (player.PendingWeapon != WP_NOCHANGE)
player.BringUpWeapon();
player.mo.BringUpWeapon();
}
else
{
@ -1262,6 +1262,56 @@ class PlayerPawn : Actor native
}
}
//---------------------------------------------------------------------------
//
// PROC P_BringUpWeapon
//
// Starts bringing the pending weapon up from the bottom of the screen.
// This is only called to start the rising, not throughout it.
//
//---------------------------------------------------------------------------
void BringUpWeapon ()
{
if (player.PendingWeapon == WP_NOCHANGE)
{
if (player.ReadyWeapon != null)
{
player.GetPSprite(PSP_WEAPON).y = WEAPONTOP;
player.SetPsprite(PSP_WEAPON, player.ReadyWeapon.GetReadyState());
}
return;
}
let weapon = player.PendingWeapon;
// If the player has a tome of power, use this weapon's powered up
// version, if one is available.
if (weapon != null &&
weapon.SisterWeapon &&
weapon.SisterWeapon.bPowered_Up &&
player.mo.FindInventory ('PowerWeaponLevel2', true))
{
weapon = weapon.SisterWeapon;
}
player.PendingWeapon = WP_NOCHANGE;
player.ReadyWeapon = weapon;
player.mo.weaponspecial = 0;
if (weapon != null)
{
weapon.PlayUpSound(self);
player.refire = 0;
player.GetPSprite(PSP_WEAPON).y = player.cheats & CF_INSTANTWEAPSWITCH? WEAPONTOP : WEAPONBOTTOM;
// make sure that the previous weapon's flash state is terminated.
// When coming here from a weapon drop it may still be active.
player.SetPsprite(PSP_FLASH, null);
player.SetPsprite(PSP_WEAPON, weapon.GetUpState());
}
}
//----------------------------------------------------------------------------
//
@ -1503,7 +1553,6 @@ struct PlayerInfo native play // this is what internally is known as player_t
native void SetLogNumber (int text);
native void SetLogText (String text);
native void DropWeapon();
native void BringUpWeapon();
native bool Resurrect();
native String GetUserName() const;
@ -1567,7 +1616,6 @@ struct PlayerInfo native play // this is what internally is known as player_t
{
return (mo.ViewHeight + crouchviewdelta - viewheight) / 8;
}
}