]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Fix nearest waypoint not updated for dropped flags, keys and keepaway ball causing...
authorterencehill <piuntn@gmail.com>
Tue, 7 Mar 2017 01:45:29 +0000 (02:45 +0100)
committerterencehill <piuntn@gmail.com>
Tue, 7 Mar 2017 01:45:29 +0000 (02:45 +0100)
qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qh
qcsrc/server/bot/api.qh
qcsrc/server/bot/default/navigation.qc
qcsrc/server/bot/default/navigation.qh
qcsrc/server/client.qc
qcsrc/server/mutators/mutator/gamemode_ctf.qc
qcsrc/server/mutators/mutator/gamemode_ctf.qh
qcsrc/server/mutators/mutator/gamemode_keepaway.qc
qcsrc/server/mutators/mutator/gamemode_keyhunt.qc
qcsrc/server/weapons/throwing.qc

index d8b7fd044bcc8e8f5faf4a76dcbac1dbb451dee6..5f05f7658bbb14b101b596ab10e6a74551da96dd 100644 (file)
@@ -70,9 +70,6 @@ bool ons_stalemate;
 
 .float teleport_antispam;
 
-// waypoint sprites
-.entity bot_basewaypoint; // generator waypointsprite
-
 .bool isgenneighbor[17];
 .bool iscpneighbor[17];
 float ons_notification_time[17];
index b0f457df4c37c496af39ef735bae1a64024b08f5..fbf1a982c5f6fa951fbb706cce17a020ee2c1517 100644 (file)
@@ -68,6 +68,11 @@ void havocbot_goalrating_enemyplayers(entity this, float ratingscale, vector org
 void havocbot_goalrating_items(entity this, float ratingscale, vector org, float sradius);
 void havocbot_goalrating_waypoints(entity this, float ratingscale, vector org, float sradius);
 
+.entity bot_basewaypoint;
+.bool navigation_dynamicgoal;
+void navigation_dynamicgoal_init(entity this, bool initially_static);
+void navigation_dynamicgoal_set(entity this);
+void navigation_dynamicgoal_unset(entity this);
 entity navigation_findnearestwaypoint(entity ent, float walkfromwp);
 void navigation_goalrating_end(entity this);
 void navigation_goalrating_start(entity this);
index 65ba4d00bfa4185877ace0ec08c0d4358557d819..857d6222f83a1387f8c449e8e8bca578937ff01b 100644 (file)
 
 .float speed;
 
+void navigation_dynamicgoal_init(entity this, bool initially_static)
+{
+       this.navigation_dynamicgoal = true;
+       this.bot_basewaypoint = this.nearestwaypoint;
+       if(initially_static)
+               this.nearestwaypointtimeout = time + 1000000000;
+       else
+               this.nearestwaypointtimeout = time;
+}
+
+void navigation_dynamicgoal_set(entity this)
+{
+       this.nearestwaypointtimeout = time;
+}
+
+void navigation_dynamicgoal_unset(entity this)
+{
+       if(this.bot_basewaypoint)
+               this.nearestwaypoint = this.bot_basewaypoint;
+       this.nearestwaypointtimeout = time + 1000000000;
+}
+
 // rough simulation of walking from one point to another to test if a path
 // can be traveled, used for waypoint linking and havocbot
 
@@ -799,21 +821,7 @@ void navigation_routerating(entity this, entity e, float f, float rangebias)
        }
        else
        {
-               bool search = true;
-
-               if((e.flags & FL_ITEM) && e.nearestwaypoint)
-               {
-                       if (e.flags & FL_WEAPON)
-                       {
-                               if(e.classname != "droppedweapon")
-                                       search = false;
-                       }
-                       else
-                               search = false;
-               }
-
-               if(search)
-               if (time > e.nearestwaypointtimeout)
+               if ((!e.nearestwaypoint || e.navigation_dynamicgoal) && time > e.nearestwaypointtimeout)
                {
                        nwp = navigation_findnearestwaypoint(e, true);
                        if(nwp)
@@ -822,16 +830,8 @@ void navigation_routerating(entity this, entity e, float f, float rangebias)
                        {
                                LOG_DEBUG("FAILED to find a nearest waypoint to '", e.classname, "' #", etos(e));
 
-                               if(e.flags & FL_ITEM)
-                               {
-                                       if (e.flags & FL_WEAPON)
-                                       {
-                                               if(e.classname != "droppedweapon")
-                                                       e.blacklisted = true;
-                                       }
-                                       else
-                                               e.blacklisted = true;
-                               }
+                               if(!e.navigation_dynamicgoal)
+                                       e.blacklisted = true;
 
                                if(e.blacklisted)
                                {
@@ -840,11 +840,8 @@ void navigation_routerating(entity this, entity e, float f, float rangebias)
                                }
                        }
 
-                       // TODO: Cleaner solution, probably handling this timeout from ctf.qc
-                       if(e.classname=="item_flag_team")
+                       if(e.navigation_dynamicgoal)
                                e.nearestwaypointtimeout = time + 2;
-                       else
-                               e.nearestwaypointtimeout = time + random() * 3 + 5;
                }
                nwp = e.nearestwaypoint;
        }
index e5097563c65109ea6607c7e3ef7b3dc2eaf207c1..88916916341efa3dec28e8fccd339831319177aa 100644 (file)
@@ -47,6 +47,13 @@ entity bot_waypoint_queue_goal;              // Head of the temporary list of goals
 entity bot_waypoint_queue_bestgoal;
 float bot_waypoint_queue_bestgoalrating;
 
+.entity bot_basewaypoint;
+.bool navigation_dynamicgoal;
+void navigation_dynamicgoal_init(entity this, bool initially_static);
+void navigation_dynamicgoal_set(entity this);
+void navigation_dynamicgoal_unset(entity this);
+
+
 /*
  * Functions
  */
index 5506a9d0fa353d290f71c6776ea5aa2a9e503adf..0e84ec82477f3fba3e39851debcb62bc3cf13d8e 100644 (file)
@@ -651,6 +651,7 @@ void PutClientInServer(entity this)
                        IL_PUSH(g_bot_targets, this);
                this.bot_attack = true;
                this.monster_attack = true;
+               navigation_dynamicgoal_init(this, false);
 
                PHYS_INPUT_BUTTON_ATCK(this) = PHYS_INPUT_BUTTON_JUMP(this) = PHYS_INPUT_BUTTON_ATCK2(this) = false;
 
index b20718ef7a918f7177a76c4717907118fd8cd6a3..b1d0ab646253632f23a1e49b02cfe52b717ab823 100644 (file)
@@ -479,6 +479,7 @@ void ctf_Handle_Throw(entity player, entity receiver, int droptype)
        flag.solid = SOLID_TRIGGER;
        flag.ctf_dropper = player;
        flag.ctf_droptime = time;
+       navigation_dynamicgoal_set(flag);
 
        flag.flags = FL_ITEM | FL_NOTARGET; // clear FL_ONGROUND for MOVETYPE_TOSS
 
@@ -1197,6 +1198,7 @@ void ctf_RespawnFlag(entity flag)
        flag.ctf_pickuptime = 0;
        flag.ctf_droptime = 0;
        flag.ctf_flagdamaged_byworld = false;
+       navigation_dynamicgoal_unset(flag);
 
        ctf_CheckStalemate();
 }
@@ -1225,8 +1227,7 @@ void ctf_DelayedFlagSetup(entity this) // called after a flag is placed on a map
 {
        // bot waypoints
        waypoint_spawnforitem_force(this, this.origin);
-       this.nearestwaypointtimeout = 0; // activate waypointing again
-       this.bot_basewaypoint = this.nearestwaypoint;
+       navigation_dynamicgoal_init(this, true);
 
        // waypointsprites
        entity basename;
index 2c67372b4f6232511dcc0c50cd315a61fa1d63b8..c0b8034229b56c7ed351903b3b24745b4c6e2041 100644 (file)
@@ -67,7 +67,6 @@ entity ctf_worldflaglist;
 .entity ctf_staleflagnext;
 
 // waypoint sprites
-.entity bot_basewaypoint; // flag waypointsprite
 .entity wps_helpme;
 .entity wps_flagbase;
 .entity wps_flagcarrier;
index 07c015f257e8175cd73cb74dc28e6a9186c5d95d..0b4bd54aaa21c554d4fbaf8b0800e683a3c8c0f2 100644 (file)
@@ -38,7 +38,6 @@ void ka_EventLog(string mode, entity actor) // use an alias for easy changing an
 }
 
 void ka_TouchEvent(entity this, entity toucher);
-void ka_RespawnBall(entity this);
 void ka_RespawnBall(entity this) // runs whenever the ball needs to be relocated
 {
        if(game_stopped) return;
@@ -59,6 +58,7 @@ void ka_RespawnBall(entity this) // runs whenever the ball needs to be relocated
        settouch(this, ka_TouchEvent);
        setthink(this, ka_RespawnBall);
        this.nextthink = time + autocvar_g_keepawayball_respawntime;
+       navigation_dynamicgoal_set(this);
 
        Send_Effect(EFFECT_ELECTRO_COMBO, oldballorigin, '0 0 0', 1);
        Send_Effect(EFFECT_ELECTRO_COMBO, this.origin, '0 0 0', 1);
@@ -114,6 +114,7 @@ void ka_TouchEvent(entity this, entity toucher) // runs any time that the ball c
        setthink(this, ka_TimeScoring);
        this.nextthink = time + autocvar_g_keepaway_score_timeinterval;
        this.takedamage = DAMAGE_NO;
+       navigation_dynamicgoal_unset(this);
 
        // apply effects to player
        toucher.glow_color = autocvar_g_keepawayball_trail_color;
@@ -158,6 +159,7 @@ void ka_DropEvent(entity plyr) // runs any time that a player is supposed to los
        ball.velocity = '0 0 200' + '0 100 0'*crandom() + '100 0 0'*crandom();
        ball.owner.ballcarried = world; // I hope nothing checks to see if the world has the ball in the rest of my code :P
        ball.owner = NULL;
+       navigation_dynamicgoal_set(ball);
 
        // reset the player effects
        plyr.glow_trail = false;
@@ -457,6 +459,7 @@ void ka_SpawnBall() // loads various values for the ball, runs only once at star
        settouch(e, ka_TouchEvent);
        e.owner = NULL;
        ka_ball = e;
+       navigation_dynamicgoal_init(ka_ball, false);
 
        InitializeEntity(e, ka_RespawnBall, INITPRIO_SETLOCATION); // is this the right priority? Neh, I have no idea.. Well-- it works! So.
 }
index 0c3d27be4e9c10cf10d7ea41af20832bd414121d..6750d48d0d5a780a2b72fdf40249f9d5ab89e3f8 100644 (file)
@@ -256,6 +256,7 @@ void kh_Key_Attach(entity key)  // runs when a player picks up a key and several
        key.damageforcescale = 0;
        key.takedamage = DAMAGE_NO;
        key.modelindex = kh_key_carried;
+       navigation_dynamicgoal_unset(key);
 }
 
 void kh_Key_Detach(entity key) // runs every time a key is dropped or lost. Runs several times times when all the keys are captured
@@ -295,6 +296,7 @@ void kh_Key_Detach(entity key) // runs every time a key is dropped or lost. Runs
        key.takedamage = DAMAGE_YES;
        // let key.team stay
        key.modelindex = kh_key_dropped;
+       navigation_dynamicgoal_set(key);
        key.kh_previous_owner = key.owner;
        key.kh_previous_owner_playerid = key.owner.playerid;
 }
@@ -742,6 +744,7 @@ void kh_Key_Spawn(entity initial_owner, float _angle, float i)  // runs every ti
        setsize(key, KH_KEY_MIN, KH_KEY_MAX);
        key.colormod = Team_ColorRGB(initial_owner.team) * KH_KEY_BRIGHTNESS;
        key.reset = key_reset;
+       navigation_dynamicgoal_init(key, false);
 
        switch(initial_owner.team)
        {
index d682566284b45d51e09fb2d43b07a57fce0e92a0..53e68d9eb2259df91048e56348e3d8b2add3b1b1 100644 (file)
@@ -47,6 +47,7 @@ string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vecto
        wep.flags |= FL_TOSSED;
        wep.colormap = own.colormap;
        wep.glowmod = weaponentity_glowmod(info, own, own.clientcolors, own.(weaponentity));
+       navigation_dynamicgoal_init(wep, false);
 
        W_DropEvent(wr_drop,own,wpn,wep,weaponentity);