10 Count: Longword; |
10 Count: Longword; |
11 ar: array[0..cMaxHHIndex*5] of TTarget; |
11 ar: array[0..cMaxHHIndex*5] of TTarget; |
12 end; |
12 end; |
13 |
13 |
14 procedure FillTargets; |
14 procedure FillTargets; |
15 procedure FillBonuses; |
15 procedure FillBonuses(isAfterAttack: boolean); |
16 function CheckBonuses(Gear: PGear): integer; |
16 function RatePlace(Gear: PGear): integer; |
17 function DxDy2AttackAngle(const _dY, _dX: Extended): integer; |
17 function DxDy2AttackAngle(const _dY, _dX: Extended): integer; |
18 function TestColl(x, y, r: integer): boolean; |
18 function TestColl(x, y, r: integer): boolean; |
19 function RateExplosion(Me: PGear; x, y, r: integer): integer; |
19 function RateExplosion(Me: PGear; x, y, r: integer): integer; |
20 function HHGo(Gear: PGear): boolean; |
20 function HHGo(Gear: PGear): boolean; |
21 |
21 |
75 TryDo(bonuses.Count <= MAXBONUS, 'Bonuses overflow', true) |
76 TryDo(bonuses.Count <= MAXBONUS, 'Bonuses overflow', true) |
76 end; |
77 end; |
77 |
78 |
78 begin |
79 begin |
79 bonuses.Count:= 0; |
80 bonuses.Count:= 0; |
|
81 MyColor:= PHedgehog(ThinkingHH.Hedgehog).Team.Color; |
80 Gear:= GearsList; |
82 Gear:= GearsList; |
81 while Gear <> nil do |
83 while Gear <> nil do |
82 begin |
84 begin |
83 case Gear.Kind of |
85 case Gear.Kind of |
84 gtCase: AddBonus(round(Gear.X), round(Gear.Y), 32, 25); |
86 gtCase: AddBonus(round(Gear.X), round(Gear.Y), 33, 25); |
85 gtMine: AddBonus(round(Gear.X), round(Gear.Y), 45, -50); |
87 gtMine: AddBonus(round(Gear.X), round(Gear.Y), 46, -50); |
86 gtAmmo_Bomb: AddBonus(round(Gear.X), round(Gear.Y), 50, -100); |
88 gtDynamite: AddBonus(round(Gear.X), round(Gear.Y), 150, -75); |
87 gtHedgehog: if Gear.Damage >= Gear.Health then AddBonus(round(Gear.X), round(Gear.Y), 50, -25); |
89 gtHedgehog: begin |
|
90 if Gear.Damage >= Gear.Health then AddBonus(round(Gear.X), round(Gear.Y), 50, -25); |
|
91 if isAfterAttack |
|
92 and (ThinkingHH.Hedgehog <> Gear.Hedgehog) |
|
93 and (MyColor = PHedgehog(Gear.Hedgehog).Team.Color) then AddBonus(round(Gear.X), round(Gear.Y), 100, -1); |
|
94 end; |
88 end; |
95 end; |
89 Gear:= Gear.NextGear |
96 Gear:= Gear.NextGear |
90 end |
97 end |
91 end; |
98 end; |
92 |
99 |
93 function CheckBonuses(Gear: PGear): integer; |
100 function RatePlace(Gear: PGear): integer; |
94 var i: integer; |
101 var i, r: integer; |
95 begin |
102 begin |
96 Result:= 0; |
103 Result:= 0; |
97 for i:= 0 to Pred(bonuses.Count) do |
104 for i:= 0 to Pred(bonuses.Count) do |
98 with bonuses.ar[i] do |
105 with bonuses.ar[i] do |
99 if sqrt(sqr(Gear.X - X) + sqr(Gear.Y - y)) <= Radius then |
106 begin |
100 inc(Result, Score) |
107 r:= round(sqrt(sqr(Gear.X - X) + sqr(Gear.Y - y))); |
|
108 if r < Radius then |
|
109 inc(Result, Score * (Radius - r)) |
|
110 end; |
101 end; |
111 end; |
102 |
112 |
103 function DxDy2AttackAngle(const _dY, _dX: Extended): integer; |
113 function DxDy2AttackAngle(const _dY, _dX: Extended): integer; |
104 const piDIVMaxAngle: Extended = pi/cMaxAngle; |
114 const piDIVMaxAngle: Extended = pi/cMaxAngle; |
105 asm |
115 asm |