21 uses SDLh, uGears, uConsts, uFloat; |
21 uses SDLh, uGears, uConsts, uFloat; |
22 |
22 |
23 function TestBazooka(Me: PGear; Targ: TPoint; Level: LongInt; var Time: Longword; var Angle, Power: LongInt; var ExplX, ExplY, ExplR: LongInt): LongInt; |
23 function TestBazooka(Me: PGear; Targ: TPoint; Level: LongInt; var Time: Longword; var Angle, Power: LongInt; var ExplX, ExplY, ExplR: LongInt): LongInt; |
24 function TestGrenade(Me: PGear; Targ: TPoint; Level: LongInt; var Time: Longword; var Angle, Power: LongInt; var ExplX, ExplY, ExplR: LongInt): LongInt; |
24 function TestGrenade(Me: PGear; Targ: TPoint; Level: LongInt; var Time: Longword; var Angle, Power: LongInt; var ExplX, ExplY, ExplR: LongInt): LongInt; |
25 function TestShotgun(Me: PGear; Targ: TPoint; Level: LongInt; var Time: Longword; var Angle, Power: LongInt; var ExplX, ExplY, ExplR: LongInt): LongInt; |
25 function TestShotgun(Me: PGear; Targ: TPoint; Level: LongInt; var Time: Longword; var Angle, Power: LongInt; var ExplX, ExplY, ExplR: LongInt): LongInt; |
26 (*function TestDesertEagle(Me: PGear; Targ: TPoint; Level: LongInt; var Time: Longword; var Angle, Power: LongInt; var ExplX, ExplY, ExplR: LongInt): LongInt; |
26 function TestDesertEagle(Me: PGear; Targ: TPoint; Level: LongInt; var Time: Longword; var Angle, Power: LongInt; var ExplX, ExplY, ExplR: LongInt): LongInt; |
27 *) |
|
28 function TestBaseballBat(Me: PGear; Targ: TPoint; Level: LongInt; var Time: Longword; var Angle, Power: LongInt; var ExplX, ExplY, ExplR: LongInt): LongInt; |
27 function TestBaseballBat(Me: PGear; Targ: TPoint; Level: LongInt; var Time: Longword; var Angle, Power: LongInt; var ExplX, ExplY, ExplR: LongInt): LongInt; |
29 function TestFirePunch(Me: PGear; Targ: TPoint; Level: LongInt; var Time: Longword; var Angle, Power: LongInt; var ExplX, ExplY, ExplR: LongInt): LongInt; |
28 function TestFirePunch(Me: PGear; Targ: TPoint; Level: LongInt; var Time: Longword; var Angle, Power: LongInt; var ExplX, ExplY, ExplR: LongInt): LongInt; |
30 |
29 |
31 type TAmmoTestProc = function (Me: PGear; Targ: TPoint; Level: LongInt; var Time: Longword; var Angle, Power: LongInt; var ExplX, ExplY, ExplR: LongInt): LongInt; |
30 type TAmmoTestProc = function (Me: PGear; Targ: TPoint; Level: LongInt; var Time: Longword; var Angle, Power: LongInt; var ExplX, ExplY, ExplR: LongInt): LongInt; |
32 const AmmoTests: array[TAmmoType] of TAmmoTestProc = |
31 const AmmoTests: array[TAmmoType] of TAmmoTestProc = |
33 ( |
32 ( |
34 {amGrenade} @TestGrenade, |
33 {amGrenade} @TestGrenade, |
35 {amClusterBomb} nil, |
34 {amClusterBomb} nil, |
36 {amBazooka} @TestBazooka, |
35 {amBazooka} @TestBazooka, |
37 {amUFO} nil, |
36 {amUFO} nil, |
38 {amShotgun} nil,//@TestShotgun, |
37 {amShotgun} @TestShotgun, |
39 {amPickHammer} nil, |
38 {amPickHammer} nil, |
40 {amSkip} nil, |
39 {amSkip} nil, |
41 {amRope} nil, |
40 {amRope} nil, |
42 {amMine} nil, |
41 {amMine} nil, |
43 {amDEagle} nil,//TestDesertEagle, |
42 {amDEagle} @TestDesertEagle, |
44 {amDynamite} nil, |
43 {amDynamite} nil, |
45 {amFirePunch} @TestFirePunch, |
44 {amFirePunch} @TestFirePunch, |
46 {amBaseballBat} @TestBaseballBat, |
45 {amBaseballBat} @TestBaseballBat, |
47 {amParachute} nil, |
46 {amParachute} nil, |
48 {amAirAttack} nil, |
47 {amAirAttack} nil, |
202 exit(Result) |
201 exit(Result) |
203 end |
202 end |
204 until (hwAbs(Targ.X - x) + hwAbs(Targ.Y - y) < 4) or (x < 0) or (y < 0) or (x > 2048) or (y > 1024); |
203 until (hwAbs(Targ.X - x) + hwAbs(Targ.Y - y) < 4) or (x < 0) or (y < 0) or (x > 2048) or (y > 1024); |
205 TestShotgun:= BadTurn |
204 TestShotgun:= BadTurn |
206 end; |
205 end; |
207 { |
206 |
208 function TestDesertEagle(Me: PGear; Targ: TPoint; Level: LongInt; var Time: Longword; var Angle, Power: LongInt; var ExplX, ExplY, ExplR: LongInt): LongInt; |
207 function TestDesertEagle(Me: PGear; Targ: TPoint; Level: LongInt; var Time: Longword; var Angle, Power: LongInt; var ExplX, ExplY, ExplR: LongInt): LongInt; |
209 var Vx, Vy, x, y, t: hwFloat; |
208 var Vx, Vy, x, y, t: hwFloat; |
210 d: Longword; |
209 d: Longword; |
211 begin |
210 Result: LongInt; |
212 ExplR:= 0; |
211 begin |
213 if abs(Me.X - Targ.X) + abs(Me.Y - Targ.Y) < 80 then |
212 ExplR:= 0; |
|
213 if hwAbs(Me^.X - Targ.X) + hwAbs(Me^.Y - Targ.Y) < 80 then |
214 begin |
214 begin |
215 Result:= BadTurn; |
215 Result:= BadTurn; |
216 exit |
216 exit |
217 end; |
217 end; |
218 Time:= 0; |
218 Time:= 0; |
219 Power:= 1; |
219 Power:= 1; |
220 t:= sqrt(sqr(Targ.X - Me.X) + sqr(Targ.Y - Me.Y)) * 2; |
220 t:= _0_5 / Distance(Targ.X - Me^.X, Targ.Y - Me^.Y); |
221 Vx:= (Targ.X - Me.X) / t; |
221 Vx:= (Targ.X - Me^.X) * t; |
222 Vy:= (Targ.Y - Me.Y) / t; |
222 Vy:= (Targ.Y - Me^.Y) * t; |
223 x:= Me.X; |
223 x:= Me^.X; |
224 y:= Me.Y; |
224 y:= Me^.Y; |
225 Angle:= DxDy2AttackAngle(Vx, -Vy); |
225 Angle:= DxDy2AttackAngle(Vx, -Vy); |
226 d:= 0; |
226 d:= 0; |
227 repeat |
227 repeat |
228 x:= x + vX; |
228 x:= x + vX; |
229 y:= y + vY; |
229 y:= y + vY; |
230 if ((round(x) and $FFFFF800) = 0)and((round(y) and $FFFFFC00) = 0) |
230 if ((hwRound(x) and $FFFFF800) = 0)and((hwRound(y) and $FFFFFC00) = 0) |
231 and (Land[round(y), round(x)] <> 0) then inc(d); |
231 and (Land[hwRound(y), hwRound(x)] <> 0) then inc(d); |
232 until (abs(Targ.X - x) + abs(Targ.Y - y) < 2) or (x < 0) or (y < 0) or (x > 2048) or (y > 1024) or (d > 200); |
232 until (hwAbs(Targ.X - x) + hwAbs(Targ.Y - y) < 4) or (x < 0) or (y < 0) or (x > 2048) or (y > 1024) or (d > 200); |
233 if abs(Targ.X - x) + abs(Targ.Y - y) < 2 then Result:= max(0, (4 - d div 50) * 7 * 1024) |
233 if hwAbs(Targ.X - x) + hwAbs(Targ.Y - y) < 2 then Result:= max(0, (4 - d div 50) * 7 * 1024) |
234 else Result:= Low(LongInt) |
234 else Result:= Low(LongInt); |
235 end; |
235 TestDesertEagle:= Result |
236 } |
236 end; |
|
237 |
237 function TestBaseballBat(Me: PGear; Targ: TPoint; Level: LongInt; var Time: Longword; var Angle, Power: LongInt; var ExplX, ExplY, ExplR: LongInt): LongInt; |
238 function TestBaseballBat(Me: PGear; Targ: TPoint; Level: LongInt; var Time: Longword; var Angle, Power: LongInt; var ExplX, ExplY, ExplR: LongInt): LongInt; |
238 var Result: LongInt; |
239 var Result: LongInt; |
239 begin |
240 begin |
240 ExplR:= 0; |
241 ExplR:= 0; |
241 if (Level > 2) and not (hwAbs(Me^.X - Targ.X) + hwAbs(Me^.Y - Targ.Y) < 25) then |
242 if (Level > 2) and not (hwAbs(Me^.X - Targ.X) + hwAbs(Me^.Y - Targ.Y) < 25) then |