From: terencehill Date: Tue, 26 Jun 2018 22:18:08 +0000 (+0200) Subject: Bot AI: make droppable items (flags, keys, etc...) easier to find out by bots the... X-Git-Tag: xonotic-v0.8.5~1923^2~16 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=ada305719835791c8f4d72c822f5cbecd4f8609c;p=xonotic%2Fxonotic-data.pk3dir.git Bot AI: make droppable items (flags, keys, etc...) easier to find out by bots the moment they are dropped --- diff --git a/qcsrc/common/gamemodes/gamemode/ctf/ctf.qc b/qcsrc/common/gamemodes/gamemode/ctf/ctf.qc index 25412be2a..b500796fe 100644 --- a/qcsrc/common/gamemodes/gamemode/ctf/ctf.qc +++ b/qcsrc/common/gamemodes/gamemode/ctf/ctf.qc @@ -449,7 +449,6 @@ 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 @@ -488,6 +487,7 @@ void ctf_Handle_Throw(entity player, entity receiver, int droptype) flag_velocity = (('0 0 1' * autocvar_g_ctf_throw_velocity_up) + ((v_forward * autocvar_g_ctf_throw_velocity_forward) * ((player.items & ITEM_Strength.m_itemid) ? autocvar_g_ctf_throw_strengthmultiplier : 1))); flag.velocity = W_CalculateProjectileVelocity(player, player.velocity, flag_velocity, false); ctf_Handle_Drop(flag, player, droptype); + navigation_dynamicgoal_set(flag, player); break; } @@ -502,6 +502,7 @@ void ctf_Handle_Throw(entity player, entity receiver, int droptype) { flag.velocity = W_CalculateProjectileVelocity(player, player.velocity, (('0 0 1' * autocvar_g_ctf_drop_velocity_up) + ((('0 1 0' * crandom()) + ('1 0 0' * crandom())) * autocvar_g_ctf_drop_velocity_side)), false); ctf_Handle_Drop(flag, player, droptype); + navigation_dynamicgoal_set(flag, player); break; } } diff --git a/qcsrc/common/gamemodes/gamemode/keepaway/keepaway.qc b/qcsrc/common/gamemodes/gamemode/keepaway/keepaway.qc index fc2793bca..77a4a41e9 100644 --- a/qcsrc/common/gamemodes/gamemode/keepaway/keepaway.qc +++ b/qcsrc/common/gamemodes/gamemode/keepaway/keepaway.qc @@ -64,7 +64,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); + navigation_dynamicgoal_set(this, NULL); Send_Effect(EFFECT_ELECTRO_COMBO, oldballorigin, '0 0 0', 1); Send_Effect(EFFECT_ELECTRO_COMBO, this.origin, '0 0 0', 1); @@ -164,10 +164,11 @@ void ka_DropEvent(entity plyr) // runs any time that a player is supposed to los ball.effects &= ~EF_NODRAW; setorigin(ball, plyr.origin + '0 0 10'); ball.velocity = '0 0 200' + '0 100 0'*crandom() + '100 0 0'*crandom(); - entity e = ball.owner; ball.owner = NULL; + entity e = ball.owner; + ball.owner = NULL; e.ballcarried = NULL; GameRules_scoring_vip(e, false); - navigation_dynamicgoal_set(ball); + navigation_dynamicgoal_set(ball, e); // reset the player effects plyr.glow_trail = false; diff --git a/qcsrc/common/gamemodes/gamemode/keyhunt/keyhunt.qc b/qcsrc/common/gamemodes/gamemode/keyhunt/keyhunt.qc index ec0b2b6d7..00eb886d5 100644 --- a/qcsrc/common/gamemodes/gamemode/keyhunt/keyhunt.qc +++ b/qcsrc/common/gamemodes/gamemode/keyhunt/keyhunt.qc @@ -299,7 +299,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); + navigation_dynamicgoal_set(key, key.owner); key.kh_previous_owner = key.owner; key.kh_previous_owner_playerid = key.owner.playerid; } diff --git a/qcsrc/server/bot/api.qh b/qcsrc/server/bot/api.qh index 0ecd7b877..0cddd3b27 100644 --- a/qcsrc/server/bot/api.qh +++ b/qcsrc/server/bot/api.qh @@ -90,7 +90,7 @@ float havocbot_symmetry_origin_order; .entity bot_basewaypoint; .bool navigation_dynamicgoal; void navigation_dynamicgoal_init(entity this, bool initially_static); -void navigation_dynamicgoal_set(entity this); +void navigation_dynamicgoal_set(entity this, entity dropper); void navigation_dynamicgoal_unset(entity this); entity navigation_findnearestwaypoint(entity ent, float walkfromwp); void navigation_goalrating_end(entity this); diff --git a/qcsrc/server/bot/default/navigation.qc b/qcsrc/server/bot/default/navigation.qc index 32d5c4814..88d189bee 100644 --- a/qcsrc/server/bot/default/navigation.qc +++ b/qcsrc/server/bot/default/navigation.qc @@ -78,9 +78,11 @@ void navigation_dynamicgoal_init(entity this, bool initially_static) this.nearestwaypointtimeout = time; } -void navigation_dynamicgoal_set(entity this) +void navigation_dynamicgoal_set(entity this, entity dropper) { this.nearestwaypointtimeout = time; + if (dropper && dropper.nearestwaypointtimeout && dropper.nearestwaypointtimeout < time + 2) + this.nearestwaypoint = dropper.nearestwaypoint; if (this.nearestwaypoint) this.nearestwaypointtimeout += 2; } @@ -1215,11 +1217,7 @@ void navigation_markroutes_inverted(entity fixed_source_waypoint) // updates the best goal according to a weighted calculation of travel cost and item value of a new proposed item void navigation_routerating(entity this, entity e, float f, float rangebias) { - if (!e) - return; - - if(e.blacklisted) - return; + if (!e || e.blacklisted) { return; } rangebias = waypoint_getlinearcost(rangebias); f = waypoint_getlinearcost(f); diff --git a/qcsrc/server/bot/default/navigation.qh b/qcsrc/server/bot/default/navigation.qh index 233ae9ae7..b8b067c3b 100644 --- a/qcsrc/server/bot/default/navigation.qh +++ b/qcsrc/server/bot/default/navigation.qh @@ -83,7 +83,7 @@ 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_set(entity this, entity dropper); void navigation_dynamicgoal_unset(entity this); .int nav_submerged_state;