From: terencehill Date: Sun, 2 Dec 2018 10:12:24 +0000 (+0100) Subject: Bot AI: properly fix bot's view angles when bot gets teleported or passes through... X-Git-Tag: xonotic-v0.8.5~1705^2~4 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=50ed46682d172b639422b41e4bce6cbf3a5278de;p=xonotic%2Fxonotic-data.pk3dir.git Bot AI: properly fix bot's view angles when bot gets teleported or passes through a warpzone --- diff --git a/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc b/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc index b4c4dc68f..854e37e5e 100644 --- a/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc +++ b/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc @@ -1625,6 +1625,11 @@ bool ons_Teleport(entity player, entity tele_target, float range, bool tele_effe player.angles = '0 1 0' * ( theta * RAD2DEG + 180 ); makevectors(player.angles); player.fixangle = true; + if (IS_BOT_CLIENT(player)) + { + player.v_angle = player.angles; + bot_aim_reset(player); + } player.teleport_antispam = time + autocvar_g_onslaught_teleport_wait; if ( tele_effects ) diff --git a/qcsrc/common/mapobjects/teleporters.qc b/qcsrc/common/mapobjects/teleporters.qc index 403d956c5..6482a3d78 100644 --- a/qcsrc/common/mapobjects/teleporters.qc +++ b/qcsrc/common/mapobjects/teleporters.qc @@ -113,6 +113,11 @@ void TeleportPlayer(entity teleporter, entity player, vector to, vector to_angle setorigin(player, to); player.oldorigin = to; // don't undo the teleport by unsticking player.angles = to_angles; + if (IS_BOT_CLIENT(player)) + { + player.v_angle = player.angles; + bot_aim_reset(player); + } player.fixangle = true; player.velocity = to_velocity; BITXOR_ASSIGN(player.effects, EF_TELEPORT_BIT); diff --git a/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc b/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc index 9338c986c..95216fe54 100644 --- a/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc +++ b/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc @@ -680,11 +680,21 @@ MUTATOR_HOOKFUNCTION(buffs, ForbidThrowCurrentWeapon) closest.velocity = my_vel; closest.angles = my_ang; + if (IS_BOT_CLIENT(closest)) + { + closest.v_angle = closest.angles; + bot_aim_reset(closest); + } closest.fixangle = true; closest.oldorigin = my_org; closest.oldvelocity = my_vel; player.velocity = their_vel; player.angles = their_ang; + if (IS_BOT_CLIENT(player)) + { + player.v_angle = player.angles; + bot_aim_reset(player); + } player.fixangle = true; player.oldorigin = their_org; player.oldvelocity = their_vel; diff --git a/qcsrc/lib/warpzone/server.qc b/qcsrc/lib/warpzone/server.qc index 2805c0050..a81d0c4fb 100644 --- a/qcsrc/lib/warpzone/server.qc +++ b/qcsrc/lib/warpzone/server.qc @@ -10,6 +10,7 @@ #include #include #include + #include #endif #ifdef WARPZONELIB_KEEPDEBUG @@ -42,11 +43,17 @@ void WarpZone_TeleportPlayer(entity teleporter, entity player, vector to, vector player.lastteleporttime = time; #endif setorigin(player, to); // NOTE: this also aborts the move, when this is called by touch + player.angles = to_angles; #ifdef SVQC player.oldorigin = to; // for DP's unsticking player.fixangle = true; + if (IS_BOT_CLIENT(player)) + { + // FIXME find a way to smooth view's angles change for bots too + player.v_angle = player.angles; + bot_aim_reset(player); + } #endif - player.angles = to_angles; player.velocity = to_velocity; BITXOR_ASSIGN(player.effects, EF_TELEPORT_BIT);