From 9ec5bf9de473136485202540ff77838b54067ed4 Mon Sep 17 00:00:00 2001 From: cypress Date: Sat, 29 Jun 2024 18:07:02 -0700 Subject: [PATCH] SERVER: Add support for nzp_lockviewmodel builtin --- source/server/defs/custom.qc | 2 +- source/server/defs/standard.qc | 2 ++ source/server/entities/machines.qc | 2 +- source/server/entities/pack_a_punch.qc | 2 +- source/server/entities/wall_weapon.qc | 2 +- source/server/player/last_stand.qc | 4 ++-- source/server/utilities/weapon_utilities.qc | 2 +- source/server/weapons/bouncing_betty.qc | 6 +++--- source/server/weapons/frames_core.qc | 14 +++++++++++-- source/server/weapons/weapon_core.qc | 22 ++++++++++----------- 10 files changed, 35 insertions(+), 23 deletions(-) diff --git a/source/server/defs/custom.qc b/source/server/defs/custom.qc index 2e8321f..50cc0e1 100644 --- a/source/server/defs/custom.qc +++ b/source/server/defs/custom.qc @@ -237,7 +237,7 @@ var struct guninventory_struct .float throw_delay; //weapon frames -void Set_W_Frame (float startframe, float endframe, float duration, float funccalledin, float animtype, void(optional float t) endanimfunc, string set_model, float dontstartnew, float side); +void Set_W_Frame (float startframe, float endframe, float duration, float funccalledin, float animtype, void(optional float t) endanimfunc, string set_model, float dontstartnew, float side, float lock_viewmodel); .float weapon_animduration; .float weapon2_animduration; .float weapon_anim_type; diff --git a/source/server/defs/standard.qc b/source/server/defs/standard.qc index 6c564d9..c286739 100644 --- a/source/server/defs/standard.qc +++ b/source/server/defs/standard.qc @@ -275,6 +275,8 @@ void (entity who) void (entity who, string name) nzp_setplayername = #505; void (entity who, float version) nzp_setdoubletapver = #506; void (entity who, float color, float duration, float type) nzp_screenflash = #507; +void (entity who, float state) nzp_lockviewmodel = #508; + // // constants // diff --git a/source/server/entities/machines.qc b/source/server/entities/machines.qc index feee394..88243a6 100644 --- a/source/server/entities/machines.qc +++ b/source/server/entities/machines.qc @@ -116,7 +116,7 @@ void DrinkPerk() { self.knife_delay = self.reload_delay2 = self.fire_delay2 = self.fire_delay = self.reload_delay = 3 + time; W_HideCrosshair(self); - Set_W_Frame (machine.weapon_animduration, machine.weapon2_animduration, 2.25, 0, PERK, GivePerk, machine.weapon2model, true, S_RIGHT); + Set_W_Frame (machine.weapon_animduration, machine.weapon2_animduration, 2.25, 0, PERK, GivePerk, machine.weapon2model, true, S_RIGHT, true); sound(self, CHAN_ITEM, machine.oldmodel, 1, ATTN_NORM); // Communicate to our engines that this client should display correct Double-Tap icon. diff --git a/source/server/entities/pack_a_punch.qc b/source/server/entities/pack_a_punch.qc index d37cc33..1a4ca7e 100644 --- a/source/server/entities/pack_a_punch.qc +++ b/source/server/entities/pack_a_punch.qc @@ -232,7 +232,7 @@ void(entity pap, entity buyer) PAP_UpgradeWeapon = Weapon_RemoveWeapon(0); W_HideCrosshair(self); - Set_W_Frame (0, 39, 2.0, 0, 0, W_PutOutHack, "models/machines/v_pap.mdl", true, S_BOTH); + Set_W_Frame (0, 39, 2.0, 0, 0, W_PutOutHack, "models/machines/v_pap.mdl", true, S_BOTH, true); self.weapon2model = ""; #ifndef FTE diff --git a/source/server/entities/wall_weapon.qc b/source/server/entities/wall_weapon.qc index 80f5c5f..b6889d6 100644 --- a/source/server/entities/wall_weapon.qc +++ b/source/server/entities/wall_weapon.qc @@ -349,7 +349,7 @@ void () WallWeapon_TouchTrigger = entity tempz; tempz = self; self = other; - Set_W_Frame(15, 30, 2.75, 0, 0, W_PlayTakeOut, "models/weapons/knife/v_bowie.mdl", false, S_BOTH); + Set_W_Frame(15, 30, 2.75, 0, 0, W_PlayTakeOut, "models/weapons/knife/v_bowie.mdl", false, S_BOTH, true); self.bowie = 1; } } diff --git a/source/server/player/last_stand.qc b/source/server/player/last_stand.qc index b0d85b8..9fda42c 100644 --- a/source/server/player/last_stand.qc +++ b/source/server/player/last_stand.qc @@ -188,7 +188,7 @@ void(entity client) LastStand_AssignWeapon = float startframe = GetFrame(self.weapon,TAKE_OUT_START); float endframe = GetFrame(self.weapon,TAKE_OUT_END); - Set_W_Frame (startframe, endframe, 0, 0, 0, SUB_Null, self.weaponmodel, false, S_BOTH); + Set_W_Frame (startframe, endframe, 0, 0, 0, SUB_Null, self.weaponmodel, false, S_BOTH, false); self = old_self; }; @@ -312,7 +312,7 @@ void(entity downed_client, entity revivee) LastStand_LinkRevivee = // Initiate an animation for morphine. entity old_self = self; self = revivee; - Set_W_Frame (0, 21, 0, 0, SPRINT, SUB_Null, "models/weapons/morphine/v_morphine.mdl", false, S_RIGHT); + Set_W_Frame (0, 21, 0, 0, SPRINT, SUB_Null, "models/weapons/morphine/v_morphine.mdl", false, S_RIGHT, true); self = old_self; }; diff --git a/source/server/utilities/weapon_utilities.qc b/source/server/utilities/weapon_utilities.qc index 07f815b..a1772d6 100644 --- a/source/server/utilities/weapon_utilities.qc +++ b/source/server/utilities/weapon_utilities.qc @@ -204,7 +204,7 @@ void (float animation_type, void(optional float t) end_function, float playback_ self.weapon2model = GetWeapon2Model(self.weapon); W_AimOut(); - Set_W_Frame(start_frame, end_frame, playback_duration, 0, 0, end_function, GetWeaponModel(self.weapon, 0), false, S_BOTH); + Set_W_Frame(start_frame, end_frame, playback_duration, 0, 0, end_function, GetWeaponModel(self.weapon, 0), false, S_BOTH, false); }; // diff --git a/source/server/weapons/bouncing_betty.qc b/source/server/weapons/bouncing_betty.qc index a62b843..155617d 100644 --- a/source/server/weapons/bouncing_betty.qc +++ b/source/server/weapons/bouncing_betty.qc @@ -139,7 +139,7 @@ void() Betty_CheckForRelease = if(self.grenade_delay < time) self.grenade_delay = time + 0.05; self.isBuying = true; - Set_W_Frame (13, 19, 0.3, 5, GRENADE, Betty_Drop, "models/weapons/grenade/v_betty.mdl", true, S_RIGHT); + Set_W_Frame (13, 19, 0.3, 5, GRENADE, Betty_Drop, "models/weapons/grenade/v_betty.mdl", true, S_RIGHT, true); sound (self, CHAN_WEAPON, "sounds/weapons/grenade/throw.wav", 1, ATTN_NORM); self.reload_delay2 = self.fire_delay2 = self.reload_delay = self.fire_delay = time + 0.4; self.throw_delay = time + 0.9; @@ -147,7 +147,7 @@ void() Betty_CheckForRelease = // Keep holding it else { self.isBuying = true; - Set_W_Frame (13, 13, 0, 0, GRENADE, Betty_CheckForRelease, "models/weapons/grenade/v_betty.mdl", true, S_RIGHT); + Set_W_Frame (13, 13, 0, 0, GRENADE, Betty_CheckForRelease, "models/weapons/grenade/v_betty.mdl", true, S_RIGHT, true); } } @@ -168,7 +168,7 @@ void() W_PrimeBetty = W_HideCrosshair(self); // Play the "prime" animation for the betty viewmodel. - Set_W_Frame (0, 13, 1, 0, GRENADE, Betty_CheckForRelease, "models/weapons/grenade/v_betty.mdl", true, S_RIGHT); + Set_W_Frame (0, 13, 1, 0, GRENADE, Betty_CheckForRelease, "models/weapons/grenade/v_betty.mdl", true, S_RIGHT, true); // Subtract a betty from our inventory, set up delays, prevent use spam. self.secondary_grenades -= 1; diff --git a/source/server/weapons/frames_core.qc b/source/server/weapons/frames_core.qc index 27d0de7..da0005f 100644 --- a/source/server/weapons/frames_core.qc +++ b/source/server/weapons/frames_core.qc @@ -43,7 +43,7 @@ void() ContinueRun = modelname = GetWeaponModel(self.weapon, 0); } else modelname = ""; - Set_W_Frame (startframe, endframe, 0, 0, SPRINT, ContinueRun, modelname, false, S_BOTH); + Set_W_Frame (startframe, endframe, 0, 0, SPRINT, ContinueRun, modelname, false, S_BOTH, false); } @@ -192,7 +192,7 @@ float(string path) model_should_hide_weapon2 = return false; } -void Set_W_Frame (float startframe, float endframe, float duration, float funccalledin, float animtype, void(optional float t) endanimfunc, string set_model, float dontstartnew, float side) = +void Set_W_Frame (float startframe, float endframe, float duration, float funccalledin, float animtype, void(optional float t) endanimfunc, string set_model, float dontstartnew, float side, float lock_viewmodel) = { float math, reversed; @@ -248,4 +248,14 @@ void Set_W_Frame (float startframe, float endframe, float duration, float funcca } } } + +#ifndef FTE + + // For source ports where the viewmodel is able to be manipulated based on the camera + // position, we explicitly communicate to those clients to prohibit that with + // lock_viewmodel whenever we are drinking a Perk-A-Cola, meleeing, etc. + nzp_lockviewmodel(self, lock_viewmodel); + +#endif // FTE + } diff --git a/source/server/weapons/weapon_core.qc b/source/server/weapons/weapon_core.qc index e86a5cc..d38f9d0 100644 --- a/source/server/weapons/weapon_core.qc +++ b/source/server/weapons/weapon_core.qc @@ -358,7 +358,7 @@ void() ContinueReload = //Special reloads delay *= 0.5; } self.reload_delay = time + delay; - Set_W_Frame (startframe, endframe, delay, 0, RELOAD, endanimfunc, modelname, false, S_RIGHT); + Set_W_Frame (startframe, endframe, delay, 0, RELOAD, endanimfunc, modelname, false, S_RIGHT, false); } } @@ -378,7 +378,7 @@ void(float side) W_AdvanceAnim = self.reload_delay = self.reload_delay2 = delay + time; - Set_W_Frame (startframe, endframe, delay, reloadcancelframe, RELOAD, W_Give_Ammo, modelname, false, side); + Set_W_Frame (startframe, endframe, delay, reloadcancelframe, RELOAD, W_Give_Ammo, modelname, false, side, false); } void(float side) W_Reload = @@ -490,7 +490,7 @@ void(float side) W_Reload = self.reload_delay2 = delay + time; } - Set_W_Frame (startframe, endframe, delay, reloadcancelframe, RELOAD, endanimfunc, modelname, false, side); + Set_W_Frame (startframe, endframe, delay, reloadcancelframe, RELOAD, endanimfunc, modelname, false, side, false); } if (self.weapon != W_TRENCH) { @@ -544,7 +544,7 @@ void () W_LoadAmmo = if (self.perks & P_DOUBLE) delay *= 0.66; - Set_W_Frame (startframe, endframe, delay, reloadcancelframe, FIRE, W_LoadAmmoDone, modelname, false, S_RIGHT); + Set_W_Frame (startframe, endframe, delay, reloadcancelframe, FIRE, W_LoadAmmoDone, modelname, false, S_RIGHT, false); self.fire_delay = delay + time; } } @@ -1137,10 +1137,10 @@ void(float side) W_Fire = if (self.weapon == W_GUT || self.weapon == W_KAR_SCOPE || self.weapon == W_TRENCH || self.weapon == W_KAR || self.weapon == W_ARMAGEDDON || self.weapon == W_HEADCRACKER || self.weapon == W_SPRING || self.weapon == W_PULVERIZER) { - Set_W_Frame (startframe, endframe, delay, 0, FIRE, W_LoadAmmo, modelname, FALSE, side); + Set_W_Frame (startframe, endframe, delay, 0, FIRE, W_LoadAmmo, modelname, FALSE, side, false); self.NeedLoad = true; } else { - Set_W_Frame (startframe, endframe, delay, 0, FIRE, WeaponCore_CheckForReload, modelname, FALSE, side); + Set_W_Frame (startframe, endframe, delay, 0, FIRE, WeaponCore_CheckForReload, modelname, FALSE, side, false); } @@ -1281,7 +1281,7 @@ void() WeaponCore_Melee = // Apply camera punch, and begin playback. self.punchangle_x = -5; self.punchangle_y = -10; - Set_W_Frame (start_frame, end_frame, anim_duration, 0, KNIFE, end_func, model_path, false, S_RIGHT); + Set_W_Frame (start_frame, end_frame, anim_duration, 0, KNIFE, end_func, model_path, false, S_RIGHT, true); self.knife_delay = anim_duration + time; // Now apply the lunge velocity, but only if we're Standing. @@ -1420,7 +1420,7 @@ void() W_ThrowGrenade = startframe = GetFrame(self.weapon,TAKE_OUT_START); endframe = GetFrame(self.weapon,TAKE_OUT_END); modelname = GetWeaponModel(self.weapon, 0); - Set_W_Frame (startframe, endframe, 0, 0, 0, ReturnWeaponModel, modelname, false, S_BOTH); + Set_W_Frame (startframe, endframe, 0, 0, 0, ReturnWeaponModel, modelname, false, S_BOTH, false); SetUpdate(self, UT_HUD, 6, 0, 0); } @@ -1438,7 +1438,7 @@ void() checkHold = self.grenade_delay = time + 0.05; self.isBuying = true; - Set_W_Frame (3, 6, 0, 5, GRENADE, W_ThrowGrenade, "models/weapons/grenade/v_grenade.mdl", true, S_RIGHT); + Set_W_Frame (3, 6, 0, 5, GRENADE, W_ThrowGrenade, "models/weapons/grenade/v_grenade.mdl", true, S_RIGHT, true); sound (self, CHAN_WEAPON, "sounds/weapons/grenade/throw.wav", 1, ATTN_NORM); self.reload_delay2 = self.fire_delay2 = self.reload_delay = self.fire_delay = time + 0.4; self.throw_delay = time + 0.9; @@ -1457,7 +1457,7 @@ void() checkHold = grenade_pulse(self); } - Set_W_Frame (2, 2, 0, 0, GRENADE, checkHold, "models/weapons/grenade/v_grenade.mdl", true, S_RIGHT); + Set_W_Frame (2, 2, 0, 0, GRENADE, checkHold, "models/weapons/grenade/v_grenade.mdl", true, S_RIGHT, true); } } @@ -1471,7 +1471,7 @@ void() W_Grenade = W_SprintStop(); W_HideCrosshair(self); - Set_W_Frame (0, 2, 0.6, 0, GRENADE, checkHold, "models/weapons/grenade/v_grenade.mdl", true, S_RIGHT); + Set_W_Frame (0, 2, 0.6, 0, GRENADE, checkHold, "models/weapons/grenade/v_grenade.mdl", true, S_RIGHT, true); sound (self, CHAN_WEAPON, "sounds/weapons/grenade/prime.wav", 1, ATTN_NORM); self.primary_grenades -= 1; self.reload_delay2 = self.fire_delay2 = self.throw_delay = self.reload_delay = self.fire_delay = time + 6;