]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'master' into terencehill/bot_ai
authorterencehill <piuntn@gmail.com>
Fri, 18 May 2018 10:54:28 +0000 (12:54 +0200)
committerterencehill <piuntn@gmail.com>
Fri, 18 May 2018 10:54:28 +0000 (12:54 +0200)
12 files changed:
qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc
qcsrc/server/bot/default/havocbot/havocbot.qc
qcsrc/server/bot/default/havocbot/roles.qc
qcsrc/server/bot/default/navigation.qc
qcsrc/server/bot/default/navigation.qh
qcsrc/server/mutators/mutator/gamemode_assault.qc
qcsrc/server/mutators/mutator/gamemode_ctf.qc
qcsrc/server/mutators/mutator/gamemode_domination.qc
qcsrc/server/mutators/mutator/gamemode_freezetag.qc
qcsrc/server/mutators/mutator/gamemode_keepaway.qc
qcsrc/server/mutators/mutator/gamemode_keyhunt.qc
xonotic-server.cfg

index 2637aeef212b5415a589b42848b99f1b1290fef6..b714a5ebcf7283d52583ebbd5fbe89dca0168b65 100644 (file)
@@ -1485,7 +1485,7 @@ void havocbot_role_ons_offense(entity this)
        if (navigation_goalrating_timeout(this))
        {
                navigation_goalrating_start(this);
-               havocbot_goalrating_enemyplayers(this, 20000, this.origin, 650);
+               havocbot_goalrating_enemyplayers(this, 10000, this.origin, 650);
                if(!havocbot_goalrating_ons_generator_attack(this, 20000))
                        havocbot_goalrating_ons_controlpoints_attack(this, 20000);
                havocbot_goalrating_ons_offenseitems(this, 10000, this.origin, 10000);
index 7ce6efa45fc63af8e3bd50991b1bdac3dcf1336c..9d4ef6336104b2d3c6006ddc07b66ad08b5c91e5 100644 (file)
@@ -801,10 +801,14 @@ void havocbot_movetogoal(entity this)
 
        navigation_shortenpath(this);
 
+       bool goalcurrent_can_be_removed = false;
        if (IS_MOVABLE(this.goalcurrent))
        {
-               if (IS_DEAD(this.goalcurrent))
+               // if is movable  =>  not frozen
+               if (IS_DEAD(this.goalcurrent) || (this.goalentity_shouldbefrozen && this.goalentity == this.goalcurrent))
                {
+                       goalcurrent_can_be_removed = true;
+                       // don't remove if not visible
                        if (checkpvs(this.origin + this.view_ofs, this.goalcurrent))
                        {
                                navigation_goalrating_timeout_force(this);
@@ -832,7 +836,7 @@ void havocbot_movetogoal(entity this)
                {
                        if (this.goalcurrent)
                        {
-                               if (IS_MOVABLE(this.goalcurrent) && IS_DEAD(this.goalcurrent))
+                               if (goalcurrent_can_be_removed)
                                {
                                        // remove even if not visible
                                        navigation_goalrating_timeout_force(this);
index e469436014e1e030cc7dd1fc3bad16e61ad9fb11..bf45cd6cd5936fc78d578fcc7a3d375a42c8170a 100644 (file)
@@ -72,7 +72,7 @@ bool havocbot_goalrating_item_pickable_check_players(entity this, vector org, en
        float enemy_distance = FLOAT_MAX;
        float dist;
 
-       FOREACH_CLIENT(IS_PLAYER(it) && it != this && !IS_DEAD(it),
+       FOREACH_CLIENT(IS_PLAYER(it) && it != this && !(IS_DEAD(it) || STAT(FROZEN, it)),
        {
                if (it.team == this.team)
                {
@@ -112,7 +112,7 @@ void havocbot_goalrating_items(entity this, float ratingscale, vector org, float
 {
        float rating;
        vector o;
-       ratingscale = ratingscale * 0.0001; // items are rated around 10000 already
+       ratingscale = ratingscale * 0.0001;
 
        IL_EACH(g_items, it.bot_pickup,
        {
@@ -120,8 +120,6 @@ void havocbot_goalrating_items(entity this, float ratingscale, vector org, float
                // NOTE: this code assumes each bot rates items in a different frame
                if(it.bot_ratingscale_time == time && ratingscale < it.bot_ratingscale)
                        continue;
-               it.bot_ratingscale_time = time;
-               it.bot_ratingscale = ratingscale;
 
                if(!it.solid)
                {
@@ -174,6 +172,8 @@ void havocbot_goalrating_items(entity this, float ratingscale, vector org, float
                if(!havocbot_goalrating_item_pickable_check_players(this, org, it, o))
                        continue;
 
+               it.bot_ratingscale_time = time;
+               it.bot_ratingscale = ratingscale;
                rating = it.bot_pickupevalfunc(this, it);
                if(rating > 0)
                        navigation_routerating(this, it, rating * ratingscale, 2000);
@@ -190,7 +190,7 @@ void havocbot_goalrating_enemyplayers(entity this, float ratingscale, vector org
        if(this.waterlevel>WATERLEVEL_WETFEET)
                return;
 
-       ratingscale = ratingscale * 0.00005; // enemies are rated around 20000 already
+       ratingscale = ratingscale * 0.0001;
 
        float t;
        FOREACH_CLIENT(IS_PLAYER(it) && bot_shouldattack(this, it), {
@@ -234,7 +234,7 @@ void havocbot_role_generic(entity this)
        {
                navigation_goalrating_start(this);
                havocbot_goalrating_items(this, 10000, this.origin, 10000);
-               havocbot_goalrating_enemyplayers(this, 20000, this.origin, 10000);
+               havocbot_goalrating_enemyplayers(this, 10000, this.origin, 10000);
                havocbot_goalrating_waypoints(this, 1, this.origin, 3000);
                navigation_goalrating_end(this);
 
index c79ed40a4304cac996f80b84b2917d94ec44ee0e..69672f78344f28758eec3ccba037e126da3a7c96 100644 (file)
@@ -731,6 +731,7 @@ void navigation_clearroute(entity this)
        this.goalcurrent_distance_z = FLOAT_MAX;
        this.goalcurrent_distance_time = 0;
        this.goalentity_lock_timeout = 0;
+       this.goalentity_shouldbefrozen = false;
        this.goalentity = NULL;
        this.goalcurrent = NULL;
        this.goalstack01 = NULL;
@@ -1387,7 +1388,6 @@ void navigation_routerating(entity this, entity e, float f, float rangebias)
                nwp = e.nearestwaypoint;
        }
 
-       LOG_DEBUG("-- checking ", e.classname, " (with cost ", ftos(nwp.wpcost), ")");
        if (nwp && nwp.wpcost < 10000000)
        {
                //te_wizspike(nwp.wpnearestpoint);
@@ -1397,12 +1397,12 @@ void navigation_routerating(entity this, entity e, float f, float rangebias)
                else
                        nwptoitem_cost = waypoint_gettravelcost(nwp.wpnearestpoint, goal_org, nwp, e);
                float cost = nwp.wpcost + nwptoitem_cost;
-               LOG_DEBUG(e.classname, " ", ftos(f), "/(1+", ftos(cost), "/", ftos(rangebias), ") = ");
+               LOG_DEBUG("checking ^5", e.classname, "^7 with base rating ^xf04", ftos(f), "^7 and rangebias ^xf40", ftos(rangebias));
                f = f * rangebias / (rangebias + cost);
-               LOG_DEBUG("considering ", e.classname, " (with rating ", ftos(f), ")");
+               LOG_DEBUG("         ^5", e.classname, "^7 with cost ^6", ftos(cost), "^7 and final rating ^2", ftos(f));
                if (navigation_bestrating < f)
                {
-                       LOG_DEBUG("ground path: added goal ", e.classname, " (with rating ", ftos(f), ")");
+                       LOG_DEBUG(" ground path: ^3added goal ^5", e.classname);
                        navigation_bestrating = f;
                        navigation_bestgoal = e;
                }
@@ -1770,6 +1770,7 @@ void navigation_goalrating_end(entity this)
                        this.aistatus |= AI_STATUS_STUCK;
                }
        }
+       this.goalentity_shouldbefrozen = boolean(STAT(FROZEN, this.goalentity));
 }
 
 void botframe_updatedangerousobjects(float maxupdate)
index f3103cc4fcd39d875708a0612e83c59addd03095..80498b691f8f2ddc4efcf7f4be0af0aeb4e7988e 100644 (file)
@@ -30,6 +30,7 @@ entity navigation_bestgoal;
 .float goalcurrent_distance_time;
 
 .float goalentity_lock_timeout;
+.bool goalentity_shouldbefrozen;
 
 .entity nearestwaypoint;
 .float nearestwaypointtimeout;
index d43dc99993adb3474c5cce5baed9baa8cb4d87f7..5dd620f1366e28855018ff346c90e39db1f3d72c 100644 (file)
@@ -474,7 +474,7 @@ void havocbot_role_ast_offense(entity this)
        if (navigation_goalrating_timeout(this))
        {
                navigation_goalrating_start(this);
-               havocbot_goalrating_enemyplayers(this, 20000, this.origin, 650);
+               havocbot_goalrating_enemyplayers(this, 10000, this.origin, 650);
                havocbot_goalrating_ast_targets(this, 20000);
                havocbot_goalrating_items(this, 15000, this.origin, 10000);
                navigation_goalrating_end(this);
@@ -508,7 +508,7 @@ void havocbot_role_ast_defense(entity this)
        if (navigation_goalrating_timeout(this))
        {
                navigation_goalrating_start(this);
-               havocbot_goalrating_enemyplayers(this, 20000, this.origin, 3000);
+               havocbot_goalrating_enemyplayers(this, 10000, this.origin, 3000);
                havocbot_goalrating_ast_targets(this, 20000);
                havocbot_goalrating_items(this, 15000, this.origin, 10000);
                navigation_goalrating_end(this);
index e0d25e9e8f494c829c8fbf3156f15c92f168cddf..4175dabc19cf7dd8c63e847450843593ff0a1c73 100644 (file)
@@ -1518,12 +1518,14 @@ void havocbot_goalrating_ctf_enemyflag(entity this, float ratingscale)
 
 void havocbot_goalrating_ctf_enemybase(entity this, float ratingscale)
 {
+       // disabled because we always spawn waypoints for flags with waypoint_spawnforitem_force
+       /*
        if (!bot_waypoints_for_items)
        {
                havocbot_goalrating_ctf_enemyflag(this, ratingscale);
                return;
        }
-
+       */
        entity head;
 
        head = havocbot_ctf_find_enemy_flag(this);
@@ -1579,7 +1581,6 @@ void havocbot_goalrating_ctf_carrieritems(entity this, float ratingscale, vector
                if (it.health || it.armorvalue)
                if (vdist(it.origin - org, <, sradius))
                {
-                       // get the value of the item
                        float t = it.bot_pickupevalfunc(this, it) * 0.0001;
                        if (t > 0)
                                navigation_routerating(this, it, t * ratingscale, 500);
@@ -1648,6 +1649,21 @@ void havocbot_ctf_reset_role(entity this)
                havocbot_role_ctf_setrole(this, HAVOCBOT_CTF_ROLE_MIDDLE);
 }
 
+bool havocbot_ctf_is_basewaypoint(entity item)
+{
+       if (item.classname != "waypoint")
+               return false;
+
+       entity head = ctf_worldflaglist;
+       while (head)
+       {
+               if (item == head.bot_basewaypoint)
+                       return true;
+               head = head.ctf_worldflagnext;
+       }
+       return false;
+}
+
 void havocbot_role_ctf_carrier(entity this)
 {
        if(IS_DEAD(this))
@@ -1678,18 +1694,11 @@ void havocbot_role_ctf_carrier(entity this)
 
                navigation_goalrating_timeout_set(this);
 
-               entity head = ctf_worldflaglist;
-               while (head)
-               {
-                       if (this.goalentity == head.bot_basewaypoint)
-                       {
-                               this.goalentity_lock_timeout = time + 5;
-                               break;
-                       }
-                       head = head.ctf_worldflagnext;
-               }
+               entity goal = this.goalentity;
+               if (havocbot_ctf_is_basewaypoint(goal) && vdist(goal.origin - this.origin, <, 100))
+                       this.goalentity_lock_timeout = time + ((this.bot_aimtarg) ? 2 : 3);
 
-               if (this.goalentity)
+               if (goal)
                        this.havocbot_cantfindflag = time + 10;
                else if (time > this.havocbot_cantfindflag)
                {
@@ -1725,6 +1734,11 @@ void havocbot_role_ctf_escort(entity this)
                this.havocbot_role_timeout = 0;
                return;
        }
+       if (ef.ctf_status == FLAG_DROPPED)
+       {
+               navigation_goalrating_timeout_expire(this, 1);
+               return;
+       }
 
        // If the flag carrier reached the base switch to defense
        mf = havocbot_ctf_find_flag(this);
@@ -1945,13 +1959,17 @@ void havocbot_role_ctf_middle(entity this)
 
                havocbot_goalrating_ctf_ourstolenflag(this, 50000);
                havocbot_goalrating_ctf_droppedflags(this, 30000, this.origin, 10000);
-               havocbot_goalrating_enemyplayers(this, 10000, org, havocbot_middlepoint_radius * 0.5);
+               havocbot_goalrating_enemyplayers(this, 5000, org, havocbot_middlepoint_radius * 0.5);
                havocbot_goalrating_items(this, 5000, org, havocbot_middlepoint_radius * 0.5);
                havocbot_goalrating_items(this, 2500, this.origin, 10000);
                havocbot_goalrating_ctf_enemybase(this, 2500);
 
                navigation_goalrating_end(this);
 
+               entity goal = this.goalentity;
+               if (havocbot_ctf_is_basewaypoint(goal) && vdist(goal.origin - this.origin, <, 100))
+                       this.goalentity_lock_timeout = time + 2;
+
                navigation_goalrating_timeout_set(this);
        }
 }
@@ -2014,7 +2032,7 @@ void havocbot_role_ctf_defense(entity this)
 
                havocbot_goalrating_ctf_ourstolenflag(this, 20000);
                havocbot_goalrating_ctf_droppedflags(this, 20000, org, havocbot_middlepoint_radius);
-               havocbot_goalrating_enemyplayers(this, 15000, org, havocbot_middlepoint_radius);
+               havocbot_goalrating_enemyplayers(this, 7500, org, havocbot_middlepoint_radius);
                havocbot_goalrating_items(this, 10000, org, havocbot_middlepoint_radius);
                havocbot_goalrating_items(this, 5000, this.origin, 10000);
 
index 38ef58b6c5c33dd43ae6b7fd174c64e2af745fe4..b0e6eabe682e7d5037a5fde701eb7c0a65ac3ec1 100644 (file)
@@ -407,7 +407,7 @@ void havocbot_role_dom(entity this)
                navigation_goalrating_start(this);
                havocbot_goalrating_controlpoints(this, 10000, this.origin, 15000);
                havocbot_goalrating_items(this, 8000, this.origin, 8000);
-               //havocbot_goalrating_enemyplayers(this, 3000, this.origin, 2000);
+               //havocbot_goalrating_enemyplayers(this, 1500, this.origin, 2000);
                havocbot_goalrating_waypoints(this, 1, this.origin, 3000);
                navigation_goalrating_end(this);
 
index 36546c43a03bebc34c5875416e7b26473a5a364d..8a23be2d7338d4ca587754525047b7a6e0c4c710 100644 (file)
@@ -261,7 +261,7 @@ void havocbot_role_ft_offense(entity this)
        {
                navigation_goalrating_start(this);
                havocbot_goalrating_items(this, 10000, this.origin, 10000);
-               havocbot_goalrating_enemyplayers(this, 20000, this.origin, 10000);
+               havocbot_goalrating_enemyplayers(this, 10000, this.origin, 10000);
                havocbot_goalrating_freeplayers(this, 9000, this.origin, 10000);
                havocbot_goalrating_waypoints(this, 1, this.origin, 3000);
                navigation_goalrating_end(this);
@@ -290,7 +290,7 @@ void havocbot_role_ft_freeing(entity this)
        {
                navigation_goalrating_start(this);
                havocbot_goalrating_items(this, 8000, this.origin, 10000);
-               havocbot_goalrating_enemyplayers(this, 10000, this.origin, 10000);
+               havocbot_goalrating_enemyplayers(this, 5000, this.origin, 10000);
                havocbot_goalrating_freeplayers(this, 20000, this.origin, 10000);
                havocbot_goalrating_waypoints(this, 1, this.origin, 3000);
                navigation_goalrating_end(this);
index 567f24b478a47d1e536f731db06af69b190ace97..9c9718e45c538030c794c0b3f316f2c5b3a3d3cc 100644 (file)
@@ -236,7 +236,7 @@ void havocbot_role_ka_carrier(entity this)
        {
                navigation_goalrating_start(this);
                havocbot_goalrating_items(this, 10000, this.origin, 10000);
-               havocbot_goalrating_enemyplayers(this, 20000, this.origin, 10000);
+               havocbot_goalrating_enemyplayers(this, 10000, this.origin, 10000);
                havocbot_goalrating_waypoints(this, 1, this.origin, 3000);
                navigation_goalrating_end(this);
 
@@ -259,7 +259,7 @@ void havocbot_role_ka_collector(entity this)
        {
                navigation_goalrating_start(this);
                havocbot_goalrating_items(this, 10000, this.origin, 10000);
-               havocbot_goalrating_enemyplayers(this, 1000, this.origin, 10000);
+               havocbot_goalrating_enemyplayers(this, 500, this.origin, 10000);
                havocbot_goalrating_ball(this, 20000, this.origin);
                navigation_goalrating_end(this);
 
index 04576486b71bacd743304e7a5de42b709d3b95d7..30d78a01e9143f27b10cc2384189a9c16a935c7e 100644 (file)
@@ -1075,9 +1075,9 @@ void havocbot_role_kh_carrier(entity this)
                navigation_goalrating_start(this);
 
                if(kh_Key_AllOwnedByWhichTeam() == this.team)
-                       havocbot_goalrating_kh(this, 10, 0.1, 0.1); // bring home
+                       havocbot_goalrating_kh(this, 10, 0.1, 0.05); // bring home
                else
-                       havocbot_goalrating_kh(this, 4, 4, 1); // play defensively
+                       havocbot_goalrating_kh(this, 4, 4, 0.5); // play defensively
 
                navigation_goalrating_end(this);
 
@@ -1115,11 +1115,11 @@ void havocbot_role_kh_defense(entity this)
 
                key_owner_team = kh_Key_AllOwnedByWhichTeam();
                if(key_owner_team == this.team)
-                       havocbot_goalrating_kh(this, 10, 0.1, 0.1); // defend key carriers
+                       havocbot_goalrating_kh(this, 10, 0.1, 0.05); // defend key carriers
                else if(key_owner_team == -1)
-                       havocbot_goalrating_kh(this, 4, 1, 0.1); // play defensively
+                       havocbot_goalrating_kh(this, 4, 1, 0.05); // play defensively
                else
-                       havocbot_goalrating_kh(this, 0.1, 0.1, 10); // ATTACK ANYWAY
+                       havocbot_goalrating_kh(this, 0.1, 0.1, 5); // ATTACK ANYWAY
 
                navigation_goalrating_end(this);
 
@@ -1158,11 +1158,11 @@ void havocbot_role_kh_offense(entity this)
 
                key_owner_team = kh_Key_AllOwnedByWhichTeam();
                if(key_owner_team == this.team)
-                       havocbot_goalrating_kh(this, 10, 0.1, 0.1); // defend anyway
+                       havocbot_goalrating_kh(this, 10, 0.1, 0.05); // defend anyway
                else if(key_owner_team == -1)
-                       havocbot_goalrating_kh(this, 0.1, 1, 4); // play offensively
+                       havocbot_goalrating_kh(this, 0.1, 1, 2); // play offensively
                else
-                       havocbot_goalrating_kh(this, 0.1, 0.1, 10); // ATTACK! EMERGENCY!
+                       havocbot_goalrating_kh(this, 0.1, 0.1, 5); // ATTACK! EMERGENCY!
 
                navigation_goalrating_end(this);
 
@@ -1207,11 +1207,11 @@ void havocbot_role_kh_freelancer(entity this)
 
                int key_owner_team = kh_Key_AllOwnedByWhichTeam();
                if(key_owner_team == this.team)
-                       havocbot_goalrating_kh(this, 10, 0.1, 0.1); // defend anyway
+                       havocbot_goalrating_kh(this, 10, 0.1, 0.05); // defend anyway
                else if(key_owner_team == -1)
-                       havocbot_goalrating_kh(this, 1, 10, 4); // prefer dropped keys
+                       havocbot_goalrating_kh(this, 1, 10, 2); // prefer dropped keys
                else
-                       havocbot_goalrating_kh(this, 0.1, 0.1, 10); // ATTACK ANYWAY
+                       havocbot_goalrating_kh(this, 0.1, 0.1, 5); // ATTACK ANYWAY
 
                navigation_goalrating_end(this);
 
index 49ba47fa39e2dfbfb4a0d24c8e22451885c05f36..c1949537626faa79d5621eb7cbcc01767278b54d 100644 (file)
@@ -440,6 +440,7 @@ set g_jetpack 0 "Jetpack mutator"
 set g_hitplots 0 "when set to 1, hitplots are stored by the server to provide a means of proving that a triggerbot was used"
 set g_hitplots_individuals "" "the individuals, by IP, that should have their hitplots recorded"
 
+// set it to 1 to "fix bot moveto command and routing... now all bots can get to their seats" (Nexuiz repo, commit 2c9873e6)
 set bot_navigation_ignoreplayers 0 // FIXME remove this once the issue is solved
 set bot_sound_monopoly 0 "when enabled, only bots can make any noise"