Make AI less annoying transitional_engine
authorunC0Rr
Fri, 22 Nov 2024 17:29:48 +0100
branchtransitional_engine
changeset 16070 fc5258d7ecb2
parent 16069 6c5b3c576fc6
child 16071 14b83df1832b
Make AI less annoying
hedgewars/uAIActions.pas
--- a/hedgewars/uAIActions.pas	Fri Nov 22 17:29:30 2024 +0100
+++ b/hedgewars/uAIActions.pas	Fri Nov 22 17:29:48 2024 +0100
@@ -146,16 +146,23 @@
         end
 end;
 
-procedure CheckHang(Me: PGear);
+procedure CheckHang(Me: PGear; fromLeft: boolean);
+var newX: LongInt;
 begin
-if hwRound(Me^.X) <> PrevX then
+newX:= hwRound(Me^.X);
+if newX <> PrevX then
     begin
-    PrevX:= hwRound(Me^.X);
+    if (newX < PrevX) = fromLeft then
+        begin
+        FreeActionsList
+        end;
+    
+    PrevX:= newX;
     timedelta:= 0
     end else
         begin
         inc(timedelta);
-        if timedelta > 1700 then
+        if timedelta > 900 then
             begin
             timedelta:= 0;
             FreeActionsList
@@ -196,7 +203,7 @@
                         end
                     else
                         begin
-                        CheckHang(Me);
+                        CheckHang(Me, false);
                         exit
                         end;
 
@@ -215,7 +222,7 @@
                         end
                     else
                         begin
-                        CheckHang(Me);
+                        CheckHang(Me, true);
                         exit
                         end;
             aia_LookLeft: begin