equal
deleted
inserted
replaced
39 ctfBreach = $00000002; |
39 ctfBreach = $00000002; |
40 |
40 |
41 function TestGrenade(Me, Targ: TPoint; Flags: Longword; out Time: Longword; out Angle, Power: integer): boolean; |
41 function TestGrenade(Me, Targ: TPoint; Flags: Longword; out Time: Longword; out Angle, Power: integer): boolean; |
42 function TestBazooka(Me, Targ: TPoint; Flags: Longword; out Time: Longword; out Angle, Power: integer): boolean; |
42 function TestBazooka(Me, Targ: TPoint; Flags: Longword; out Time: Longword; out Angle, Power: integer): boolean; |
43 function TestShotgun(Me, Targ: TPoint; Flags: Longword; out Time: Longword; out Angle, Power: integer): boolean; |
43 function TestShotgun(Me, Targ: TPoint; Flags: Longword; out Time: Longword; out Angle, Power: integer): boolean; |
|
44 function TestDEagle(Me, Targ: TPoint; Flags: Longword; out Time: Longword; out Angle, Power: integer): boolean; |
44 |
45 |
45 type TAmmoTestProc = function (Me, Targ: TPoint; Flags: Longword; out Time: Longword; out Angle, Power: integer): boolean; |
46 type TAmmoTestProc = function (Me, Targ: TPoint; Flags: Longword; out Time: Longword; out Angle, Power: integer): boolean; |
46 const AmmoTests: array[TAmmoType] of |
47 const AmmoTests: array[TAmmoType] of |
47 record |
48 record |
48 Test: TAmmoTestProc; |
49 Test: TAmmoTestProc; |
70 Flags: 0; |
71 Flags: 0; |
71 ), |
72 ), |
72 ( Test: nil; |
73 ( Test: nil; |
73 Flags: 0; |
74 Flags: 0; |
74 ), |
75 ), |
|
76 ( Test: TestDEagle; |
|
77 Flags: 0; |
|
78 ), |
75 ( Test: nil; |
79 ( Test: nil; |
76 Flags: 0; |
80 Flags: 0; |
77 ) |
81 ) |
78 ); |
82 ); |
79 |
83 |
80 implementation |
84 implementation |
81 uses uMisc, uAIMisc; |
85 uses uMisc, uAIMisc, uLand; |
82 |
86 |
83 function TestGrenade(Me, Targ: TPoint; Flags: Longword; out Time: Longword; out Angle, Power: integer): boolean; |
87 function TestGrenade(Me, Targ: TPoint; Flags: Longword; out Time: Longword; out Angle, Power: integer): boolean; |
84 var Vx, Vy, r: real; |
88 var Vx, Vy, r: real; |
85 flHasTrace: boolean; |
89 flHasTrace: boolean; |
86 |
90 |
196 end |
200 end |
197 until (abs(Targ.X - x) + abs(Targ.Y - y) < 4) or (x < 0) or (y < 0) or (x > 2048) or (y > 1024); |
201 until (abs(Targ.X - x) + abs(Targ.Y - y) < 4) or (x < 0) or (y < 0) or (x > 2048) or (y > 1024); |
198 Result:= true |
202 Result:= true |
199 end; |
203 end; |
200 |
204 |
|
205 function TestDEagle(Me, Targ: TPoint; Flags: Longword; out Time: Longword; out Angle, Power: integer): boolean; |
|
206 var Vx, Vy, x, y: real; |
|
207 d: Longword; |
|
208 begin |
|
209 Time:= 0; |
|
210 Power:= 1; |
|
211 Vx:= (Targ.X - Me.X)/1024; |
|
212 Vy:= (Targ.Y - Me.Y)/1024; |
|
213 x:= Me.X; |
|
214 y:= Me.Y; |
|
215 Angle:= DxDy2Angle(Vx, -Vy); |
|
216 d:= 0; |
|
217 repeat |
|
218 x:= x + vX; |
|
219 y:= y + vY; |
|
220 if ((round(x) and $FFFFF800) = 0)and((round(y) and $FFFFFC00) = 0) |
|
221 and (Land[round(y), round(x)] <> 0) then inc(d); |
|
222 until (abs(Targ.X - x) + abs(Targ.Y - y) < 2) or (x < 0) or (y < 0) or (x > 2048) or (y > 1024); |
|
223 Result:= d < 50 |
|
224 end; |
201 |
225 |
202 end. |
226 end. |