From 95445293a2c0e0e65114eeed31a0c45d2251f1fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johnny=20Bergstr=C3=B6m?= Date: Mon, 22 Mar 2004 12:20:00 +0000 Subject: [PATCH] Fixed anim after cs_set_weapon_silenc --- dlls/cstrike/cstrike.cpp | 45 ++++++++++++++++++++++++++++------------ dlls/cstrike/cstrike.h | 10 +++++---- 2 files changed, 38 insertions(+), 17 deletions(-) diff --git a/dlls/cstrike/cstrike.cpp b/dlls/cstrike/cstrike.cpp index 713c88c5..d9820148 100755 --- a/dlls/cstrike/cstrike.cpp +++ b/dlls/cstrike/cstrike.cpp @@ -243,10 +243,10 @@ static cell AMX_NATIVE_CALL cs_get_weapon_silenced(AMX *amx, cell *params) // cs int *silencemode = ((int *)pWeapon->pvPrivateData + OFFSET_SILENCER_FIREMODE); switch (weapontype) { case CSW_M4A1: - if (*silencemode == M4A1_SILENCED) + if (*silencemode & M4A1_SILENCED) return 1; case CSW_USP: - if (*silencemode == USP_SILENCED) + if (*silencemode & USP_SILENCED) return 1; } @@ -258,7 +258,7 @@ static cell AMX_NATIVE_CALL cs_set_weapon_silenced(AMX *amx, cell *params) // cs { // Silence/unsilence gun. Does only work on M4A1 and USP. // params[1] = weapon index - // params[2] = 1, and we silence the gun, 0 and we unsilence gun- + // params[2] = 1, and we silence the gun, 0 and we unsilence gun. // Valid entity should be within range if (params[1] < 1 || params[1] > gpGlobals->maxEntities) @@ -281,22 +281,41 @@ static cell AMX_NATIVE_CALL cs_set_weapon_silenced(AMX *amx, cell *params) // cs switch (weapontype) { case CSW_M4A1: - if (params[2]) - *silencemode = M4A1_SILENCED; - else - *silencemode = M4A1_UNSILENCED; + if (params[2] == 1) { + if (!(*silencemode & M4A1_SILENCED)) { // want to silence - can't already be silenced + *silencemode |= M4A1_SILENCED; + // If this weapon has an owner that is a player, play animation for that player. + if (UTIL_IsPlayer(amx, pWeapon->v.owner)) + pWeapon->v.owner->v.weaponanim = M4A1_ATTACHSILENCEANIM; + } + } + else if (*silencemode & M4A1_SILENCED) { // want to unsilence - can't already be unsilenced + *silencemode &= ~M4A1_SILENCED; + // If this weapon has an owner that is a player, play animation for that player. + if (UTIL_IsPlayer(amx, pWeapon->v.owner)) + pWeapon->v.owner->v.weaponanim = M4A1_DETACHSILENCEANIM; + } break; case CSW_USP: - if (params[2]) - *silencemode = USP_SILENCED; - else - *silencemode = USP_UNSILENCED; - break; + if (params[2] == 1) { + if (!(*silencemode & USP_SILENCED)) { // want to silence - can't already be silenced + *silencemode |= USP_SILENCED; + // If this weapon has an owner that is a player, play animation for that player. + if (UTIL_IsPlayer(amx, pWeapon->v.owner)) + pWeapon->v.owner->v.weaponanim = USP_ATTACHSILENCEANIM; + } + } + else if (*silencemode & USP_SILENCED) { // want to unsilence - can't already be unsilenced + *silencemode &= ~USP_SILENCED; + // If this weapon has an owner that is a player, play animation for that player. + if (UTIL_IsPlayer(amx, pWeapon->v.owner)) + pWeapon->v.owner->v.weaponanim = USP_DETACHSILENCEANIM; + } + break; default: return 0; } - return 1; } diff --git a/dlls/cstrike/cstrike.h b/dlls/cstrike/cstrike.h index 2cfd84e5..8a1f4c01 100755 --- a/dlls/cstrike/cstrike.h +++ b/dlls/cstrike/cstrike.h @@ -202,10 +202,12 @@ pfnmodule_engine_g* g_engModuleFunc; //#define CSW_KNIFE 29 #define CSW_P90 30 -#define M4A1_UNSILENCED 0 -#define M4A1_SILENCED 4 -#define USP_UNSILENCED 0 -#define USP_SILENCED 1 +#define M4A1_SILENCED (1<<2) +#define M4A1_ATTACHSILENCEANIM 6 +#define M4A1_DETACHSILENCEANIM 13 +#define USP_SILENCED (1<<0) +#define USP_ATTACHSILENCEANIM 7 +#define USP_DETACHSILENCEANIM 15 #define GLOCK_SEMIAUTOMATIC 0 #define GLOCK_BURSTMODE 2