196 function calcBeeFlight(Me: PGear; x, y, dx, dy, tX, tY: real; var eX, eY: LongInt): LongInt; |
196 function calcBeeFlight(Me: PGear; x, y, dx, dy, tX, tY: real; var eX, eY: LongInt): LongInt; |
197 var t: Longword; |
197 var t: Longword; |
198 f: boolean; |
198 f: boolean; |
199 speed, d: real; |
199 speed, d: real; |
200 begin |
200 begin |
201 addfilelog('002'); |
|
202 |
|
203 speed:= sqrt(sqr(dx) + sqr(dy)); |
|
204 // parabola flight before activation |
201 // parabola flight before activation |
205 t:= 500; |
202 t:= 500; |
206 repeat |
203 repeat |
207 x:= x + dx; |
204 x:= x + dx; |
208 y:= y + dy; |
205 y:= y + dy; |
216 begin |
213 begin |
217 eX:= trunc(x); |
214 eX:= trunc(x); |
218 eY:= trunc(y); |
215 eY:= trunc(y); |
219 exit(RateExplosion(Me, eX, eY, 101, afTrackFall or afErasesLand)); |
216 exit(RateExplosion(Me, eX, eY, 101, afTrackFall or afErasesLand)); |
220 end; |
217 end; |
221 |
218 |
|
219 |
222 // activated |
220 // activated |
223 t:= 5000; |
221 t:= 5000; |
224 |
222 speed:= sqrt(sqr(dx) + sqr(dy)); |
|
223 |
225 repeat |
224 repeat |
226 if (t and $F) = 0 then |
225 if (t and $F) = 0 then |
227 begin |
226 begin |
228 dx:= 0.9 * (dx + 0.000064 * (tX - x)); |
227 dx:= dx + 0.000064 * (tX - x); |
229 dy:= 0.9 * (dy + 0.000064 * (tY - y)); |
228 dy:= dy + 0.000064 * (tY - y); |
230 d := speed / sqrt(sqr(dx) + sqr(dy)); |
229 d := speed / sqrt(sqr(dx) + sqr(dy)); |
231 dx:= dx * d; |
230 dx:= dx * d; |
232 dy:= dy * d; |
231 dy:= dy * d; |
233 end; |
232 end; |
234 |
233 |
235 x:= x + dx; |
234 x:= x + dx; |
236 y:= y + dy; |
235 y:= y + dy; |
237 f:= ((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 5)) or |
236 f:= ((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 5)) or |
238 ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me^.Hedgehog^.Gear, trunc(x), trunc(y), 5)); |
237 ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me^.Hedgehog^.Gear, trunc(x), trunc(y), 5)); |
249 calcBeeFlight:= BadTurn |
248 calcBeeFlight:= BadTurn |
250 end; |
249 end; |
251 |
250 |
252 function TestBee(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt; |
251 function TestBee(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt; |
253 var i, j: LongInt; |
252 var i, j: LongInt; |
254 valueResult, v: LongInt; |
253 valueResult, v, a, p: LongInt; |
255 mX, mY, dX: real; |
254 mX, mY, dX: real; |
256 eX, eY: LongInt; |
255 eX, eY: LongInt; |
257 begin |
256 begin |
258 if Level > 1 then |
257 if Level > 1 then |
259 exit(BadTurn); |
258 exit(BadTurn); |
260 addfilelog('001'); |
259 |
261 eX:= 0; |
260 eX:= 0; |
262 eY:= 0; |
261 eY:= 0; |
263 mX:= hwFloat2Float(Me^.X); |
262 mX:= hwFloat2Float(Me^.X); |
264 mY:= hwFloat2Float(Me^.Y); |
263 mY:= hwFloat2Float(Me^.Y); |
265 valueResult:= BadTurn; |
264 valueResult:= BadTurn; |
266 for i:= 0 to 8 do |
265 for i:= 0 to 8 do |
267 for j:= 0 to 1 do |
266 for j:= 0 to 1 do |
268 begin |
267 begin |
269 ap.Angle:= i * 120; |
268 a:= i * 120; |
270 ap.Power:= random(1700) + 300; |
269 p:= random(cMaxPower - 200) + 180; |
271 dx:= sin(ap.Angle / 2048); |
270 |
272 if j = 0 then |
271 if j = 0 then |
273 begin |
272 a:= -a; |
274 ap.Angle:= -ap.Angle; |
273 |
275 dx:= -dx; |
|
276 end; |
|
277 |
|
278 v:= calcBeeFlight(Me |
274 v:= calcBeeFlight(Me |
279 , mX |
275 , mX |
280 , mY |
276 , mY |
281 , sin(ap.Angle / 2048) * ap.Power / cMaxPower |
277 , sin(a * pi / 2048) * p / cPowerDivisor |
282 , cos(ap.Angle / 2048) * ap.Power / cMaxPower |
278 , -cos(a * pi / 2048) * p / cPowerDivisor |
283 , Targ.Point.X |
279 , Targ.Point.X |
284 , Targ.Point.Y |
280 , Targ.Point.Y |
285 , eX |
281 , eX |
286 , eY); |
282 , eY); |
287 |
283 |
288 if v > valueResult then |
284 if v > valueResult then |
289 begin |
285 begin |
290 ap.ExplR:= 100; |
286 ap.ExplR:= 100; |
291 ap.ExplX:= eX; |
287 ap.ExplX:= eX; |
292 ap.ExplY:= eY; |
288 ap.ExplY:= eY; |
|
289 ap.Angle:= a; |
|
290 ap.Power:= p; |
293 valueResult:= v |
291 valueResult:= v |
294 end |
292 end |
295 end; |
293 end; |
296 |
294 |
297 ap.AttackPutX:= Targ.Point.X; |
295 ap.AttackPutX:= Targ.Point.X; |
298 ap.AttackPutY:= Targ.Point.Y; |
296 ap.AttackPutY:= Targ.Point.Y; |
299 |
297 |
300 TestBee:= valueResult |
298 if valueResult > 0 then |
|
299 TestBee:= valueResult - 5000 |
|
300 else |
|
301 TestBee:= BadTurn // no digging |
301 end; |
302 end; |
302 |
303 |
303 function TestDrillRocket(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt; |
304 function TestDrillRocket(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt; |
304 var Vx, Vy, r, mX, mY: real; |
305 var Vx, Vy, r, mX, mY: real; |
305 rTime: LongInt; |
306 rTime: LongInt; |