38 function TestBazooka(Me: PGear; Targ: TPoint; out Time: Longword; out Angle, Power: integer; out ExplX, ExplY, ExplR: integer): integer; |
38 function TestBazooka(Me: PGear; Targ: TPoint; out Time: Longword; out Angle, Power: integer; out ExplX, ExplY, ExplR: integer): integer; |
39 function TestGrenade(Me: PGear; Targ: TPoint; out Time: Longword; out Angle, Power: integer; out ExplX, ExplY, ExplR: integer): integer; |
39 function TestGrenade(Me: PGear; Targ: TPoint; out Time: Longword; out Angle, Power: integer; out ExplX, ExplY, ExplR: integer): integer; |
40 function TestShotgun(Me: PGear; Targ: TPoint; out Time: Longword; out Angle, Power: integer; out ExplX, ExplY, ExplR: integer): integer; |
40 function TestShotgun(Me: PGear; Targ: TPoint; out Time: Longword; out Angle, Power: integer; out ExplX, ExplY, ExplR: integer): integer; |
41 function TestDesertEagle(Me: PGear; Targ: TPoint; out Time: Longword; out Angle, Power: integer; out ExplX, ExplY, ExplR: integer): integer; |
41 function TestDesertEagle(Me: PGear; Targ: TPoint; out Time: Longword; out Angle, Power: integer; out ExplX, ExplY, ExplR: integer): integer; |
42 function TestBaseballBat(Me: PGear; Targ: TPoint; out Time: Longword; out Angle, Power: integer; out ExplX, ExplY, ExplR: integer): integer; |
42 function TestBaseballBat(Me: PGear; Targ: TPoint; out Time: Longword; out Angle, Power: integer; out ExplX, ExplY, ExplR: integer): integer; |
|
43 function TestFirePunch(Me: PGear; Targ: TPoint; out Time: Longword; out Angle, Power: integer; out ExplX, ExplY, ExplR: integer): integer; |
43 |
44 |
44 type TAmmoTestProc = function (Me: PGear; Targ: TPoint; out Time: Longword; out Angle, Power: integer; out ExplX, ExplY, ExplR: integer): integer; |
45 type TAmmoTestProc = function (Me: PGear; Targ: TPoint; out Time: Longword; out Angle, Power: integer; out ExplX, ExplY, ExplR: integer): integer; |
45 const AmmoTests: array[TAmmoType] of TAmmoTestProc = |
46 const AmmoTests: array[TAmmoType] of TAmmoTestProc = |
46 ( |
47 ( |
47 {amGrenade} TestGrenade, |
48 {amGrenade} TestGrenade, |
53 {amSkip} nil, |
54 {amSkip} nil, |
54 {amRope} nil, |
55 {amRope} nil, |
55 {amMine} nil, |
56 {amMine} nil, |
56 {amDEagle} TestDesertEagle, |
57 {amDEagle} TestDesertEagle, |
57 {amDynamite} nil, |
58 {amDynamite} nil, |
58 {amBaseballBat} TestBaseballBat |
59 {amBaseballBat} TestBaseballBat, |
|
60 {amFirePunch} TestFirePunch |
59 ); |
61 ); |
60 |
62 |
61 implementation |
63 implementation |
62 uses uMisc, uAIMisc, uLand; |
64 uses uMisc, uAIMisc, uLand; |
63 const BadTurn = Low(integer); |
65 const BadTurn = Low(integer); |
94 if Result = 0 then Result:= - Metric(Targ.X, Targ.Y, round(x), round(y)) div 64 |
96 if Result = 0 then Result:= - Metric(Targ.X, Targ.Y, round(x), round(y)) div 64 |
95 end; |
97 end; |
96 |
98 |
97 begin |
99 begin |
98 Time:= 0; |
100 Time:= 0; |
99 rTime:= 10; |
101 rTime:= 50; |
100 ExplR:= 0; |
102 ExplR:= 0; |
101 Result:= BadTurn; |
103 Result:= BadTurn; |
102 repeat |
104 repeat |
103 rTime:= rTime + 100 + random*250; |
105 rTime:= rTime + 150 + random*250; |
104 Vx:= - cWindSpeed * rTime / 2 + (Targ.X - Me.X) / rTime; |
106 Vx:= - cWindSpeed * rTime / 2 + (Targ.X - Me.X) / rTime; |
105 Vy:= cGravity * rTime / 2 - (Targ.Y - Me.Y) / rTime; |
107 Vy:= cGravity * rTime / 2 - (Targ.Y - Me.Y) / rTime; |
106 r:= sqr(Vx) + sqr(Vy); |
108 r:= sqr(Vx) + sqr(Vy); |
107 if r <= 1 then |
109 if r <= 1 then |
108 begin |
110 begin |
244 Power:= 1; |
246 Power:= 1; |
245 Angle:= DxDy2AttackAngle(Sign(Targ.X - Me.X), 1); |
247 Angle:= DxDy2AttackAngle(Sign(Targ.X - Me.X), 1); |
246 Result:= RateShove(Me, round(Me.X) + 10 * Sign(Targ.X - Me.X), round(Me.Y), 15, 30) |
248 Result:= RateShove(Me, round(Me.X) + 10 * Sign(Targ.X - Me.X), round(Me.Y), 15, 30) |
247 end; |
249 end; |
248 |
250 |
|
251 function TestFirePunch(Me: PGear; Targ: TPoint; out Time: Longword; out Angle, Power: integer; out ExplX, ExplY, ExplR: integer): integer; |
|
252 var i: integer; |
|
253 begin |
|
254 ExplR:= 0; |
|
255 if (abs(Me.X - Targ.X) > 25) or (abs(Me.Y - 50 - Targ.Y) > 50) then |
|
256 begin |
|
257 Result:= BadTurn; |
|
258 exit |
|
259 end; |
|
260 Time:= 0; |
|
261 Power:= 1; |
|
262 Angle:= DxDy2AttackAngle(Sign(Targ.X - Me.X), 1); |
|
263 Result:= 0; |
|
264 for i:= 0 to 4 do |
|
265 Result:= Result + RateShove(Me, round(Me.X) + 10 * Sign(Targ.X - Me.X), round(Me.Y) - 20 * i - 5, 10, 30) |
|
266 end; |
|
267 |
249 end. |
268 end. |