This commit is contained in:
Your Name 2020-08-30 13:49:36 -06:00
parent c4afc7f806
commit 08d983810c
2 changed files with 28 additions and 11 deletions

View File

@ -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;
@ -1150,9 +1153,7 @@ 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;

View File

@ -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");
}