#include <common/items/_mod.qh>
#include <common/wepent.qh>
+#include <common/mapobjects/func/ladder.qh>
#include <common/mapobjects/teleporters.qh>
#include <common/mapobjects/trigger/jumppads.qh>
{
// Calculate brake distance in xy
float d = vlen(vec2(this.origin - (this.goalcurrent.absmin + this.goalcurrent.absmax) * 0.5));
- float v = vlen(vec2(this.velocity));
- float db = ((v ** 2) / (autocvar_g_jetpack_acceleration_side * 2)) + 100;
+ float vel2 = vlen2(vec2(this.velocity));
+ float db = (vel2 / (autocvar_g_jetpack_acceleration_side * 2)) + 100;
//LOG_INFOF("distance %d, velocity %d, brake at %d ", ceil(d), ceil(v), ceil(db));
if(d < db || d < 500)
{
// Brake
- if(v > maxspeed * 0.3)
+ if (vel2 > (maxspeed * 0.3) ** 2)
{
CS(this).movement_x = dir * v_forward * -maxspeed;
return;
return;
}
- else if(GetResourceAmount(this, RESOURCE_HEALTH) + GetResourceAmount(this, RESOURCE_ARMOR) > ROCKETJUMP_DAMAGE())
+ else if(!this.jumppadcount && !this.goalcurrent.wphardwired
+ && GetResourceAmount(this, RESOURCE_HEALTH) + GetResourceAmount(this, RESOURCE_ARMOR) > ROCKETJUMP_DAMAGE())
{
if(this.velocity.z < 0)
{
else
PHYS_INPUT_BUTTON_JUMP(this) = false;
makevectors(this.v_angle.y * '0 1 0');
- CS(this).movement_x = dir * v_forward * maxspeed;
- CS(this).movement_y = dir * v_right * maxspeed;
- CS(this).movement_z = dir * v_up * maxspeed;
+ vector v = dir * maxspeed;
+ CS(this).movement.x = v * v_forward;
+ CS(this).movement.y = v * v_right;
+ CS(this).movement.z = v * v_up;
}
// if there is nowhere to go, exit
{
if (vdist(this.origin - this.goalcurrent_prev.origin, <, 50)
&& navigation_goalrating_timeout_can_be_anticipated(this))
+ {
navigation_goalrating_timeout_force(this);
+ }
}
bool goalcurrent_can_be_removed = false;
// if bot used the jumppad, push towards jumppad origin until jumppad waypoint gets removed
destorg = this.goalcurrent.origin;
}
- else if (this.goalcurrent.wpisbox && boxesoverlap(this.goalcurrent.absmin, this.goalcurrent.absmax, this.origin + eZ * this.mins.z, this.origin + eZ * this.maxs.z))
+ else if (this.goalcurrent.wpisbox)
{
// if bot is inside the teleport waypoint, head to teleport origin until teleport gets used
- bunnyhop_forbidden = true;
- destorg = this.goalcurrent.origin;
- if(destorg.z > this.origin.z)
- PHYS_INPUT_BUTTON_JUMP(this) = true;
+ // do it even if bot is on a ledge above a teleport/jumppad so it doesn't get stuck
+ if (boxesoverlap(this.goalcurrent.absmin, this.goalcurrent.absmax, this.origin + eZ * this.mins.z, this.origin + eZ * this.maxs.z)
+ || (this.absmin.z > destorg.z && destorg.x == this.origin.x && destorg.y == this.origin.y))
+ {
+ bunnyhop_forbidden = true;
+ destorg = this.goalcurrent.origin;
+ if(destorg.z > this.origin.z)
+ PHYS_INPUT_BUTTON_JUMP(this) = true;
+ }
}
diff = destorg - this.origin;
- // 1. stop if too close to target player (even if frozen)
- // 2. stop if the locked goal has been reached
- if ((IS_PLAYER(this.goalcurrent) && vdist(diff, <, 80))
- || (this.goalcurrent == this.goalentity && time < this.goalentity_lock_timeout && vdist(diff, <, 10)))
+ if (this.goalcurrent == this.goalentity && time < this.goalentity_lock_timeout && vdist(diff, <, 10))
{
+ // stop if the locked goal has been reached
destorg = this.origin;
- diff = '0 0 0';
+ diff = dir = '0 0 0';
}
-
- dir = normalize(diff);
+ else if (IS_PLAYER(this.goalcurrent) || IS_MONSTER(this.goalcurrent))
+ {
+ if (vdist(diff, <, 80))
+ {
+ // stop if too close to target player (even if frozen)
+ destorg = this.origin;
+ diff = dir = '0 0 0';
+ }
+ else
+ {
+ // move destorg out of target players, otherwise bot will consider them
+ // an obstacle that needs to be jumped (especially if frozen)
+ dir = normalize(diff);
+ destorg -= dir * PL_MAX_CONST.x * M_SQRT2;
+ diff = destorg - this.origin;
+ }
+ }
+ else
+ dir = normalize(diff);
flatdir = (diff.z == 0) ? dir : normalize(vec2(diff));
//if (this.bot_dodgevector_time < time)
{
if (vlen2(flat_diff) < vlen2(offset))
{
- actual_destorg.x = destorg.x;
- actual_destorg.y = destorg.y;
+ if (this.goalcurrent.wpflags & WAYPOINTFLAG_JUMP && this.goalstack01)
+ {
+ // oblique warpzones need a jump otherwise bots gets stuck
+ PHYS_INPUT_BUTTON_JUMP(this) = true;
+ }
+ else
+ {
+ actual_destorg.x = destorg.x;
+ actual_destorg.y = destorg.y;
+ }
}
}
else if (vdist(flat_diff, <, 32) && diff.z < -16) // destination is under the bot
}
if (ladder_zdir)
{
- dir.z = ladder_zdir * 1.3;
- dir = normalize(dir);
+ if (vdist(flatdir, <, 15))
+ dir = ladder_zdir * '0 0 1';
+ else
+ {
+ dir.z = ladder_zdir * 1.3;
+ dir = normalize(dir);
+ }
}
}