Don't rely on hedgehog facing direction, check intentions instead. Should fix excessive turns around and weird jumps to water
authorunc0rr
Thu, 15 Nov 2012 13:58:49 +0400
changeset 8036 89740f927254
parent 8033 4e40503e2b2c
child 8039 a3b86c1f63b4
Don't rely on hedgehog facing direction, check intentions instead. Should fix excessive turns around and weird jumps to water
hedgewars/uAI.pas
--- a/hedgewars/uAI.pas	Thu Nov 15 13:57:29 2012 +0400
+++ b/hedgewars/uAI.pas	Thu Nov 15 13:58:49 2012 +0400
@@ -291,18 +291,13 @@
                     begin
                     with Stack.States[Pred(Stack.Count)] do
                         begin
-                        if Me^.dX.isNegative then
+                        if (Me^.Message and gmLeft) <> 0 then
                             AddAction(MadeActions, aia_LookRight, 0, 200, 0, 0)
                         else
                             AddAction(MadeActions, aia_LookLeft, 0, 200, 0, 0);
                             
                         AddAction(MadeActions, aia_HJump, 0, 305 + random(50), 0, 0);
                         AddAction(MadeActions, aia_HJump, 0, 350, 0, 0);
-                        
-                        if Me^.dX.isNegative then
-                            AddAction(MadeActions, aia_LookLeft, 0, 200, 0, 0)
-                        else
-                            AddAction(MadeActions, aia_LookRight, 0, 200, 0, 0);
                         end;
                     // but first check walking forward
                     Push(ticks, Stack.States[Pred(Stack.Count)].MadeActions, AltMe, Me^.Message)
@@ -318,7 +313,7 @@
                 if Push(ticks, Actions, AltMe, Me^.Message xor 3) then
                     with Stack.States[Pred(Stack.Count)] do
                         begin
-                        if Me^.dX.isNegative then
+                        if (Me^.Message and gmLeft) <> 0 then
                             AddAction(MadeActions, aia_LookLeft, 0, 200, 0, 0)
                         else
                             AddAction(MadeActions, aia_LookRight, 0, 200, 0, 0);