From 08d983810c8584152f01b0d2a2ebc8c1a10c6b17 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 30 Aug 2020 13:49:36 -0600 Subject: [PATCH] goal --- main_shared/maps/mp/bots/_bot_internal.gsc | 38 +++++++++++++++------- main_shared/maps/mp/bots/_bot_utility.gsc | 1 + 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/main_shared/maps/mp/bots/_bot_internal.gsc b/main_shared/maps/mp/bots/_bot_internal.gsc index 0f88069..162d4d1 100644 --- a/main_shared/maps/mp/bots/_bot_internal.gsc +++ b/main_shared/maps/mp/bots/_bot_internal.gsc @@ -1090,20 +1090,23 @@ walk() else goal = (0, 0, 0); + isScriptGoal = false; if(isDefined(self.bot.script_goal) && !hasTarget) { goal = self.bot.script_goal; dist = self.bot.script_goal_dist; + + isScriptGoal = true; } else { if(hasTarget) goal = self.bot.target.last_seen_pos; - self notify("new_goal"); + self notify("new_goal_internal"); } - self doWalk(goal, dist); + self doWalk(goal, dist, isScriptGoal); self.bot.towards_goal = undefined; self.bot.next_wp = -1; self.bot.second_next_wp = -1; @@ -1149,10 +1152,8 @@ watchOnGoal(goal, dis) while(DistanceSquared(self.origin, goal) > dis) wait 0.05; - - if (isDefined(self.bot.script_goal) && self.bot.script_goal == goal) - self notify("script_goal"); - self notify("goal"); + + self notify("goal_internal"); } /* @@ -1207,22 +1208,37 @@ killWalkOnEvents() self endon("disconnect"); self endon("death"); - self waittill_any("flash_rumble_loop", "new_enemy", "new_goal", "goal", "bad_path"); + self waittill_any("flash_rumble_loop", "new_enemy", "new_goal_internal", "goal_internal", "bad_path_internal"); self notify("kill_goal"); } +doWalkScriptNotify() +{ + self endon("disconnect"); + self endon("death"); + + ret = self waittill_any_return("kill_goal", "goal_internal", "bad_path_internal"); + + if (ret == "goal_internal") + self notify("goal"); + else if (ret == "bad_path_internal") + self notify("bad_path"); +} + /* Will walk to the given goal when dist near. Uses AStar path finding with the level's nodes. */ -doWalk(goal, dist) +doWalk(goal, dist, isScriptGoal) { self endon("kill_goal"); - self endon("goal");//so that the watchOnGoal notify can happen same frame, not a frame later + self endon("goal_internal");//so that the watchOnGoal notify can happen same frame, not a frame later distsq = dist*dist; self thread killWalkOnEvents(); self thread watchOnGoal(goal, distsq); + if (isScriptGoal) + self thread doWalkScriptNotify(); current = self initAStar(goal); while(current >= 0) @@ -1252,7 +1268,7 @@ doWalk(goal, dist) wait 1; if(DistanceSquared(self.origin, goal) > distsq) - self notify("bad_path"); + self notify("bad_path_internal"); } /* @@ -1303,7 +1319,7 @@ movetowards(goal) timeslow = 0; if(stucks == 3) - self notify("bad_path"); + self notify("bad_path_internal"); } self.bot.towards_goal = undefined; diff --git a/main_shared/maps/mp/bots/_bot_utility.gsc b/main_shared/maps/mp/bots/_bot_utility.gsc index 37e724f..a41a2e5 100644 --- a/main_shared/maps/mp/bots/_bot_utility.gsc +++ b/main_shared/maps/mp/bots/_bot_utility.gsc @@ -126,6 +126,7 @@ SetScriptGoal(goal, dist) { self.bot.script_goal = goal; self.bot.script_goal_dist = dist; + self notify("new_goal_internal"); self notify("new_goal"); }