30 AttackPutX, AttackPutY: LongInt; |
30 AttackPutX, AttackPutY: LongInt; |
31 end; |
31 end; |
32 |
32 |
33 function TestBazooka(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
33 function TestBazooka(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
34 function TestGrenade(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
34 function TestGrenade(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
|
35 function TestMolotov(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
35 function TestClusterBomb(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
36 function TestClusterBomb(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
36 function TestWatermelon(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
37 function TestWatermelon(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
37 function TestMortar(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
38 function TestMortar(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
38 function TestShotgun(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
39 function TestShotgun(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
39 function TestDesertEagle(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
40 function TestDesertEagle(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
60 (proc: nil; flags: 0), // amRope |
61 (proc: nil; flags: 0), // amRope |
61 (proc: nil; flags: 0), // amMine |
62 (proc: nil; flags: 0), // amMine |
62 (proc: @TestDesertEagle; flags: 0), // amDEagle |
63 (proc: @TestDesertEagle; flags: 0), // amDEagle |
63 (proc: nil; flags: 0), // amDynamite |
64 (proc: nil; flags: 0), // amDynamite |
64 (proc: @TestFirePunch; flags: 0), // amFirePunch |
65 (proc: @TestFirePunch; flags: 0), // amFirePunch |
65 (proc: nil; flags: 0), // amWhip |
66 (proc: @TestFirePunch; flags: 0), // amWhip |
66 (proc: @TestBaseballBat; flags: 0), // amBaseballBat |
67 (proc: @TestBaseballBat; flags: 0), // amBaseballBat |
67 (proc: nil; flags: 0), // amParachute |
68 (proc: nil; flags: 0), // amParachute |
68 (proc: @TestAirAttack; flags: amtest_OnTurn), // amAirAttack |
69 (proc: @TestAirAttack; flags: amtest_OnTurn), // amAirAttack |
69 (proc: nil; flags: 0), // amMineStrike |
70 (proc: nil; flags: 0), // amMineStrike |
70 (proc: nil; flags: 0), // amBlowTorch |
71 (proc: nil; flags: 0), // amBlowTorch |
87 (proc: nil; flags: 0), // amExtraTime |
88 (proc: nil; flags: 0), // amExtraTime |
88 (proc: nil; flags: 0), // amLaserSight |
89 (proc: nil; flags: 0), // amLaserSight |
89 (proc: nil; flags: 0), // amVampiric |
90 (proc: nil; flags: 0), // amVampiric |
90 (proc: nil; flags: 0), // amSniperRifle |
91 (proc: nil; flags: 0), // amSniperRifle |
91 (proc: nil; flags: 0), // amJetpack |
92 (proc: nil; flags: 0), // amJetpack |
92 (proc: nil; flags: 0) // amMolotov |
93 (proc: @TestMolotov; flags: 0) // amMolotov |
93 ); |
94 ); |
94 |
95 |
95 const BadTurn = Low(LongInt) div 4; |
96 const BadTurn = Low(LongInt) div 4; |
96 |
97 |
97 implementation |
98 implementation |
155 valueResult:= Score |
156 valueResult:= Score |
156 end; |
157 end; |
157 end |
158 end |
158 until (rTime > 4250); |
159 until (rTime > 4250); |
159 TestBazooka:= valueResult |
160 TestBazooka:= valueResult |
|
161 end; |
|
162 |
|
163 function TestMolotov(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
|
164 const tDelta = 24; |
|
165 var Vx, Vy, r: hwFloat; |
|
166 Score, EX, EY, valueResult: LongInt; |
|
167 TestTime: Longword; |
|
168 |
|
169 function CheckTrace: LongInt; |
|
170 var x, y, dY: hwFloat; |
|
171 t: LongInt; |
|
172 begin |
|
173 x:= Me^.X; |
|
174 y:= Me^.Y; |
|
175 dY:= -Vy; |
|
176 t:= TestTime; |
|
177 repeat |
|
178 x:= x + Vx; |
|
179 y:= y + dY; |
|
180 dY:= dY + cGravity; |
|
181 dec(t) |
|
182 until TestCollExcludingMe(Me, hwRound(x), hwRound(y), 7) or (t = 0); |
|
183 EX:= hwRound(x); |
|
184 EY:= hwRound(y); |
|
185 if t < 50 then CheckTrace:= RateExplosion(Me, EX, EY, 97) // average of 17 attempts, most good, but some failing spectacularly |
|
186 else CheckTrace:= BadTurn |
|
187 end; |
|
188 begin |
|
189 valueResult:= BadTurn; |
|
190 TestTime:= 0; |
|
191 ap.ExplR:= 0; |
|
192 repeat |
|
193 inc(TestTime, 1000); |
|
194 Vx:= (int2hwFloat(Targ.X) - Me^.X) / int2hwFloat(TestTime + tDelta); |
|
195 Vy:= cGravity * ((TestTime + tDelta) div 2) - (int2hwFloat(Targ.Y) - Me^.Y) / int2hwFloat(TestTime + tDelta); |
|
196 r:= Distance(Vx, Vy); |
|
197 if not (r > _1) then |
|
198 begin |
|
199 Score:= CheckTrace; |
|
200 if valueResult < Score then |
|
201 begin |
|
202 ap.Angle:= DxDy2AttackAngle(Vx, Vy) + AIrndSign(random(Level)); |
|
203 ap.Power:= hwRound(r * cMaxPower) + AIrndSign(random(Level) * 15); |
|
204 ap.Time:= TestTime; |
|
205 ap.ExplR:= 100; |
|
206 ap.ExplX:= EX; |
|
207 ap.ExplY:= EY; |
|
208 valueResult:= Score |
|
209 end; |
|
210 end |
|
211 until (TestTime = 4000); |
|
212 TestMolotov:= valueResult |
160 end; |
213 end; |
161 |
214 |
162 function TestGrenade(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
215 function TestGrenade(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
163 const tDelta = 24; |
216 const tDelta = 24; |
164 var Vx, Vy, r: hwFloat; |
217 var Vx, Vy, r: hwFloat; |
231 dY:= dY + cGravity; |
284 dY:= dY + cGravity; |
232 dec(t) |
285 dec(t) |
233 until TestCollExcludingMe(Me, hwRound(x), hwRound(y), 5) or (t = 0); |
286 until TestCollExcludingMe(Me, hwRound(x), hwRound(y), 5) or (t = 0); |
234 EX:= hwRound(x); |
287 EX:= hwRound(x); |
235 EY:= hwRound(y); |
288 EY:= hwRound(y); |
236 if t < 50 then CheckTrace:= RateExplosion(Me, EX, EY, 91) |
289 if t < 50 then CheckTrace:= RateExplosion(Me, EX, EY, 81) |
237 else CheckTrace:= BadTurn |
290 else CheckTrace:= BadTurn |
238 end; |
291 end; |
239 begin |
292 begin |
240 valueResult:= BadTurn; |
293 valueResult:= BadTurn; |
241 TestTime:= 0; |
294 TestTime:= 0; |
242 ap.ExplR:= 0; |
295 ap.ExplR:= 0; |
243 repeat |
296 repeat |
244 inc(TestTime, 1000); |
297 inc(TestTime, 1000); |
245 Vx:= (int2hwFloat(Targ.X) - Me^.X) / int2hwFloat(TestTime + tDelta); |
298 // Try to overshoot slightly, seems to pay slightly better dividends in terms of hitting cluster |
246 Vy:= cGravity * ((TestTime + tDelta) div 2) - (int2hwFloat(Targ.Y) - Me^.Y) / int2hwFloat(TestTime + tDelta); |
299 if Me^.X<int2hwFloat(Targ.X) then |
|
300 Vx:= (int2hwFloat(Targ.X+10) - Me^.X) / int2hwFloat(TestTime + tDelta) |
|
301 else |
|
302 Vx:= (int2hwFloat(Targ.X-10) - Me^.X) / int2hwFloat(TestTime + tDelta); |
|
303 Vy:= cGravity * ((TestTime + tDelta) div 2) - (int2hwFloat(Targ.Y-25) - Me^.Y) / int2hwFloat(TestTime + tDelta); |
247 r:= Distance(Vx, Vy); |
304 r:= Distance(Vx, Vy); |
248 if not (r > _1) then |
305 if not (r > _1) then |
249 begin |
306 begin |
250 Score:= CheckTrace; |
307 Score:= CheckTrace; |
251 if valueResult < Score then |
308 if valueResult < Score then |
252 begin |
309 begin |
253 ap.Angle:= DxDy2AttackAngle(Vx, Vy) + AIrndSign(random(Level)); |
310 ap.Angle:= DxDy2AttackAngle(Vx, Vy) + AIrndSign(random(Level)); |
254 ap.Power:= hwRound(r * cMaxPower) + AIrndSign(random(Level) * 15)+10; |
311 ap.Power:= hwRound(r * cMaxPower) + AIrndSign(random(Level) * 15); |
255 ap.Time:= TestTime; |
312 ap.Time:= TestTime; |
256 ap.ExplR:= 90; |
313 ap.ExplR:= 90; |
257 ap.ExplX:= EX; |
314 ap.ExplX:= EX; |
258 ap.ExplY:= EY; |
315 ap.ExplY:= EY; |
259 valueResult:= Score |
316 valueResult:= Score |
283 dY:= dY + cGravity; |
340 dY:= dY + cGravity; |
284 dec(t) |
341 dec(t) |
285 until TestCollExcludingMe(Me, hwRound(x), hwRound(y), 5) or (t = 0); |
342 until TestCollExcludingMe(Me, hwRound(x), hwRound(y), 5) or (t = 0); |
286 EX:= hwRound(x); |
343 EX:= hwRound(x); |
287 EY:= hwRound(y); |
344 EY:= hwRound(y); |
288 if t < 50 then CheckTrace:= RateExplosion(Me, EX, EY, 301) |
345 if t < 50 then CheckTrace:= RateExplosion(Me, EX, EY, 381) |
289 else CheckTrace:= BadTurn |
346 else CheckTrace:= BadTurn |
290 end; |
347 end; |
291 begin |
348 begin |
292 valueResult:= BadTurn; |
349 valueResult:= BadTurn; |
293 TestTime:= 0; |
350 TestTime:= 0; |
294 ap.ExplR:= 0; |
351 ap.ExplR:= 0; |
295 repeat |
352 repeat |
296 inc(TestTime, 1000); |
353 inc(TestTime, 1000); |
297 Vx:= (int2hwFloat(Targ.X) - Me^.X) / int2hwFloat(TestTime + tDelta); |
354 Vx:= (int2hwFloat(Targ.X) - Me^.X) / int2hwFloat(TestTime + tDelta); |
298 Vy:= cGravity * ((TestTime + tDelta) div 2) - (int2hwFloat(Targ.Y) - Me^.Y) / int2hwFloat(TestTime + tDelta); |
355 Vy:= cGravity * ((TestTime + tDelta) div 2) - (int2hwFloat(Targ.Y-125) - Me^.Y) / int2hwFloat(TestTime + tDelta); |
299 r:= Distance(Vx, Vy); |
356 r:= Distance(Vx, Vy); |
300 if not (r > _1) then |
357 if not (r > _1) then |
301 begin |
358 begin |
302 Score:= CheckTrace; |
359 Score:= CheckTrace; |
303 if valueResult < Score then |
360 if valueResult < Score then |
304 begin |
361 begin |
305 ap.Angle:= DxDy2AttackAngle(Vx, Vy) + AIrndSign(random(Level)); |
362 ap.Angle:= DxDy2AttackAngle(Vx, Vy) + AIrndSign(random(Level)); |
306 ap.Power:= hwRound(r * cMaxPower) + AIrndSign(random(Level) * 15)+50; |
363 ap.Power:= hwRound(r * cMaxPower) + AIrndSign(random(Level) * 15); |
307 ap.Time:= TestTime; |
364 ap.Time:= TestTime; |
308 ap.ExplR:= 300; |
365 ap.ExplR:= 300; |
309 ap.ExplX:= EX; |
366 ap.ExplX:= EX; |
310 ap.ExplY:= EY; |
367 ap.ExplY:= EY; |
311 valueResult:= Score |
368 valueResult:= Score |