From 4fe8c71d6275706de5ad7ffc04d161d15ab061b8 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Fri, 18 Aug 2006 20:12:20 +0000 Subject: [PATCH] Added request am41375 (animation toggling on silenced weapons) --- dlls/cstrike/cstrike.cpp | 44 ++++++++++++++++++++++++++----------- plugins/include/cstrike.inc | 2 +- 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/dlls/cstrike/cstrike.cpp b/dlls/cstrike/cstrike.cpp index 4fa6c81d..55a4d21c 100755 --- a/dlls/cstrike/cstrike.cpp +++ b/dlls/cstrike/cstrike.cpp @@ -218,40 +218,58 @@ static cell AMX_NATIVE_CALL cs_set_weapon_silenced(AMX *amx, cell *params) // cs // Make into edict pointer edict_t *pWeapon = INDEXENT(params[1]); + bool draw_animation = true; + + if ((params[0] / sizeof(cell)) >= 3) + { + draw_animation = params[3] ? true : false; + } + int weapontype = (int)*((int *)pWeapon->pvPrivateData + OFFSET_WEAPONTYPE); int *silencemode = ((int *)pWeapon->pvPrivateData + OFFSET_SILENCER_FIREMODE); - switch (weapontype) { + switch (weapontype) + { case CSW_M4A1: - if (params[2] == 1) { - if (!(*silencemode & M4A1_SILENCED)) { // want to silence - can't already be silenced + 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)) + if (draw_animation && 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 + } 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)) + if (draw_animation && UTIL_IsPlayer(amx, pWeapon->v.owner)) + { pWeapon->v.owner->v.weaponanim = M4A1_DETACHSILENCEANIM; + } } break; case CSW_USP: - if (params[2] == 1) { - if (!(*silencemode & USP_SILENCED)) { // want to silence - can't already be silenced + 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)) + if (draw_animation && 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 + } 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)) + if (draw_animation && UTIL_IsPlayer(amx, pWeapon->v.owner)) + { pWeapon->v.owner->v.weaponanim = USP_DETACHSILENCEANIM; + } } break; default: diff --git a/plugins/include/cstrike.inc b/plugins/include/cstrike.inc index 40e5fce8..68efcf3c 100755 --- a/plugins/include/cstrike.inc +++ b/plugins/include/cstrike.inc @@ -222,7 +222,7 @@ native cs_get_weapon_silen(index); /* If silence = 1, weapon will be silenced, 0 and silencer will be removed. Only USP and M4A1 can be silenced. */ -native cs_set_weapon_silen(index, silence = 1); +native cs_set_weapon_silen(index, silence = 1, draw_animation = 1); /* Returns amount of ammo in weapon's clip. */