From ed273c1ef193543bfbba462c574a1bc6e18d83b3 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 21 Aug 2016 23:06:56 +1000 Subject: [PATCH] Add a list for domination control points --- qcsrc/server/bot/api.qh | 1 - qcsrc/server/bot/default/havocbot/roles.qc | 13 ---------- qcsrc/server/bot/default/havocbot/roles.qh | 1 - qcsrc/server/bot/null/bot_null.qc | 1 - .../mutators/mutator/gamemode_domination.qc | 25 ++++++++++++++++--- .../mutators/mutator/gamemode_domination.qh | 3 +++ 6 files changed, 24 insertions(+), 20 deletions(-) diff --git a/qcsrc/server/bot/api.qh b/qcsrc/server/bot/api.qh index 59af78cb0..64957b92e 100644 --- a/qcsrc/server/bot/api.qh +++ b/qcsrc/server/bot/api.qh @@ -63,7 +63,6 @@ void bot_think(entity this); entity find_bot_by_name(string name); entity find_bot_by_number(float number); -void havocbot_goalrating_controlpoints(entity this, float ratingscale, vector org, float sradius); void havocbot_goalrating_enemyplayers(entity this, float ratingscale, vector org, float sradius); void havocbot_goalrating_items(entity this, float ratingscale, vector org, float sradius); diff --git a/qcsrc/server/bot/default/havocbot/roles.qc b/qcsrc/server/bot/default/havocbot/roles.qc index 04cf043ae..dcf18ef19 100644 --- a/qcsrc/server/bot/default/havocbot/roles.qc +++ b/qcsrc/server/bot/default/havocbot/roles.qc @@ -118,19 +118,6 @@ void havocbot_goalrating_items(entity this, float ratingscale, vector org, float }); } -void havocbot_goalrating_controlpoints(entity this, float ratingscale, vector org, float sradius) -{ - FOREACH_ENTITY_CLASS("dom_controlpoint", vdist((((it.absmin + it.absmax) * 0.5) - org), <, sradius), - { - if(it.cnt > -1) // this is just being fought - navigation_routerating(this, it, ratingscale, 5000); - else if(it.goalentity.cnt == 0) // unclaimed - navigation_routerating(this, it, ratingscale * 0.5, 5000); - else if(it.goalentity.team != this.team) // other team's point - navigation_routerating(this, it, ratingscale * 0.2, 5000); - }); -} - void havocbot_goalrating_enemyplayers(entity this, float ratingscale, vector org, float sradius) { if (autocvar_bot_nofire) diff --git a/qcsrc/server/bot/default/havocbot/roles.qh b/qcsrc/server/bot/default/havocbot/roles.qh index 5b1f2b530..6f70f09be 100644 --- a/qcsrc/server/bot/default/havocbot/roles.qh +++ b/qcsrc/server/bot/default/havocbot/roles.qh @@ -1,2 +1 @@ #pragma once -void havocbot_goalrating_controlpoints(entity this, float ratingscale, vector org, float sradius); diff --git a/qcsrc/server/bot/null/bot_null.qc b/qcsrc/server/bot/null/bot_null.qc index 271252dee..b4102cb6c 100644 --- a/qcsrc/server/bot/null/bot_null.qc +++ b/qcsrc/server/bot/null/bot_null.qc @@ -18,7 +18,6 @@ void bot_think(entity this) { } entity find_bot_by_name(string name) { return NULL; } entity find_bot_by_number(float number) { return NULL; } -void havocbot_goalrating_controlpoints(entity this, float ratingscale, vector org, float sradius) { } void havocbot_goalrating_enemyplayers(entity this, float ratingscale, vector org, float sradius) { } void havocbot_goalrating_items(entity this, float ratingscale, vector org, float sradius) { } diff --git a/qcsrc/server/mutators/mutator/gamemode_domination.qc b/qcsrc/server/mutators/mutator/gamemode_domination.qc index 1d229f3a3..abcae5ada 100644 --- a/qcsrc/server/mutators/mutator/gamemode_domination.qc +++ b/qcsrc/server/mutators/mutator/gamemode_domination.qc @@ -99,7 +99,8 @@ void dompoint_captured(entity this) WaypointSprite_UpdateSprites(this.sprite, msg, WP_Null, WP_Null); total_pps = 0, pps_red = 0, pps_blue = 0, pps_yellow = 0, pps_pink = 0; - FOREACH_ENTITY_CLASS("dom_controlpoint", true, LAMBDA( + IL_EACH(g_dompoints, true, + { if (autocvar_g_domination_point_amt) points = autocvar_g_domination_point_amt; else @@ -116,7 +117,7 @@ void dompoint_captured(entity this) case NUM_TEAM_4: pps_pink += points/wait_time; break; } total_pps += points/wait_time; - )); + }); WaypointSprite_UpdateTeamRadar(this.sprite, RADARICON_DOMPOINT, colormapPaletteColor(this.goalentity.team - 1, 0)); WaypointSprite_Ping(this.sprite); @@ -283,8 +284,9 @@ void dom_controlpoint_setup(entity this) this.nextthink = time; settouch(this, dompointtouch); this.solid = SOLID_TRIGGER; + if(!this.flags & FL_ITEM) + IL_PUSH(g_items, this); this.flags = FL_ITEM; - IL_PUSH(g_items, this); setsize(this, '-32 -32 -32', '32 32 32'); setorigin(this, this.origin + '0 0 20'); droptofloor(this); @@ -297,7 +299,7 @@ float total_controlpoints; void Domination_count_controlpoints() { total_controlpoints = redowned = blueowned = yellowowned = pinkowned = 0; - FOREACH_ENTITY_CLASS("dom_controlpoint", true, + IL_EACH(g_dompoints, true, { ++total_controlpoints; redowned += (it.goalentity.team == NUM_TEAM_1); @@ -379,6 +381,19 @@ void Domination_RoundStart() } //go to best items, or control points you don't own +void havocbot_goalrating_controlpoints(entity this, float ratingscale, vector org, float sradius) +{ + IL_EACH(g_dompoints, vdist((((it.absmin + it.absmax) * 0.5) - org), <, sradius), + { + if(it.cnt > -1) // this is just being fought + navigation_routerating(this, it, ratingscale, 5000); + else if(it.goalentity.cnt == 0) // unclaimed + navigation_routerating(this, it, ratingscale * 0.5, 5000); + else if(it.goalentity.team != this.team) // other team's point + navigation_routerating(this, it, ratingscale * 0.2, 5000); + }); +} + void havocbot_role_dom(entity this) { if(IS_DEAD(this)) @@ -483,6 +498,8 @@ spawnfunc(dom_controlpoint) this.effects = this.effects | EF_LOWPRECISION; if (autocvar_g_domination_point_fullbright) this.effects |= EF_FULLBRIGHT; + + IL_PUSH(g_dompoints, this); } /*QUAKED spawnfunc_dom_team (0 .5 .8) (-32 -32 -24) (32 32 32) diff --git a/qcsrc/server/mutators/mutator/gamemode_domination.qh b/qcsrc/server/mutators/mutator/gamemode_domination.qh index e9eb2c2d9..609fcfd0d 100644 --- a/qcsrc/server/mutators/mutator/gamemode_domination.qh +++ b/qcsrc/server/mutators/mutator/gamemode_domination.qh @@ -61,3 +61,6 @@ float domination_roundbased; float domination_teams; void AnimateDomPoint(entity this); + +IntrusiveList g_dompoints; +STATIC_INIT(g_dompoints) { g_dompoints = IL_NEW(); } -- 2.39.2