--- a/hedgewars/uAIAmmoTests.pas Sat Apr 14 22:40:23 2012 +0400
+++ b/hedgewars/uAIAmmoTests.pas Sat Apr 14 23:19:45 2012 +0400
@@ -826,8 +826,9 @@
maxTop: longword;
begin
TestTeleport := BadTurn;
+ exit();
Level:= Level; // avoid compiler hint
- FillBonuses(true, [gtCase]);
+ //FillBonuses(true, [gtCase]);
if bonuses.Count = 0 then
begin
if Me^.Health <= 100 then
--- a/hedgewars/uAIMisc.pas Sat Apr 14 22:40:23 2012 +0400
+++ b/hedgewars/uAIMisc.pas Sat Apr 14 23:19:45 2012 +0400
@@ -48,7 +48,7 @@
procedure freeModule;
procedure FillTargets;
-procedure FillBonuses(isAfterAttack: boolean; filter: TGearsType = []);
+procedure FillBonuses(isAfterAttack: boolean);
procedure AwareOfExplosion(x, y, r: LongInt); inline;
function RatePlace(Gear: PGear): LongInt;
function TestCollExcludingMe(Me: PGear; x, y, r: LongInt): boolean; inline;
@@ -126,7 +126,7 @@
TryDo(bonuses.Count <= MAXBONUS, 'Bonuses overflow', true)
end;
-procedure FillBonuses(isAfterAttack: boolean; filter: TGearsType);
+procedure FillBonuses(isAfterAttack: boolean);
var Gear: PGear;
MyClan: PClan;
begin
@@ -135,7 +135,6 @@
Gear:= GearsList;
while Gear <> nil do
begin
- if (filter = []) or (Gear^.Kind in filter) then
case Gear^.Kind of
gtCase:
AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 33, 25);
--- a/hedgewars/uGearsUtils.pas Sat Apr 14 22:40:23 2012 +0400
+++ b/hedgewars/uGearsUtils.pas Sat Apr 14 23:19:45 2012 +0400
@@ -32,7 +32,6 @@
procedure ResurrectHedgehog(gear: PGear);
procedure FindPlace(var Gear: PGear; withFall: boolean; Left, Right: LongInt; skipProximity: boolean = false);
function CheckGearNear(Gear: PGear; Kind: TGearType; rX, rY: LongInt): PGear;
-function CheckGearsNear(mX, mY: LongInt; Kind: TGearsType; rX, rY: LongInt): PGear;
function CheckGearDrowning(Gear: PGear): boolean;
var doStepHandlers: array[TGearType] of TGearStepProcedure;
@@ -475,6 +474,24 @@
CountNonZeroz:= count;
end;
+
+function NoGearsToAvoid(mX, mY: LongInt; rX, rY: LongInt): boolean;
+var t: PGear;
+begin
+t:= GearsList;
+rX:= sqr(rX);
+rY:= sqr(rY);
+while t <> nil do
+ begin
+ if t^.Kind <= gtExplosives then
+ if not (hwSqr(int2hwFloat(mX) - t^.X) / rX + hwSqr(int2hwFloat(mY) - t^.Y) / rY > _1) then
+ exit(false);
+ t:= t^.NextGear
+ end;
+NoGearsToAvoid:= true
+end;
+
+
procedure FindPlace(var Gear: PGear; withFall: boolean; Left, Right: LongInt; skipProximity: boolean);
var x: LongInt;
y, sy: LongInt;
@@ -511,14 +528,14 @@
if (y - sy > Gear^.Radius * 2)
and (((Gear^.Kind = gtExplosives)
and (y < cWaterLine)
- and (reallySkip or (CheckGearsNear(x, y - Gear^.Radius, [gtFlame, gtHedgehog, gtMine, gtCase, gtExplosives], 60, 60) = nil))
+ and (reallySkip or NoGearsToAvoid(x, y - Gear^.Radius, 60, 60))
and (CountNonZeroz(x, y+1, Gear^.Radius - 1, Gear^.Radius+1) > Gear^.Radius))
or
((Gear^.Kind <> gtExplosives)
and (y < cWaterLine)
- and (reallySkip or (CheckGearsNear(x, y - Gear^.Radius, [gtFlame, gtHedgehog, gtMine, gtCase, gtExplosives], 110, 110) = nil)))) then
-
- begin
+ and (reallySkip or NoGearsToAvoid(x, y - Gear^.Radius, 110, 110))
+ )) then
+ begin
ar[cnt].X:= x;
if withFall then
ar[cnt].Y:= sy + Gear^.Radius
@@ -582,20 +599,4 @@
CheckGearNear:= nil
end;
-
-function CheckGearsNear(mX, mY: LongInt; Kind: TGearsType; rX, rY: LongInt): PGear;
-var t: PGear;
-begin
-t:= GearsList;
-rX:= sqr(rX);
-rY:= sqr(rY);
-while t <> nil do
- begin
- if t^.Kind in Kind then
- if not (hwSqr(int2hwFloat(mX) - t^.X) / rX + hwSqr(int2hwFloat(mY) - t^.Y) / rY > _1) then
- exit(t);
- t:= t^.NextGear
- end;
-CheckGearsNear:= nil
-end;
end.
--- a/hedgewars/uTypes.pas Sat Apr 14 22:40:23 2012 +0400
+++ b/hedgewars/uTypes.pas Sat Apr 14 23:19:45 2012 +0400
@@ -90,15 +90,16 @@
);
// Gears that interact with other Gears and/or Land
- TGearType = (gtGrenade, gtHedgehog, gtShell, gtGrave, gtBee, // 4
- gtShotgunShot, gtPickHammer, gtRope, gtMine, gtCase, // 9
- gtDEagleShot, gtDynamite, gtClusterBomb, gtCluster, gtShover, // 14
- gtFlame, gtFirePunch, gtATStartGame, // 17
- gtATFinishGame, gtParachute, gtAirAttack, gtAirBomb, gtBlowTorch, // 22
- gtGirder, gtTeleport, gtSwitcher, gtTarget, gtMortar, // 27
- gtWhip, gtKamikaze, gtCake, gtSeduction, gtWatermelon, gtMelonPiece, // 33
- gtHellishBomb, gtWaterUp, gtDrill, gtBallGun, gtBall, gtRCPlane, // 39
- gtSniperRifleShot, gtJetpack, gtMolotov, gtExplosives, gtBirdy, // 44
+ TGearType = ({-->}gtFlame, gtHedgehog, gtMine, gtCase, gtExplosives, // <-- these are gears which should be avoided when searching a spawn place
+ gtGrenade, gtShell, gtGrave, gtBee, // 8
+ gtShotgunShot, gtPickHammer, gtRope, // 11
+ gtDEagleShot, gtDynamite, gtClusterBomb, gtCluster, gtShover, // 16
+ gtFirePunch, gtATStartGame, // 18
+ gtATFinishGame, gtParachute, gtAirAttack, gtAirBomb, gtBlowTorch, // 23
+ gtGirder, gtTeleport, gtSwitcher, gtTarget, gtMortar, // 28
+ gtWhip, gtKamikaze, gtCake, gtSeduction, gtWatermelon, gtMelonPiece, // 34
+ gtHellishBomb, gtWaterUp, gtDrill, gtBallGun, gtBall, gtRCPlane, // 40
+ gtSniperRifleShot, gtJetpack, gtMolotov, gtBirdy, // 44
gtEgg, gtPortal, gtPiano, gtGasBomb, gtSineGunShot, gtFlamethrower, // 50
gtSMine, gtPoisonCloud, gtHammer, gtHammerHit, gtResurrector, // 55
gtNapalmBomb, gtSnowball, gtFlake, gtStructure, gtLandGun, gtTardis); // 61
@@ -112,8 +113,6 @@
vgtBigExplosion, vgtChunk, vgtNote, vgtLineTrail, vgtBulletHit, vgtCircle,
vgtSmoothWindBar, vgtStraightShot);
- TGearsType = set of TGearType;
-
// Damage can be caused by different sources
TDamageSource = (dsUnknown, dsFall, dsBullet, dsExplosion, dsShove, dsPoison);