]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Bot AI: CTF: fix offense role assigned to all bots when they spawn all at once
authorterencehill <piuntn@gmail.com>
Sun, 10 Jun 2018 17:20:42 +0000 (19:20 +0200)
committerterencehill <piuntn@gmail.com>
Sun, 10 Jun 2018 17:20:42 +0000 (19:20 +0200)
qcsrc/server/mutators/mutator/gamemode_ctf.qc

index 059af1e491d94066ff61142c7125a2b5ed00b7e7..df9b68c7dc666b1dc0f90e05297c234f49b36d81 100644 (file)
@@ -1623,6 +1623,20 @@ void havocbot_ctf_reset_role(entity this)
                havocbot_role_ctf_setrole(this, HAVOCBOT_CTF_ROLE_OFFENSE);
                return;
        }
+       else if (CS(this).jointime < time + 1)
+       {
+               // if bots spawn all at once set good default roles
+               if (count == 1)
+               {
+                       havocbot_role_ctf_setrole(this, HAVOCBOT_CTF_ROLE_DEFENSE);
+                       return;
+               }
+               else if (count == 2)
+               {
+                       havocbot_role_ctf_setrole(this, HAVOCBOT_CTF_ROLE_MIDDLE);
+                       return;
+               }
+       }
 
        // Evaluate best position to take
        // Count mates on middle position
@@ -1640,6 +1654,10 @@ void havocbot_ctf_reset_role(entity this)
                havocbot_role_ctf_setrole(this, HAVOCBOT_CTF_ROLE_OFFENSE);
        else
                havocbot_role_ctf_setrole(this, HAVOCBOT_CTF_ROLE_MIDDLE);
+
+       // if bots spawn all at once assign them a more appropriated role after a while
+       if (CS(this).jointime < time + 1 && count > 2)
+               this.havocbot_role_timeout = time + 10 + random() * 10;
 }
 
 bool havocbot_ctf_is_basewaypoint(entity item)