mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-29 23:33:00 +00:00
Renamed the weapon action function caller check to ACTION_CALL_FROM_PSPRITE to avoid confusion
This was always checking for every psprites rather than just weapon layers
This commit is contained in:
parent
abc7113e09
commit
68c483c041
4 changed files with 24 additions and 24 deletions
|
@ -38,7 +38,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Punch)
|
||||||
if (self->player != NULL)
|
if (self->player != NULL)
|
||||||
{
|
{
|
||||||
AWeapon *weapon = self->player->ReadyWeapon;
|
AWeapon *weapon = self->player->ReadyWeapon;
|
||||||
if (weapon != NULL && !(weapon->WeaponFlags & WIF_DEHAMMO) && ACTION_CALL_FROM_WEAPON())
|
if (weapon != NULL && !(weapon->WeaponFlags & WIF_DEHAMMO) && ACTION_CALL_FROM_PSPRITE())
|
||||||
{
|
{
|
||||||
if (!weapon->DepleteAmmo (weapon->bAltFire))
|
if (!weapon->DepleteAmmo (weapon->bAltFire))
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -76,7 +76,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FirePistol)
|
||||||
if (self->player != nullptr)
|
if (self->player != nullptr)
|
||||||
{
|
{
|
||||||
AWeapon *weapon = self->player->ReadyWeapon;
|
AWeapon *weapon = self->player->ReadyWeapon;
|
||||||
if (weapon != nullptr && ACTION_CALL_FROM_WEAPON())
|
if (weapon != nullptr && ACTION_CALL_FROM_PSPRITE())
|
||||||
{
|
{
|
||||||
if (!weapon->DepleteAmmo (weapon->bAltFire, true, 1))
|
if (!weapon->DepleteAmmo (weapon->bAltFire, true, 1))
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -160,7 +160,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Saw)
|
||||||
slope = P_AimLineAttack (self, angle, range, &t) + spread_z * (pr_saw.Random2() / 255.);
|
slope = P_AimLineAttack (self, angle, range, &t) + spread_z * (pr_saw.Random2() / 255.);
|
||||||
|
|
||||||
AWeapon *weapon = self->player->ReadyWeapon;
|
AWeapon *weapon = self->player->ReadyWeapon;
|
||||||
if ((weapon != NULL) && !(flags & SF_NOUSEAMMO) && !(!t.linetarget && (flags & SF_NOUSEAMMOMISS)) && !(weapon->WeaponFlags & WIF_DEHAMMO) && ACTION_CALL_FROM_WEAPON())
|
if ((weapon != NULL) && !(flags & SF_NOUSEAMMO) && !(!t.linetarget && (flags & SF_NOUSEAMMOMISS)) && !(weapon->WeaponFlags & WIF_DEHAMMO) && ACTION_CALL_FROM_PSPRITE())
|
||||||
{
|
{
|
||||||
if (!weapon->DepleteAmmo (weapon->bAltFire))
|
if (!weapon->DepleteAmmo (weapon->bAltFire))
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -269,7 +269,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireShotgun)
|
||||||
|
|
||||||
S_Sound (self, CHAN_WEAPON, "weapons/shotgf", 1, ATTN_NORM);
|
S_Sound (self, CHAN_WEAPON, "weapons/shotgf", 1, ATTN_NORM);
|
||||||
AWeapon *weapon = self->player->ReadyWeapon;
|
AWeapon *weapon = self->player->ReadyWeapon;
|
||||||
if (weapon != nullptr && ACTION_CALL_FROM_WEAPON())
|
if (weapon != nullptr && ACTION_CALL_FROM_PSPRITE())
|
||||||
{
|
{
|
||||||
if (!weapon->DepleteAmmo (weapon->bAltFire, true, 1))
|
if (!weapon->DepleteAmmo (weapon->bAltFire, true, 1))
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -305,7 +305,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireShotgun2)
|
||||||
|
|
||||||
S_Sound (self, CHAN_WEAPON, "weapons/sshotf", 1, ATTN_NORM);
|
S_Sound (self, CHAN_WEAPON, "weapons/sshotf", 1, ATTN_NORM);
|
||||||
AWeapon *weapon = self->player->ReadyWeapon;
|
AWeapon *weapon = self->player->ReadyWeapon;
|
||||||
if (weapon != nullptr && ACTION_CALL_FROM_WEAPON())
|
if (weapon != nullptr && ACTION_CALL_FROM_PSPRITE())
|
||||||
{
|
{
|
||||||
if (!weapon->DepleteAmmo (weapon->bAltFire, true, 2))
|
if (!weapon->DepleteAmmo (weapon->bAltFire, true, 2))
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -421,7 +421,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireCGun)
|
||||||
}
|
}
|
||||||
|
|
||||||
AWeapon *weapon = player->ReadyWeapon;
|
AWeapon *weapon = player->ReadyWeapon;
|
||||||
if (weapon != nullptr && ACTION_CALL_FROM_WEAPON())
|
if (weapon != nullptr && ACTION_CALL_FROM_PSPRITE())
|
||||||
{
|
{
|
||||||
if (!weapon->DepleteAmmo (weapon->bAltFire, true, 1))
|
if (!weapon->DepleteAmmo (weapon->bAltFire, true, 1))
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -465,7 +465,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireMissile)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
AWeapon *weapon = self->player->ReadyWeapon;
|
AWeapon *weapon = self->player->ReadyWeapon;
|
||||||
if (weapon != NULL && ACTION_CALL_FROM_WEAPON())
|
if (weapon != NULL && ACTION_CALL_FROM_PSPRITE())
|
||||||
{
|
{
|
||||||
if (!weapon->DepleteAmmo (weapon->bAltFire, true, 1))
|
if (!weapon->DepleteAmmo (weapon->bAltFire, true, 1))
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -492,7 +492,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireSTGrenade)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
AWeapon *weapon = self->player->ReadyWeapon;
|
AWeapon *weapon = self->player->ReadyWeapon;
|
||||||
if (weapon != NULL && ACTION_CALL_FROM_WEAPON())
|
if (weapon != NULL && ACTION_CALL_FROM_PSPRITE())
|
||||||
{
|
{
|
||||||
if (!weapon->DepleteAmmo (weapon->bAltFire))
|
if (!weapon->DepleteAmmo (weapon->bAltFire))
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -520,7 +520,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FirePlasma)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
AWeapon *weapon = self->player->ReadyWeapon;
|
AWeapon *weapon = self->player->ReadyWeapon;
|
||||||
if (weapon != NULL && ACTION_CALL_FROM_WEAPON())
|
if (weapon != NULL && ACTION_CALL_FROM_PSPRITE())
|
||||||
{
|
{
|
||||||
if (!weapon->DepleteAmmo (weapon->bAltFire, true, 1))
|
if (!weapon->DepleteAmmo (weapon->bAltFire, true, 1))
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -575,21 +575,21 @@ static void FireRailgun(AActor *self, int offset_xy, bool fromweapon)
|
||||||
DEFINE_ACTION_FUNCTION(AActor, A_FireRailgun)
|
DEFINE_ACTION_FUNCTION(AActor, A_FireRailgun)
|
||||||
{
|
{
|
||||||
PARAM_ACTION_PROLOGUE;
|
PARAM_ACTION_PROLOGUE;
|
||||||
FireRailgun(self, 0, ACTION_CALL_FROM_WEAPON());
|
FireRailgun(self, 0, ACTION_CALL_FROM_PSPRITE());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFINE_ACTION_FUNCTION(AActor, A_FireRailgunRight)
|
DEFINE_ACTION_FUNCTION(AActor, A_FireRailgunRight)
|
||||||
{
|
{
|
||||||
PARAM_ACTION_PROLOGUE;
|
PARAM_ACTION_PROLOGUE;
|
||||||
FireRailgun(self, 10, ACTION_CALL_FROM_WEAPON());
|
FireRailgun(self, 10, ACTION_CALL_FROM_PSPRITE());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFINE_ACTION_FUNCTION(AActor, A_FireRailgunLeft)
|
DEFINE_ACTION_FUNCTION(AActor, A_FireRailgunLeft)
|
||||||
{
|
{
|
||||||
PARAM_ACTION_PROLOGUE;
|
PARAM_ACTION_PROLOGUE;
|
||||||
FireRailgun(self, -10, ACTION_CALL_FROM_WEAPON());
|
FireRailgun(self, -10, ACTION_CALL_FROM_PSPRITE());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -615,7 +615,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireBFG)
|
||||||
}
|
}
|
||||||
|
|
||||||
AWeapon *weapon = self->player->ReadyWeapon;
|
AWeapon *weapon = self->player->ReadyWeapon;
|
||||||
if (weapon != NULL && ACTION_CALL_FROM_WEAPON())
|
if (weapon != NULL && ACTION_CALL_FROM_PSPRITE())
|
||||||
{
|
{
|
||||||
if (!weapon->DepleteAmmo (weapon->bAltFire, true, deh.BFGCells))
|
if (!weapon->DepleteAmmo (weapon->bAltFire, true, deh.BFGCells))
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -751,7 +751,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireOldBFG)
|
||||||
}
|
}
|
||||||
|
|
||||||
AWeapon *weapon = self->player->ReadyWeapon;
|
AWeapon *weapon = self->player->ReadyWeapon;
|
||||||
if (!ACTION_CALL_FROM_WEAPON()) weapon = NULL;
|
if (!ACTION_CALL_FROM_PSPRITE()) weapon = NULL;
|
||||||
if (weapon != NULL)
|
if (weapon != NULL)
|
||||||
{
|
{
|
||||||
if (!weapon->DepleteAmmo (weapon->bAltFire, true, 1))
|
if (!weapon->DepleteAmmo (weapon->bAltFire, true, 1))
|
||||||
|
|
|
@ -106,7 +106,7 @@ DEFINE_ACTION_FUNCTION_PARAMS (AActor, A_Blast)
|
||||||
AActor *mo;
|
AActor *mo;
|
||||||
TThinkerIterator<AActor> iterator;
|
TThinkerIterator<AActor> iterator;
|
||||||
|
|
||||||
if (self->player && (blastflags & BF_USEAMMO) && ACTION_CALL_FROM_WEAPON())
|
if (self->player && (blastflags & BF_USEAMMO) && ACTION_CALL_FROM_PSPRITE())
|
||||||
{
|
{
|
||||||
AWeapon *weapon = self->player->ReadyWeapon;
|
AWeapon *weapon = self->player->ReadyWeapon;
|
||||||
if (weapon != NULL && !weapon->DepleteAmmo(weapon->bAltFire))
|
if (weapon != NULL && !weapon->DepleteAmmo(weapon->bAltFire))
|
||||||
|
|
|
@ -361,6 +361,6 @@ int MatchString (const char *in, const char **strings);
|
||||||
|
|
||||||
// Checks to see what called the current action function
|
// Checks to see what called the current action function
|
||||||
#define ACTION_CALL_FROM_ACTOR() (stateinfo == nullptr || stateinfo->mStateType == STATE_Actor)
|
#define ACTION_CALL_FROM_ACTOR() (stateinfo == nullptr || stateinfo->mStateType == STATE_Actor)
|
||||||
#define ACTION_CALL_FROM_WEAPON() (self->player && stateinfo != nullptr && stateinfo->mStateType == STATE_Psprite)
|
#define ACTION_CALL_FROM_PSPRITE() (self->player && stateinfo != nullptr && stateinfo->mStateType == STATE_Psprite)
|
||||||
#define ACTION_CALL_FROM_INVENTORY() (stateinfo != nullptr && stateinfo->mStateType == STATE_StateChain)
|
#define ACTION_CALL_FROM_INVENTORY() (stateinfo != nullptr && stateinfo->mStateType == STATE_StateChain)
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1740,7 +1740,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfNoAmmo)
|
||||||
PARAM_ACTION_PROLOGUE;
|
PARAM_ACTION_PROLOGUE;
|
||||||
PARAM_STATE(jump);
|
PARAM_STATE(jump);
|
||||||
|
|
||||||
if (!ACTION_CALL_FROM_WEAPON())
|
if (!ACTION_CALL_FROM_PSPRITE())
|
||||||
{
|
{
|
||||||
ACTION_RETURN_STATE(NULL);
|
ACTION_RETURN_STATE(NULL);
|
||||||
}
|
}
|
||||||
|
@ -1789,7 +1789,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireBullets)
|
||||||
DAngle bslope = 0.;
|
DAngle bslope = 0.;
|
||||||
int laflags = (flags & FBF_NORANDOMPUFFZ)? LAF_NORANDOMPUFFZ : 0;
|
int laflags = (flags & FBF_NORANDOMPUFFZ)? LAF_NORANDOMPUFFZ : 0;
|
||||||
|
|
||||||
if ((flags & FBF_USEAMMO) && weapon && ACTION_CALL_FROM_WEAPON())
|
if ((flags & FBF_USEAMMO) && weapon && ACTION_CALL_FROM_PSPRITE())
|
||||||
{
|
{
|
||||||
if (!weapon->DepleteAmmo(weapon->bAltFire, true))
|
if (!weapon->DepleteAmmo(weapon->bAltFire, true))
|
||||||
return 0; // out of ammo
|
return 0; // out of ammo
|
||||||
|
@ -1880,7 +1880,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireCustomMissile)
|
||||||
FTranslatedLineTarget t;
|
FTranslatedLineTarget t;
|
||||||
|
|
||||||
// Only use ammo if called from a weapon
|
// Only use ammo if called from a weapon
|
||||||
if (useammo && ACTION_CALL_FROM_WEAPON() && weapon)
|
if (useammo && ACTION_CALL_FROM_PSPRITE() && weapon)
|
||||||
{
|
{
|
||||||
if (!weapon->DepleteAmmo(weapon->bAltFire, true))
|
if (!weapon->DepleteAmmo(weapon->bAltFire, true))
|
||||||
return 0; // out of ammo
|
return 0; // out of ammo
|
||||||
|
@ -1972,7 +1972,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomPunch)
|
||||||
pitch = P_AimLineAttack (self, angle, range, &t);
|
pitch = P_AimLineAttack (self, angle, range, &t);
|
||||||
|
|
||||||
// only use ammo when actually hitting something!
|
// only use ammo when actually hitting something!
|
||||||
if ((flags & CPF_USEAMMO) && t.linetarget && weapon && ACTION_CALL_FROM_WEAPON())
|
if ((flags & CPF_USEAMMO) && t.linetarget && weapon && ACTION_CALL_FROM_PSPRITE())
|
||||||
{
|
{
|
||||||
if (!weapon->DepleteAmmo(weapon->bAltFire, true))
|
if (!weapon->DepleteAmmo(weapon->bAltFire, true))
|
||||||
return 0; // out of ammo
|
return 0; // out of ammo
|
||||||
|
@ -2073,7 +2073,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_RailAttack)
|
||||||
AWeapon *weapon = self->player->ReadyWeapon;
|
AWeapon *weapon = self->player->ReadyWeapon;
|
||||||
|
|
||||||
// only use ammo when actually hitting something!
|
// only use ammo when actually hitting something!
|
||||||
if (useammo && weapon != NULL && ACTION_CALL_FROM_WEAPON())
|
if (useammo && weapon != NULL && ACTION_CALL_FROM_PSPRITE())
|
||||||
{
|
{
|
||||||
if (!weapon->DepleteAmmo(weapon->bAltFire, true))
|
if (!weapon->DepleteAmmo(weapon->bAltFire, true))
|
||||||
return 0; // out of ammo
|
return 0; // out of ammo
|
||||||
|
@ -2660,7 +2660,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnItem)
|
||||||
ACTION_RETURN_BOOL(true);
|
ACTION_RETURN_BOOL(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ACTION_CALL_FROM_WEAPON())
|
if (ACTION_CALL_FROM_PSPRITE())
|
||||||
{
|
{
|
||||||
// Used from a weapon, so use some ammo
|
// Used from a weapon, so use some ammo
|
||||||
AWeapon *weapon = self->player->ReadyWeapon;
|
AWeapon *weapon = self->player->ReadyWeapon;
|
||||||
|
@ -2785,7 +2785,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ThrowGrenade)
|
||||||
{
|
{
|
||||||
ACTION_RETURN_BOOL(true);
|
ACTION_RETURN_BOOL(true);
|
||||||
}
|
}
|
||||||
if (ACTION_CALL_FROM_WEAPON())
|
if (ACTION_CALL_FROM_PSPRITE())
|
||||||
{
|
{
|
||||||
// Used from a weapon, so use some ammo
|
// Used from a weapon, so use some ammo
|
||||||
AWeapon *weapon = self->player->ReadyWeapon;
|
AWeapon *weapon = self->player->ReadyWeapon;
|
||||||
|
@ -5838,7 +5838,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetTics)
|
||||||
PARAM_ACTION_PROLOGUE;
|
PARAM_ACTION_PROLOGUE;
|
||||||
PARAM_INT(tics_to_set);
|
PARAM_INT(tics_to_set);
|
||||||
|
|
||||||
if (ACTION_CALL_FROM_WEAPON())
|
if (ACTION_CALL_FROM_PSPRITE())
|
||||||
{
|
{
|
||||||
DPSprite *pspr = self->player->FindPSprite(stateinfo->mPSPIndex);
|
DPSprite *pspr = self->player->FindPSprite(stateinfo->mPSPIndex);
|
||||||
if (pspr != nullptr)
|
if (pspr != nullptr)
|
||||||
|
|
Loading…
Reference in a new issue