hedgewars/uAIActions.pas
changeset 371 731ad6d27bd1
parent 369 2aed85310727
child 393 db01cc79f278
equal deleted inserted replaced
370:c75410fe3133 371:731ad6d27bd1
    43       aim_push       = $8000;
    43       aim_push       = $8000;
    44       aim_release    = $8001;
    44       aim_release    = $8001;
    45       ai_specmask    = $8000;
    45       ai_specmask    = $8000;
    46 
    46 
    47 type TAction = record
    47 type TAction = record
    48                Action, Param: Longword;
    48                Action: Longword;
    49                X, Y: integer;
    49                X, Y, Param: LongInt;
    50                Time: Longword;
    50                Time: Longword;
    51                end;
    51                end;
    52      TActions = record
    52      TActions = record
    53                 Count, Pos: Longword;
    53                 Count, Pos: Longword;
    54                 actions: array[0..Pred(MAXACTIONS)] of TAction;
    54                 actions: array[0..Pred(MAXACTIONS)] of TAction;
    55                 Score: integer;
    55                 Score: LongInt;
    56                 end;
    56                 end;
    57 
    57 
    58 procedure AddAction(var Actions: TActions; Action, Param, TimeDelta: Longword; X, Y: integer);
    58 procedure AddAction(var Actions: TActions; Action: Longword; Param: LongInt; TimeDelta: Longword; X, Y: LongInt);
    59 procedure ProcessAction(var Actions: TActions; Me: PGear);
    59 procedure ProcessAction(var Actions: TActions; Me: PGear);
    60 
    60 
    61 implementation
    61 implementation
    62 uses uMisc, uTeams, uConsts, uConsole, uAIMisc;
    62 uses uMisc, uTeams, uConsts, uConsole, uAIMisc;
    63 
    63 
    95       WriteLnToConsole('AI action Wait X = '+inttostr(Action.Param)+', current X = '+inttostr(round(Me.X)));
    95       WriteLnToConsole('AI action Wait X = '+inttostr(Action.Param)+', current X = '+inttostr(round(Me.X)));
    96    end
    96    end
    97 end;
    97 end;
    98 {$ENDIF}
    98 {$ENDIF}
    99 
    99 
   100 procedure AddAction(var Actions: TActions; Action, Param, TimeDelta: Longword; X, Y: integer);
   100 procedure AddAction(var Actions: TActions; Action: Longword; Param: LongInt; TimeDelta: Longword; X, Y: LongInt);
   101 begin
   101 begin
   102 with Actions do
   102 with Actions do
   103      begin
   103      begin
   104      actions[Count].Action:= Action;
   104      actions[Count].Action:= Action;
   105      actions[Count].Param:= Param;
   105      actions[Count].Param:= Param;
   114 
   114 
   115 procedure ProcessAction(var Actions: TActions; Me: PGear);
   115 procedure ProcessAction(var Actions: TActions; Me: PGear);
   116 var s: shortstring;
   116 var s: shortstring;
   117 
   117 
   118     procedure CheckHang;
   118     procedure CheckHang;
   119     const PrevX: integer = 0;
   119     const PrevX: LongInt = 0;
   120           timedelta: Longword = 0;
   120           timedelta: Longword = 0;
   121     begin
   121     begin
   122     if hwRound(Me^.X) <> PrevX then
   122     if hwRound(Me^.X) <> PrevX then
   123        begin
   123        begin
   124        PrevX:= hwRound(Me^.X);
   124        PrevX:= hwRound(Me^.X);