From 6fd6d0dafd4bcf8d6060998aff39650098b8b5af Mon Sep 17 00:00:00 2001 From: Steam Deck User Date: Sat, 25 Mar 2023 20:07:25 -0400 Subject: [PATCH] SERVER: Quick and dirty game_counter implementation, mostly adlib --- source/server/defs/custom.qc | 1 + source/server/entities/map_entities.qc | 35 +++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/source/server/defs/custom.qc b/source/server/defs/custom.qc index 6f8d62b..92133d3 100644 --- a/source/server/defs/custom.qc +++ b/source/server/defs/custom.qc @@ -53,6 +53,7 @@ void(string com) SV_ParseClientCommand; .float recoil_delay; .float mapversion; .float ammo; +.float frags; #endif // FTE diff --git a/source/server/entities/map_entities.qc b/source/server/entities/map_entities.qc index 157ae33..5954e46 100644 --- a/source/server/entities/map_entities.qc +++ b/source/server/entities/map_entities.qc @@ -359,4 +359,37 @@ void() place_model = // Now just execute the misc_model spawn function. misc_model(); -}; \ No newline at end of file +}; + +// +// game_counter() +// Quick and dirty game_counter implementation, referenced +// from TWHL docs (https://twhl.info/index.php/wiki/page/game_counter) +// +#define SPAWNFLAG_COUNTER_REMOVEONFIRE 1 +#define SPAWNFLAG_COUNTER_RESETONFIRE 2 +void() game_counter_increment = +{ + self.frags++; + + if (self.frags == self.health) { + SUB_UseTargets(); + + if (self.spawnflags & SPAWNFLAG_COUNTER_REMOVEONFIRE) { + remove(self); + } else if (self.spawnflags & SPAWNFLAG_COUNTER_RESETONFIRE) { + self.frags = self.cost; + } + } +} + +void() game_counter = +{ + // TODO: master checking.. + + // Store the initial value in case RESET ON FIRE is set. + self.cost = self.frags; + + // Every time its triggered, increment. + self.use = game_counter_increment; +} \ No newline at end of file