Prevent AI from flooding +L/+R messages
authorunc0rr
Sun, 01 Sep 2019 10:42:33 +0200
changeset 15390 56f2c70723c8
parent 15389 7718bdf60d45
child 15391 7a3d70c364fd
Prevent AI from flooding +L/+R messages
hedgewars/uAIActions.pas
--- a/hedgewars/uAIActions.pas	Sun Sep 01 10:37:16 2019 +0200
+++ b/hedgewars/uAIActions.pas	Sun Sep 01 10:42:33 2019 +0200
@@ -206,21 +206,31 @@
                         CheckHang(Me);
                         exit
                         end;
-            aia_LookLeft:
+            aia_LookLeft: begin
+                if (Me^.State and gstMoving) <> 0 then
+                    exit;
+            
                 if not Me^.dX.isNegative then
-                    begin
-                    ParseCommand('+left', true);
+                begin
+                    if (Me^.Message and gmLeft) = 0 then
+                        ParseCommand('+left', true);
                     exit
                     end
                 else
                     ParseCommand('-left', true);
-            aia_LookRight:
+            end;
+            aia_LookRight: begin
+                if (Me^.State and gstMoving) <> 0 then
+                    exit;
+            
                 if Me^.dX.isNegative then
-                    begin
-                    ParseCommand('+right', true);
+                begin
+                    if (Me^.Message and gmRight) = 0 then
+                        ParseCommand('+right', true);
                     exit
                     end
                 else ParseCommand('-right', true);
+            end;
             aia_AwareExpl:
                 AwareOfExplosion(X, Y, Param);