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 TestClusterBomb(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
35 function TestWatermelon(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
36 function TestWatermelon(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
36 function TestMortar(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
37 function TestMortar(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
37 function TestShotgun(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
38 function TestShotgun(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
38 function TestDesertEagle(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
39 function TestDesertEagle(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
39 function TestBaseballBat(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
40 function TestBaseballBat(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
48 |
49 |
49 const AmmoTests: array[TAmmoType] of TAmmoTest = |
50 const AmmoTests: array[TAmmoType] of TAmmoTest = |
50 ( |
51 ( |
51 (proc: nil; flags: 0), // amNothing |
52 (proc: nil; flags: 0), // amNothing |
52 (proc: @TestGrenade; flags: 0), // amGrenade |
53 (proc: @TestGrenade; flags: 0), // amGrenade |
53 (proc: nil; flags: 0), // amClusterBomb |
54 (proc: @TestClusterBomb; flags: 0), // amClusterBomb |
54 (proc: @TestBazooka; flags: 0), // amBazooka |
55 (proc: @TestBazooka; flags: 0), // amBazooka |
55 (proc: nil; flags: 0), // amUFO |
56 (proc: nil; flags: 0), // amUFO |
56 (proc: @TestShotgun; flags: 0), // amShotgun |
57 (proc: @TestShotgun; flags: 0), // amShotgun |
57 (proc: nil; flags: 0), // amPickHammer |
58 (proc: nil; flags: 0), // amPickHammer |
58 (proc: nil; flags: 0), // amSkip |
59 (proc: nil; flags: 0), // amSkip |
208 end |
209 end |
209 until (TestTime = 4000); |
210 until (TestTime = 4000); |
210 TestGrenade:= valueResult |
211 TestGrenade:= valueResult |
211 end; |
212 end; |
212 |
213 |
|
214 function TestClusterBomb(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
|
215 const tDelta = 24; |
|
216 var Vx, Vy, r: hwFloat; |
|
217 Score, EX, EY, valueResult: LongInt; |
|
218 TestTime: Longword; |
|
219 |
|
220 function CheckTrace: LongInt; |
|
221 var x, y, dY: hwFloat; |
|
222 t: LongInt; |
|
223 begin |
|
224 x:= Me^.X; |
|
225 y:= Me^.Y; |
|
226 dY:= -Vy; |
|
227 t:= TestTime; |
|
228 repeat |
|
229 x:= x + Vx; |
|
230 y:= y + dY; |
|
231 dY:= dY + cGravity; |
|
232 dec(t) |
|
233 until TestCollExcludingMe(Me, hwRound(x), hwRound(y), 5) or (t = 0); |
|
234 EX:= hwRound(x); |
|
235 EY:= hwRound(y); |
|
236 if t < 50 then CheckTrace:= RateExplosion(Me, EX, EY, 91) |
|
237 else CheckTrace:= BadTurn |
|
238 end; |
|
239 begin |
|
240 valueResult:= BadTurn; |
|
241 TestTime:= 0; |
|
242 ap.ExplR:= 0; |
|
243 repeat |
|
244 inc(TestTime, 1000); |
|
245 Vx:= (int2hwFloat(Targ.X) - Me^.X) / int2hwFloat(TestTime + tDelta); |
|
246 Vy:= cGravity * ((TestTime + tDelta) div 2) - (int2hwFloat(Targ.Y) - Me^.Y) / int2hwFloat(TestTime + tDelta); |
|
247 r:= Distance(Vx, Vy); |
|
248 if not (r > _1) then |
|
249 begin |
|
250 Score:= CheckTrace; |
|
251 if valueResult < Score then |
|
252 begin |
|
253 ap.Angle:= DxDy2AttackAngle(Vx, Vy) + AIrndSign(random(Level)); |
|
254 ap.Power:= hwRound(r * cMaxPower) + AIrndSign(random(Level) * 15)+10; |
|
255 ap.Time:= TestTime; |
|
256 ap.ExplR:= 90; |
|
257 ap.ExplX:= EX; |
|
258 ap.ExplY:= EY; |
|
259 valueResult:= Score |
|
260 end; |
|
261 end |
|
262 until (TestTime = 4000); |
|
263 TestClusterBomb:= valueResult |
|
264 end; |
|
265 |
213 function TestWatermelon(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
266 function TestWatermelon(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
214 const tDelta = 24; |
267 const tDelta = 24; |
215 var Vx, Vy, r: hwFloat; |
268 var Vx, Vy, r: hwFloat; |
216 Score, EX, EY, valueResult: LongInt; |
269 Score, EX, EY, valueResult: LongInt; |
217 TestTime: Longword; |
270 TestTime: Longword; |