47 function HHGo(Gear, AltGear: PGear; var GoInfo: TGoInfo): boolean; |
47 function HHGo(Gear, AltGear: PGear; var GoInfo: TGoInfo): boolean; |
48 function AIrndSign(num: LongInt): LongInt; |
48 function AIrndSign(num: LongInt): LongInt; |
49 |
49 |
50 var ThinkingHH: PGear; |
50 var ThinkingHH: PGear; |
51 Targets: TTargets; |
51 Targets: TTargets; |
52 |
52 |
53 implementation |
53 implementation |
54 uses uTeams, uMisc, uLand, uCollisions; |
54 uses uTeams, uMisc, uLand, uCollisions, uconsole; |
55 const KillScore = 200; |
55 const KillScore = 200; |
56 MAXBONUS = 1024; |
56 MAXBONUS = 1024; |
|
57 friendlyfactor: Longword = 300; |
57 |
58 |
58 type TBonus = record |
59 type TBonus = record |
59 X, Y: LongInt; |
60 X, Y: LongInt; |
60 Radius: LongInt; |
61 Radius: LongInt; |
61 Score: LongInt; |
62 Score: LongInt; |
68 X, Y, Radius: LongInt |
69 X, Y, Radius: LongInt |
69 end = (X: 0; Y: 0; Radius: 0); |
70 end = (X: 0; Y: 0; Radius: 0); |
70 |
71 |
71 procedure FillTargets; |
72 procedure FillTargets; |
72 var i, t: Longword; |
73 var i, t: Longword; |
|
74 f, e: Longword; |
73 begin |
75 begin |
74 Targets.Count:= 0; |
76 Targets.Count:= 0; |
|
77 f:= 0; |
|
78 e:= 0; |
75 for t:= 0 to Pred(TeamsCount) do |
79 for t:= 0 to Pred(TeamsCount) do |
76 with TeamsArray[t]^ do |
80 with TeamsArray[t]^ do |
77 begin |
81 begin |
78 for i:= 0 to cMaxHHIndex do |
82 for i:= 0 to cMaxHHIndex do |
79 if (Hedgehogs[i].Gear <> nil) |
83 if (Hedgehogs[i].Gear <> nil) |
80 and (Hedgehogs[i].Gear <> ThinkingHH) then |
84 and (Hedgehogs[i].Gear <> ThinkingHH) then |
81 begin |
85 begin |
82 with Targets.ar[Targets.Count], Hedgehogs[i] do |
86 with Targets.ar[Targets.Count], Hedgehogs[i] do |
83 begin |
87 begin |
84 Point.X:= hwRound(Gear^.X); |
88 Point.X:= hwRound(Gear^.X); |
85 Point.Y:= hwRound(Gear^.Y); |
89 Point.Y:= hwRound(Gear^.Y); |
86 if Clan <> CurrentTeam^.Clan then Score:= Gear^.Health |
90 if Clan <> CurrentTeam^.Clan then |
87 else Score:= -Gear^.Health |
91 begin |
88 end; |
92 Score:= Gear^.Health; |
89 inc(Targets.Count) |
93 inc(e) |
90 end; |
94 end else |
91 end |
95 begin |
|
96 Score:= -Gear^.Health; |
|
97 inc(f) |
|
98 end |
|
99 end; |
|
100 inc(Targets.Count) |
|
101 end; |
|
102 end; |
|
103 |
|
104 if e > f then friendlyfactor:= 300 + (e - f) * 30 |
|
105 else friendlyfactor:= max(30, 300 - f * 80 div e); |
|
106 writelntoconsole('e:' +inttostr(e) + ' f:' + inttostr(f) + ' ff:'+ inttostr(friendlyfactor)) |
92 end; |
107 end; |
93 |
108 |
94 procedure FillBonuses(isAfterAttack: boolean); |
109 procedure FillBonuses(isAfterAttack: boolean); |
95 var Gear: PGear; |
110 var Gear: PGear; |
96 MyClan: PClan; |
111 MyClan: PClan; |
183 if dmg > 0 then |
198 if dmg > 0 then |
184 begin |
199 begin |
185 dmg:= dmg shr 1; |
200 dmg:= dmg shr 1; |
186 if dmg >= abs(Score) then |
201 if dmg >= abs(Score) then |
187 if Score > 0 then inc(Result, KillScore) |
202 if Score > 0 then inc(Result, KillScore) |
188 else dec(Result, KillScore * 3) |
203 else dec(Result, KillScore * friendlyfactor div 100) |
189 else |
204 else |
190 if Score > 0 then inc(Result, dmg) |
205 if Score > 0 then inc(Result, dmg) |
191 else dec(Result, dmg * 3) |
206 else dec(Result, dmg * friendlyfactor div 100) |
192 end; |
207 end; |
193 end; |
208 end; |
194 RateExplosion:= Result * 1024 |
209 RateExplosion:= Result * 1024 |
195 end; |
210 end; |
196 |
211 |
204 dmg:= r - hwRound(DistanceI(Point.x - x, Point.y - y)); |
219 dmg:= r - hwRound(DistanceI(Point.x - x, Point.y - y)); |
205 if dmg > 0 then |
220 if dmg > 0 then |
206 begin |
221 begin |
207 if power >= abs(Score) then |
222 if power >= abs(Score) then |
208 if Score > 0 then inc(Result, KillScore) |
223 if Score > 0 then inc(Result, KillScore) |
209 else dec(Result, KillScore * 3) |
224 else dec(Result, KillScore * friendlyfactor div 100) |
210 else |
225 else |
211 if Score > 0 then inc(Result, power) |
226 if Score > 0 then inc(Result, power) |
212 else dec(Result, power * 3) |
227 else dec(Result, power * friendlyfactor div 100) |
213 end; |
228 end; |
214 end; |
229 end; |
215 RateShove:= Result * 1024 |
230 RateShove:= Result * 1024 |
216 end; |
231 end; |
217 |
232 |
233 dmg:= min(cHHRadius + cShotgunRadius - hwRound(DistanceI(Point.x - x, Point.y - y)), 25); |
248 dmg:= min(cHHRadius + cShotgunRadius - hwRound(DistanceI(Point.x - x, Point.y - y)), 25); |
234 if dmg > 0 then |
249 if dmg > 0 then |
235 begin |
250 begin |
236 if dmg >= abs(Score) then |
251 if dmg >= abs(Score) then |
237 if Score > 0 then inc(Result, KillScore) |
252 if Score > 0 then inc(Result, KillScore) |
238 else dec(Result, KillScore * 3) |
253 else dec(Result, KillScore * friendlyfactor div 100) |
239 else |
254 else |
240 if Score > 0 then inc(Result, dmg) |
255 if Score > 0 then inc(Result, dmg) |
241 else dec(Result, dmg * 3) |
256 else dec(Result, dmg * friendlyfactor div 100) |
242 end; |
257 end; |
243 end; |
258 end; |
244 RateShotgun:= Result * 1024 |
259 RateShotgun:= Result * 1024 |
245 end; |
260 end; |
246 |
261 |