mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-10 23:01:50 +00:00
Reimplemented P_SetPsprite.
This commit is contained in:
parent
0b88bae458
commit
c9f4620702
14 changed files with 50 additions and 43 deletions
|
@ -81,7 +81,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FirePistol)
|
|||
if (!weapon->DepleteAmmo (weapon->bAltFire, true, 1))
|
||||
return 0;
|
||||
|
||||
self->player->GetPSprite(PSP_FLASH)->SetState(weapon->FindState(NAME_Flash), true);
|
||||
P_SetPsprite(self->player, PSP_FLASH, weapon->FindState(NAME_Flash), true);
|
||||
}
|
||||
self->player->mo->PlayAttacking2 ();
|
||||
|
||||
|
@ -273,7 +273,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireShotgun)
|
|||
{
|
||||
if (!weapon->DepleteAmmo (weapon->bAltFire, true, 1))
|
||||
return 0;
|
||||
player->GetPSprite(PSP_FLASH)->SetState(weapon->FindState(NAME_Flash), true);
|
||||
P_SetPsprite(player, PSP_FLASH, weapon->FindState(NAME_Flash), true);
|
||||
}
|
||||
player->mo->PlayAttacking2 ();
|
||||
|
||||
|
@ -309,7 +309,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireShotgun2)
|
|||
{
|
||||
if (!weapon->DepleteAmmo (weapon->bAltFire, true, 2))
|
||||
return 0;
|
||||
player->GetPSprite(PSP_FLASH)->SetState(weapon->FindState(NAME_Flash), true);
|
||||
P_SetPsprite(player, PSP_FLASH, weapon->FindState(NAME_Flash), true);
|
||||
}
|
||||
player->mo->PlayAttacking2 ();
|
||||
|
||||
|
@ -381,13 +381,13 @@ void P_SetSafeFlash(AWeapon *weapon, player_t *player, FState *flashstate, int i
|
|||
if (flashstate + index < cls->OwnedStates + cls->NumOwnedStates)
|
||||
{
|
||||
// we're ok so set the state
|
||||
player->GetPSprite(PSP_FLASH)->SetState(flashstate + index, true);
|
||||
P_SetPsprite(player, PSP_FLASH, flashstate + index, true);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
// oh, no! The state is beyond the end of the state table so use the original flash state.
|
||||
player->GetPSprite(PSP_FLASH)->SetState(flashstate, true);
|
||||
P_SetPsprite(player, PSP_FLASH, flashstate, true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -403,7 +403,7 @@ void P_SetSafeFlash(AWeapon *weapon, player_t *player, FState *flashstate, int i
|
|||
{ // Invalid state. With no index offset, it should at least be valid.
|
||||
index = 0;
|
||||
}
|
||||
player->GetPSprite(PSP_FLASH)->SetState(flashstate + index, true);
|
||||
P_SetPsprite(player, PSP_FLASH, flashstate + index, true);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -146,7 +146,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_BeakRaise)
|
|||
return 0;
|
||||
}
|
||||
player->GetPSprite(PSP_WEAPON)->y = WEAPONTOP;
|
||||
player->GetPSprite(PSP_WEAPON)->SetState(player->ReadyWeapon->GetReadyState());
|
||||
P_SetPsprite(player, PSP_WEAPON, player->ReadyWeapon->GetReadyState());
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1164,7 +1164,7 @@ void APhoenixRodPowered::EndPowerup ()
|
|||
Owner->player->refire = 0;
|
||||
S_StopSound (Owner, CHAN_WEAPON);
|
||||
Owner->player->ReadyWeapon = SisterWeapon;
|
||||
Owner->player->GetPSprite(PSP_WEAPON)->SetState(SisterWeapon->GetReadyState());
|
||||
P_SetPsprite(Owner->player, PSP_WEAPON, SisterWeapon->GetReadyState());
|
||||
}
|
||||
|
||||
class APhoenixFX1 : public AActor
|
||||
|
@ -1310,7 +1310,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FirePhoenixPL2)
|
|||
flamethrower = static_cast<APhoenixRod *> (player->ReadyWeapon);
|
||||
if (flamethrower == nullptr || --flamethrower->FlameCount == 0)
|
||||
{ // Out of flame
|
||||
player->GetPSprite(PSP_WEAPON)->SetState(flamethrower->FindState("Powerdown"));
|
||||
P_SetPsprite(player, PSP_WEAPON, flamethrower->FindState("Powerdown"));
|
||||
player->refire = 0;
|
||||
S_StopSound (self, CHAN_WEAPON);
|
||||
return 0;
|
||||
|
|
|
@ -92,7 +92,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CStaffCheck)
|
|||
if (weapon != nullptr)
|
||||
{
|
||||
FState * newstate = weapon->FindState("Drain");
|
||||
if (newstate != nullptr) player->GetPSprite(PSP_WEAPON)->SetState(newstate);
|
||||
if (newstate != nullptr) P_SetPsprite(player, PSP_WEAPON, newstate);
|
||||
}
|
||||
}
|
||||
if (weapon != nullptr)
|
||||
|
@ -187,7 +187,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CStaffCheckBlink)
|
|||
{
|
||||
if (!--self->weaponspecial)
|
||||
{
|
||||
self->player->GetPSprite(PSP_WEAPON)->SetState(self->player->ReadyWeapon->FindState ("Blink"));
|
||||
P_SetPsprite(self->player, PSP_WEAPON, self->player->ReadyWeapon->FindState ("Blink"));
|
||||
self->weaponspecial = (pr_blink()+50)>>2;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -76,7 +76,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FAxeCheckReady)
|
|||
}
|
||||
if (player->ReadyWeapon->Ammo1->Amount)
|
||||
{
|
||||
player->GetPSprite(PSP_WEAPON)->SetState(player->ReadyWeapon->FindState ("ReadyGlow"));
|
||||
P_SetPsprite(player, PSP_WEAPON, player->ReadyWeapon->FindState ("ReadyGlow"));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -103,7 +103,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FAxeCheckReadyG)
|
|||
}
|
||||
if (player->ReadyWeapon->Ammo1->Amount <= 0)
|
||||
{
|
||||
player->GetPSprite(PSP_WEAPON)->SetState(player->ReadyWeapon->FindState ("Ready"));
|
||||
P_SetPsprite(player, PSP_WEAPON, player->ReadyWeapon->FindState ("Ready"));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -130,7 +130,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FAxeCheckUp)
|
|||
}
|
||||
if (player->ReadyWeapon->Ammo1->Amount)
|
||||
{
|
||||
player->GetPSprite(PSP_WEAPON)->SetState(player->ReadyWeapon->FindState ("SelectGlow"));
|
||||
P_SetPsprite(player, PSP_WEAPON, player->ReadyWeapon->FindState ("SelectGlow"));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -157,7 +157,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FAxeCheckUpG)
|
|||
}
|
||||
if (player->ReadyWeapon->Ammo1->Amount <= 0)
|
||||
{
|
||||
player->GetPSprite(PSP_WEAPON)->SetState(player->ReadyWeapon->FindState ("Select"));
|
||||
P_SetPsprite(player, PSP_WEAPON, player->ReadyWeapon->FindState ("Select"));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -184,7 +184,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FAxeCheckAtk)
|
|||
}
|
||||
if (player->ReadyWeapon->Ammo1->Amount)
|
||||
{
|
||||
player->GetPSprite(PSP_WEAPON)->SetState(player->ReadyWeapon->FindState ("FireGlow"));
|
||||
P_SetPsprite(player, PSP_WEAPON, player->ReadyWeapon->FindState ("FireGlow"));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -273,7 +273,7 @@ axedone:
|
|||
(!(weapon->WeaponFlags & WIF_PRIMARY_USES_BOTH) ||
|
||||
weapon->Ammo2 == nullptr || weapon->Ammo2->Amount == 0))
|
||||
{
|
||||
player->GetPSprite(PSP_WEAPON)->SetState(player->ReadyWeapon->FindState ("Fire") + 5);
|
||||
P_SetPsprite(player, PSP_WEAPON, player->ReadyWeapon->FindState ("Fire") + 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -120,7 +120,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FPunchAttack)
|
|||
if (pmo->weaponspecial >= 3)
|
||||
{
|
||||
pmo->weaponspecial = 0;
|
||||
player->GetPSprite(PSP_WEAPON)->SetState(player->ReadyWeapon->FindState("Fire2"));
|
||||
P_SetPsprite(player, PSP_WEAPON, player->ReadyWeapon->FindState("Fire2"));
|
||||
S_Sound (pmo, CHAN_VOICE, "*fistgrunt", 1, ATTN_NORM);
|
||||
}
|
||||
return 0;
|
||||
|
|
|
@ -39,7 +39,7 @@ void APigPlayer::MorphPlayerThink ()
|
|||
{ // Snout sniff
|
||||
if (player->ReadyWeapon != nullptr)
|
||||
{
|
||||
player->GetPSprite(PSP_WEAPON)->SetState(player->ReadyWeapon->FindState("Grunt"));
|
||||
P_SetPsprite(player, PSP_WEAPON, player->ReadyWeapon->FindState("Grunt"));
|
||||
}
|
||||
S_Sound (this, CHAN_VOICE, "PigActive1", 1, ATTN_NORM); // snort
|
||||
return;
|
||||
|
|
|
@ -1131,7 +1131,7 @@ void APowerWeaponLevel2::InitEffect ()
|
|||
|
||||
if (weapon->GetReadyState() != sister->GetReadyState())
|
||||
{
|
||||
Owner->player->GetPSprite(PSP_WEAPON)->SetState(sister->GetReadyState());
|
||||
P_SetPsprite(Owner->player, PSP_WEAPON, sister->GetReadyState());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1310,9 +1310,9 @@ void APowerTargeter::InitEffect ()
|
|||
|
||||
if (state != nullptr)
|
||||
{
|
||||
player->GetPSprite(PSP_TARGETCENTER)->SetState(state + 0);
|
||||
player->GetPSprite(PSP_TARGETLEFT)->SetState(state + 1);
|
||||
player->GetPSprite(PSP_TARGETRIGHT)->SetState(state + 2);
|
||||
P_SetPsprite(player, PSP_TARGETCENTER, state + 0);
|
||||
P_SetPsprite(player, PSP_TARGETLEFT, state + 1);
|
||||
P_SetPsprite(player, PSP_TARGETRIGHT, state + 2);
|
||||
}
|
||||
|
||||
player->GetPSprite(PSP_TARGETCENTER)->x = (160-3);
|
||||
|
@ -1357,13 +1357,13 @@ void APowerTargeter::DoEffect ()
|
|||
{
|
||||
if (EffectTics & 32)
|
||||
{
|
||||
player->GetPSprite(PSP_TARGETRIGHT)->SetState(nullptr);
|
||||
player->GetPSprite(PSP_TARGETLEFT)->SetState(state + 1);
|
||||
P_SetPsprite(player, PSP_TARGETRIGHT, nullptr);
|
||||
P_SetPsprite(player, PSP_TARGETLEFT, state + 1);
|
||||
}
|
||||
else if (EffectTics & 16)
|
||||
{
|
||||
player->GetPSprite(PSP_TARGETRIGHT)->SetState(state + 2);
|
||||
player->GetPSprite(PSP_TARGETLEFT)->SetState(nullptr);
|
||||
P_SetPsprite(player, PSP_TARGETRIGHT, state + 2);
|
||||
P_SetPsprite(player, PSP_TARGETLEFT, nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -352,7 +352,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_ItBurnsItBurns)
|
|||
|
||||
if (self->player != nullptr && self->player->mo == self)
|
||||
{
|
||||
self->player->GetPSprite(PSP_STRIFEHANDS)->SetState(self->FindState("FireHands"));
|
||||
P_SetPsprite(self->player, PSP_STRIFEHANDS, self->FindState("FireHands"));
|
||||
self->player->ReadyWeapon = nullptr;
|
||||
self->player->PendingWeapon = WP_NOCHANGE;
|
||||
self->player->playerstate = PST_LIVE;
|
||||
|
|
|
@ -219,7 +219,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_ClearFlash)
|
|||
if (player == nullptr)
|
||||
return 0;
|
||||
|
||||
player->GetPSprite(PSP_FLASH)->SetState(nullptr);
|
||||
P_SetPsprite (player, PSP_FLASH, nullptr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -235,7 +235,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_ShowElectricFlash)
|
|||
|
||||
if (self->player != nullptr)
|
||||
{
|
||||
self->player->GetPSprite(PSP_FLASH)->SetState(self->player->ReadyWeapon->FindState(NAME_Flash));
|
||||
P_SetPsprite (self->player, PSP_FLASH, self->player->ReadyWeapon->FindState(NAME_Flash));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -707,7 +707,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireGrenade)
|
|||
if (!weapon->DepleteAmmo (weapon->bAltFire))
|
||||
return 0;
|
||||
|
||||
player->GetPSprite(PSP_FLASH)->SetState(flash, true);
|
||||
P_SetPsprite (player, PSP_FLASH, flash, true);
|
||||
|
||||
if (grenadetype != nullptr)
|
||||
{
|
||||
|
|
|
@ -345,7 +345,7 @@ void cht_DoCheat (player_t *player, int cheat)
|
|||
player->mo->DamageType = NAME_None;
|
||||
if (player->ReadyWeapon != nullptr)
|
||||
{
|
||||
player->GetPSprite(PSP_WEAPON)->SetState(player->ReadyWeapon->GetUpState());
|
||||
P_SetPsprite(player, PSP_WEAPON, player->ReadyWeapon->GetUpState());
|
||||
}
|
||||
|
||||
if (player->morphTics > 0)
|
||||
|
|
|
@ -175,6 +175,12 @@ DPSprite *player_t::FindPSprite(int layer)
|
|||
//
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
void P_SetPsprite(player_t *player, PSPLayers id, FState *state, bool pending)
|
||||
{
|
||||
if (player == nullptr) return;
|
||||
player->GetPSprite(id)->SetState(state, pending);
|
||||
}
|
||||
|
||||
DPSprite *player_t::GetPSprite(PSPLayers layer)
|
||||
{
|
||||
AActor *oldcaller = nullptr;
|
||||
|
@ -360,7 +366,7 @@ void P_BringUpWeapon (player_t *player)
|
|||
if (player->ReadyWeapon != nullptr)
|
||||
{
|
||||
player->GetPSprite(PSP_WEAPON)->y = WEAPONTOP;
|
||||
player->GetPSprite(PSP_WEAPON)->SetState(player->ReadyWeapon->GetReadyState());
|
||||
P_SetPsprite(player, PSP_WEAPON, player->ReadyWeapon->GetReadyState());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -393,8 +399,8 @@ void P_BringUpWeapon (player_t *player)
|
|||
? 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->GetPSprite(PSP_FLASH)->SetState(nullptr);
|
||||
player->GetPSprite(PSP_WEAPON)->SetState(weapon->GetUpState());
|
||||
P_SetPsprite(player, PSP_FLASH, nullptr);
|
||||
P_SetPsprite(player, PSP_WEAPON, weapon->GetUpState());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -427,7 +433,7 @@ void P_FireWeapon (player_t *player, FState *state)
|
|||
{
|
||||
state = weapon->GetAtkState(!!player->refire);
|
||||
}
|
||||
player->GetPSprite(PSP_WEAPON)->SetState(state);
|
||||
P_SetPsprite(player, PSP_WEAPON, state);
|
||||
if (!(weapon->WeaponFlags & WIF_NOALERT))
|
||||
{
|
||||
P_NoiseAlert (player->mo, player->mo, false);
|
||||
|
@ -465,7 +471,7 @@ void P_FireWeaponAlt (player_t *player, FState *state)
|
|||
state = weapon->GetAltAtkState(!!player->refire);
|
||||
}
|
||||
|
||||
player->GetPSprite(PSP_WEAPON)->SetState(state);
|
||||
P_SetPsprite(player, PSP_WEAPON, state);
|
||||
if (!(weapon->WeaponFlags & WIF_NOALERT))
|
||||
{
|
||||
P_NoiseAlert (player->mo, player->mo, false);
|
||||
|
@ -490,7 +496,7 @@ void P_DropWeapon (player_t *player)
|
|||
player->WeaponState &= ~WF_DISABLESWITCH;
|
||||
if (player->ReadyWeapon != nullptr)
|
||||
{
|
||||
player->GetPSprite(PSP_WEAPON)->SetState(player->ReadyWeapon->GetDownState());
|
||||
P_SetPsprite(player, PSP_WEAPON, player->ReadyWeapon->GetDownState());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -834,7 +840,7 @@ static void P_CheckWeaponButtons (player_t *player)
|
|||
// state, the weapon won't disappear. ;)
|
||||
if (state != nullptr)
|
||||
{
|
||||
player->GetPSprite(PSP_WEAPON)->SetState(state);
|
||||
P_SetPsprite(player, PSP_WEAPON, state);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1070,7 +1076,7 @@ DEFINE_ACTION_FUNCTION(AInventory, A_Lower)
|
|||
return 0;
|
||||
}
|
||||
// [RH] Clear the flash state. Only needed for Strife.
|
||||
player->GetPSprite(PSP_FLASH)->SetState(nullptr);
|
||||
P_SetPsprite(player, PSP_FLASH, nullptr);
|
||||
P_BringUpWeapon (player);
|
||||
return 0;
|
||||
}
|
||||
|
@ -1174,7 +1180,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AInventory, A_GunFlash)
|
|||
flash = player->ReadyWeapon->FindState(NAME_Flash);
|
||||
}
|
||||
}
|
||||
player->GetPSprite(PSP_FLASH)->SetState(flash);
|
||||
P_SetPsprite(player, PSP_FLASH, flash);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -105,6 +105,7 @@ private:
|
|||
|
||||
void P_NewPspriteTick();
|
||||
void P_CalcSwing (player_t *player);
|
||||
void P_SetPsprite(player_t *player, PSPLayers id, FState *state, bool pending = false);
|
||||
void P_BringUpWeapon (player_t *player);
|
||||
void P_FireWeapon (player_t *player);
|
||||
void P_DropWeapon (player_t *player);
|
||||
|
|
|
@ -1400,13 +1400,13 @@ void APlayerPawn::ActivateMorphWeapon ()
|
|||
}
|
||||
if (player->ReadyWeapon != nullptr)
|
||||
{
|
||||
player->GetPSprite(PSP_WEAPON)->SetState(player->ReadyWeapon->GetReadyState());
|
||||
P_SetPsprite(player, PSP_WEAPON, player->ReadyWeapon->GetReadyState());
|
||||
}
|
||||
}
|
||||
|
||||
if (player->ReadyWeapon != nullptr)
|
||||
{
|
||||
player->GetPSprite(PSP_FLASH)->SetState(nullptr);
|
||||
P_SetPsprite(player, PSP_FLASH, nullptr);
|
||||
}
|
||||
|
||||
player->PendingWeapon = WP_NOCHANGE;
|
||||
|
|
Loading…
Reference in a new issue