# HG changeset patch # User unc0rr # Date 1183320979 0 # Node ID 9e068d2398ca6f8e6487ee64a26aeae8158003ee # Parent 465e2ec8f05fc0b977e0ae1077d856a0523c2a37 Fix AI jumping to wrong direction on the turn start diff -r 465e2ec8f05f -r 9e068d2398ca hedgewars/uAI.pas --- a/hedgewars/uAI.pas Sun Jul 01 11:02:47 2007 +0000 +++ b/hedgewars/uAI.pas Sun Jul 01 20:16:19 2007 +0000 @@ -208,7 +208,6 @@ AddAction(Actions, Me^.Message, aim_push, 250, 0, 0); if (Me^.Message and gm_Left) <> 0 then AddAction(Actions, aia_WaitXL, hwRound(Me^.X), 0, 0, 0) else AddAction(Actions, aia_WaitXR, hwRound(Me^.X), 0, 0, 0); - AddAction(Actions, Me^.Message, aim_release, 0, 0, 0); steps:= 0; while (not StopThinking) and (not PosInThinkStack(Me)) do @@ -231,7 +230,7 @@ if not CanGo then break; inc(steps); - Actions.actions[Actions.Count - 2].Param:= hwRound(Me^.X); + Actions.actions[Pred(Actions.Count)].Param:= hwRound(Me^.X); Rate:= RatePlace(Me); if Rate > BestRate then begin diff -r 465e2ec8f05f -r 9e068d2398ca hedgewars/uAIActions.pas --- a/hedgewars/uAIActions.pas Sun Jul 01 11:02:47 2007 +0000 +++ b/hedgewars/uAIActions.pas Sun Jul 01 20:16:19 2007 +0000 @@ -93,7 +93,7 @@ else begin WriteLnToConsole('AI action: '+SpecActionIdToStr[Action.Action]); if (Action.Action = aia_WaitXL) or (Action.Action = aia_WaitXR) then - WriteLnToConsole('AI action Wait X = '+inttostr(Action.Param)+', current X = '+inttostr(round(Me.X))); + WriteLnToConsole('AI action Wait X = '+inttostr(Action.Param)+', current X = '+inttostr(hwRound(Me^.X))); end end; {$ENDIF} @@ -147,18 +147,28 @@ if (Action and ai_specmask) <> 0 then case Action of aia_Weapon: SetWeapon(TAmmoType(Param)); - aia_WaitXL: if hwRound(Me^.X) = Param then Time:= GameTicks + aia_WaitXL: if hwRound(Me^.X) = Param then + begin + Action:= aia_LookLeft; + Time:= GameTicks; + exit + end else if hwRound(Me^.X) < Param then begin - OutError('AI: WaitXL assert', false); + OutError('AI: WaitXL assert (' + IntToStr(hwRound(Me^.X)) + ' < ' + IntToStr(Param) + ')', false); FreeActionsList; exit end else begin CheckHang; exit end; - aia_WaitXR: if hwRound(Me^.X) = Param then Time:= GameTicks + aia_WaitXR: if hwRound(Me^.X) = Param then + begin + Action:= aia_LookRight; + Time:= GameTicks; + exit + end else if hwRound(Me^.X) > Param then begin - OutError('AI: WaitXR assert', false); + OutError('AI: WaitXR assert (' + IntToStr(hwRound(Me^.X)) + ' > ' + IntToStr(Param) + ')', false); FreeActionsList; exit end