mirror of
https://github.com/ineedbots/iw3_bot_warfare.git
synced 2025-04-21 01:55:43 +00:00
goal
This commit is contained in:
parent
c4afc7f806
commit
08d983810c
@ -1090,20 +1090,23 @@ walk()
|
|||||||
else
|
else
|
||||||
goal = (0, 0, 0);
|
goal = (0, 0, 0);
|
||||||
|
|
||||||
|
isScriptGoal = false;
|
||||||
if(isDefined(self.bot.script_goal) && !hasTarget)
|
if(isDefined(self.bot.script_goal) && !hasTarget)
|
||||||
{
|
{
|
||||||
goal = self.bot.script_goal;
|
goal = self.bot.script_goal;
|
||||||
dist = self.bot.script_goal_dist;
|
dist = self.bot.script_goal_dist;
|
||||||
|
|
||||||
|
isScriptGoal = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(hasTarget)
|
if(hasTarget)
|
||||||
goal = self.bot.target.last_seen_pos;
|
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.towards_goal = undefined;
|
||||||
self.bot.next_wp = -1;
|
self.bot.next_wp = -1;
|
||||||
self.bot.second_next_wp = -1;
|
self.bot.second_next_wp = -1;
|
||||||
@ -1150,9 +1153,7 @@ watchOnGoal(goal, dis)
|
|||||||
while(DistanceSquared(self.origin, goal) > dis)
|
while(DistanceSquared(self.origin, goal) > dis)
|
||||||
wait 0.05;
|
wait 0.05;
|
||||||
|
|
||||||
if (isDefined(self.bot.script_goal) && self.bot.script_goal == goal)
|
self notify("goal_internal");
|
||||||
self notify("script_goal");
|
|
||||||
self notify("goal");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1207,22 +1208,37 @@ killWalkOnEvents()
|
|||||||
self endon("disconnect");
|
self endon("disconnect");
|
||||||
self endon("death");
|
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");
|
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.
|
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("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;
|
distsq = dist*dist;
|
||||||
self thread killWalkOnEvents();
|
self thread killWalkOnEvents();
|
||||||
self thread watchOnGoal(goal, distsq);
|
self thread watchOnGoal(goal, distsq);
|
||||||
|
if (isScriptGoal)
|
||||||
|
self thread doWalkScriptNotify();
|
||||||
|
|
||||||
current = self initAStar(goal);
|
current = self initAStar(goal);
|
||||||
while(current >= 0)
|
while(current >= 0)
|
||||||
@ -1252,7 +1268,7 @@ doWalk(goal, dist)
|
|||||||
|
|
||||||
wait 1;
|
wait 1;
|
||||||
if(DistanceSquared(self.origin, goal) > distsq)
|
if(DistanceSquared(self.origin, goal) > distsq)
|
||||||
self notify("bad_path");
|
self notify("bad_path_internal");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1303,7 +1319,7 @@ movetowards(goal)
|
|||||||
timeslow = 0;
|
timeslow = 0;
|
||||||
|
|
||||||
if(stucks == 3)
|
if(stucks == 3)
|
||||||
self notify("bad_path");
|
self notify("bad_path_internal");
|
||||||
}
|
}
|
||||||
|
|
||||||
self.bot.towards_goal = undefined;
|
self.bot.towards_goal = undefined;
|
||||||
|
@ -126,6 +126,7 @@ SetScriptGoal(goal, dist)
|
|||||||
{
|
{
|
||||||
self.bot.script_goal = goal;
|
self.bot.script_goal = goal;
|
||||||
self.bot.script_goal_dist = dist;
|
self.bot.script_goal_dist = dist;
|
||||||
|
self notify("new_goal_internal");
|
||||||
self notify("new_goal");
|
self notify("new_goal");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user