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 b4c4dc6..854e37e 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 403d956..6482a3d 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 9338c98..95216fe 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 2805c00..a81d0c4 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);