]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/mutators/mutator/gamemode_cts.qc
Merge branch 'terencehill/bot_waypoints' into terencehill/bot_ai
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / mutator / gamemode_cts.qc
index 3de77f372ae54cef342670d29b2530f82e22a655..daaf8a969592e810af3531a1cdcded327b46a8fc 100644 (file)
@@ -1,7 +1,7 @@
 #include "gamemode_cts.qh"
-#include <server/race.qh>
 
 #include <server/race.qh>
+#include <server/items.qh>
 
 float autocvar_g_cts_finish_kill_delay;
 bool autocvar_g_cts_selfdamage;
@@ -13,37 +13,49 @@ void havocbot_role_cts(entity this)
        if(IS_DEAD(this))
                return;
 
-       if (this.bot_strategytime < time)
+       if (navigation_goalrating_timeout(this))
        {
-               this.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
                navigation_goalrating_start(this);
 
+               bool raw_touch_check = true;
+               int cp = this.race_checkpoint;
+
+               LABEL(search_racecheckpoints)
                IL_EACH(g_racecheckpoints, true,
                {
-                       if(it.cnt == this.race_checkpoint)
-                               navigation_routerating(this, it, 1000000, 5000);
-                       else if(this.race_checkpoint == -1)
+                       if(it.cnt == cp || cp == -1)
+                       {
+                               // redirect bot to next goal if it touched the waypoint of an untouchable checkpoint
+                               // e.g. checkpoint in front of Stormkeep's warpzone
+                               // the same workaround is applied in Race game mode
+                               if (raw_touch_check && vdist(this.origin - it.nearestwaypoint.origin, <, 30))
+                               {
+                                       cp = race_NextCheckpoint(cp);
+                                       raw_touch_check = false;
+                                       goto search_racecheckpoints;
+                               }
                                navigation_routerating(this, it, 1000000, 5000);
+                       }
                });
 
                navigation_goalrating_end(this);
+
+               navigation_goalrating_timeout_set(this);
        }
 }
 
 void cts_ScoreRules()
 {
-       ScoreRules_basics(0, 0, 0, false);
-       if(g_race_qualifying)
-       {
-               ScoreInfo_SetLabel_PlayerScore(SP_RACE_FASTEST, "fastest",   SFL_SORT_PRIO_PRIMARY | SFL_LOWER_IS_BETTER | SFL_TIME);
-       }
-       else
-       {
-               ScoreInfo_SetLabel_PlayerScore(SP_RACE_LAPS,    "laps",      SFL_SORT_PRIO_PRIMARY);
-               ScoreInfo_SetLabel_PlayerScore(SP_RACE_TIME,    "time",      SFL_SORT_PRIO_SECONDARY | SFL_LOWER_IS_BETTER | SFL_TIME);
-               ScoreInfo_SetLabel_PlayerScore(SP_RACE_FASTEST, "fastest",   SFL_LOWER_IS_BETTER | SFL_TIME);
-       }
-       ScoreRules_basics_end();
+    GameRules_score_enabled(false);
+    GameRules_scoring(0, 0, 0, {
+        if (g_race_qualifying) {
+            field(SP_RACE_FASTEST, "fastest", SFL_SORT_PRIO_PRIMARY | SFL_LOWER_IS_BETTER | SFL_TIME);
+        } else {
+            field(SP_RACE_LAPS, "laps", SFL_SORT_PRIO_PRIMARY);
+            field(SP_RACE_TIME, "time", SFL_SORT_PRIO_SECONDARY | SFL_LOWER_IS_BETTER | SFL_TIME);
+            field(SP_RACE_FASTEST, "fastest", SFL_LOWER_IS_BETTER | SFL_TIME);
+        }
+    });
 }
 
 void cts_EventLog(string mode, entity actor) // use an alias for easy changing and quick editing later
@@ -149,7 +161,7 @@ MUTATOR_HOOKFUNCTION(cts, reset_map_global)
        FOREACH_CLIENT(true, {
                if(it.race_place)
                {
-                       s = PlayerScore_Add(it, SP_RACE_FASTEST, 0);
+                       s = GameRules_scoring_add(it, RACE_FASTEST, 0);
                        if(!s)
                                it.race_place = 0;
                }
@@ -206,7 +218,7 @@ MUTATOR_HOOKFUNCTION(cts, MakePlayerObserver)
 {
        entity player = M_ARGV(0, entity);
 
-       if(PlayerScore_Add(player, SP_RACE_FASTEST, 0))
+       if(GameRules_scoring_add(player, RACE_FASTEST, 0))
                player.frags = FRAGS_LMS_LOSER;
        else
                player.frags = FRAGS_SPECTATOR;
@@ -316,8 +328,10 @@ MUTATOR_HOOKFUNCTION(cts, FilterItem)
 {
        entity item = M_ARGV(0, entity);
 
-       if(item.classname == "droppedweapon")
+       if (Item_IsLoot(item))
+       {
                return true;
+       }
 }
 
 MUTATOR_HOOKFUNCTION(cts, Damage_Calculate)