From 1891e974d015ed17d9f168c1630ba50eb4e71549 Mon Sep 17 00:00:00 2001 From: Marco Hladik Date: Wed, 22 Apr 2020 05:32:58 +0200 Subject: [PATCH] Counter-Strike: Handle player animation code in its own files, update weapons to use the newly defined sequences. --- src/client/cstrike/player.c | 11 +- src/client/cstrike/progs.src | 5 +- src/client/player.c | 24 +-- src/server/cstrike/gamerules_multiplayer.cpp | 26 ++- src/server/cstrike/progs.src | 8 +- src/shared/cstrike/animations.c | 159 +++++++++++++++++++ src/shared/cstrike/animations.h | 117 ++++++++++++++ src/shared/cstrike/defs.h | 1 + src/shared/cstrike/w_ak47.c | 6 +- src/shared/cstrike/w_aug.c | 4 +- src/shared/cstrike/w_awp.c | 4 +- src/shared/cstrike/w_c4bomb.c | 2 +- src/shared/cstrike/w_deagle.c | 6 +- src/shared/cstrike/w_elites.c | 23 ++- src/shared/cstrike/w_fiveseven.c | 4 +- src/shared/cstrike/w_flashbang.c | 2 +- src/shared/cstrike/w_g3sg1.c | 4 +- src/shared/cstrike/w_glock18.c | 4 +- src/shared/cstrike/w_knife.c | 7 +- src/shared/cstrike/w_m3.c | 4 +- src/shared/cstrike/w_m4a1.c | 4 +- src/shared/cstrike/w_mac10.c | 4 +- src/shared/cstrike/w_mp5.c | 4 +- src/shared/cstrike/w_p228.c | 4 +- src/shared/cstrike/w_p90.c | 4 +- src/shared/cstrike/w_para.c | 4 +- src/shared/cstrike/w_scout.c | 4 +- src/shared/cstrike/w_sg550.c | 4 +- src/shared/cstrike/w_sg552.c | 4 +- src/shared/cstrike/w_tmp.c | 4 +- src/shared/cstrike/w_ump45.c | 4 +- src/shared/cstrike/w_usp45.c | 4 +- src/shared/cstrike/w_xm1014.c | 4 +- src/shared/pmove.c | 1 - 34 files changed, 395 insertions(+), 79 deletions(-) create mode 100755 src/shared/cstrike/animations.c create mode 100644 src/shared/cstrike/animations.h diff --git a/src/client/cstrike/player.c b/src/client/cstrike/player.c index 32ee845b..dfa8ee10 100644 --- a/src/client/cstrike/player.c +++ b/src/client/cstrike/player.c @@ -94,13 +94,14 @@ Player_ReadEntity(float new) pl.movetype = readbyte(); if (fl & PLAYER_VIEWOFS) pl.view_ofs[2] = readfloat(); - if (fl & PLAYER_BASEFRAME) + if (fl & PLAYER_BASEFRAME) { pl.baseframe = readbyte(); - if (fl & PLAYER_FRAME) { - pl.frame = readbyte(); - pl.frame1time = 0.0f; - pl.frame2time = 0.0f; + pl.baseframe1time = 0.0f; + pl.baseframe2time = 0.0f; } + if (fl & PLAYER_FRAME) + pl.frame = readbyte(); + if (fl & PLAYER_AMMO1) pl.a_ammo1 = readbyte(); if (fl & PLAYER_AMMO2) diff --git a/src/client/cstrike/progs.src b/src/client/cstrike/progs.src index aa26877c..a1fa7d55 100644 --- a/src/client/cstrike/progs.src +++ b/src/client/cstrike/progs.src @@ -33,9 +33,8 @@ ../sentences.c ../prints.c ../voice.c -../../shared/valve/animations.h -../../shared/valve/animations.c -../../shared/cstrike/player.cpp +../../shared/cstrike/animations.c +../../shared/cstrike/player.h ../player.c ../../shared/cstrike/pmove.c ../../shared/pmove.c diff --git a/src/client/player.c b/src/client/player.c index 573667be..e3888aac 100644 --- a/src/client/player.c +++ b/src/client/player.c @@ -14,13 +14,6 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -//.float bonecontrol1; //Half-Life model format bone controller. On player models, this typically affects the spine's yaw. -//.float bonecontrol2; //Half-Life model format bone controller. On player models, this typically affects the spine's yaw. -//.float bonecontrol3; //Half-Life model format bone controller. On player models, this typically affects the spine's yaw. -//.float bonecontrol4; //Half-Life model format bone controller. On player models, this typically affects the spine's yaw. -//.float bonecontrol5; //Half-Life model format bone controller. This typically affects the mouth. -//.float subblendfrac; //Weird animation value specific to Half-Life models. On player models, this typically affects the spine's pitch. -//.float basesubblendfrac; // legs part. .float subblend2frac; // Up/Down void @@ -81,14 +74,24 @@ player::draw(void) } this.bonecontrol5 = getplayerkeyfloat(this.entnum - 1, "voiploudness"); + makevectors([0, this.angles[1], 0]); + float fCorrect = dotproduct(this.velocity, v_right) * 0.25f; + +#ifdef CSTRIKE + /* hack, we can't play the animations in reverse the normal way */ + if (this.frame1time < 0.0f) { + this.frame1time = 10.0f; + } + + this.subblendfrac = -fCorrect * 0.05f; + this.subblend2frac *= -0.1f; + this.angles[1] -= fCorrect; +#else /* hack, we can't play the animations in reverse the normal way */ if (this.baseframe1time < 0.0f) { this.baseframe1time = 10.0f; } - makevectors([0, this.angles[1], 0]); - float fCorrect = dotproduct(this.velocity, v_right) * 0.25f; - /* Turn torso */ this.bonecontrol1 = fCorrect; this.bonecontrol2 = this.bonecontrol1 * 0.5; @@ -97,6 +100,7 @@ player::draw(void) /* Correct the legs */ this.angles[1] -= fCorrect; +#endif if (cvar("bonetest") == 1) { this.bonecontrol1 = cvar("bonecontrol1"); diff --git a/src/server/cstrike/gamerules_multiplayer.cpp b/src/server/cstrike/gamerules_multiplayer.cpp index 99be9bb0..04c4b86b 100644 --- a/src/server/cstrike/gamerules_multiplayer.cpp +++ b/src/server/cstrike/gamerules_multiplayer.cpp @@ -31,9 +31,10 @@ CSMultiplayerRules::PlayerDeath(player pl) corpse.movetype = MOVETYPE_TOSS; corpse.solid = SOLID_TRIGGER; corpse.modelindex = pl.modelindex; - corpse.frame = ANIM_DIESIMPLE; + corpse.frame = ANIM_DEATH1; corpse.angles = pl.angles; corpse.velocity = pl.velocity; + corpse.classname = "remove_me"; /* gamerule stuff */ PlayerMakeSpectator(pl); @@ -446,7 +447,6 @@ This happens whenever an objective is complete or time is up void CSMultiplayerRules::RoundOver(int iTeamWon, int iMoneyReward, int fSilent) { - if (g_cs_gamestate != GAME_ACTIVE) { return; } @@ -864,3 +864,25 @@ void CSEv_JoinTeam_f(float flChar) rules.RoundOver(FALSE, 0, FALSE); } } + +void CSEv_JoinAuto(void) +{ + int ct_count = 0; + int t_count = 1; + + for (entity eFind = world; (eFind = find(eFind, ::classname, "player"));) { + player pl = (player)eFind; + if (pl.team == TEAM_T) { + t_count++; + } + if (pl.team == TEAM_CT) { + ct_count++; + } + } + + if (ct_count > t_count) { + CSEv_JoinTeam_f(floor(random(1,5))); + } else { + CSEv_JoinTeam_f(floor(random(5,9))); + } +} diff --git a/src/server/cstrike/progs.src b/src/server/cstrike/progs.src index ee4297a5..7442e84e 100755 --- a/src/server/cstrike/progs.src +++ b/src/server/cstrike/progs.src @@ -5,13 +5,13 @@ #define SERVER #define VALVE #define CSTRIKE +#define BULLETPENETRATION #includelist ../../shared/fteextensions.qc ../../shared/defs.h ../../shared/cstrike/defs.h ../../shared/sound.c -../../shared/valve/animations.h ../defs.h ../plugins.c ../logging.c @@ -22,7 +22,7 @@ ../../gs-entbase/server.src ../../gs-entbase/shared.src -../../shared/cstrike/player.cpp +../../shared/cstrike/player.h ../cstrike/defs.h ../../shared/effects.c @@ -79,7 +79,7 @@ ../spawn.c ../vox.c -../../shared/valve/animations.c +../../shared/cstrike/animations.c ../gamerules.cpp ../cstrike/game_money.c @@ -97,6 +97,8 @@ ../valve/rules.c ../footsteps.c ../flashlight.c +../../botlib/include.src + ../cstrike/input.c ../cstrike/spawn.c ../vote.c diff --git a/src/shared/cstrike/animations.c b/src/shared/cstrike/animations.c new file mode 100755 index 00000000..3515d8ee --- /dev/null +++ b/src/shared/cstrike/animations.c @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2016-2020 Marco Hladik + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER + * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +.float baseframe1time; +.float baseframe2time; +.float baseframe2; +.float baseframe_last; +.float baseframe_old; +.float baseframe_time; +.float baselerpfrac; +.float frame2; +.float frame2time; +.float frame_last; +.float fWasCrouching; +.float lerpfrac; +.float subblend2frac; +.float subblendfrac; + +void Animation_Print(string sWow) { +#ifdef CLIENT + print(sprintf("[DEBUG] %s", sWow)); +#else + bprint(PRINT_HIGH, sprintf("SSQC: %s", sWow) ); +#endif +} + +/* +================= +Animation_PlayerUpdate + +Called every frame to update the animation sequences +depending on what the player is doing +================= +*/ +void Animation_PlayerUpdate(void) { + self.basebone = cvar("spinebone"); // gettagindex(self, "Bip01 Spine"); +#ifdef SERVER + if (self.baseframe_time < time) { + player pl = (player)self; + self.baseframe = Weapons_GetAim(pl.activeweapon); + self.baseframe_old = self.frame; + } +#endif + + /* in order to appear jumping, we want to not be on ground, + * but also make sure we're not just going down a ramp */ + if (!(self.flags & FL_ONGROUND) && (self.velocity[2] > 0 || self.frame == ANIM_JUMP)) { + self.frame = ANIM_JUMP; + } else if (vlen(self.velocity) == 0) { + if (self.flags & FL_CROUCHING) { + self.frame = ANIM_IDLE_CROUCH; + } else { + self.frame = ANIM_IDLE; + } + } else if (vlen(self.velocity) < 150) { + if (self.flags & FL_CROUCHING) { + self.frame = ANIM_RUN_CROUCH; + } else { + self.frame = ANIM_WALK; + } + } else if (vlen(self.velocity) > 150) { + if (self.flags & FL_CROUCHING) { + self.frame = ANIM_RUN_CROUCH; + } else { + self.frame = ANIM_RUN; + } + } + + // Lerp it down! + if (self.lerpfrac > 0) { + self.lerpfrac -= frametime * 5; + if (self.lerpfrac < 0) { + self.lerpfrac = 0; + } + } + + if (self.baselerpfrac > 0) { + self.baselerpfrac -= frametime * 5; + if (self.baselerpfrac < 0) { + self.baselerpfrac = 0; + } + } + + if (self.frame != self.frame_last) { + //Animation_Print(sprintf("New Frame: %d, Last Frame: %d\n", self.frame, self.frame_last)); + + // Move everything over to frame 2 + self.frame2time = self.frame1time; + self.frame2 = self.frame_last; + + // Set frame_last to avoid this being called again + self.frame_last = self.frame; + + self.lerpfrac = 1.0f; + self.frame1time = 0.0f; + } + + if (self.baseframe != self.baseframe_last) { + //Animation_Print(sprintf("New Baseframe: %d, Last Baseframe: %d\n", self.baseframe, self.baseframe_last)); + + // Move everything over to frame 2 + self.baseframe2time = self.baseframe1time; + self.baseframe2 = self.baseframe_last; + + // Set frame_last to avoid this being called again + self.baseframe_last = self.baseframe; + + self.baselerpfrac = 1.0f; + self.baseframe1time = 0.0f; + } + + // Force the code above to update if we switched positions + if (self.fWasCrouching != (self.flags & FL_CROUCHING)) { + self.baseframe_old = 0; + self.baseframe_time = 0; + self.fWasCrouching = (self.flags & FL_CROUCHING); + } + +#ifdef SERVER + // On the CSQC it's done in Player.c + self.subblendfrac = + self.subblend2frac = self.v_angle[0] / 90; +#endif + + self.angles[0] = self.angles[2] = 0; +} + +/* +================= +Animation_PlayerTop + +Changes the animation sequence for the upper body part +================= +*/ +void Animation_PlayerTop(float fFrame) { + self.baseframe = fFrame; + self.baseframe_old = fFrame; +} + +void Animation_PlayerTopTemp(float fFrame, float fTime) { + self.baseframe = fFrame; + self.baseframe_time = time + fTime; +#ifdef SERVER + self.SendFlags |= PLAYER_FRAME; +#endif +} diff --git a/src/shared/cstrike/animations.h b/src/shared/cstrike/animations.h new file mode 100644 index 00000000..920874da --- /dev/null +++ b/src/shared/cstrike/animations.h @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2016-2020 Marco Hladik + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER + * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +enum +{ + ANIM_DUMMY1, + ANIM_IDLE, + ANIM_IDLE_CROUCH, + ANIM_WALK, + ANIM_RUN, + ANIM_RUN_CROUCH, + ANIM_JUMP, + ANIM_LONGJUMP, + ANIM_SWIM, + ANIM_TREADWATER, + ANIM_CROUCH_AIM_CARBINE, + ANIM_CROUCH_SHOOT_CARBINE, + ANIM_CROUCH_RELOAD_CARBINE, + ANIM_AIM_CARBINE, + ANIM_SHOOT_CARBINE, + ANIM_RELOAD_CARBINE, + ANIM_CROUCH_AIM_ONEHAND, + ANIM_CROUCH_SHOOT_ONEHAND, + ANIM_CROUCH_RELOAD_ONEHAND, + ANIM_AIM_ONEHAND, + ANIM_SHOOT_ONEHAND, + ANIM_RELOAD_ONEHAND, + ANIM_CROUCH_AIM_DUALPISTOLS, + ANIM_CROUCH_SHOOT_DUALPISTOLS, + ANIM_CROUCH_SHOOT2_DUALPISTOLS, + ANIM_CROUCH_RELOAD_DUALPISTOLS, + ANIM_AIM_DUALPISTOLS, + ANIM_SHOOT_DUALPISTOLS, + ANIM_SHOOT2_DUALPISTOLS, + ANIM_RELOAD_DUALPISTOLS, + ANIM_CROUCH_AIM_RIFLE, + ANIM_CROUCH_SHOOT_RIFLE, + ANIM_CROUCH_RELOAD_RIFLE, + ANIM_AIM_RIFLE, + ANIM_SHOOT_RIFLE, + ANIM_RELOAD_RIFLE, + ANIM_CROUCH_AIM_MP5, + ANIM_CROUCH_SHOOT_MP5, + ANIM_CROUCH_RELOAD_MP5, + ANIM_AIM_MP5, + ANIM_SHOOT_MP5, + ANIM_RELOAD_MP5, + ANIM_CROUCH_AIM_SHOTGUN, + ANIM_CROUCH_SHOOT_SHOTGUN, + ANIM_CROUCH_RELOAD_SHOTGUN, + ANIM_AIM_SHOTGUN, + ANIM_SHOOT_SHOTGUN, + ANIM_RELOAD_SHOTGUN, + ANIM_CROUCH_AIM_PARA, + ANIM_CROUCH_SHOOT_PARA, + ANIM_CROUCH_RELOAD_PARA, + ANIM_AIM_PARA, + ANIM_SHOOT_PARA, + ANIM_RELOAD_PARA, + ANIM_DUMMY2, + ANIM_DUMMY3, + ANIM_AIM_GRENADE, + ANIM_SHOOT_GRENADE, + ANIM_CROUCH_AIM_GRENADE, + ANIM_CROUCH_SHOOT_GRENADE, + ANIM_CROUCH_AIM_C4, + ANIM_CROUCH_SHOOT_C4, + ANIM_AIM_C4, + ANIM_SHOOT_C4, + ANIM_RELOAD_C4, + ANIM_DUPLICATE1, + ANIM_DUPLICATE2, + ANIM_DUPLICATE3, + ANIM_DUPLICATE4, + ANIM_DUPLICATE5, + ANIM_DUPLICATE6, + ANIM_DUPLICATE7, + ANIM_DUPLICATE8, + ANIM_CROUCH_AIM_KNIFE, + ANIM_CROUCH_SHOOT_KNIFE, + ANIM_AIM_KNIFE, + ANIM_SHOOT_KNIFE, + ANIM_CROUCH_AIM_AK47, + ANIM_CROUCH_SHOOT_AK47, + ANIM_CROUCH_RELOAD_AK47, + ANIM_AIM_AK47, + ANIM_SHOOT_AK47, + ANIM_RELOAD_AK47, + ANIM_GUT_FLINCH, + ANIM_HEAD_FLINCH, + ANIM_DEATH1, + ANIM_DEATH2, + ANIM_DEATH3, + ANIM_DIE_HEAD, + ANIM_DIE_GUT, + ANIM_DIE_LEFT, + ANIM_DIE_BACK, + ANIM_DIE_RIGHT, + ANIM_DIE_FORWARD, + ANIM_CROUCH_DIE +}; + +void Animation_PlayerTop(float); +void Animation_PlayerTopTemp(float, float); diff --git a/src/shared/cstrike/defs.h b/src/shared/cstrike/defs.h index 79881610..171ab1d9 100644 --- a/src/shared/cstrike/defs.h +++ b/src/shared/cstrike/defs.h @@ -14,6 +14,7 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include "animations.h" #include "radio.h" #include "weapons.h" #include "items.h" diff --git a/src/shared/cstrike/w_ak47.c b/src/shared/cstrike/w_ak47.c index c5ec7860..705b3aef 100644 --- a/src/shared/cstrike/w_ak47.c +++ b/src/shared/cstrike/w_ak47.c @@ -136,9 +136,9 @@ w_ak47_primary(void) pl.ak47_mag--; if (self.flags & FL_CROUCHING) - Animation_PlayerTopTemp(ANIM_SHOOT1HAND, 0.45f); + Animation_PlayerTopTemp(ANIM_SHOOT_AK47, 0.45f); else - Animation_PlayerTopTemp(ANIM_CR_SHOOT1HAND, 0.45f); + Animation_PlayerTopTemp(ANIM_CROUCH_SHOOT_AK47, 0.45f); Sound_Play(pl, CHAN_WEAPON, "weapon_ak47.fire"); #endif @@ -196,7 +196,7 @@ w_ak47_reload(void) float w_ak47_aimanim(void) { - return self.flags & FL_CROUCHING ? ANIM_CR_AIM1HAND : ANIM_AIM1HAND; + return self.flags & FL_CROUCHING ? ANIM_CROUCH_AIM_AK47 : ANIM_AIM_AK47; } void diff --git a/src/shared/cstrike/w_aug.c b/src/shared/cstrike/w_aug.c index 14730809..6e8c7c89 100644 --- a/src/shared/cstrike/w_aug.c +++ b/src/shared/cstrike/w_aug.c @@ -136,9 +136,9 @@ w_aug_primary(void) TraceAttack_FireBullets(1, pl.origin + pl.view_ofs, 32, [accuracy,accuracy], WEAPON_AUG); if (self.flags & FL_CROUCHING) - Animation_PlayerTopTemp(ANIM_SHOOT1HAND, 0.45f); + Animation_PlayerTopTemp(ANIM_SHOOT_RIFLE, 0.45f); else - Animation_PlayerTopTemp(ANIM_CR_SHOOT1HAND, 0.45f); + Animation_PlayerTopTemp(ANIM_CROUCH_SHOOT_RIFLE, 0.45f); Sound_Play(pl, CHAN_WEAPON, "weapon_aug.fire"); #endif diff --git a/src/shared/cstrike/w_awp.c b/src/shared/cstrike/w_awp.c index 4382b9d6..6e65b2f6 100644 --- a/src/shared/cstrike/w_awp.c +++ b/src/shared/cstrike/w_awp.c @@ -184,9 +184,9 @@ w_awp_primary(void) TraceAttack_FireBullets(1, pl.origin + pl.view_ofs, 115, [accuracy,accuracy], WEAPON_AWP); if (self.flags & FL_CROUCHING) - Animation_PlayerTopTemp(ANIM_SHOOT1HAND, 0.45f); + Animation_PlayerTopTemp(ANIM_SHOOT_RIFLE, 0.45f); else - Animation_PlayerTopTemp(ANIM_CR_SHOOT1HAND, 0.45f); + Animation_PlayerTopTemp(ANIM_CROUCH_SHOOT_RIFLE, 0.45f); Sound_Play(pl, CHAN_WEAPON, "weapon_awp.fire"); #endif diff --git a/src/shared/cstrike/w_c4bomb.c b/src/shared/cstrike/w_c4bomb.c index f88a27f2..46ef45a5 100644 --- a/src/shared/cstrike/w_c4bomb.c +++ b/src/shared/cstrike/w_c4bomb.c @@ -259,7 +259,7 @@ w_c4bomb_primary(void) float w_c4bomb_aimanim(void) { - return self.flags & FL_CROUCHING ? ANIM_CR_AIM1HAND : ANIM_AIM1HAND; + return self.flags & FL_CROUCHING ? ANIM_CROUCH_AIM_C4 : ANIM_AIM_C4; } void diff --git a/src/shared/cstrike/w_deagle.c b/src/shared/cstrike/w_deagle.c index e9788884..5cc1a38e 100644 --- a/src/shared/cstrike/w_deagle.c +++ b/src/shared/cstrike/w_deagle.c @@ -139,9 +139,9 @@ w_deagle_primary(void) TraceAttack_FireBullets(1, pl.origin + pl.view_ofs, 54, [accuracy,accuracy], WEAPON_DEAGLE); if (self.flags & FL_CROUCHING) - Animation_PlayerTopTemp(ANIM_SHOOT1HAND, 0.45f); + Animation_PlayerTopTemp(ANIM_CROUCH_SHOOT_ONEHAND, 0.45f); else - Animation_PlayerTopTemp(ANIM_CR_SHOOT1HAND, 0.45f); + Animation_PlayerTopTemp(ANIM_SHOOT_ONEHAND, 0.45f); Sound_Play(pl, CHAN_WEAPON, "weapon_deagle.fire"); #endif @@ -201,7 +201,7 @@ w_deagle_reload(void) float w_deagle_aimanim(void) { - return self.flags & FL_CROUCHING ? ANIM_CR_AIM1HAND : ANIM_AIM1HAND; + return self.flags & FL_CROUCHING ? ANIM_CROUCH_AIM_ONEHAND : ANIM_AIM_ONEHAND; } void diff --git a/src/shared/cstrike/w_elites.c b/src/shared/cstrike/w_elites.c index 6c68cc40..1765ee32 100644 --- a/src/shared/cstrike/w_elites.c +++ b/src/shared/cstrike/w_elites.c @@ -60,7 +60,7 @@ void w_elites_updateammo(player pl) { #ifdef SERVER - Weapons_UpdateAmmo(pl, pl.elites_mag, pl.ammo_9mm, -1); + Weapons_UpdateAmmo(pl, pl.elites_mag, pl.ammo_9mm, pl.a_ammo3); #endif } @@ -137,6 +137,8 @@ w_elites_primary(void) } #endif + pl.a_ammo3 = 1 - pl.a_ammo3; + Cstrike_ShotMultiplierAdd(pl, 1); float accuracy = Cstrike_CalculateAccuracy(pl, 200); @@ -147,16 +149,21 @@ w_elites_primary(void) TraceAttack_FireBullets(1, pl.origin + pl.view_ofs, 45, [accuracy,accuracy], WEAPON_ELITES); pl.elites_mag--; - if (self.flags & FL_CROUCHING) - Animation_PlayerTopTemp(ANIM_SHOOT1HAND, 0.45f); - else - Animation_PlayerTopTemp(ANIM_CR_SHOOT1HAND, 0.45f); + if (self.flags & FL_CROUCHING) { + if (pl.a_ammo3) + Animation_PlayerTopTemp(ANIM_CROUCH_SHOOT2_DUALPISTOLS, 0.45f); + else + Animation_PlayerTopTemp(ANIM_CROUCH_SHOOT_DUALPISTOLS, 0.45f); + } else { + if (pl.a_ammo3) + Animation_PlayerTopTemp(ANIM_SHOOT2_DUALPISTOLS, 0.45f); + else + Animation_PlayerTopTemp(ANIM_SHOOT_DUALPISTOLS, 0.45f); + } Sound_Play(pl, CHAN_WEAPON, "weapon_elites.fire"); #endif - pl.a_ammo3 = 1 - pl.a_ammo3; - int r = (float)input_sequence % 5; if (pl.a_ammo3) { if (pl.a_ammo1 <= 0) { @@ -245,7 +252,7 @@ w_elites_reload(void) float w_elites_aimanim(void) { - return self.flags & FL_CROUCHING ? ANIM_CR_AIM1HAND : ANIM_AIM1HAND; + return self.flags & FL_CROUCHING ? ANIM_CROUCH_AIM_DUALPISTOLS : ANIM_AIM_DUALPISTOLS; } void diff --git a/src/shared/cstrike/w_fiveseven.c b/src/shared/cstrike/w_fiveseven.c index 7cacf27a..398a3392 100644 --- a/src/shared/cstrike/w_fiveseven.c +++ b/src/shared/cstrike/w_fiveseven.c @@ -139,9 +139,9 @@ w_fiveseven_primary(void) pl.fiveseven_mag--; if (self.flags & FL_CROUCHING) - Animation_PlayerTopTemp(ANIM_SHOOT1HAND, 0.45f); + Animation_PlayerTopTemp(ANIM_SHOOT_ONEHAND, 0.45f); else - Animation_PlayerTopTemp(ANIM_CR_SHOOT1HAND, 0.45f); + Animation_PlayerTopTemp(ANIM_CROUCH_SHOOT_ONEHAND, 0.45f); Sound_Play(pl, CHAN_WEAPON, "weapon_fiveseven.fire"); #endif diff --git a/src/shared/cstrike/w_flashbang.c b/src/shared/cstrike/w_flashbang.c index d8398f39..1a91953d 100644 --- a/src/shared/cstrike/w_flashbang.c +++ b/src/shared/cstrike/w_flashbang.c @@ -216,7 +216,7 @@ w_flashbang_release(void) float w_flashbang_aimanim(void) { - return self.flags & FL_CROUCHING ? ANIM_CR_AIM1HAND : ANIM_AIM1HAND; + return self.flags & FL_CROUCHING ? ANIM_CROUCH_AIM_GRENADE : ANIM_AIM_GRENADE; } void diff --git a/src/shared/cstrike/w_g3sg1.c b/src/shared/cstrike/w_g3sg1.c index 4b39c6a7..466e0eae 100644 --- a/src/shared/cstrike/w_g3sg1.c +++ b/src/shared/cstrike/w_g3sg1.c @@ -134,9 +134,9 @@ w_g3sg1_primary(void) pl.g3sg1_mag--; if (self.flags & FL_CROUCHING) - Animation_PlayerTopTemp(ANIM_SHOOT1HAND, 0.45f); + Animation_PlayerTopTemp(ANIM_SHOOT_RIFLE, 0.45f); else - Animation_PlayerTopTemp(ANIM_CR_SHOOT1HAND, 0.45f); + Animation_PlayerTopTemp(ANIM_CROUCH_SHOOT_RIFLE, 0.45f); Sound_Play(pl, CHAN_WEAPON, "weapon_g3sg1.fire"); #endif diff --git a/src/shared/cstrike/w_glock18.c b/src/shared/cstrike/w_glock18.c index 2e27d754..807f28f7 100644 --- a/src/shared/cstrike/w_glock18.c +++ b/src/shared/cstrike/w_glock18.c @@ -157,9 +157,9 @@ w_glock18_primary(void) pl.glock18_mag--; if (self.flags & FL_CROUCHING) - Animation_PlayerTopTemp(ANIM_SHOOT1HAND, 0.45f); + Animation_PlayerTopTemp(ANIM_SHOOT_ONEHAND, 0.45f); else - Animation_PlayerTopTemp(ANIM_CR_SHOOT1HAND, 0.45f); + Animation_PlayerTopTemp(ANIM_CROUCH_SHOOT_ONEHAND, 0.45f); if (pl.a_ammo3) { Sound_Play(pl, CHAN_WEAPON, "weapon_glock18.burstfire"); diff --git a/src/shared/cstrike/w_knife.c b/src/shared/cstrike/w_knife.c index 64f8d37a..4b6b5e37 100644 --- a/src/shared/cstrike/w_knife.c +++ b/src/shared/cstrike/w_knife.c @@ -114,6 +114,11 @@ w_knife_primary(void) Sound_Play(pl, CHAN_WEAPON, "weapon_knife.miss"); + if (self.flags & FL_CROUCHING) + Animation_PlayerTopTemp(ANIM_CROUCH_SHOOT_KNIFE, 0.45f); + else + Animation_PlayerTopTemp(ANIM_SHOOT_KNIFE, 0.45f); + if (trace_fraction >= 1.0) { return; } @@ -172,7 +177,7 @@ w_knife_secondary(void) float w_knife_aimanim(void) { - return self.flags & FL_CROUCHING ? ANIM_CR_AIM1HAND : ANIM_AIM1HAND; + return self.flags & FL_CROUCHING ? ANIM_CROUCH_AIM_KNIFE : ANIM_AIM_KNIFE; } void diff --git a/src/shared/cstrike/w_m3.c b/src/shared/cstrike/w_m3.c index 2267bdc3..1ec1a0fc 100644 --- a/src/shared/cstrike/w_m3.c +++ b/src/shared/cstrike/w_m3.c @@ -144,9 +144,9 @@ w_m3_primary(void) pl.m3_mag--; if (self.flags & FL_CROUCHING) - Animation_PlayerTopTemp(ANIM_SHOOT1HAND, 0.45f); + Animation_PlayerTopTemp(ANIM_SHOOT_SHOTGUN, 0.45f); else - Animation_PlayerTopTemp(ANIM_CR_SHOOT1HAND, 0.45f); + Animation_PlayerTopTemp(ANIM_CROUCH_SHOOT_SHOTGUN, 0.45f); Sound_Play(pl, CHAN_WEAPON, "weapon_m3.fire"); #endif diff --git a/src/shared/cstrike/w_m4a1.c b/src/shared/cstrike/w_m4a1.c index 48e79932..e220bfb2 100644 --- a/src/shared/cstrike/w_m4a1.c +++ b/src/shared/cstrike/w_m4a1.c @@ -167,9 +167,9 @@ w_m4a1_primary(void) TraceAttack_FireBullets(1, pl.origin + pl.view_ofs, 33, [accuracy,accuracy], WEAPON_M4A1); if (self.flags & FL_CROUCHING) - Animation_PlayerTopTemp(ANIM_SHOOT1HAND, 0.45f); + Animation_PlayerTopTemp(ANIM_SHOOT_RIFLE, 0.45f); else - Animation_PlayerTopTemp(ANIM_CR_SHOOT1HAND, 0.45f); + Animation_PlayerTopTemp(ANIM_CROUCH_SHOOT_RIFLE, 0.45f); #endif /* this stuff is predicted */ diff --git a/src/shared/cstrike/w_mac10.c b/src/shared/cstrike/w_mac10.c index 39ed7929..211884be 100644 --- a/src/shared/cstrike/w_mac10.c +++ b/src/shared/cstrike/w_mac10.c @@ -135,9 +135,9 @@ w_mac10_primary(void) pl.mac10_mag--; if (self.flags & FL_CROUCHING) - Animation_PlayerTopTemp(ANIM_SHOOT1HAND, 0.45f); + Animation_PlayerTopTemp(ANIM_SHOOT_MP5, 0.45f); else - Animation_PlayerTopTemp(ANIM_CR_SHOOT1HAND, 0.45f); + Animation_PlayerTopTemp(ANIM_CROUCH_SHOOT_MP5, 0.45f); Sound_Play(pl, CHAN_WEAPON, "weapon_mac10.fire"); #endif diff --git a/src/shared/cstrike/w_mp5.c b/src/shared/cstrike/w_mp5.c index ed912f0e..e4f08b14 100644 --- a/src/shared/cstrike/w_mp5.c +++ b/src/shared/cstrike/w_mp5.c @@ -140,9 +140,9 @@ w_mp5_primary(void) pl.mp5_mag--; if (self.flags & FL_CROUCHING) - Animation_PlayerTopTemp(ANIM_SHOOT1HAND, 0.45f); + Animation_PlayerTopTemp(ANIM_SHOOT_MP5, 0.45f); else - Animation_PlayerTopTemp(ANIM_CR_SHOOT1HAND, 0.45f); + Animation_PlayerTopTemp(ANIM_CROUCH_SHOOT_MP5, 0.45f); Sound_Play(pl, CHAN_WEAPON, "weapon_mp5.fire"); #endif diff --git a/src/shared/cstrike/w_p228.c b/src/shared/cstrike/w_p228.c index 9b62ede4..2140d558 100644 --- a/src/shared/cstrike/w_p228.c +++ b/src/shared/cstrike/w_p228.c @@ -143,9 +143,9 @@ w_p228_primary(void) pl.p228_mag--; if (self.flags & FL_CROUCHING) - Animation_PlayerTopTemp(ANIM_SHOOT1HAND, 0.45f); + Animation_PlayerTopTemp(ANIM_SHOOT_ONEHAND, 0.45f); else - Animation_PlayerTopTemp(ANIM_CR_SHOOT1HAND, 0.45f); + Animation_PlayerTopTemp(ANIM_CROUCH_SHOOT_ONEHAND, 0.45f); Sound_Play(pl, CHAN_WEAPON, "weapon_p228.fire"); #endif diff --git a/src/shared/cstrike/w_p90.c b/src/shared/cstrike/w_p90.c index 72ec97da..731a4fe6 100644 --- a/src/shared/cstrike/w_p90.c +++ b/src/shared/cstrike/w_p90.c @@ -136,9 +136,9 @@ w_p90_primary(void) pl.p90_mag--; if (self.flags & FL_CROUCHING) - Animation_PlayerTopTemp(ANIM_SHOOT1HAND, 0.45f); + Animation_PlayerTopTemp(ANIM_SHOOT_MP5, 0.45f); else - Animation_PlayerTopTemp(ANIM_CR_SHOOT1HAND, 0.45f); + Animation_PlayerTopTemp(ANIM_CROUCH_SHOOT_MP5, 0.45f); Sound_Play(pl, CHAN_WEAPON, "weapon_p90.fire"); #endif diff --git a/src/shared/cstrike/w_para.c b/src/shared/cstrike/w_para.c index 92d35945..01160f04 100644 --- a/src/shared/cstrike/w_para.c +++ b/src/shared/cstrike/w_para.c @@ -135,9 +135,9 @@ w_para_primary(void) pl.para_mag--; if (self.flags & FL_CROUCHING) - Animation_PlayerTopTemp(ANIM_SHOOT1HAND, 0.45f); + Animation_PlayerTopTemp(ANIM_CROUCH_SHOOT_PARA, 0.45f); else - Animation_PlayerTopTemp(ANIM_CR_SHOOT1HAND, 0.45f); + Animation_PlayerTopTemp(ANIM_SHOOT_PARA, 0.45f); Sound_Play(pl, CHAN_WEAPON, "weapon_para.fire"); #endif diff --git a/src/shared/cstrike/w_scout.c b/src/shared/cstrike/w_scout.c index 96739da2..94304e43 100644 --- a/src/shared/cstrike/w_scout.c +++ b/src/shared/cstrike/w_scout.c @@ -184,9 +184,9 @@ w_scout_primary(void) pl.scout_mag--; if (self.flags & FL_CROUCHING) - Animation_PlayerTopTemp(ANIM_SHOOT1HAND, 0.45f); + Animation_PlayerTopTemp(ANIM_SHOOT_RIFLE, 0.45f); else - Animation_PlayerTopTemp(ANIM_CR_SHOOT1HAND, 0.45f); + Animation_PlayerTopTemp(ANIM_CROUCH_SHOOT_RIFLE, 0.45f); Sound_Play(pl, CHAN_WEAPON, "weapon_scout.fire"); #endif diff --git a/src/shared/cstrike/w_sg550.c b/src/shared/cstrike/w_sg550.c index b27e6a8c..72cbd5b9 100644 --- a/src/shared/cstrike/w_sg550.c +++ b/src/shared/cstrike/w_sg550.c @@ -135,9 +135,9 @@ w_sg550_primary(void) pl.sg550_mag--; if (self.flags & FL_CROUCHING) - Animation_PlayerTopTemp(ANIM_SHOOT1HAND, 0.45f); + Animation_PlayerTopTemp(ANIM_SHOOT_RIFLE, 0.45f); else - Animation_PlayerTopTemp(ANIM_CR_SHOOT1HAND, 0.45f); + Animation_PlayerTopTemp(ANIM_CROUCH_SHOOT_RIFLE, 0.45f); Sound_Play(pl, CHAN_WEAPON, "weapon_sg550.fire"); #endif diff --git a/src/shared/cstrike/w_sg552.c b/src/shared/cstrike/w_sg552.c index 4f5d0b0b..b21f21a1 100644 --- a/src/shared/cstrike/w_sg552.c +++ b/src/shared/cstrike/w_sg552.c @@ -136,9 +136,9 @@ w_sg552_primary(void) pl.sg552_mag--; if (self.flags & FL_CROUCHING) - Animation_PlayerTopTemp(ANIM_SHOOT1HAND, 0.45f); + Animation_PlayerTopTemp(ANIM_SHOOT_RIFLE, 0.45f); else - Animation_PlayerTopTemp(ANIM_CR_SHOOT1HAND, 0.45f); + Animation_PlayerTopTemp(ANIM_CROUCH_SHOOT_RIFLE, 0.45f); Sound_Play(pl, CHAN_WEAPON, "weapon_sg552.fire"); #endif diff --git a/src/shared/cstrike/w_tmp.c b/src/shared/cstrike/w_tmp.c index d77cc9b4..ee282f1c 100644 --- a/src/shared/cstrike/w_tmp.c +++ b/src/shared/cstrike/w_tmp.c @@ -136,9 +136,9 @@ w_tmp_primary(void) pl.tmp_mag--; if (self.flags & FL_CROUCHING) - Animation_PlayerTopTemp(ANIM_SHOOT1HAND, 0.45f); + Animation_PlayerTopTemp(ANIM_SHOOT_MP5, 0.45f); else - Animation_PlayerTopTemp(ANIM_CR_SHOOT1HAND, 0.45f); + Animation_PlayerTopTemp(ANIM_CROUCH_SHOOT_MP5, 0.45f); Sound_Play(pl, CHAN_WEAPON, "weapon_tmp.fire"); #endif diff --git a/src/shared/cstrike/w_ump45.c b/src/shared/cstrike/w_ump45.c index ad842f41..176c17ea 100644 --- a/src/shared/cstrike/w_ump45.c +++ b/src/shared/cstrike/w_ump45.c @@ -136,9 +136,9 @@ w_ump45_primary(void) pl.ump45_mag--; if (self.flags & FL_CROUCHING) - Animation_PlayerTopTemp(ANIM_SHOOT1HAND, 0.45f); + Animation_PlayerTopTemp(ANIM_SHOOT_MP5, 0.45f); else - Animation_PlayerTopTemp(ANIM_CR_SHOOT1HAND, 0.45f); + Animation_PlayerTopTemp(ANIM_CROUCH_SHOOT_MP5, 0.45f); Sound_Play(pl, CHAN_WEAPON, "weapon_ump45.fire"); #endif diff --git a/src/shared/cstrike/w_usp45.c b/src/shared/cstrike/w_usp45.c index f1a988e5..44c32996 100644 --- a/src/shared/cstrike/w_usp45.c +++ b/src/shared/cstrike/w_usp45.c @@ -172,9 +172,9 @@ w_usp45_primary(void) TraceAttack_FireBullets(1, pl.origin + pl.view_ofs, 33, [accuracy,accuracy], WEAPON_USP45); if (self.flags & FL_CROUCHING) - Animation_PlayerTopTemp(ANIM_SHOOT1HAND, 0.45f); + Animation_PlayerTopTemp(ANIM_SHOOT_ONEHAND, 0.45f); else - Animation_PlayerTopTemp(ANIM_CR_SHOOT1HAND, 0.45f); + Animation_PlayerTopTemp(ANIM_CROUCH_SHOOT_ONEHAND, 0.45f); #endif /* this stuff is predicted */ diff --git a/src/shared/cstrike/w_xm1014.c b/src/shared/cstrike/w_xm1014.c index 9c0f138a..6f7d6e2b 100644 --- a/src/shared/cstrike/w_xm1014.c +++ b/src/shared/cstrike/w_xm1014.c @@ -146,9 +146,9 @@ w_xm1014_primary(void) pl.xm1014_mag--; if (self.flags & FL_CROUCHING) - Animation_PlayerTopTemp(ANIM_SHOOT1HAND, 0.45f); + Animation_PlayerTopTemp(ANIM_SHOOT_SHOTGUN, 0.45f); else - Animation_PlayerTopTemp(ANIM_CR_SHOOT1HAND, 0.45f); + Animation_PlayerTopTemp(ANIM_CROUCH_SHOOT_SHOTGUN, 0.45f); Sound_Play(pl, CHAN_WEAPON, "weapon_xm1014.fire"); #endif diff --git a/src/shared/pmove.c b/src/shared/pmove.c index aeea7a1e..6af11064 100644 --- a/src/shared/pmove.c +++ b/src/shared/pmove.c @@ -709,7 +709,6 @@ PMove_Run(void) float flFallVel = (self.flags & FL_ONGROUND) ? 0 : -self.velocity[2]; - /* maxspeed changes when crouching, TODO: make this game-specific */ self.maxspeed = GamePMove_Maxspeed((player)self);