hedgewars/uAI.pas
changeset 371 731ad6d27bd1
parent 370 c75410fe3133
child 375 18012da67681
equal deleted inserted replaced
370:c75410fe3133 371:731ad6d27bd1
    39 BestActions.Pos:= 0
    39 BestActions.Pos:= 0
    40 end;
    40 end;
    41 
    41 
    42 procedure TestAmmos(var Actions: TActions; Me: PGear);
    42 procedure TestAmmos(var Actions: TActions; Me: PGear);
    43 var Time, BotLevel: Longword;
    43 var Time, BotLevel: Longword;
    44     Angle, Power, Score, ExplX, ExplY, ExplR: integer;
    44     Angle, Power, Score, ExplX, ExplY, ExplR: LongInt;
    45     i: integer;
    45     i: LongInt;
    46     a, aa: TAmmoType;
    46     a, aa: TAmmoType;
    47 begin
    47 begin
    48 BotLevel:= PHedgehog(Me^.Hedgehog)^.BotLevel;
    48 BotLevel:= PHedgehog(Me^.Hedgehog)^.BotLevel;
    49 for i:= 0 to Pred(Targets.Count) do
    49 for i:= 0 to Pred(Targets.Count) do
    50     if (Targets.ar[i].Score >= 0) then
    50     if (Targets.ar[i].Score >= 0) then
    65               if Time <> 0 then AddAction(BestActions, aia_Timer, Time div 1000, 400, 0, 0);
    65               if Time <> 0 then AddAction(BestActions, aia_Timer, Time div 1000, 400, 0, 0);
    66               if (Angle > 0) then AddAction(BestActions, aia_LookRight, 0, 200, 0, 0)
    66               if (Angle > 0) then AddAction(BestActions, aia_LookRight, 0, 200, 0, 0)
    67               else if (Angle < 0) then AddAction(BestActions, aia_LookLeft, 0, 200, 0, 0);
    67               else if (Angle < 0) then AddAction(BestActions, aia_LookLeft, 0, 200, 0, 0);
    68               if (Ammoz[a].Ammo.Propz and ammoprop_NoCrosshair) = 0 then
    68               if (Ammoz[a].Ammo.Propz and ammoprop_NoCrosshair) = 0 then
    69                  begin
    69                  begin
    70                  Angle:= integer(Me^.Angle) - Abs(Angle);
    70                  Angle:= LongInt(Me^.Angle) - Abs(Angle);
    71                  if Angle > 0 then
    71                  if Angle > 0 then
    72                     begin
    72                     begin
    73                     AddAction(BestActions, aia_Up, aim_push, 500, 0, 0);
    73                     AddAction(BestActions, aia_Up, aim_push, 500, 0, 0);
    74                     AddAction(BestActions, aia_Up, aim_release, Angle, 0, 0)
    74                     AddAction(BestActions, aia_Up, aim_release, Angle, 0, 0)
    75                     end else if Angle < 0 then
    75                     end else if Angle < 0 then
    93 procedure Walk(Me: PGear);
    93 procedure Walk(Me: PGear);
    94 const FallPixForBranching = cHHRadius * 2 + 8;
    94 const FallPixForBranching = cHHRadius * 2 + 8;
    95       
    95       
    96 var Actions: TActions;
    96 var Actions: TActions;
    97     ticks, maxticks, steps, BotLevel: Longword;
    97     ticks, maxticks, steps, BotLevel: Longword;
    98     BaseRate, Rate: integer;
    98     BaseRate, Rate: LongInt;
    99     GoInfo: TGoInfo;
    99     GoInfo: TGoInfo;
   100     CanGo: boolean;
   100     CanGo: boolean;
   101     AltMe: TGear;
   101     AltMe: TGear;
   102 begin
   102 begin
   103 BotLevel:= PHedgehog(Me^.Hedgehog)^.BotLevel;
   103 BotLevel:= PHedgehog(Me^.Hedgehog)^.BotLevel;
   201       end
   201       end
   202 end;
   202 end;
   203 
   203 
   204 procedure StartThink(Me: PGear);
   204 procedure StartThink(Me: PGear);
   205 var a: TAmmoType;
   205 var a: TAmmoType;
   206     tmp: integer;
   206     tmp: LongInt;
   207 begin
   207 begin
   208 if ((Me^.State and gstAttacking) <> 0) or isInMultiShoot then exit;
   208 if ((Me^.State and gstAttacking) <> 0) or isInMultiShoot then exit;
   209 ThinkingHH:= Me;
   209 ThinkingHH:= Me;
   210 isThinking:= true;
   210 isThinking:= true;
   211 
   211 
   229 BestActions.Pos:= 0;
   229 BestActions.Pos:= 0;
   230 BestActions.Score:= 0;
   230 BestActions.Score:= 0;
   231 tmp:= random(2) + 1;
   231 tmp:= random(2) + 1;
   232 Push(0, BestActions, Me^, tmp);
   232 Push(0, BestActions, Me^, tmp);
   233 Push(0, BestActions, Me^, tmp xor 3);
   233 Push(0, BestActions, Me^, tmp xor 3);
   234 BestActions.Score:= Low(integer);
   234 BestActions.Score:= Low(LongInt);
   235 
   235 
   236 Think(Me)
   236 Think(Me)
   237 end; 
   237 end; 
   238 
   238 
   239 procedure ProcessBot(FrameNo: Longword);
   239 procedure ProcessBot(FrameNo: Longword);