74 procedure AddBonus(x, y: LongInt; r: Longword; s: LongInt); inline; |
74 procedure AddBonus(x, y: LongInt; r: Longword; s: LongInt); inline; |
75 procedure FillBonuses(isAfterAttack: boolean); |
75 procedure FillBonuses(isAfterAttack: boolean); |
76 procedure AwareOfExplosion(x, y, r: LongInt); inline; |
76 procedure AwareOfExplosion(x, y, r: LongInt); inline; |
77 |
77 |
78 function RatePlace(Gear: PGear): LongInt; |
78 function RatePlace(Gear: PGear): LongInt; |
|
79 function CheckWrap(x: real): real; inline; |
79 function TestColl(x, y, r: LongInt): boolean; inline; |
80 function TestColl(x, y, r: LongInt): boolean; inline; |
80 function TestCollExcludingObjects(x, y, r: LongInt): boolean; inline; |
81 function TestCollExcludingObjects(x, y, r: LongInt): boolean; inline; |
81 function TestCollExcludingMe(Me: PGear; x, y, r: LongInt): boolean; inline; |
82 function TestCollExcludingMe(Me: PGear; x, y, r: LongInt): boolean; inline; |
82 |
83 |
83 function RateExplosion(Me: PGear; x, y, r: LongInt): LongInt; inline; |
84 function RateExplosion(Me: PGear; x, y, r: LongInt): LongInt; inline; |
328 inc(rate, Score * (Radius - r)) |
329 inc(rate, Score * (Radius - r)) |
329 end; |
330 end; |
330 RatePlace:= rate; |
331 RatePlace:= rate; |
331 end; |
332 end; |
332 |
333 |
|
334 function CheckWrap(x: real): real; inline; |
|
335 begin |
|
336 if WorldEdge = weWrap then |
|
337 if (x < leftX) then |
|
338 x:= x + (rightX - leftX) |
|
339 else if x > rightX then |
|
340 x:= x - (rightX - leftX); |
|
341 CheckWrap:= x; |
|
342 end; |
|
343 |
333 function CheckBounds(x, y, r: Longint): boolean; inline; |
344 function CheckBounds(x, y, r: Longint): boolean; inline; |
334 begin |
345 begin |
335 CheckBounds := (((x-r) and LAND_WIDTH_MASK) = 0) and |
346 CheckBounds := (((x-r) and LAND_WIDTH_MASK) = 0) and |
336 (((x+r) and LAND_WIDTH_MASK) = 0) and |
347 (((x+r) and LAND_WIDTH_MASK) = 0) and |
337 (((y-r) and LAND_HEIGHT_MASK) = 0) and |
348 (((y-r) and LAND_HEIGHT_MASK) = 0) and |
410 skipLandCheck:= true; |
421 skipLandCheck:= true; |
411 // ok. attempt approximate search for an unbroken trajectory into water. if it continues far enough, assume out of map |
422 // ok. attempt approximate search for an unbroken trajectory into water. if it continues far enough, assume out of map |
412 rCorner:= r * 0.75; |
423 rCorner:= r * 0.75; |
413 while true do |
424 while true do |
414 begin |
425 begin |
|
426 x:= CheckWrap(x); |
415 x:= x + dX; |
427 x:= x + dX; |
416 y:= y + dY; |
428 y:= y + dY; |
417 dY:= dY + cGravityf; |
429 dY:= dY + cGravityf; |
418 skipLandCheck:= skipLandCheck and (r <> 0) and (abs(eX-x) + abs(eY-y) < r) and ((abs(eX-x) < rCorner) or (abs(eY-y) < rCorner)); |
430 skipLandCheck:= skipLandCheck and (r <> 0) and (abs(eX-x) + abs(eY-y) < r) and ((abs(eX-x) < rCorner) or (abs(eY-y) < rCorner)); |
419 if not skipLandCheck and TestCollExcludingObjects(trunc(x), trunc(y), Target.Radius) then |
431 if not skipLandCheck and TestCollExcludingObjects(trunc(x), trunc(y), Target.Radius) then |
517 function RealRateExplosion(Me: PGear; x, y, r: LongInt; Flags: LongWord): LongInt; |
530 function RealRateExplosion(Me: PGear; x, y, r: LongInt; Flags: LongWord): LongInt; |
518 var i, fallDmg, dmg, dmgBase, rate, subrate, erasure: LongInt; |
531 var i, fallDmg, dmg, dmgBase, rate, subrate, erasure: LongInt; |
519 pX, pY, dX, dY: real; |
532 pX, pY, dX, dY: real; |
520 hadSkips: boolean; |
533 hadSkips: boolean; |
521 begin |
534 begin |
|
535 x:= round(CheckWrap(real(x))); |
522 fallDmg:= 0; |
536 fallDmg:= 0; |
523 rate:= 0; |
537 rate:= 0; |
524 // add our virtual position |
538 // add our virtual position |
525 with Targets.ar[Targets.Count] do |
539 with Targets.ar[Targets.Count] do |
526 begin |
540 begin |