- Gez's patch for more A_WeaponReady flags:

* WRF_NOBOB (1): Weapon won't bob
  * WRF_NOFIRE (12): Weapon won't fire at all
  * WRF_NOSWITCH (2): Weapon can't be switched off
  * WRF_NOPRIMARY (4): Weapon will not fire its main attack
  * WRF_NOSECONDARY (8): Weapon will not fire its alt attack


SVN r1720 (trunk)
This commit is contained in:
Randy Heit 2009-07-16 22:40:04 +00:00
parent 800b50ff6f
commit b1b258ec55
7 changed files with 78 additions and 39 deletions

View file

@ -195,8 +195,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CStaffCheckBlink)
}
else
{
DoReadyWeaponToFire(self);
DoReadyWeaponToBob(self);
DoReadyWeapon(self);
}
}
}

View file

@ -82,8 +82,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FAxeCheckReady)
}
else
{
DoReadyWeaponToFire(self);
DoReadyWeaponToBob(self);
DoReadyWeapon(self);
}
}
@ -107,8 +106,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FAxeCheckReadyG)
}
else
{
DoReadyWeaponToFire(self);
DoReadyWeaponToBob(self);
DoReadyWeapon(self);
}
}

View file

@ -18,7 +18,7 @@
// Sorcerer Variables
// special1 Angle of ball 1 (all others relative to that)
// StopBall which ball to stop at in stop mode (MT_???)
// args[0] Denfense time
// args[0] Defense time
// args[1] Number of full rotations since stopping mode
// args[2] Target orbit speed for acceleration/deceleration
// args[3] Movement mode (see SORC_ macros)

View file

@ -126,8 +126,7 @@ int ALightningZap::SpecialMissileHit (AActor *thing)
DEFINE_ACTION_FUNCTION(AActor, A_LightningReady)
{
DoReadyWeaponToFire(self);
DoReadyWeaponToBob(self);
DoReadyWeapon(self);
if (pr_lightningready() < 160)
{
S_Sound (self, CHAN_WEAPON, "MageLightningReady", 1, ATTN_NORM);

View file

@ -68,7 +68,7 @@ void P_SetPsprite (player_t *player, int position, FState *state)
if (position == ps_weapon)
{
// A_WeaponReady will re-set these as needed
player->cheats &= ~(CF_WEAPONREADY | CF_WEAPONBOBBING);
player->cheats &= ~(CF_WEAPONREADY | CF_WEAPONREADYALT | CF_WEAPONBOBBING | CF_WEAPONSWITCHOK);
}
psp = &player->psprites[position];
@ -349,12 +349,20 @@ void P_BobWeapon (player_t *player, pspdef_t *psp, fixed_t *x, fixed_t *y)
//
// PROC A_WeaponReady
//
// Readies a weapon for firing or bobbing with its two ancillary functions,
// DoReadyWeaponToFire() and DoReadyWeaponToBob().
// Readies a weapon for firing or bobbing with its three ancillary functions,
// DoReadyWeaponToSwitch(), DoReadyWeaponToFire() and DoReadyWeaponToBob().
//
//============================================================================
void DoReadyWeaponToFire (AActor * self)
void DoReadyWeaponToSwitch (AActor * self)
{
// Prepare for switching action.
player_t *player;
if (self && (player = self->player))
player->cheats |= CF_WEAPONSWITCHOK;
}
void DoReadyWeaponToFire (AActor * self, bool prim, bool alt)
{
player_t *player;
AWeapon *weapon;
@ -381,29 +389,36 @@ void DoReadyWeaponToFire (AActor * self)
}
// Prepare for firing action.
player->cheats |= CF_WEAPONREADY;
player->cheats |= ((prim ? CF_WEAPONREADY : 0) | (alt ? CF_WEAPONREADYALT : 0));
return;
}
void DoReadyWeaponToBob (AActor * self)
{
player_t *player;
if (!self || !(player = self->player) || !(player->ReadyWeapon))
if (self && self->player && self->player->ReadyWeapon)
{
return;
// Prepare for bobbing action.
self->player->cheats |= CF_WEAPONBOBBING;
self->player->psprites[ps_weapon].sx = 0;
self->player->psprites[ps_weapon].sy = WEAPONTOP;
}
}
// Prepare for bobbing action.
player->cheats |= CF_WEAPONBOBBING;
player->psprites[ps_weapon].sx = 0;
player->psprites[ps_weapon].sy = WEAPONTOP;
// This function replaces calls to A_WeaponReady in other codepointers.
void DoReadyWeapon(AActor * self)
{
DoReadyWeaponToBob(self);
DoReadyWeaponToFire(self);
DoReadyWeaponToSwitch(self);
}
enum EWRF_Options
{
WRF_NoBob = 1,
WRF_NoFire = 2,
WRF_NoFire = 12,
WRF_NoSwitch = 2,
WRF_NoPrimary = 4,
WRF_NoSecondary = 8,
};
DEFINE_ACTION_FUNCTION_PARAMS(AInventory, A_WeaponReady)
@ -411,15 +426,17 @@ DEFINE_ACTION_FUNCTION_PARAMS(AInventory, A_WeaponReady)
ACTION_PARAM_START(1);
ACTION_PARAM_INT(paramflags, 0);
if (!(paramflags & WRF_NoFire)) DoReadyWeaponToFire(self);
if (!(paramflags & WRF_NoBob)) DoReadyWeaponToBob(self);
if (!(paramflags & WRF_NoSwitch)) DoReadyWeaponToSwitch(self);
if ((paramflags & WRF_NoFire) != WRF_NoFire) DoReadyWeaponToFire(self,
(!(paramflags & WRF_NoPrimary)), (!(paramflags & WRF_NoSecondary)));
if (!(paramflags & WRF_NoBob)) DoReadyWeaponToBob(self);
}
//---------------------------------------------------------------------------
//
// PROC P_CheckWeaponFire
//
// The player can fire the weapon or change to another weapon at this time.
// The player can fire the weapon.
// [RH] This was in A_WeaponReady before, but that only works well when the
// weapon's ready frames have a one tic delay.
//
@ -432,15 +449,8 @@ void P_CheckWeaponFire (player_t *player)
if (weapon == NULL)
return;
// Put the weapon away if the player has a pending weapon or has died.
if ((player->morphTics == 0 && player->PendingWeapon != WP_NOCHANGE) || player->health <= 0)
{
P_SetPsprite (player, ps_weapon, weapon->GetDownState());
return;
}
// Check for fire. Some weapons do not auto fire.
if (player->cmd.ucmd.buttons & BT_ATTACK)
if ((player->cheats & CF_WEAPONREADY) && (player->cmd.ucmd.buttons & BT_ATTACK))
{
if (!player->attackdown || !(weapon->WeaponFlags & WIF_NOAUTOFIRE))
{
@ -449,7 +459,7 @@ void P_CheckWeaponFire (player_t *player)
return;
}
}
else if (player->cmd.ucmd.buttons & BT_ALTATTACK)
else if ((player->cheats & CF_WEAPONREADYALT) && (player->cmd.ucmd.buttons & BT_ALTATTACK))
{
if (!player->attackdown || !(weapon->WeaponFlags & WIF_NOAUTOFIRE))
{
@ -464,6 +474,30 @@ void P_CheckWeaponFire (player_t *player)
}
}
//---------------------------------------------------------------------------
//
// PROC P_CheckWeaponSwitch
//
// The player can change to another weapon at this time.
// [GZ] This was cut from P_CheckWeaponFire.
//
//---------------------------------------------------------------------------
void P_CheckWeaponSwitch (player_t *player)
{
AWeapon *weapon;
if (!player || !(weapon = player->ReadyWeapon))
return;
// Put the weapon away if the player has a pending weapon or has died.
if ((player->morphTics == 0 && player->PendingWeapon != WP_NOCHANGE) || player->health <= 0)
{
P_SetPsprite (player, ps_weapon, weapon->GetDownState());
return;
}
}
//---------------------------------------------------------------------------
//
// PROC A_ReFire
@ -809,10 +843,14 @@ void P_MovePsprites (player_t *player)
}
player->psprites[ps_flash].sx = player->psprites[ps_weapon].sx;
player->psprites[ps_flash].sy = player->psprites[ps_weapon].sy;
if (player->cheats & CF_WEAPONREADY)
if (player->cheats & (CF_WEAPONREADY | CF_WEAPONREADYALT))
{
P_CheckWeaponFire (player);
}
if (player->cheats & CF_WEAPONSWITCHOK)
{
P_CheckWeaponSwitch (player);
}
}
}

View file

@ -89,8 +89,10 @@ void P_BobWeapon (player_t *player, pspdef_t *psp, fixed_t *x, fixed_t *y);
angle_t P_BulletSlope (AActor *mo, AActor **pLineTarget = NULL);
void P_GunShot (AActor *mo, bool accurate, const PClass *pufftype, angle_t pitch);
void DoReadyWeapon(AActor * self);
void DoReadyWeaponToBob(AActor * self);
void DoReadyWeaponToFire(AActor * self);
void DoReadyWeaponToFire(AActor * self, bool primary = true, bool secondary = true);
void DoReadyWeaponToSwitch(AActor * self);
DECLARE_ACTION(A_Raise)
DECLARE_ACTION(A_ReFire)

View file

@ -38,8 +38,11 @@ const int CVF_RELATIVE = 1;
const int CVF_REPLACE = 2;
// Flags for A_WeaponReady
const int WRF_NoBob = 1;
const int WRF_NoFire = 2;
const int WRF_NOBOB = 1;
const int WRF_NOFIRE = 12;
const int WRF_NOSWITCH = 2;
const int WRF_NOPRIMARY = 4;
const int WRF_NOSECONDARY = 8;
// Morph constants
const int MRF_ADDSTAMINA = 1;