FIx rubberbanding

This commit is contained in:
INeedBots 2021-03-11 15:11:22 -06:00
parent 9744ff6ccd
commit 52f1062793

View File

@ -133,6 +133,8 @@ resetBotVars()
self.bot.stop_move = false;
self.bot.greedy_path = false;
self.bot.climbing = false;
self.bot.last_next_wp = -1;
self.bot.last_second_next_wp = -1;
self.bot.isfrozen = false;
self.bot.sprintendtime = -1;
@ -147,6 +149,7 @@ resetBotVars()
self.bot.semi_time = false;
self.bot.jump_time = undefined;
self.bot.last_fire_time = -1;
self.bot.is_cur_full_auto = false;
self.bot.cur_weap_dist_multi = 1;
@ -249,7 +252,7 @@ doBotMovement()
// check if need to jump
bt = bulletTrace(startPosForward, startPosForward - (0, 0, 40), false, self);
if (bt["fraction"] < 1 && bt["normal"][2] > 0.75 && i > 1.5 && !self isOnLadder())
if (bt["fraction"] < 1 && bt["normal"][2] > 0.9 && i > 1.5 && !self isOnLadder())
{
i = 0;
self thread jump();
@ -336,7 +339,7 @@ watchHoldBreath()
if(self.bot.isfrozen)
continue;
self holdbreath(self playerADS() >= 1);
self holdbreath(self playerADS() > 0);
}
}
@ -1211,7 +1214,7 @@ aim()
//c4 logic here, but doesnt work anyway
canADS = (self canAds(dist, curweap) && conedot > 0.65);
canADS = (self canAds(dist, curweap) && conedot > 0.75);
if (canADS)
self thread pressADS();
@ -1248,7 +1251,7 @@ aim()
if(!self canFire(curweap) || !self isInRange(dist, curweap))
continue;
canADS = (self canAds(dist, curweap) && conedot > 0.65);
canADS = (self canAds(dist, curweap) && conedot > 0.75);
if (canADS)
self thread pressADS();
@ -1288,6 +1291,8 @@ aim()
*/
botFire()
{
self.bot.last_fire_time = getTime();
if(self.bot.is_cur_full_auto)
{
self thread pressFire();
@ -1405,6 +1410,8 @@ walk()
if(self isFlared())
{
self.bot.last_next_wp = -1;
self.bot.last_second_next_wp = -1;
self botMoveTo(self.origin + self GetVelocity()*500);
continue;
}
@ -1520,6 +1527,8 @@ strafe(target)
if(traceRight["fraction"] > traceLeft["fraction"])
strafe = traceRight["position"];
self.bot.last_next_wp = -1;
self.bot.last_second_next_wp = -1;
self botMoveTo(strafe);
wait 2;
self notify("kill_goal");
@ -1631,39 +1640,34 @@ doWalk(goal, dist, isScriptGoal)
self thread watchOnGoal(goal, distsq);
current = self initAStar(goal);
// if a waypoint is closer than the goal
//if (current >= 0 && DistanceSquared(self.origin, level.waypoints[self.bot.astar[current]].origin) < DistanceSquared(self.origin, goal))
//{
while(current >= 0)
// skip waypoints we already completed to prevent rubber banding
if (current > 0 && self.bot.astar[current] == self.bot.last_next_wp && self.bot.astar[current-1] == self.bot.last_second_next_wp)
current = self removeAStar();
if (current >= 0)
{
// check if a waypoint is closer than the goal
wpOrg = level.waypoints[self.bot.astar[current]].origin;
ppt = PlayerPhysicsTrace(self.origin + (0,0,32), wpOrg, false, self);
if (DistanceSquared(self.origin, wpOrg) < DistanceSquared(self.origin, goal) || DistanceSquared(wpOrg, ppt) > 1.0)
{
// skip down the line of waypoints and go to the waypoint we have a direct path too
/*for (;;)
while(current >= 0)
{
if (current <= 0)
break;
self.bot.next_wp = self.bot.astar[current];
self.bot.second_next_wp = -1;
if(current > 0)
self.bot.second_next_wp = self.bot.astar[current-1];
ppt = PlayerPhysicsTrace(self.origin + (0,0,32), level.waypoints[self.bot.astar[current-1]].origin, false, self);
if (DistanceSquared(level.waypoints[self.bot.astar[current-1]].origin, ppt) > 1.0)
break;
self notify("new_static_waypoint");
if (level.waypoints[self.bot.astar[current-1]].type == "climb" || level.waypoints[self.bot.astar[current]].type == "climb")
break;
self movetowards(level.waypoints[self.bot.next_wp].origin);
self.bot.last_next_wp = self.bot.next_wp;
self.bot.last_second_next_wp = self.bot.second_next_wp;
current = self removeAStar();
}*/
self.bot.next_wp = self.bot.astar[current];
self.bot.second_next_wp = -1;
if(current != 0)
self.bot.second_next_wp = self.bot.astar[current-1];
self notify("new_static_waypoint");
self movetowards(level.waypoints[self.bot.next_wp].origin);
current = self removeAStar();
}
}
//}
}
self.bot.next_wp = -1;
self.bot.second_next_wp = -1;
@ -1671,6 +1675,8 @@ doWalk(goal, dist, isScriptGoal)
if(DistanceSquared(self.origin, goal) > distsq)
{
self.bot.last_next_wp = -1;
self.bot.last_second_next_wp = -1;
self movetowards(goal); // any better way??
}