diff --git a/docs/rh-log.txt b/docs/rh-log.txt index a4b040074..0857687ea 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,7 @@ -July 5, 2009 (Changes by Graf Zahl) +July 6, 2009 (Changes by Graf Zahl) +- Added Gez's A_WeaponReady enhancement submission. + +July 5, 2009 (Changes by Graf Zahl) - Added Gez's CheckActorProperty submission. July 4, 2009 (Changes by Graf Zahl) diff --git a/src/g_hexen/a_clericstaff.cpp b/src/g_hexen/a_clericstaff.cpp index 09f6513f8..821ac9610 100644 --- a/src/g_hexen/a_clericstaff.cpp +++ b/src/g_hexen/a_clericstaff.cpp @@ -195,7 +195,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_CStaffCheckBlink) } else { - CALL_ACTION(A_WeaponReady, self); + DoReadyWeaponToFire(self); + DoReadyWeaponToBob(self); } } } diff --git a/src/g_hexen/a_fighteraxe.cpp b/src/g_hexen/a_fighteraxe.cpp index 9e2e36963..cb78395a7 100644 --- a/src/g_hexen/a_fighteraxe.cpp +++ b/src/g_hexen/a_fighteraxe.cpp @@ -82,7 +82,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_FAxeCheckReady) } else { - CALL_ACTION(A_WeaponReady, self); + DoReadyWeaponToFire(self); + DoReadyWeaponToBob(self); } } @@ -106,7 +107,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_FAxeCheckReadyG) } else { - CALL_ACTION(A_WeaponReady, self); + DoReadyWeaponToFire(self); + DoReadyWeaponToBob(self); } } diff --git a/src/g_hexen/a_magelightning.cpp b/src/g_hexen/a_magelightning.cpp index c213afdbe..f6a645b8f 100644 --- a/src/g_hexen/a_magelightning.cpp +++ b/src/g_hexen/a_magelightning.cpp @@ -126,7 +126,8 @@ int ALightningZap::SpecialMissileHit (AActor *thing) DEFINE_ACTION_FUNCTION(AActor, A_LightningReady) { - CALL_ACTION(A_WeaponReady, self); + DoReadyWeaponToFire(self); + DoReadyWeaponToBob(self); if (pr_lightningready() < 160) { S_Sound (self, CHAN_WEAPON, "MageLightningReady", 1, ATTN_NORM); diff --git a/src/p_pspr.cpp b/src/p_pspr.cpp index d7219465a..ff6add392 100644 --- a/src/p_pspr.cpp +++ b/src/p_pspr.cpp @@ -345,50 +345,21 @@ void P_BobWeapon (player_t *player, pspdef_t *psp, fixed_t *x, fixed_t *y) } } -//--------------------------------------------------------------------------- -// -// PROC A_WeaponBob -// -// The player's weapon will bob, but they cannot fire it at this time. -// -//--------------------------------------------------------------------------- - -DEFINE_ACTION_FUNCTION(AInventory, A_WeaponBob) -{ - player_t *player = self->player; - - if (player == NULL || player->ReadyWeapon == NULL) - { - return; - } - - // Prepare for bobbing action. - player->cheats |= CF_WEAPONBOBBING; - player->psprites[ps_weapon].sx = 0; - player->psprites[ps_weapon].sy = WEAPONTOP; -} - -//--------------------------------------------------------------------------- +//============================================================================ // // PROC A_WeaponReady // -// The player can fire the weapon or change to another weapon at this time. +// Readies a weapon for firing or bobbing with its two ancillary functions, +// DoReadyWeaponToFire() and DoReadyWeaponToBob(). // -//--------------------------------------------------------------------------- +//============================================================================ -DEFINE_ACTION_FUNCTION(AInventory, A_WeaponReady) +void DoReadyWeaponToFire (AActor * self) { - player_t *player = self->player; + player_t *player; AWeapon *weapon; - if (NULL == player) - { - return; - } - - weapon = player->ReadyWeapon; - - if (NULL == weapon) + if (!self || !(player = self->player) || !(weapon = player->ReadyWeapon)) { return; } @@ -409,12 +380,41 @@ DEFINE_ACTION_FUNCTION(AInventory, A_WeaponReady) } } - // Prepare for bobbing and firing action. - player->cheats |= CF_WEAPONREADY | CF_WEAPONBOBBING; + // Prepare for firing action. + player->cheats |= CF_WEAPONREADY; + return; +} + +void DoReadyWeaponToBob (AActor * self) +{ + player_t *player; + + if (!self || !(player = self->player) || !(player->ReadyWeapon)) + { + return; + } + + // Prepare for bobbing action. + player->cheats |= CF_WEAPONBOBBING; player->psprites[ps_weapon].sx = 0; player->psprites[ps_weapon].sy = WEAPONTOP; } +enum EWRF_Options +{ + WRF_NoBob = 1, + WRF_NoFire = 2, +}; + +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); +} + //--------------------------------------------------------------------------- // // PROC P_CheckWeaponFire diff --git a/src/p_pspr.h b/src/p_pspr.h index c50be6e42..01b4fc33c 100644 --- a/src/p_pspr.h +++ b/src/p_pspr.h @@ -89,7 +89,9 @@ 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); -DECLARE_ACTION(A_WeaponReady) +void DoReadyWeaponToBob(AActor * self); +void DoReadyWeaponToFire(AActor * self); + DECLARE_ACTION(A_Raise) DECLARE_ACTION(A_ReFire) diff --git a/wadsrc/static/actors/constants.txt b/wadsrc/static/actors/constants.txt index 3aabbe403..0a78360e3 100644 --- a/wadsrc/static/actors/constants.txt +++ b/wadsrc/static/actors/constants.txt @@ -37,6 +37,10 @@ const int LOF_FULLVOLSEESOUND = 16; const int CVF_RELATIVE = 1; const int CVF_REPLACE = 2; +// Flags for A_WeaponReady +const int WRF_NoBob = 1; +const int WRF_NoFire = 2; + // Morph constants const int MRF_ADDSTAMINA = 1; const int MRF_FULLHEALTH = 2; diff --git a/wadsrc/static/actors/shared/inventory.txt b/wadsrc/static/actors/shared/inventory.txt index a9c184137..8850932ab 100644 --- a/wadsrc/static/actors/shared/inventory.txt +++ b/wadsrc/static/actors/shared/inventory.txt @@ -15,8 +15,7 @@ ACTOR Inventory native action native A_Light1(); action native A_Light2(); action native A_LightInverse(); - action native A_WeaponReady(); - action native A_WeaponBob(); + action native A_WeaponReady(int flags = 0); action native A_Lower(); action native A_Raise(); action native A_FirePistol();