From ecc963a0fe1e6ddc57fc2294d5dd5e9e867f598c Mon Sep 17 00:00:00 2001 From: Marco Hladik Date: Thu, 13 May 2021 09:26:26 +0200 Subject: [PATCH] Fix the consistency pack pk3, where modders can make different hand models for each team. Add crosshair to first-person spectating. Network view-ofs. --- src/client/game_event.qc | 7 ----- src/client/hud.qc | 8 ++++++ src/client/progs.src | 2 +- src/client/view.qc | 57 ++++++++++++++++++++++++++++++++++++++++ src/shared/animations.qc | 2 ++ src/shared/player.h | 1 - 6 files changed, 68 insertions(+), 9 deletions(-) create mode 100644 src/client/view.qc diff --git a/src/client/game_event.qc b/src/client/game_event.qc index 4710992..e86a62a 100644 --- a/src/client/game_event.qc +++ b/src/client/game_event.qc @@ -127,13 +127,6 @@ switch (fHeader) { sendevent("PlayerSwitchWeapon", "i", w); } - player pl = (player)pSeat->m_ePlayer; - if (getplayerkeyfloat(pl.entnum-1, "*team") == TEAM_CT) { - setcustomskin(pSeat->m_eViewModel, "", "geomset 0 2\n"); - } else { - setcustomskin(pSeat->m_eViewModel, "", "geomset 0 1\n"); - } - HUD_WeaponPickupNotify(w); break; case EV_RADIOMSG: diff --git a/src/client/hud.qc b/src/client/hud.qc index 4a51275..78088d9 100644 --- a/src/client/hud.qc +++ b/src/client/hud.qc @@ -721,6 +721,14 @@ HUD_DrawSpectator(void) vecPos[1] = g_hudres[1]-21; drawstring(vecPos, strText, [12,12], SPEC_FG_COL, 1.0f, DRAWFLAG_NORMAL); + if (spec.spec_mode == SPECMODE_FIRSTPERSON) { + entity oself = self; + self = findfloat(world, ::entnum, spec.spec_ent); + if (self) + Cstrike_DrawCrosshair(); + self = oself; + } + /* money */ strText = sprintf("$ %i", getstati(STAT_MONEY)); flSep = stringwidth(strText, TRUE, [12,12]); diff --git a/src/client/progs.src b/src/client/progs.src index d9cd6d9..99b15f5 100644 --- a/src/client/progs.src +++ b/src/client/progs.src @@ -28,7 +28,7 @@ init.qc entities.qc cmds.qc game_event.qc -../../../valve/src/client/view.qc +view.qc crosshair.qc ../../../valve/src/client/obituary.qc hud.qc diff --git a/src/client/view.qc b/src/client/view.qc new file mode 100644 index 0000000..b417387 --- /dev/null +++ b/src/client/view.qc @@ -0,0 +1,57 @@ +/* + * 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. + */ + +void +View_UpdateWeapon(entity vm, entity mflash) +{ + player pl = (player)pSeat->m_ePlayer; + + /* only bother upon change */ + if (pSeat->m_iLastWeapon == pl.activeweapon) { + return; + } + pSeat->m_iOldWeapon = pSeat->m_iLastWeapon; + pSeat->m_iLastWeapon = pl.activeweapon; + + if (!pl.activeweapon) { + return; + } + + /* hack, we changed the wep, move this into Game_Input/PMove */ + Weapons_Draw(); + + /* we forced a weapon call outside the prediction, + * thus we need to update all the net variables to + * make sure these updates are recognized. this is + * vile but it'll have to do for now */ + SAVE_STATE(pl.w_attack_next); + SAVE_STATE(pl.w_idle_next); + SAVE_STATE(pl.viewzoom); + SAVE_STATE(pl.weapontime); + + /* figure out when the attachments start. in FTE attachments for + * HLMDL are treated as bones. they start at numbones + 1 */ + skel_delete(mflash.skeletonindex); + mflash.skeletonindex = skel_create(vm.modelindex); + pSeat->m_iVMBones = skel_get_numbones(mflash.skeletonindex) + 1; + + player pl = (player)pSeat->m_ePlayer; + if (getplayerkeyfloat(pl.entnum-1, "*team") == TEAM_CT) { + setcustomskin(pSeat->m_eViewModel, "", "geomset 0 2\n"); + } else { + setcustomskin(pSeat->m_eViewModel, "", "geomset 0 1\n"); + } +} diff --git a/src/shared/animations.qc b/src/shared/animations.qc index 9eb7a69..d27c3aa 100755 --- a/src/shared/animations.qc +++ b/src/shared/animations.qc @@ -103,12 +103,14 @@ Animation_PlayerUpdate(player pl) pl.frame1time = 10.0f; } +#if 0 makevectors([0, pl.angles[1], 0]); float fCorrect = dotproduct(pl.velocity, v_right) * 0.25f; pl.subblendfrac = -fCorrect * 0.05f; pl.subblend2frac *= -0.1f; pl.angles[1] -= fCorrect; +#endif #ifdef SERVER pl.basesubblendfrac = diff --git a/src/shared/player.h b/src/shared/player.h index 0dcc44f..5f763f7 100644 --- a/src/shared/player.h +++ b/src/shared/player.h @@ -519,7 +519,6 @@ player::SendEntity(entity ePEnt, float fChanged) fChanged &= ~PLAYER_ITEMS; fChanged &= ~PLAYER_HEALTH; fChanged &= ~PLAYER_ARMOR; - fChanged &= ~PLAYER_VIEWOFS; fChanged &= ~PLAYER_AMMO1; fChanged &= ~PLAYER_AMMO2; fChanged &= ~PLAYER_AMMO3;