From 46512b5e673fe5b5e4f8d948109a410bad25d758 Mon Sep 17 00:00:00 2001 From: EladNLG Date: Sat, 7 Dec 2024 17:27:08 +0200 Subject: [PATCH] Update scripts to co-operate with launcher changes --- .../vscripts/sh_northstar_mod_weapon_vars.nut | 30 +++++++------------ 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/Northstar.Custom/mod/scripts/vscripts/sh_northstar_mod_weapon_vars.nut b/Northstar.Custom/mod/scripts/vscripts/sh_northstar_mod_weapon_vars.nut index 22cefaf18..4afe43634 100644 --- a/Northstar.Custom/mod/scripts/vscripts/sh_northstar_mod_weapon_vars.nut +++ b/Northstar.Custom/mod/scripts/vscripts/sh_northstar_mod_weapon_vars.nut @@ -130,30 +130,20 @@ void function CodeCallback_PredictWeaponMods( entity weapon ) #endif #if SERVER -// called every TICK (NOT script frame) for every player. +// called every TICK (NOT script frame) for every weapon. // used for calculating a player's weaponvars for -// their active and selected (weapon being switched to) -// weapons. -void function CodeCallback_DoWeaponModsForPlayer( entity player ) +// all of their weapons. +void function CodeCallback_CalcWeaponModsForWeapon( entity weapon ) { - if (!IsValid(player)) + if (!IsValid(weapon)) return - if (!IsValid(player.GetActiveWeapon())) + // only recalculate mods for weapons owned by players + if (!IsValid(weapon.GetWeaponOwner()) || !weapon.GetWeaponOwner().IsPlayer()) return - // recalculating mods is slightly expensive - enough - // that doing it for all weapons for all players - // is a bad idea. so offloading mod recalculation - // responsibility to the modder is better imo. - // we do it for the active weapon to not cause mispredictions. - // However, client does it every frame for the all of their weapons. - // (done in native, we arent in control of it.) - ModWeaponVars_CalculateWeaponMods( player.GetActiveWeapon() ) - - // the weapon the player is about to switch to - if (IsValid(player.GetSelectedWeapon())) - { - ModWeaponVars_CalculateWeaponMods( player.GetSelectedWeapon() ) - } + // recalculating mods is slightly expensive? i think? + // TODO: check performance at high player counts? + // 32 * (max 6 offhand + 4 main weapons) = 320 calls per tick <-- a lot!!!!! + ModWeaponVars_CalculateWeaponMods( weapon ) } #endif \ No newline at end of file