hedgewars/uAIActions.pas
changeset 165 9b9144948668
parent 144 e6084b0c9316
child 183 57c2ef19f719
equal deleted inserted replaced
164:92cff18a3ab6 165:9b9144948668
   123      inc(Count);
   123      inc(Count);
   124      TryDo(Count < MAXACTIONS, 'AI: actions overflow', true);
   124      TryDo(Count < MAXACTIONS, 'AI: actions overflow', true);
   125      end
   125      end
   126 end;
   126 end;
   127 
   127 
   128 procedure SetWeapon(weap: Longword);
       
   129 begin
       
   130 with CurrentTeam^ do
       
   131      with Hedgehogs[CurrHedgehog] do
       
   132           while Ammo[CurSlot, CurAmmo].AmmoType <> TAmmoType(weap) do
       
   133                 ParseCommand('/slot ' + chr(49 + Ammoz[TAmmoType(weap)].Slot));
       
   134 end;
       
   135 
       
   136 procedure ProcessAction(var Actions: TActions; Me: PGear);
   128 procedure ProcessAction(var Actions: TActions; Me: PGear);
   137 var s: shortstring;
   129 var s: shortstring;
   138 begin
   130 begin
   139 if Actions.Pos >= Actions.Count then exit;
   131 if Actions.Pos >= Actions.Count then exit;
   140 with Actions.actions[Actions.Pos] do
   132 with Actions.actions[Actions.Pos] do
   143      {$IFDEF TRACEAIACTIONS}
   135      {$IFDEF TRACEAIACTIONS}
   144      DumpAction(Actions.actions[Actions.Pos], Me);
   136      DumpAction(Actions.actions[Actions.Pos], Me);
   145      {$ENDIF}
   137      {$ENDIF}
   146      if (Action and ai_specmask) <> 0 then
   138      if (Action and ai_specmask) <> 0 then
   147         case Action of
   139         case Action of
   148            aia_Weapon: SetWeapon(Param);
   140            aia_Weapon: SetWeapon(TAmmoType(Param));
   149             aia_WaitX: if round(Me.X) = Param then Time:= GameTicks
   141             aia_WaitX: if round(Me.X) = Param then Time:= GameTicks
   150                                               else exit;
   142                                               else exit;
   151             aia_WaitY: if round(Me.Y) = Param then Time:= GameTicks
   143             aia_WaitY: if round(Me.Y) = Param then Time:= GameTicks
   152                                               else exit;
   144                                               else exit;
   153          aia_LookLeft: if Me.dX >= 0 then
   145          aia_LookLeft: if Me.dX >= 0 then