--- a/ChangeLog.txt Mon Jul 06 14:51:24 2020 +0200
+++ b/ChangeLog.txt Mon Jul 06 15:41:22 2020 +0200
@@ -6,7 +6,8 @@
+ Easier to push hogs around with blowtorch
+ Backjumps are now a bit easier
+ Teach computer players how to ...
- + - use drill strike, piano strike, air mine, cleaver, seduction, resurrector, laser sight
+ + - use drill strike, piano strike, air mine, cleaver, seduction
+ + - use resurrector, laser sight, low gravity
+ - use mine strike (0 seconds only)
+ - use RC plane (very basic)
+ - drop mines from a cliff
--- a/hedgewars/uAI.pas Mon Jul 06 14:51:24 2020 +0200
+++ b/hedgewars/uAI.pas Mon Jul 06 15:41:22 2020 +0200
@@ -100,18 +100,33 @@
procedure TestAmmos(var Actions: TActions; Me: PGear; rareChecks: boolean);
var BotLevel: Byte;
ap: TAttackParams;
- Score, i, t, n, dAngle: LongInt;
+ Score, i, l, t, n, dAngle: LongInt;
a, aa: TAmmoType;
- useThisActions: boolean;
+ useThisActions, hasLowGrav: boolean;
begin
BotLevel:= Me^.Hedgehog^.BotLevel;
aiWindSpeed:= hwFloat2Float(cWindSpeed);
-aiGravity:= cGravity;
-aiGravityf:= cGravityf;
aiLaserSighting:= (cLaserSighting) or (HHHasAmmo(Me^.Hedgehog^, amLaserSight) > 0);
+hasLowGrav:= HHHasAmmo(Me^.Hedgehog^, amLowGravity) > 0;
useThisActions:= false;
Me^.AIHints:= Me^.AIHints and (not aihAmmosChanged);
+for l:= 0 to 1 do // 0 = test with normal gravity. 1 = test with low gravity
+if (l = 0) or ((hasLowGrav) and (not cLowGravity)) then
+begin
+// simulate normal or low gravity
+if (l = 0) then
+ begin
+ aiGravity:= cGravity;
+ aiGravityf:= cGravityf;
+ end
+else if (l = 1) then
+ begin
+ // We calculate the values to better support scripts like Gravity.
+ // This might have a slight inaccuracy, but none have been spotted in testing.
+ aiGravity:= cGravity / _2;
+ aiGravityf:= cGravityf / 2;
+ end;
for i:= 0 to Pred(Targets.Count) do
if (Targets.ar[i].Score >= 0) and (not StopThinking) then
begin
@@ -123,6 +138,7 @@
if (CanUseAmmo[a])
and ((not rareChecks) or ((AmmoTests[a].flags and amtest_Rare) = 0))
and ((i = 0) or ((AmmoTests[a].flags and amtest_NoTarget) = 0))
+ and ((l = 0) or ((AmmoTests[a].flags and amtest_NoLowGravity) = 0))
then
begin
{$HINTS OFF}
@@ -160,6 +176,12 @@
AddAction(BestActions, aia_attack, aim_push, 10, 0, 0);
AddAction(BestActions, aia_attack, aim_release, 10, 0, 0);
end;
+ if (l = 1) and (hasLowGrav) then
+ begin
+ AddAction(BestActions, aia_Weapon, Longword(amLowGravity), 80, 0, 0);
+ AddAction(BestActions, aia_attack, aim_push, 10, 0, 0);
+ AddAction(BestActions, aia_attack, aim_release, 10, 0, 0);
+ end;
if (HHHasAmmo(Me^.Hedgehog^, amExtraDamage) > 0) and (cDamageModifier <> _1_5) then
begin
AddAction(BestActions, aia_Weapon, Longword(amExtraDamage), 80, 0, 0);
@@ -271,6 +293,7 @@
or StopThinking
end
end;
+end;
procedure Walk(Me: PGear; var Actions: TActions);
const FallPixForBranching = cHHRadius;
--- a/hedgewars/uAIAmmoTests.pas Mon Jul 06 14:51:24 2020 +0200
+++ b/hedgewars/uAIAmmoTests.pas Mon Jul 06 15:41:22 2020 +0200
@@ -29,6 +29,7 @@
amtest_LaserSight = $00000010; // supports laser sighting
amtest_NoVampiric = $00000020; // don't use vampirism with this ammo
amtest_NoInvulnerable = $00000040; // don't use invulnerable with this with ammo
+ amtest_NoLowGravity = $00000080; // don't use low gravity with this with ammo
var aiWindSpeed: real;
aiGravity: hwFloat;
@@ -133,7 +134,7 @@
(proc: nil; flags: 0), // amFlamethrower
(proc: @TestSMine; flags: 0), // amSMine
(proc: @TestHammer; flags: amtest_NoTarget or amtest_NoInvulnerable), // amHammer
- (proc: @TestResurrector; flags: amtest_NoTarget or amtest_NoInvulnerable or amtest_NoVampiric), // amResurrector
+ (proc: @TestResurrector; flags: amtest_NoTarget or amtest_NoInvulnerable or amtest_NoVampiric or amtest_NoLowGravity), // amResurrector
(proc: @TestDrillStrike; flags: amtest_Rare), // amDrillStrike
(proc: nil; flags: 0), // amSnowball
(proc: nil; flags: 0), // amTardis