222 dX:= dX + windSpeed; |
226 dX:= dX + windSpeed; |
223 dY:= dY + cGravityf; |
227 dY:= dY + cGravityf; |
224 dec(t) |
228 dec(t) |
225 until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 5)) or |
229 until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 5)) or |
226 ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me, trunc(x), trunc(y), 5))) or (y > cWaterLine); |
230 ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me, trunc(x), trunc(y), 5))) or (y > cWaterLine); |
227 |
231 |
|
232 if TestCollWithLand(trunc(x), trunc(y), 5) and (Abs(Targ.X - trunc(x)) + Abs(Targ.Y - trunc(y)) > 21) then |
|
233 begin |
|
234 timer := 500; |
|
235 t2 := 0.5 / sqrt(sqr(dX) + sqr(dY)); |
|
236 dX := dX * t2; |
|
237 dY := dY * t2; |
|
238 repeat |
|
239 x:= x + dX; |
|
240 y:= y + dY; |
|
241 dec(timer); |
|
242 until (Abs(Targ.X - trunc(x)) + Abs(Targ.Y - trunc(y)) < 22) |
|
243 or (x < 0) |
|
244 or (y < 0) |
|
245 or (trunc(x) > LAND_WIDTH) |
|
246 or (trunc(y) > LAND_HEIGHT) |
|
247 or not TestCollWithLand(trunc(x), trunc(y), 5) |
|
248 or (timer = 0) |
|
249 end; |
228 EX:= trunc(x); |
250 EX:= trunc(x); |
229 EY:= trunc(y); |
251 EY:= trunc(y); |
|
252 // Try to prevent AI from thinking firing into water will cause a drowning |
|
253 if (EY < cWaterLine-5) and (Timer > 0) and (Abs(Targ.X - trunc(x)) + Abs(Targ.Y - trunc(y)) > 21) then exit(BadTurn); |
230 if Level = 1 then |
254 if Level = 1 then |
231 value:= RateExplosion(Me, EX, EY, 101, afTrackFall or afErasesLand) |
255 value:= RateExplosion(Me, EX, EY, 101, afTrackFall or afErasesLand) |
232 else value:= RateExplosion(Me, EX, EY, 101); |
256 else value:= RateExplosion(Me, EX, EY, 101); |
233 if value = 0 then |
|
234 value:= 1024 - Metric(Targ.X, Targ.Y, EX, EY) div 64; |
|
235 if valueResult <= value then |
257 if valueResult <= value then |
236 begin |
258 begin |
237 ap.Angle:= DxDy2AttackAnglef(Vx, Vy) + AIrndSign(random((Level - 1) * 9)); |
259 ap.Angle:= DxDy2AttackAnglef(Vx, Vy) + AIrndSign(random((Level - 1) * 9)); |
238 ap.Power:= trunc(sqrt(r) * cMaxPower) - random((Level - 1) * 17 + 1); |
260 ap.Power:= trunc(sqrt(r) * cMaxPower) - random((Level - 1) * 17 + 1); |
239 ap.ExplR:= 100; |
261 ap.ExplR:= 100; |
240 ap.ExplX:= EX; |
262 ap.ExplX:= EX; |
241 ap.ExplY:= EY; |
263 ap.ExplY:= EY; |
242 valueResult:= value |
264 valueResult:= value-2500 // trying to make it slightly less attractive than a bazooka, to prevent waste. AI could use awareness of weapon count |
243 end; |
265 end; |
244 end |
266 end |
245 until rTime > 4250; |
267 until rTime > 4250; |
246 TestDrillRocket:= valueResult |
268 TestDrillRocket:= valueResult |
247 end; |
269 end; |