hedgewars/uAIActions.pas
changeset 7442 9bb6abdb5675
parent 7433 c7fff3e61d49
child 7671 43f38923bc6e
equal deleted inserted replaced
7392:bc3306c59a08 7442:9bb6abdb5675
    42     aia_LJump      = $8007;
    42     aia_LJump      = $8007;
    43     aia_Skip       = $8008;
    43     aia_Skip       = $8008;
    44     aia_Wait       = $8009;
    44     aia_Wait       = $8009;
    45     aia_Put        = $800A;
    45     aia_Put        = $800A;
    46     aia_waitAngle  = $800B;
    46     aia_waitAngle  = $800B;
       
    47     aia_waitAmmoXY = $800C;
    47     
    48     
    48     aim_push       = $8000;
    49     aim_push       = $8000;
    49     aim_release    = $8001;
    50     aim_release    = $8001;
    50     ai_specmask    = $8000;
    51     ai_specmask    = $8000;
    51 
    52 
   113 end;
   114 end;
   114 {$ENDIF}
   115 {$ENDIF}
   115 
   116 
   116 procedure AddAction(var Actions: TActions; Action: Longword; Param: LongInt; TimeDelta: Longword; X, Y: LongInt);
   117 procedure AddAction(var Actions: TActions; Action: Longword; Param: LongInt; TimeDelta: Longword; X, Y: LongInt);
   117 begin
   118 begin
   118 with Actions do
   119 if Actions.Count < MAXACTIONS then
   119     begin
   120     with Actions do
   120     actions[Count].Action:= Action;
   121         begin
   121     actions[Count].Param:= Param;
   122         actions[Count].Action:= Action;
   122     actions[Count].X:= X;
   123         actions[Count].Param:= Param;
   123     actions[Count].Y:= Y;
   124         actions[Count].X:= X;
   124     if Count > 0 then
   125         actions[Count].Y:= Y;
   125         actions[Count].Time:= TimeDelta
   126         if Count > 0 then
   126     else
   127             actions[Count].Time:= TimeDelta
   127         actions[Count].Time:= GameTicks + TimeDelta;
   128         else
   128     inc(Count);
   129             actions[Count].Time:= GameTicks + TimeDelta;
   129     TryDo(Count < MAXACTIONS, 'AI: actions overflow', true);
   130         inc(Count);
   130     end
   131         end
   131 end;
   132 end;
   132 
   133 
   133 procedure CheckHang(Me: PGear);
   134 procedure CheckHang(Me: PGear);
   134 begin
   135 begin
   135 if hwRound(Me^.X) <> PrevX then
   136 if hwRound(Me^.X) <> PrevX then
   232             aia_Put:
   233             aia_Put:
   233                 doPut(X, Y, true);
   234                 doPut(X, Y, true);
   234                 
   235                 
   235             aia_waitAngle:
   236             aia_waitAngle:
   236                 if Me^.Angle <> Abs(Param) then exit;
   237                 if Me^.Angle <> Abs(Param) then exit;
       
   238 
       
   239             aia_waitAmmoXY:
       
   240                 if (CurAmmoGear <> nil) and ((hwRound(CurAmmoGear^.X) <> X) or (hwRound(CurAmmoGear^.Y) <> Y)) then exit;
       
   241 
   237             end
   242             end
   238         else
   243         else
   239             begin
   244             begin
   240             s:= ActionIdToStr[Action];
   245             s:= ActionIdToStr[Action];
   241             if (Param and ai_specmask) <> 0 then
   246             if (Param and ai_specmask) <> 0 then