From: Mario Date: Mon, 16 Nov 2020 03:17:39 +0000 (+1000) Subject: Add g_balance_electro_secondary_limit setting to allow controlling the maximum number... X-Git-Tag: xonotic-v0.8.5~670 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=f60c97b464bf395a40120d5101a550efb015051e;p=xonotic%2Fxonotic-data.pk3dir.git Add g_balance_electro_secondary_limit setting to allow controlling the maximum number of electro orbs a player can have active at a time (the oldest orb will explode when the limit is reached) --- diff --git a/bal-wep-mario.cfg b/bal-wep-mario.cfg index 640ce2720..1026700fc 100644 --- a/bal-wep-mario.cfg +++ b/bal-wep-mario.cfg @@ -216,6 +216,7 @@ set g_balance_electro_secondary_edgedamage 15 set g_balance_electro_secondary_force 50 set g_balance_electro_secondary_health 5 set g_balance_electro_secondary_lifetime 4 +set g_balance_electro_secondary_limit 0 set g_balance_electro_secondary_radius 150 set g_balance_electro_secondary_refire 0.2 set g_balance_electro_secondary_refire2 1.6 diff --git a/bal-wep-nexuiz25.cfg b/bal-wep-nexuiz25.cfg index 1cbfe88e9..d82db5a15 100644 --- a/bal-wep-nexuiz25.cfg +++ b/bal-wep-nexuiz25.cfg @@ -216,6 +216,7 @@ set g_balance_electro_secondary_edgedamage 0 set g_balance_electro_secondary_force 200 set g_balance_electro_secondary_health 5 set g_balance_electro_secondary_lifetime 5 +set g_balance_electro_secondary_limit 0 set g_balance_electro_secondary_radius 150 set g_balance_electro_secondary_refire 0.3 set g_balance_electro_secondary_refire2 0 diff --git a/bal-wep-samual.cfg b/bal-wep-samual.cfg index 055afcc2a..8a1e40c29 100644 --- a/bal-wep-samual.cfg +++ b/bal-wep-samual.cfg @@ -216,6 +216,7 @@ set g_balance_electro_secondary_edgedamage 20 set g_balance_electro_secondary_force 50 set g_balance_electro_secondary_health 5 set g_balance_electro_secondary_lifetime 4 +set g_balance_electro_secondary_limit 0 set g_balance_electro_secondary_radius 150 set g_balance_electro_secondary_refire 0.2 set g_balance_electro_secondary_refire2 1.6 diff --git a/bal-wep-xdf.cfg b/bal-wep-xdf.cfg index a1fea0c38..611f67bce 100644 --- a/bal-wep-xdf.cfg +++ b/bal-wep-xdf.cfg @@ -216,6 +216,7 @@ set g_balance_electro_secondary_edgedamage 15 set g_balance_electro_secondary_force 200 set g_balance_electro_secondary_health 5 set g_balance_electro_secondary_lifetime 3 +set g_balance_electro_secondary_limit 0 set g_balance_electro_secondary_radius 150 set g_balance_electro_secondary_refire 0.2 set g_balance_electro_secondary_refire2 1.5 diff --git a/bal-wep-xonotic.cfg b/bal-wep-xonotic.cfg index 647fb2290..5f27b7ebf 100644 --- a/bal-wep-xonotic.cfg +++ b/bal-wep-xonotic.cfg @@ -216,6 +216,7 @@ set g_balance_electro_secondary_edgedamage 15 set g_balance_electro_secondary_force 50 set g_balance_electro_secondary_health 5 set g_balance_electro_secondary_lifetime 4 +set g_balance_electro_secondary_limit 0 set g_balance_electro_secondary_radius 150 set g_balance_electro_secondary_refire 0.2 set g_balance_electro_secondary_refire2 1.6 diff --git a/qcsrc/common/effects/qc/_mod.inc b/qcsrc/common/effects/qc/_mod.inc index 8df95b821..069ec0796 100644 --- a/qcsrc/common/effects/qc/_mod.inc +++ b/qcsrc/common/effects/qc/_mod.inc @@ -5,3 +5,4 @@ #include #include #include +#include diff --git a/qcsrc/common/effects/qc/_mod.qh b/qcsrc/common/effects/qc/_mod.qh index 3f6387f0e..124299ad7 100644 --- a/qcsrc/common/effects/qc/_mod.qh +++ b/qcsrc/common/effects/qc/_mod.qh @@ -5,3 +5,4 @@ #include #include #include +#include diff --git a/qcsrc/common/effects/qc/rubble.qc b/qcsrc/common/effects/qc/rubble.qc new file mode 100644 index 000000000..27dd7d40e --- /dev/null +++ b/qcsrc/common/effects/qc/rubble.qc @@ -0,0 +1,40 @@ +#include "rubble.qh" + +#ifdef GAMEQC +void RubbleLimit(string cname, int limit, void(entity) deleteproc) +{ + // remove rubble of the same type if it's at the limit + // remove multiple rubble if the limit has been decreased + while (1) + { + // walk the list and count the entities, find the oldest + // initialize our search with the first entity + int c = 0; + entity oldest = NULL; + float oldesttime = 0; + // compare to all other matching entities + IL_EACH(g_rubble, it.classname == cname, + { + ++c; + if(!oldest || oldesttime > it.creationtime) + { + oldest = it; + oldesttime = it.creationtime; + } + }); + + // stop if there are less than the limit already + if (c <= limit) break; + + // delete this oldest one and search again + deleteproc(oldest); + } +} + +entity RubbleNew(entity e) +{ + e.creationtime = time; + IL_PUSH(g_rubble, e); + return e; +} +#endif diff --git a/qcsrc/common/effects/qc/rubble.qh b/qcsrc/common/effects/qc/rubble.qh index 83f0ce855..406d602c1 100644 --- a/qcsrc/common/effects/qc/rubble.qh +++ b/qcsrc/common/effects/qc/rubble.qh @@ -1,48 +1,13 @@ #pragma once -#ifdef CSQC - +#ifdef GAMEQC entityclass(Rubble); classfield(Rubble).float creationtime; IntrusiveList g_rubble; STATIC_INIT(g_rubble) { g_rubble = IL_NEW(); } -void RubbleLimit(string cname, int limit, void(entity) deleteproc) -{ - // remove rubble of the same type if it's at the limit - // remove multiple rubble if the limit has been decreased - while (1) - { - // walk the list and count the entities, find the oldest - // initialize our search with the first entity - int c = 0; - entity oldest = NULL; - float oldesttime = 0; - // compare to all other matching entities - IL_EACH(g_rubble, it.classname == cname, - { - ++c; - if(!oldest || oldesttime > it.creationtime) - { - oldest = it; - oldesttime = it.creationtime; - } - }); - - // stop if there are less than the limit already - if (c <= limit) break; - - // delete this oldest one and search again - deleteproc(oldest); - } -} - -entity RubbleNew(entity e) -{ - e.creationtime = time; - IL_PUSH(g_rubble, e); - return e; -} +void RubbleLimit(string cname, int limit, void(entity) deleteproc); +entity RubbleNew(entity e); #endif diff --git a/qcsrc/common/weapons/weapon/electro.qc b/qcsrc/common/weapons/weapon/electro.qc index 10005f22e..21a2f9b01 100644 --- a/qcsrc/common/weapons/weapon/electro.qc +++ b/qcsrc/common/weapons/weapon/electro.qc @@ -1,6 +1,7 @@ #include "electro.qh" #ifdef SVQC +#include void W_Electro_TriggerCombo(vector org, float rad, entity own) { @@ -295,6 +296,13 @@ void W_Electro_Orb_Stick(entity this, entity to) IL_PUSH(g_projectiles, newproj); IL_PUSH(g_bot_dodge, newproj); + // check if limits are enabled (we can tell by checking if the original orb is listed) and push it to the list if so + if(IL_CONTAINS(g_rubble, this)) + { + newproj.creationtime = this.creationtime; + IL_PUSH(g_rubble, newproj); + } + delete(this); if(to) @@ -413,6 +421,12 @@ void W_Electro_Attack_Orb(Weapon thiswep, entity actor, .entity weaponentity) proj.bouncestop = WEP_CVAR_SEC(electro, bouncestop); proj.missile_flags = MIF_SPLASH | MIF_ARC; + if(WEP_CVAR_SEC(electro, limit) > 0) + { + RubbleNew(proj); + RubbleLimit("electro_orb", WEP_CVAR_SEC(electro, limit), adaptor_think2use_hittype_splash); + } + CSQCProjectile(proj, true, PROJECTILE_ELECTRO, false); // no culling, it has sound MUTATOR_CALLHOOK(EditProjectile, actor, proj); diff --git a/qcsrc/common/weapons/weapon/electro.qh b/qcsrc/common/weapons/weapon/electro.qh index 9583bc9f2..2f38024de 100644 --- a/qcsrc/common/weapons/weapon/electro.qh +++ b/qcsrc/common/weapons/weapon/electro.qh @@ -42,6 +42,7 @@ CLASS(Electro, Weapon) P(class, prefix, force, float, BOTH) \ P(class, prefix, health, float, SEC) \ P(class, prefix, lifetime, float, BOTH) \ + P(class, prefix, limit, float, SEC) \ P(class, prefix, midaircombo_enemy, bool, PRI) \ P(class, prefix, midaircombo_explode, float, PRI) \ P(class, prefix, midaircombo_interval, float, PRI) \