327 // returning -1 for drowning so it can be considered in the Rate routine |
332 // returning -1 for drowning so it can be considered in the Rate routine |
328 exit(-1) |
333 exit(-1) |
329 end; |
334 end; |
330 end; |
335 end; |
331 |
336 |
332 // Flags are not defined yet but 1 for checking drowning and 2 for assuming land erasure. |
|
333 function RateExplosion(Me: PGear; x, y, r: LongInt): LongInt; |
337 function RateExplosion(Me: PGear; x, y, r: LongInt): LongInt; |
334 begin |
338 begin |
335 RateExplosion:= RateExplosion(Me, x, y, r, 0); |
339 RateExplosion:= RateExplosion(Me, x, y, r, 0); |
336 end; |
340 end; |
337 |
341 |
349 Point.y:= hwRound(Me^.Y); |
353 Point.y:= hwRound(Me^.Y); |
350 Score:= - ThinkingHH^.Health |
354 Score:= - ThinkingHH^.Health |
351 end; |
355 end; |
352 // rate explosion |
356 // rate explosion |
353 dmgBase:= r + cHHRadius div 2; |
357 dmgBase:= r + cHHRadius div 2; |
354 if (Flags and 2 <> 0) and (GameFlags and gfSolidLand = 0) then erasure:= r |
358 if (Flags and afErasesLand <> 0) and (GameFlags and gfSolidLand = 0) then erasure:= r |
355 else erasure:= 0; |
359 else erasure:= 0; |
356 for i:= 0 to Targets.Count do |
360 for i:= 0 to Targets.Count do |
357 with Targets.ar[i] do |
361 with Targets.ar[i] do |
358 begin |
362 begin |
359 dmg:= 0; |
363 dmg:= 0; |
360 if abs(Point.x - x) + abs(Point.y - y) < dmgBase then |
364 if abs(Point.x - x) + abs(Point.y - y) < dmgBase then |
361 dmg:= trunc(dmgMod * min((dmgBase - trunc(sqrt(sqr(Point.x - x)+sqr(Point.y - y)))) div 2, r)); |
365 dmg:= trunc(dmgMod * min((dmgBase - trunc(sqrt(sqr(Point.x - x)+sqr(Point.y - y)))) div 2, r)); |
362 |
366 |
363 if dmg > 0 then |
367 if dmg > 0 then |
364 begin |
368 begin |
365 if Flags and 1 <> 0 then |
369 if Flags and afTrackFall <> 0 then |
366 begin |
370 begin |
367 dX:= 0.005 * dmg + 0.01; |
371 dX:= 0.005 * dmg + 0.01; |
368 dY:= dX; |
372 dY:= dX; |
369 fallDmg:= trunc(TraceFall(x, y, Point.x, Point.y, dX, dY, erasure) * dmgMod); |
373 fallDmg:= trunc(TraceFall(x, y, Point.x, Point.y, dX, dY, erasure) * dmgMod); |
370 end; |
374 end; |
397 dmgMod:= 0.01 * hwFloat2Float(cDamageModifier) * cDamagePercent; |
401 dmgMod:= 0.01 * hwFloat2Float(cDamageModifier) * cDamagePercent; |
398 rate:= 0; |
402 rate:= 0; |
399 for i:= 0 to Pred(Targets.Count) do |
403 for i:= 0 to Pred(Targets.Count) do |
400 with Targets.ar[i] do |
404 with Targets.ar[i] do |
401 if skip then |
405 if skip then |
402 if (Flags and fSetSkip = 0) then skip:= false else {still skip} |
406 if (Flags and afSetSkip = 0) then skip:= false else {still skip} |
403 else |
407 else |
404 begin |
408 begin |
405 dmg:= 0; |
409 dmg:= 0; |
406 if abs(Point.x - x) + abs(Point.y - y) < r then |
410 if abs(Point.x - x) + abs(Point.y - y) < r then |
407 begin |
411 begin |
408 dmg:= r - trunc(sqrt(sqr(Point.x - x)+sqr(Point.y - y))); |
412 dmg:= r - trunc(sqrt(sqr(Point.x - x)+sqr(Point.y - y))); |
409 dmg:= trunc(dmg * dmgMod); |
413 dmg:= trunc(dmg * dmgMod); |
410 end; |
414 end; |
411 if dmg > 0 then |
415 if dmg > 0 then |
412 begin |
416 begin |
413 if (Flags and fSetSkip <> 0) then skip:= true; |
417 if (Flags and afSetSkip <> 0) then skip:= true; |
414 if (Flags and 1 <> 0) then |
418 if (Flags and afTrackFall <> 0) then |
415 fallDmg:= trunc(TraceShoveFall(Me, Point.x, Point.y - 2, dX, dY) * dmgMod); |
419 fallDmg:= trunc(TraceShoveFall(Me, Point.x, Point.y - 2, dX, dY) * dmgMod); |
416 if fallDmg < 0 then // drowning. score healthier hogs higher, since their death is more likely to benefit the AI |
420 if fallDmg < 0 then // drowning. score healthier hogs higher, since their death is more likely to benefit the AI |
417 if Score > 0 then |
421 if Score > 0 then |
418 inc(rate, KillScore + Score div 10) // Add a bit of a bonus for bigger hog drownings |
422 inc(rate, KillScore + Score div 10) // Add a bit of a bonus for bigger hog drownings |
419 else |
423 else |