From ee6e87d94bb5de1531d8c0614fa6fd2549ef7132 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 13 Sep 2014 12:38:16 +0200 Subject: [PATCH] - use a separate counter from AActor::special1 to count weapon use with some Hexen weapons. special1 is used for some other purposes as well, and when using a separate counter it can be reset to 0 when changing weapons, preventing counting errors. --- src/actor.h | 1 + src/g_hexen/a_clericmace.cpp | 2 +- src/g_hexen/a_clericstaff.cpp | 6 +++--- src/g_hexen/a_fighteraxe.cpp | 2 +- src/g_hexen/a_fighterhammer.cpp | 12 ++++++------ src/g_hexen/a_fighterplayer.cpp | 8 ++++---- src/p_mobj.cpp | 4 ++++ src/p_pspr.cpp | 1 + src/version.h | 2 +- 9 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src/actor.h b/src/actor.h index 783eb5408..bf4b92457 100644 --- a/src/actor.h +++ b/src/actor.h @@ -857,6 +857,7 @@ public: int special1; // Special info int special2; // Special info + int weaponspecial; // Special info for weapons. int health; BYTE movedir; // 0-7 SBYTE visdir; diff --git a/src/g_hexen/a_clericmace.cpp b/src/g_hexen/a_clericmace.cpp index 0e43f3df9..79b5df340 100644 --- a/src/g_hexen/a_clericmace.cpp +++ b/src/g_hexen/a_clericmace.cpp @@ -56,7 +56,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CMaceAttack) } } // didn't find any creatures, so try to strike any walls - player->mo->special1 = 0; + player->mo->weaponspecial = 0; angle = player->mo->angle; slope = P_AimLineAttack (player->mo, angle, MELEERANGE, &linetarget); diff --git a/src/g_hexen/a_clericstaff.cpp b/src/g_hexen/a_clericstaff.cpp index 36f0c7686..aa8b94d74 100644 --- a/src/g_hexen/a_clericstaff.cpp +++ b/src/g_hexen/a_clericstaff.cpp @@ -164,7 +164,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CStaffMissileSlither) DEFINE_ACTION_FUNCTION(AActor, A_CStaffInitBlink) { - self->special1 = (pr_blink()>>1)+20; + self->weaponspecial = (pr_blink()>>1)+20; } //============================================================================ @@ -177,10 +177,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_CStaffCheckBlink) { if (self->player && self->player->ReadyWeapon) { - if (!--self->special1) + if (!--self->weaponspecial) { P_SetPsprite (self->player, ps_weapon, self->player->ReadyWeapon->FindState ("Blink")); - self->special1 = (pr_blink()+50)>>2; + self->weaponspecial = (pr_blink()+50)>>2; } else { diff --git a/src/g_hexen/a_fighteraxe.cpp b/src/g_hexen/a_fighteraxe.cpp index f80af876b..c1e396810 100644 --- a/src/g_hexen/a_fighteraxe.cpp +++ b/src/g_hexen/a_fighteraxe.cpp @@ -253,7 +253,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FAxeAttack) } } // didn't find any creatures, so try to strike any walls - pmo->special1 = 0; + pmo->weaponspecial = 0; angle = pmo->angle; slope = P_AimLineAttack (pmo, angle, MELEERANGE, &linetarget); diff --git a/src/g_hexen/a_fighterhammer.cpp b/src/g_hexen/a_fighterhammer.cpp index 85bbb3aae..42aae31fb 100644 --- a/src/g_hexen/a_fighterhammer.cpp +++ b/src/g_hexen/a_fighterhammer.cpp @@ -57,7 +57,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FHammerAttack) { P_ThrustMobj (linetarget, angle, power); } - pmo->special1 = false; // Don't throw a hammer + pmo->weaponspecial = false; // Don't throw a hammer goto hammerdone; } } @@ -73,7 +73,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FHammerAttack) { P_ThrustMobj(linetarget, angle, power); } - pmo->special1 = false; // Don't throw a hammer + pmo->weaponspecial = false; // Don't throw a hammer goto hammerdone; } } @@ -83,11 +83,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_FHammerAttack) slope = P_AimLineAttack (pmo, angle, HAMMER_RANGE, &linetarget, 0, ALF_CHECK3D); if (P_LineAttack (pmo, angle, HAMMER_RANGE, slope, damage, NAME_Melee, PClass::FindClass ("HammerPuff"), true) != NULL) { - pmo->special1 = false; + pmo->weaponspecial = false; } else { - pmo->special1 = true; + pmo->weaponspecial = true; } hammerdone: // Don't spawn a hammer if the player doesn't have enough mana @@ -95,7 +95,7 @@ hammerdone: !player->ReadyWeapon->CheckAmmo (player->ReadyWeapon->bAltFire ? AWeapon::AltFire : AWeapon::PrimaryFire, false, true)) { - pmo->special1 = false; + pmo->weaponspecial = false; } return; } @@ -116,7 +116,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FHammerThrow) return; } - if (!player->mo->special1) + if (!player->mo->weaponspecial) { return; } diff --git a/src/g_hexen/a_fighterplayer.cpp b/src/g_hexen/a_fighterplayer.cpp index 1b051a608..5df183901 100644 --- a/src/g_hexen/a_fighterplayer.cpp +++ b/src/g_hexen/a_fighterplayer.cpp @@ -66,7 +66,7 @@ static bool TryPunch(APlayerPawn *pmo, angle_t angle, int damage, fixed_t power) slope = P_AimLineAttack (pmo, angle, 2*MELEERANGE, &linetarget); if (linetarget != NULL) { - if (++pmo->special1 >= 3) + if (++pmo->weaponspecial >= 3) { damage <<= 1; power *= 3; @@ -117,9 +117,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_FPunchAttack) if (TryPunch(pmo, pmo->angle + i*(ANG45/16), damage, power) || TryPunch(pmo, pmo->angle - i*(ANG45/16), damage, power)) { // hit something - if (pmo->special1 >= 3) + if (pmo->weaponspecial >= 3) { - pmo->special1 = 0; + pmo->weaponspecial = 0; P_SetPsprite (player, ps_weapon, player->ReadyWeapon->FindState ("Fire2")); S_Sound (pmo, CHAN_VOICE, "*fistgrunt", 1, ATTN_NORM); } @@ -127,7 +127,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FPunchAttack) } } // didn't find any creatures, so try to strike any walls - pmo->special1 = 0; + pmo->weaponspecial = 0; AActor *linetarget; int slope = P_AimLineAttack (pmo, pmo->angle, MELEERANGE, &linetarget); diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index cdc511d11..50461c43a 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -206,6 +206,10 @@ void AActor::Serialize (FArchive &arc) { arc << flags7; } + if (SaveVersion >= 4511) + { + arc << weaponspecial; + } arc << special1 << special2 << health diff --git a/src/p_pspr.cpp b/src/p_pspr.cpp index 49f8bcb84..e477d9751 100644 --- a/src/p_pspr.cpp +++ b/src/p_pspr.cpp @@ -211,6 +211,7 @@ void P_BringUpWeapon (player_t *player) // 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, ps_flash, NULL); + player->mo->weaponspecial = 0; } diff --git a/src/version.h b/src/version.h index af376938c..c8917212d 100644 --- a/src/version.h +++ b/src/version.h @@ -76,7 +76,7 @@ const char *GetVersionString(); // Use 4500 as the base git save version, since it's higher than the // SVN revision ever got. -#define SAVEVER 4511 +#define SAVEVER 4512 #define SAVEVERSTRINGIFY2(x) #x #define SAVEVERSTRINGIFY(x) SAVEVERSTRINGIFY2(x)