hedgewars/uAIMisc.pas
changeset 7375 16ae2e1c9005
parent 7360 d833d1010710
child 7378 ac9ce7f033df
--- a/hedgewars/uAIMisc.pas	Mon Jul 09 23:28:02 2012 -0400
+++ b/hedgewars/uAIMisc.pas	Wed Jul 11 22:18:43 2012 -0400
@@ -54,6 +54,7 @@
 procedure freeModule;
 
 procedure FillTargets;
+procedure AddBonus(x, y: LongInt; r: Longword; s: LongInt); inline;
 procedure FillBonuses(isAfterAttack: boolean);
 procedure AwareOfExplosion(x, y, r: LongInt); inline;
 
@@ -80,6 +81,11 @@
         ar: array[0..Pred(MAXBONUS)] of TBonus;
         end;
 
+    walkbonuses: record
+        Count: Longword;
+        ar: array[0..Pred(MAXBONUS div 4)] of TBonus;  // don't use too many
+        end;
+
 implementation
 uses uCollisions, uVariables, uUtils, uDebug, uLandTexture;
 
@@ -140,9 +146,22 @@
     end;
 end;
 
+procedure AddWalkBonus(x, y: LongInt; r: Longword; s: LongInt); inline;
+begin
+if(walkbonuses.Count < MAXBONUS div 4) then
+    begin
+    walkbonuses.ar[walkbonuses.Count].x:= x;
+    walkbonuses.ar[walkbonuses.Count].y:= y;
+    walkbonuses.ar[walkbonuses.Count].Radius:= r;
+    walkbonuses.ar[walkbonuses.Count].Score:= s;
+    inc(walkbonuses.Count);
+    end;
+end;
+
 procedure FillBonuses(isAfterAttack: boolean);
 var Gear: PGear;
     MyClan: PClan;
+    i: Longint;
 begin
 bonuses.Count:= 0;
 MyClan:= ThinkingHH^.Hedgehog^.Team^.Clan;
@@ -190,6 +209,11 @@
 if isAfterAttack and (KnownExplosion.Radius > 0) then
     with KnownExplosion do
         AddBonus(X, Y, Radius + 10, -Radius);
+if isAfterAttack then
+    for i:= 0 to Pred(walkbonuses.Count) do
+        with walkbonuses.ar[i] do
+            AddBonus(X, Y, Radius, Score);
+walkbonuses.Count:= 0
 end;
 
 procedure AwareOfExplosion(x, y, r: LongInt); inline;
@@ -642,7 +666,7 @@
 end;
 
 function HHGo(Gear, AltGear: PGear; var GoInfo: TGoInfo): boolean;
-var pX, pY: LongInt;
+var pX, pY, tY: LongInt;
 begin
 HHGo:= false;
 AltGear^:= Gear^;
@@ -650,12 +674,16 @@
 GoInfo.Ticks:= 0;
 GoInfo.FallPix:= 0;
 GoInfo.JumpType:= jmpNone;
-
+tY:= hwRound(Gear^.Y);
 repeat
     pX:= hwRound(Gear^.X);
     pY:= hwRound(Gear^.Y);
     if pY + cHHRadius >= cWaterLine then
-        exit(false);
+        begin
+        if AltGear^.Hedgehog^.BotLevel < 4 then
+            AddWalkBonus(pX, tY, 250, -40);
+        exit(false)
+        end;
         
     // hog is falling    
     if (Gear^.State and gstMoving) <> 0 then
@@ -667,6 +695,8 @@
             Goinfo.FallPix:= 0;
             // try ljump instead of fall with damage
             HHJump(AltGear, jmpLJump, GoInfo); 
+            if AltGear^.Hedgehog^.BotLevel < 4 then
+                AddWalkBonus(pX, tY, 175, -20);
             exit(false)
             end;
         Gear^.Y:= Gear^.Y + Gear^.dY;