From 53ad8ccc6d0978e73686532a9839d401edf7b412 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Sun, 28 Dec 2025 14:19:17 -0600 Subject: [PATCH 1/2] offload weapon/ammo counter update commands to the generic damagemodel --- .../game/data/DamageModel/DamageModel.tscript | 2 + .../DamageModel/scripts/client/client.tscript | 67 +++++++++++++++++++ .../scripts/server/commands.tscript | 12 ++++ 3 files changed, 81 insertions(+) create mode 100644 Templates/BaseGame/game/data/DamageModel/scripts/client/client.tscript create mode 100644 Templates/BaseGame/game/data/DamageModel/scripts/server/commands.tscript diff --git a/Templates/BaseGame/game/data/DamageModel/DamageModel.tscript b/Templates/BaseGame/game/data/DamageModel/DamageModel.tscript index 3268a5b9e..f3932781d 100644 --- a/Templates/BaseGame/game/data/DamageModel/DamageModel.tscript +++ b/Templates/BaseGame/game/data/DamageModel/DamageModel.tscript @@ -23,6 +23,7 @@ function DamageModel::onCreateGameServer(%this) %this.queueExec("./scripts/server/shapeBase"); %this.queueExec("./scripts/server/vehicle"); %this.queueExec("./scripts/server/player"); + %this.queueExec("./scripts/server/commands"); } //This is called when the server is shut down due to the game/map being exited @@ -35,6 +36,7 @@ function DamageModel::initClient(%this) { %this.queueExec("./guis/damageGuiOverlay.gui"); %this.queueExec("./scripts/client/playGui"); + %this.queueExec("./scripts/client/client"); } //This is called when a client connects to a server diff --git a/Templates/BaseGame/game/data/DamageModel/scripts/client/client.tscript b/Templates/BaseGame/game/data/DamageModel/scripts/client/client.tscript new file mode 100644 index 000000000..4f015a954 --- /dev/null +++ b/Templates/BaseGame/game/data/DamageModel/scripts/client/client.tscript @@ -0,0 +1,67 @@ + +// ---------------------------------------------------------------------------- +// WeaponHUD +// ---------------------------------------------------------------------------- + +// Update the Ammo Counter with current ammo, if not any then hide the counter. +function clientCmdSetAmmoAmountHud(%amount, %amountInClips) +{ + if (!%amount) + AmmoAmount.setVisible(false); + else + { + AmmoAmount.setVisible(true); + AmmoAmount.setText("Ammo: " @ %amount @ "/" @ %amountInClips); + } +} + +// Here we update the Weapon Preview image & reticle for each weapon. We also +// update the Ammo Counter (just so we don't have to call it separately). +// Passing an empty parameter ("") hides the HUD component. + +function clientCmdRefreshWeaponHUD(%amount, %preview, %ret, %zoomRet, %amountInClips) +{ + if (!%amount) + AmmoAmount.setVisible(false); + else + { + AmmoAmount.setVisible(true); + AmmoAmount.setText("Ammo: " @ %amount @ "/" @ %amountInClips); + } + + if (%preview $= "" || detag(%preview) $= "blank") + { + WeaponHUD.setVisible(false); + PreviewImage.setBitmap(""); + } + else + { + WeaponHUD.setVisible(true); + PreviewImage.setbitmap(detag(%preview)); + } + + if (%ret $= "" || detag(%ret) $= "blank") + { + Reticle.setVisible(false); + Reticle.setBitmap(""); + } + else + { + Reticle.setVisible(true); + Reticle.setbitmap(detag(%ret)); + } + + if (isObject(ZoomReticle) || detag(%zoomRet) $= "blank") + { + if (%zoomRet $= "" || detag(%zoomRet) $= "blank") + { + ZoomReticle.setVisible(false); + ZoomReticle.setBitmap(""); + } + else + { + ZoomReticle.setVisible(true); + ZoomReticle.setBitmap(detag(%zoomRet)); + } + } +} \ No newline at end of file diff --git a/Templates/BaseGame/game/data/DamageModel/scripts/server/commands.tscript b/Templates/BaseGame/game/data/DamageModel/scripts/server/commands.tscript new file mode 100644 index 000000000..1a03625ce --- /dev/null +++ b/Templates/BaseGame/game/data/DamageModel/scripts/server/commands.tscript @@ -0,0 +1,12 @@ +// ---------------------------------------------------------------------------- +// weapon HUD +// ---------------------------------------------------------------------------- +function GameConnection::setAmmoAmountHud(%client, %amount, %amountInClips ) +{ + commandToClient(%client, 'SetAmmoAmountHud', %amount, %amountInClips); +} + +function GameConnection::RefreshWeaponHud(%client, %amount, %preview, %ret, %zoomRet, %amountInClips) +{ + commandToClient(%client, 'RefreshWeaponHud', %amount, %preview, %ret, %zoomRet, %amountInClips); +} \ No newline at end of file From 235be5eccd6f342f23f170c9931521d1389ca27f Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Mon, 29 Dec 2025 17:36:08 -0600 Subject: [PATCH 2/2] remove damagemodel from the game subgroup --- Templates/BaseGame/game/data/DamageModel/DamageModel.module | 1 - 1 file changed, 1 deletion(-) diff --git a/Templates/BaseGame/game/data/DamageModel/DamageModel.module b/Templates/BaseGame/game/data/DamageModel/DamageModel.module index 26de8f0dc..3fb5ab454 100644 --- a/Templates/BaseGame/game/data/DamageModel/DamageModel.module +++ b/Templates/BaseGame/game/data/DamageModel/DamageModel.module @@ -5,7 +5,6 @@ scriptFile="DamageModel.tscript" CreateFunction="onCreate" DestroyFunction="onDestroy" - Group="Game" Dependencies="UI=1">