]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Bot AI: properly fix bot's view angles when bot gets teleported or passes through...
authorterencehill <piuntn@gmail.com>
Sun, 2 Dec 2018 10:12:24 +0000 (11:12 +0100)
committerterencehill <piuntn@gmail.com>
Sun, 2 Dec 2018 10:13:21 +0000 (11:13 +0100)
qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc
qcsrc/common/mapobjects/teleporters.qc
qcsrc/common/mutators/mutator/buffs/sv_buffs.qc
qcsrc/lib/warpzone/server.qc

index b4c4dc68fed96fa6a6c32b7e47ca2cb0b3a7957f..854e37e5eb71e81baa8646ebe6ebba139ca52d56 100644 (file)
@@ -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 )
index 403d956c59b22552521ec569d243f2d198db90ff..6482a3d787b09e4e9b134dd1ce9d8c51c3091095 100644 (file)
@@ -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);
index 9338c986c9d6ca3e3cd571c51895697a113e0543..95216fe548c1c9c6bfe9c5a2c53cff1ea0cd39d5 100644 (file)
@@ -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;
index 2805c005096582383c78f9464906ccecca337817..a81d0c4fb777a122fabab58222be9677d116d6ff 100644 (file)
@@ -10,6 +10,7 @@
        #include <common/util.qh>
        #include <server/constants.qh>
        #include <server/defs.qh>
+       #include <server/utils.qh>
 #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);