20 interface |
20 interface |
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 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; |
28 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; |
29 *) |
29 *) |
30 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; |
31 const AmmoTests: array[TAmmoType] of TAmmoTestProc = |
31 const AmmoTests: array[TAmmoType] of TAmmoTestProc = |
32 ( |
32 ( |
33 {amGrenade} @TestGrenade, |
33 {amGrenade} @TestGrenade, |
34 {amClusterBomb} nil, |
34 {amClusterBomb} nil, |
35 {amBazooka} @TestBazooka, |
35 {amBazooka} @TestBazooka, |
36 {amUFO} nil, |
36 {amUFO} nil, |
37 {amShotgun} nil,//TestShotgun, |
37 {amShotgun} @TestShotgun, |
38 {amPickHammer} nil, |
38 {amPickHammer} nil, |
39 {amSkip} nil, |
39 {amSkip} nil, |
40 {amRope} nil, |
40 {amRope} nil, |
41 {amMine} nil, |
41 {amMine} nil, |
42 {amDEagle} nil,//TestDesertEagle, |
42 {amDEagle} nil,//TestDesertEagle, |
167 end; |
167 end; |
168 end |
168 end |
169 until (TestTime = 5000); |
169 until (TestTime = 5000); |
170 TestGrenade:= Result |
170 TestGrenade:= Result |
171 end; |
171 end; |
172 { |
172 |
173 function TestShotgun(Me: PGear; Targ: TPoint; Level: LongInt; var Time: Longword; var Angle, Power: LongInt; var ExplX, ExplY, ExplR: LongInt): LongInt; |
173 function TestShotgun(Me: PGear; Targ: TPoint; Level: LongInt; var Time: Longword; var Angle, Power: LongInt; var ExplX, ExplY, ExplR: LongInt): LongInt; |
174 var Vx, Vy, x, y: hwFloat; |
174 var Vx, Vy, x, y: hwFloat; |
175 begin |
175 rx, ry, Result: LongInt; |
176 ExplR:= 0; |
176 begin |
177 if Metric(round(Me.X), round(Me.Y), Targ.X, Targ.Y) < 80 then |
177 ExplR:= 0; |
178 begin |
178 if Metric(hwRound(Me^.X), hwRound(Me^.Y), Targ.X, Targ.Y) < 80 then |
179 Result:= BadTurn; |
179 begin |
180 exit |
180 Result:= BadTurn; |
181 end; |
181 exit |
182 Time:= 0; |
182 end; |
183 Power:= 1; |
183 Time:= 0; |
184 Vx:= (Targ.X - Me.X)/1024; |
184 Power:= 1; |
185 Vy:= (Targ.Y - Me.Y)/1024; |
185 Vx:= (Targ.X - Me^.X) * _1div1024; |
186 x:= Me.X; |
186 Vy:= (Targ.Y - Me^.Y) * _1div1024; |
187 y:= Me.Y; |
187 x:= Me^.X; |
|
188 y:= Me^.Y; |
188 Angle:= DxDy2AttackAngle(Vx, -Vy); |
189 Angle:= DxDy2AttackAngle(Vx, -Vy); |
189 repeat |
190 repeat |
190 x:= x + vX; |
191 x:= x + vX; |
191 y:= y + vY; |
192 y:= y + vY; |
192 if TestColl(round(x), round(y), 2) then |
193 rx:= hwRound(x); |
|
194 ry:= hwRound(y); |
|
195 if TestColl(rx, ry, 2) then |
193 begin |
196 begin |
194 Result:= RateShove(Me, round(x), round(y), 25, 25) * 2; |
197 Result:= RateShove(Me, rx, ry, 25, 25) * 2; |
195 if Result = 0 then Result:= - Metric(Targ.X, Targ.Y, round(x), round(y)) div 64 |
198 if Result = 0 then Result:= - Metric(Targ.X, Targ.Y, rx, ry) div 64 |
196 else dec(Result, Level * 4000); |
199 else dec(Result, Level * 4000); |
197 exit |
200 exit(Result) |
198 end |
201 end |
199 until (abs(Targ.X - x) + abs(Targ.Y - y) < 4) or (x < 0) or (y < 0) or (x > 2048) or (y > 1024); |
202 until (hwAbs(Targ.X - x) + hwAbs(Targ.Y - y) < 4) or (x < 0) or (y < 0) or (x > 2048) or (y > 1024); |
200 Result:= BadTurn |
203 TestShotgun:= BadTurn |
201 end; |
204 end; |
202 |
205 { |
203 function TestDesertEagle(Me: PGear; Targ: TPoint; Level: LongInt; var Time: Longword; var Angle, Power: LongInt; var ExplX, ExplY, ExplR: LongInt): LongInt; |
206 function TestDesertEagle(Me: PGear; Targ: TPoint; Level: LongInt; var Time: Longword; var Angle, Power: LongInt; var ExplX, ExplY, ExplR: LongInt): LongInt; |
204 var Vx, Vy, x, y, t: hwFloat; |
207 var Vx, Vy, x, y, t: hwFloat; |
205 d: Longword; |
208 d: Longword; |
206 begin |
209 begin |
207 ExplR:= 0; |
210 ExplR:= 0; |