healthcap plugin: vampire heals only up to g_startingHealth (QL allowed 2x, players hit 400)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
esefandClaude Opus 5.5 committed 2026-10-16 00:45:04 +03:00
1 parent 266cc20b76
commit af1e29b1de
3 files changed
+44 -5

No files matched your search

+1 -1
View File
@@ -23,7 +23,7 @@ set zmq_rcon_ip "127.0.0.1"
set zmq_stats_enable "0"
// minqlx: only our plugins (the default minqlx plugin list needs a redis server)
set qlx_plugins "nowarmuptext,welcome,lgbot"
set qlx_plugins "nowarmuptext,welcome,lgbot,healthcap"
set qlx_pluginsPath "/ql/home/minqlx-plugins"
exec secrets.cfg
+39
View File
@@ -0,0 +1,39 @@
# cap health at the spawn health. Vampire healing in QL goes up to 2x max health
# (g_startingHealth 200 let players reach 400) and there is no cvar for a vampire cap,
# so every server frame any living player above the cap is set back to it.
# Cap = qlx_healthCap if > 0, else g_startingHealth (200 on lgvamp, 100 on lgvamp100).
import minqlx
REREAD_FRAMES = 40 # re-read the cvars about once a second (sv_fps 40)
def to_int(value):
try:
return int(float(value))
except (TypeError, ValueError):
return 0
class healthcap(minqlx.Plugin):
def __init__(self):
super().__init__()
self.set_cvar_once("qlx_healthCap", "0")
self.cap = 0
self.frames = 0
self.add_hook("frame", self.handle_frame)
self.read_cap()
self.logger.info("healthcap loaded: cap %d", self.cap)
def read_cap(self):
self.cap = to_int(self.get_cvar("qlx_healthCap")) or to_int(self.get_cvar("g_startingHealth"))
def handle_frame(self):
self.frames += 1
if self.frames >= REREAD_FRAMES:
self.frames = 0
self.read_cap()
if self.cap <= 0:
return
for p in self.players():
if p.is_alive and p.health > self.cap:
p.health = self.cap