mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-10 23:01:50 +00:00
- scriptified P_BringUpWeapon because this was the only native function still referencing AWeapon::GetReadyState.
This commit is contained in:
parent
b4c272ddff
commit
9584e3bc53
6 changed files with 65 additions and 84 deletions
|
@ -267,27 +267,6 @@ FState *AWeapon::GetDownState ()
|
||||||
return nullptr;
|
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 ***********************************************************/
|
/* Weapon slots ***********************************************************/
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
|
@ -131,7 +131,6 @@ public:
|
||||||
// scripted virtuals.
|
// scripted virtuals.
|
||||||
FState *GetUpState ();
|
FState *GetUpState ();
|
||||||
FState *GetDownState ();
|
FState *GetDownState ();
|
||||||
FState *GetReadyState ();
|
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
|
|
@ -556,56 +556,11 @@ DEFINE_ACTION_FUNCTION(DPSprite, SetState)
|
||||||
|
|
||||||
void P_BringUpWeapon (player_t *player)
|
void P_BringUpWeapon (player_t *player)
|
||||||
{
|
{
|
||||||
AWeapon *weapon;
|
IFVM(PlayerPawn, BringUpWeapon)
|
||||||
|
|
||||||
if (player->PendingWeapon == WP_NOCHANGE)
|
|
||||||
{
|
{
|
||||||
if (player->ReadyWeapon != nullptr)
|
VMValue param = player->mo;
|
||||||
{
|
VMCall(func, ¶m, 1, nullptr, 0);
|
||||||
player->GetPSprite(PSP_WEAPON)->y = WEAPONTOP;
|
|
||||||
P_SetPsprite(player, PSP_WEAPON, player->ReadyWeapon->GetReadyState());
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
|
@ -678,15 +678,7 @@ FString FStringFormat(VM_ARGS, int offset = 0);
|
||||||
#define IFVM(cls, funcname) \
|
#define IFVM(cls, funcname) \
|
||||||
static VMFunction * func = nullptr; \
|
static VMFunction * func = nullptr; \
|
||||||
if (func == nullptr) { \
|
if (func == nullptr) { \
|
||||||
func = dyn_cast<PFunction>(RUNTIME_CLASS(cls)->FindSymbol(#funcname, false)); \
|
PClass::FindFunction(&func, #cls, #funcname); \
|
||||||
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)); \
|
|
||||||
assert(func); \
|
assert(func); \
|
||||||
} \
|
} \
|
||||||
if (func != nullptr)
|
if (func != nullptr)
|
||||||
|
|
|
@ -109,6 +109,14 @@ class Weapon : StateProvider native
|
||||||
return s;
|
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)
|
override String GetObituary(Actor victim, Actor inflictor, Name mod, bool playerattack)
|
||||||
{
|
{
|
||||||
// Weapons may never return HitObituary by default. Override this if it is needed.
|
// 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)
|
if (null == player.ReadyWeapon)
|
||||||
{
|
{
|
||||||
player.BringUpWeapon();
|
player.mo.BringUpWeapon();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let psp = player.GetPSprite(PSP_WEAPON);
|
let psp = player.GetPSprite(PSP_WEAPON);
|
||||||
|
@ -190,7 +198,7 @@ class Weapon : StateProvider native
|
||||||
}
|
}
|
||||||
// [RH] Clear the flash state. Only needed for Strife.
|
// [RH] Clear the flash state. Only needed for Strife.
|
||||||
player.SetPsprite(PSP_FLASH, null);
|
player.SetPsprite(PSP_FLASH, null);
|
||||||
player.BringUpWeapon ();
|
player.mo.BringUpWeapon ();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -421,7 +421,7 @@ class PlayerPawn : Actor native
|
||||||
if (player.ReadyWeapon == null)
|
if (player.ReadyWeapon == null)
|
||||||
{
|
{
|
||||||
if (player.PendingWeapon != WP_NOCHANGE)
|
if (player.PendingWeapon != WP_NOCHANGE)
|
||||||
player.BringUpWeapon();
|
player.mo.BringUpWeapon();
|
||||||
}
|
}
|
||||||
else
|
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 SetLogNumber (int text);
|
||||||
native void SetLogText (String text);
|
native void SetLogText (String text);
|
||||||
native void DropWeapon();
|
native void DropWeapon();
|
||||||
native void BringUpWeapon();
|
|
||||||
native bool Resurrect();
|
native bool Resurrect();
|
||||||
|
|
||||||
native String GetUserName() const;
|
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;
|
return (mo.ViewHeight + crouchviewdelta - viewheight) / 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue