hedgewars/uAIMisc.pas
changeset 549 4278a80140a8
parent 547 b81a055f2d06
child 568 d0690b7aa808
equal deleted inserted replaced
548:ac1e32b538fd 549:4278a80140a8
    81              begin
    81              begin
    82              with Targets.ar[Targets.Count], Hedgehogs[i] do
    82              with Targets.ar[Targets.Count], Hedgehogs[i] do
    83                   begin
    83                   begin
    84                   Point.X:= hwRound(Gear^.X);
    84                   Point.X:= hwRound(Gear^.X);
    85                   Point.Y:= hwRound(Gear^.Y);
    85                   Point.Y:= hwRound(Gear^.Y);
    86                   if Color <> CurrentTeam^.Color then Score:=  Gear^.Health
    86                   if Clan <> CurrentTeam^.Clan then Score:=  Gear^.Health
    87                                                  else Score:= -Gear^.Health
    87                                                else Score:= -Gear^.Health
    88                   end;
    88                   end;
    89              inc(Targets.Count)
    89              inc(Targets.Count)
    90              end;
    90              end;
    91       end
    91       end
    92 end;
    92 end;
    93 
    93 
    94 procedure FillBonuses(isAfterAttack: boolean);
    94 procedure FillBonuses(isAfterAttack: boolean);
    95 var Gear: PGear;
    95 var Gear: PGear;
    96     MyColor: Longword;
    96     MyClan: PClan;
    97 
    97 
    98     procedure AddBonus(x, y: LongInt; r: Longword; s: LongInt);
    98     procedure AddBonus(x, y: LongInt; r: Longword; s: LongInt);
    99     begin
    99     begin
   100     bonuses.ar[bonuses.Count].x:= x;
   100     bonuses.ar[bonuses.Count].x:= x;
   101     bonuses.ar[bonuses.Count].y:= y;
   101     bonuses.ar[bonuses.Count].y:= y;
   105     TryDo(bonuses.Count <= MAXBONUS, 'Bonuses overflow', true)
   105     TryDo(bonuses.Count <= MAXBONUS, 'Bonuses overflow', true)
   106     end;
   106     end;
   107 
   107 
   108 begin
   108 begin
   109 bonuses.Count:= 0;
   109 bonuses.Count:= 0;
   110 MyColor:= PHedgehog(ThinkingHH^.Hedgehog)^.Team^.Color;
   110 MyClan:= PHedgehog(ThinkingHH^.Hedgehog)^.Team^.Clan;
   111 Gear:= GearsList;
   111 Gear:= GearsList;
   112 while Gear <> nil do
   112 while Gear <> nil do
   113       begin
   113       begin
   114       case Gear^.Kind of
   114       case Gear^.Kind of
   115            gtCase: AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 33, 25);
   115            gtCase: AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 33, 25);
   117                                                         else AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 100, -50); // mine is on
   117                                                         else AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 100, -50); // mine is on
   118            gtDynamite: AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 150, -75);
   118            gtDynamite: AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 150, -75);
   119            gtHedgehog: begin
   119            gtHedgehog: begin
   120                        if Gear^.Damage >= Gear^.Health then AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 60, -25) else
   120                        if Gear^.Damage >= Gear^.Health then AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 60, -25) else
   121                           if isAfterAttack and (ThinkingHH^.Hedgehog <> Gear^.Hedgehog) then
   121                           if isAfterAttack and (ThinkingHH^.Hedgehog <> Gear^.Hedgehog) then
   122                              if (MyColor = PHedgehog(Gear^.Hedgehog)^.Team^.Color) then AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 150, -3) // hedgehog-friend
   122                              if (MyClan = PHedgehog(Gear^.Hedgehog)^.Team^.Clan) then AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 150, -3) // hedgehog-friend
   123                                                                                    else AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 100, 3)
   123                                                                                  else AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 100, 3)
   124                        end;
   124                        end;
   125            end;
   125            end;
   126       Gear:= Gear^.NextGear
   126       Gear:= Gear^.NextGear
   127       end;
   127       end;
   128 if isAfterAttack and (KnownExplosion.Radius > 0) then
   128 if isAfterAttack and (KnownExplosion.Radius > 0) then