From c034911f3803a5098cb735c8cde4913e146814d8 Mon Sep 17 00:00:00 2001 From: div0 Date: Mon, 28 Sep 2009 10:52:49 +0000 Subject: [PATCH] hagar: support randomized lifetime on secondary (unused) feature: cvar filters on map entities git-svn-id: svn://svn.icculus.org/nexuiz/trunk@7970 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- data/balance.cfg | 5 +- data/balance25.cfg | 5 +- data/balanceHavoc.cfg | 5 +- data/balanceSamual.cfg | 5 +- data/qcsrc/server/constants.qh | 2 +- data/qcsrc/server/sv_main.qc | 97 ++++++++++++++++++++++++++++++++++ data/qcsrc/server/w_hagar.qc | 2 +- data/scripts/entities.def | 1 + 8 files changed, 112 insertions(+), 10 deletions(-) diff --git a/data/balance.cfg b/data/balance.cfg index 26c72be59..9d5092b8a 100644 --- a/data/balance.cfg +++ b/data/balance.cfg @@ -3,7 +3,7 @@ // // And... don't forget to edit the other balance*.cfg too. -set cvar_check_balance 3ec2d034ac400bba7e93eef2c720669a +set cvar_check_balance 9b590c8f7c3065d917ac8e2e5e842a88 // {{{ weapon replacement // NOTE: this only replaces weapons on the map @@ -392,7 +392,8 @@ set g_balance_hagar_secondary_force 50 set g_balance_hagar_secondary_radius 90 set g_balance_hagar_secondary_spread 0.1 set g_balance_hagar_secondary_speed 2000 -set g_balance_hagar_secondary_lifetime 30 +set g_balance_hagar_secondary_lifetime_min 30 +set g_balance_hagar_secondary_lifetime_rand 0 set g_balance_hagar_secondary_refire 0.15 set g_balance_hagar_secondary_ammo 1 // }}} diff --git a/data/balance25.cfg b/data/balance25.cfg index abc8fa853..7ea0e12a9 100644 --- a/data/balance25.cfg +++ b/data/balance25.cfg @@ -3,7 +3,7 @@ // // And... don't forget to edit the other balance*.cfg too. -set cvar_check_balance 3ec2d034ac400bba7e93eef2c720669a +set cvar_check_balance 9b590c8f7c3065d917ac8e2e5e842a88 // {{{ weapon replacement // NOTE: this only replaces weapons on the map @@ -392,7 +392,8 @@ set g_balance_hagar_secondary_force 100 set g_balance_hagar_secondary_radius 65 set g_balance_hagar_secondary_spread 0.015 set g_balance_hagar_secondary_speed 1400 -set g_balance_hagar_secondary_lifetime 30 +set g_balance_hagar_secondary_lifetime_min 30 +set g_balance_hagar_secondary_lifetime_rand 0 set g_balance_hagar_secondary_refire 0.15 set g_balance_hagar_secondary_ammo 1 // }}} diff --git a/data/balanceHavoc.cfg b/data/balanceHavoc.cfg index 646e1f98d..3b53b3359 100644 --- a/data/balanceHavoc.cfg +++ b/data/balanceHavoc.cfg @@ -3,7 +3,7 @@ // // And... don't forget to edit the other balance*.cfg too. -set cvar_check_balance 3ec2d034ac400bba7e93eef2c720669a +set cvar_check_balance 9b590c8f7c3065d917ac8e2e5e842a88 // {{{ weapon replacement // NOTE: this only replaces weapons on the map @@ -392,7 +392,8 @@ set g_balance_hagar_secondary_force 50 set g_balance_hagar_secondary_radius 90 set g_balance_hagar_secondary_spread 0.1 set g_balance_hagar_secondary_speed 2000 -set g_balance_hagar_secondary_lifetime 30 +set g_balance_hagar_secondary_lifetime_min 30 +set g_balance_hagar_secondary_lifetime_rand 0 set g_balance_hagar_secondary_refire 0.1 set g_balance_hagar_secondary_ammo 1 // }}} diff --git a/data/balanceSamual.cfg b/data/balanceSamual.cfg index 01c4b200f..4eb2bb250 100644 --- a/data/balanceSamual.cfg +++ b/data/balanceSamual.cfg @@ -3,7 +3,7 @@ // // And... don't forget to edit the other balance*.cfg too. -set cvar_check_balance 3ec2d034ac400bba7e93eef2c720669a +set cvar_check_balance 9b590c8f7c3065d917ac8e2e5e842a88 // {{{ weapon replacement // NOTE: this only replaces weapons on the map @@ -392,7 +392,8 @@ set g_balance_hagar_secondary_force 50 set g_balance_hagar_secondary_radius 70 set g_balance_hagar_secondary_spread 0.05 set g_balance_hagar_secondary_speed 2000 -set g_balance_hagar_secondary_lifetime 30 +set g_balance_hagar_secondary_lifetime_min 30 +set g_balance_hagar_secondary_lifetime_rand 0 set g_balance_hagar_secondary_refire 0.15 set g_balance_hagar_secondary_ammo 1 // }}} diff --git a/data/qcsrc/server/constants.qh b/data/qcsrc/server/constants.qh index 15198b630..8a842ebf0 100644 --- a/data/qcsrc/server/constants.qh +++ b/data/qcsrc/server/constants.qh @@ -1,5 +1,5 @@ string CVAR_CHECK_DEFAULT = "4bb48bd2d43bd891aa49d542abb24bf8"; -string CVAR_CHECK_BALANCE = "3ec2d034ac400bba7e93eef2c720669a"; +string CVAR_CHECK_BALANCE = "9b590c8f7c3065d917ac8e2e5e842a88"; float FALSE = 0; float TRUE = 1; diff --git a/data/qcsrc/server/sv_main.qc b/data/qcsrc/server/sv_main.qc index c64bfded4..588141678 100644 --- a/data/qcsrc/server/sv_main.qc +++ b/data/qcsrc/server/sv_main.qc @@ -241,6 +241,7 @@ void StartFrame (void) .vector anglesjitter; .float anglejitter; .string gametypefilter; +.string cvarfilter; void SV_OnEntityPreSpawnFunction() { if(self.gametypefilter != "") @@ -249,6 +250,102 @@ void SV_OnEntityPreSpawnFunction() remove(self); return; } + if(self.cvarfilter != "") + { + float n, i, o, inv; + string s, k, v; + inv = 0; + + s = self.cvarfilter; + if(substring(s, 0, 1) == "+") + { + s = substring(s, 1, -1); + } + else if(substring(s, 0, 1) == "-") + { + inv = 1; + s = substring(s, 1, -1); + } + + n = tokenize(s); + for(i = 0; i < n; ++i) + { + s = argv(i); + // syntax: + // var>x + // var=x + // var<=x + // var==x + // var!=x + // var===x + // var!==x + if((o = strstrofs(s, ">=", 0)) >= 0) + { + k = substring(s, 0, o); + v = substring(s, o+2, -1); + if(cvar(k) < stof(v)) + goto cvar_fail; + } + else if((o = strstrofs(s, "<=", 0)) >= 0) + { + k = substring(s, 0, o); + v = substring(s, o+2, -1); + if(cvar(k) > stof(v)) + goto cvar_fail; + } + else if((o = strstrofs(s, ">", 0)) >= 0) + { + k = substring(s, 0, o); + v = substring(s, o+1, -1); + if(cvar(k) <= stof(v)) + goto cvar_fail; + } + else if((o = strstrofs(s, "<", 0)) >= 0) + { + k = substring(s, 0, o); + v = substring(s, o+1, -1); + if(cvar(k) >= stof(v)) + goto cvar_fail; + } + else if((o = strstrofs(s, "==", 0)) >= 0) + { + k = substring(s, 0, o); + v = substring(s, o+2, -1); + if(cvar(k) != stof(v)) + goto cvar_fail; + } + else if((o = strstrofs(s, "!=", 0)) >= 0) + { + k = substring(s, 0, o); + v = substring(s, o+2, -1); + if(cvar(k) == stof(v)) + goto cvar_fail; + } + else if((o = strstrofs(s, "===", 0)) >= 0) + { + k = substring(s, 0, o); + v = substring(s, o+2, -1); + if(cvar_string(k) != v) + goto cvar_fail; + } + else if((o = strstrofs(s, "!==", 0)) >= 0) + { + k = substring(s, 0, o); + v = substring(s, o+2, -1); + if(cvar_string(k) == v) + goto cvar_fail; + } + } + inv = !inv; +:cvar_fail + // now inv is 1 if we want to keep the item, and 0 if we want to get rid of it + if not(inv) + { + remove(self); + return; + } + } // support special -1 and -2 angle from radiant if (self.angles == '0 -1 0') diff --git a/data/qcsrc/server/w_hagar.qc b/data/qcsrc/server/w_hagar.qc index 5b55517d5..0d9fdf348 100644 --- a/data/qcsrc/server/w_hagar.qc +++ b/data/qcsrc/server/w_hagar.qc @@ -90,7 +90,7 @@ void W_Hagar_Attack2 (void) missile.cnt = 0; missile.use = W_Hagar_Explode; missile.think = adaptor_think2use; - missile.nextthink = time + cvar("g_balance_hagar_secondary_lifetime"); + missile.nextthink = time + cvar("g_balance_hagar_secondary_lifetime_min") + random() * cvar("g_balance_hagar_secondary_lifetime_rand"); PROJECTILE_MAKETRIGGER(missile); missile.projectiledeathtype = WEP_HAGAR | HITTYPE_SECONDARY; setorigin (missile, w_shotorg); diff --git a/data/scripts/entities.def b/data/scripts/entities.def index 14fd5c847..797de694b 100644 --- a/data/scripts/entities.def +++ b/data/scripts/entities.def @@ -684,6 +684,7 @@ originjitter: a vector describing a random offset this entity will be moved on i anglesjitter: a vector in the order "pitch yaw roll" describing a random angles change on this entity on initial spawn. The value 180 180 180 makes the angles entirely random and uniformly distributed (among euler angles). This corresponds to the "angles" field. Works on any non-q3map2-only entity. anglejitter: a float describing a random yaw angle change on this entity on initial spawn. The value 180 makes the yaw angle entirely random (maybe good for items). This corresponds to the "angle" field. Works on any non-q3map2-only entity. gametypefilter: either a + sign and a comma separated list of game types or the aliases "teams" and "noteams" to ONLY show the entity in the listed game types, or a - sign and a comma separated list of game types or the aliases "teams" and "noteams" to NOT show the entity in the listed game types. The syntax is the same as in sbar_columns_set strings. Works on any non-q3map2-only entity. +cvarfilter: either a + sign and a space separated list of conditions, or a - sign and the same for an inverted filter. The conditions are ALWAYS combined with AND! Possible conditions are: "cvar==value", "cvar!=value", "cvarvalue", "cvar<=value", "cvar>=value", "cvar===string", "cvar!==string", "cvar", "!cvar". Ridiculous example filter: "-g_balance_health_start<150 g_balance_armor_start==0" spawns an item only if start health is at least 150 or start armor is not 0. Other ideas: "+g_campaign" and "-g_campaign" for enabling/disabling items when the map is played as part of the campaign. -------- SPAWNFLAGS -------- ALIGN_ORIGN: align the origin to the surface below the model ALIGN_BOTTOM: align the bottom of the model to the surface below it -- 2.39.2