Engine:
authorsmaxx
Mon, 26 Jul 2010 11:04:32 +0200
changeset 3677 7d917b587547
parent 3675 857c9546a822
child 3679 acf5acc18522
Engine: * Added weapon offsets to AI's gear prediction. This should improve its aiming once again.
CMakeLists.txt
QTfrontend/pages.cpp
hedgewars/uAIAmmoTests.pas
--- a/CMakeLists.txt	Sun Jul 25 22:40:31 2010 +0400
+++ b/CMakeLists.txt	Mon Jul 26 11:04:32 2010 +0200
@@ -19,7 +19,7 @@
 				     OUTPUT_VARIABLE version_suffix
 				     )
 			STRING(REGEX REPLACE "(.*) +(.*)" "\\2:\\1" version_suffix ${version_suffix})
-			MESSAGE(STATUS "Builing revision ${version_suffix}")
+			MESSAGE(STATUS "Building revision ${version_suffix}")
 			set(version_suffix ".${version_suffix}")
 #			#truncate to numbers only - trying to fix a problem described in http://www.hedgewars.org/node/2019
 #			STRING(REGEX REPLACE "^\\.(\\d+)" ".\\1" version_suffix ${version_suffix})
@@ -156,6 +156,7 @@
 endif(LOWRES)
 
 if(Optz)
+#	set(pascal_compiler_flags_cmn "-O3" "-OpPENTIUM4" "-CfSSE3" "-Xs" "-Si" ${pascal_compiler_flags_cmn})
 	set(pascal_compiler_flags_cmn "-O2" "-Xs" "-Si" ${pascal_compiler_flags_cmn})
 	set(haskell_compiler_flags_cmn "-O2" "-w")
 else(Optz)
--- a/QTfrontend/pages.cpp	Sun Jul 25 22:40:31 2010 +0400
+++ b/QTfrontend/pages.cpp	Mon Jul 26 11:04:32 2010 +0200
@@ -108,7 +108,7 @@
     Tips << tr("Hedgewars is available in many languages. If the translation in your language seems to be missing or outdated, feel free to contact us!", "Tips");
     Tips << tr("Hedgewars can be run on lots of different operating systems including Microsoft Windows, Mac OS X and Linux.", "Tips");
     Tips << tr("Always remember you're able to set up your own games in local and network/online play. You're not restricted to the 'Simple Game' option.", "Tips");
-    Tips << tr("Connect a gamepad before launching the game to be able to assign its controls to your team.", "Tips");
+    Tips << tr("Connect one or more gamepads before launching the game to be able to assign their controls to your teams.", "Tips");
     Tips << tr("Create an account on http://www.hedgewars.org/ to keep others from using your most favourite nickname while playing on the official server.", "Tips");
     Tips << tr("While playing you should give yourself a short break at least once an hour.", "Tips");
     Tips << tr("If your graphics card isn't able to provide hardware accelerated OpenGL, try to enable the low quality mode to improve performance.", "Tips");
@@ -122,7 +122,7 @@
     
 
     if(isDevBuild)
-        mainNote->setText(QLabel::tr("This HG build is 'work in progress' and may not be compatible with other versions of the game. Some features might be broken or incomplete. Use at your own risk!"));
+        mainNote->setText(QLabel::tr("This development build is 'work in progress' and may not be compatible with other versions of the game. Some features might be broken or incomplete. Use at your own risk!"));
     else
         mainNote->setText(QLabel::tr("Tip: ") + Tips[QTime(0, 0, 0).secsTo(QTime::currentTime()) % Tips.length()]);
 
--- a/hedgewars/uAIAmmoTests.pas	Sun Jul 25 22:40:31 2010 +0400
+++ b/hedgewars/uAIAmmoTests.pas	Mon Jul 26 11:04:32 2010 +0200
@@ -103,7 +103,7 @@
 const BadTurn = Low(LongInt) div 4;
 
 implementation
-uses uMisc, uAIMisc, uLand;
+uses uMisc, uAIMisc, uLand, uTeams;
 
 function Metric(x1, y1, x2, y2: LongInt): LongInt;
 begin
@@ -121,8 +121,11 @@
         t: LongInt;
         value: LongInt;
     begin
-    x:= Me^.X;
-    y:= Me^.Y;
+    with PHedgehog(Me^.Hedgehog)^ do
+        begin
+        x:= Me^.X + int2hwfloat(round(GetLaunchX(Ammo^[CurSlot, CurAmmo].AmmoType, hwSign(Me^.dX), Me^.Angle)));
+        y:= Me^.Y + int2hwfloat(round(GetLaunchY(Ammo^[CurSlot, CurAmmo].AmmoType, Me^.Angle)))
+        end;
     dX:= Vx;
     dY:= -Vy;
     t:= rTime;
@@ -176,8 +179,11 @@
     var x, y, dY: hwFloat;
         t: LongInt;
     begin
-    x:= Me^.X;
-    y:= Me^.Y;
+    with PHedgehog(Me^.Hedgehog)^ do
+        begin
+        x:= Me^.X + int2hwfloat(round(GetLaunchX(Ammo^[CurSlot, CurAmmo].AmmoType, hwSign(Me^.dX), Me^.Angle)));
+        y:= Me^.Y + int2hwfloat(round(GetLaunchY(Ammo^[CurSlot, CurAmmo].AmmoType, Me^.Angle)))
+        end;
     dY:= -Vy;
     t:= TestTime;
     repeat
@@ -228,8 +234,11 @@
     var x, y, dY: hwFloat;
         t: LongInt;
     begin
-    x:= Me^.X;
-    y:= Me^.Y;
+    with PHedgehog(Me^.Hedgehog)^ do
+        begin
+        x:= Me^.X + int2hwfloat(round(GetLaunchX(Ammo^[CurSlot, CurAmmo].AmmoType, hwSign(Me^.dX), Me^.Angle)));
+        y:= Me^.Y + int2hwfloat(round(GetLaunchY(Ammo^[CurSlot, CurAmmo].AmmoType, Me^.Angle)))
+        end;
     dY:= -Vy;
     t:= TestTime;
     repeat
@@ -280,8 +289,11 @@
     var x, y, dY: hwFloat;
         t: LongInt;
     begin
-    x:= Me^.X;
-    y:= Me^.Y;
+    with PHedgehog(Me^.Hedgehog)^ do
+        begin
+        x:= Me^.X + int2hwfloat(round(GetLaunchX(Ammo^[CurSlot, CurAmmo].AmmoType, hwSign(Me^.dX), Me^.Angle)));
+        y:= Me^.Y + int2hwfloat(round(GetLaunchY(Ammo^[CurSlot, CurAmmo].AmmoType, Me^.Angle)))
+        end;
     dY:= -Vy;
     t:= TestTime;
     repeat
@@ -336,8 +348,11 @@
     var x, y, dY: hwFloat;
         t: LongInt;
     begin
-    x:= Me^.X;
-    y:= Me^.Y;
+    with PHedgehog(Me^.Hedgehog)^ do
+        begin
+        x:= Me^.X + int2hwfloat(round(GetLaunchX(Ammo^[CurSlot, CurAmmo].AmmoType, hwSign(Me^.dX), Me^.Angle)));
+        y:= Me^.Y + int2hwfloat(round(GetLaunchY(Ammo^[CurSlot, CurAmmo].AmmoType, Me^.Angle)))
+        end;
     dY:= -Vy;
     t:= TestTime;
     repeat
@@ -388,8 +403,11 @@
     var x, y, dY: hwFloat;
         value: LongInt;
     begin
-        x:= Me^.X;
-        y:= Me^.Y;
+    with PHedgehog(Me^.Hedgehog)^ do
+        begin
+        x:= Me^.X + int2hwfloat(round(GetLaunchX(Ammo^[CurSlot, CurAmmo].AmmoType, hwSign(Me^.dX), Me^.Angle)));
+        y:= Me^.Y + int2hwfloat(round(GetLaunchY(Ammo^[CurSlot, CurAmmo].AmmoType, Me^.Angle)))
+        end;
         dY:= -Vy;
 
         repeat
@@ -473,12 +491,15 @@
 ap.ExplR:= 0;
 ap.Time:= 0;
 ap.Power:= 1;
-range:= Metric(hwRound(Me^.X), hwRound(Me^.Y), Targ.X, Targ.Y);
+with PHedgehog(Me^.Hedgehog)^ do
+    begin
+    x:= Me^.X + int2hwfloat(round(GetLaunchX(Ammo^[CurSlot, CurAmmo].AmmoType, hwSign(Me^.dX), Me^.Angle)));
+    y:= Me^.Y + int2hwfloat(round(GetLaunchY(Ammo^[CurSlot, CurAmmo].AmmoType, Me^.Angle)))
+    end;
+range:= Metric(hwRound(x), hwRound(y), Targ.X, Targ.Y);
 if ( range < MIN_RANGE ) or ( range > MAX_RANGE ) then exit(BadTurn);
-Vx:= (int2hwFloat(Targ.X) - Me^.X) * _1div1024;
-Vy:= (int2hwFloat(Targ.Y) - Me^.Y) * _1div1024;
-x:= Me^.X;
-y:= Me^.Y;
+Vx:= (int2hwFloat(Targ.X) - x) * _1div1024;
+Vy:= (int2hwFloat(Targ.Y) - y) * _1div1024;
 ap.Angle:= DxDy2AttackAngle(Vx, -Vy);
 repeat
   x:= x + vX;
@@ -507,13 +528,16 @@
 ap.ExplR:= 0;
 ap.Time:= 0;
 ap.Power:= 1;
+with PHedgehog(Me^.Hedgehog)^ do
+    begin
+    x:= Me^.X + int2hwfloat(round(GetLaunchX(Ammo^[CurSlot, CurAmmo].AmmoType, hwSign(Me^.dX), Me^.Angle)));
+    y:= Me^.Y + int2hwfloat(round(GetLaunchY(Ammo^[CurSlot, CurAmmo].AmmoType, Me^.Angle)))
+    end;
 if Abs(hwRound(Me^.X) - Targ.X) + Abs(hwRound(Me^.Y) - Targ.Y) < 80 then
    exit(BadTurn);
-t:= _0_5 / Distance(int2hwFloat(Targ.X) - Me^.X, int2hwFloat(Targ.Y) - Me^.Y);
-Vx:= (int2hwFloat(Targ.X) - Me^.X) * t;
-Vy:= (int2hwFloat(Targ.Y) - Me^.Y) * t;
-x:= Me^.X;
-y:= Me^.Y;
+t:= _0_5 / Distance(int2hwFloat(Targ.X) - x, int2hwFloat(Targ.Y) - y);
+Vx:= (int2hwFloat(Targ.X) - x) * t;
+Vy:= (int2hwFloat(Targ.Y) - y) * t;
 ap.Angle:= DxDy2AttackAngle(Vx, -Vy);
 d:= 0;
 
@@ -531,6 +555,7 @@
 
 function TestBaseballBat(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
 var valueResult: LongInt;
+    x, y: hwFloat;
 begin
 Level:= Level; // avoid compiler hint
 ap.ExplR:= 0;
@@ -539,26 +564,37 @@
 
 ap.Time:= 0;
 ap.Power:= 1;
-if (Targ.X) - hwRound(Me^.X) >= 0 then ap.Angle:=   cMaxAngle div 4
+with PHedgehog(Me^.Hedgehog)^ do
+    begin
+    x:= Me^.X + int2hwfloat(round(GetLaunchX(Ammo^[CurSlot, CurAmmo].AmmoType, hwSign(Me^.dX), Me^.Angle)));
+    y:= Me^.Y + int2hwfloat(round(GetLaunchY(Ammo^[CurSlot, CurAmmo].AmmoType, Me^.Angle)))
+    end;
+if (Targ.X) - hwRound(x) >= 0 then ap.Angle:=   cMaxAngle div 4
                                   else ap.Angle:= - cMaxAngle div 4;
-valueResult:= RateShove(Me, hwRound(Me^.X) + 10 * hwSign(int2hwFloat(Targ.X) - Me^.X), hwRound(Me^.Y), 15, 30);
+valueResult:= RateShove(Me, hwRound(x) + 10 * hwSign(int2hwFloat(Targ.X) - x), hwRound(y), 15, 30);
 if valueResult <= 0 then valueResult:= BadTurn else inc(valueResult);
 TestBaseballBat:= valueResult;
 end;
 
 function TestFirePunch(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
 var i, valueResult: LongInt;
+    x, y: hwFloat;
 begin
 Level:= Level; // avoid compiler hint
 ap.ExplR:= 0;
 ap.Time:= 0;
 ap.Power:= 1;
 ap.Angle:= 0;
-if (Abs(hwRound(Me^.X) - Targ.X) > 25)
-or (Abs(hwRound(Me^.Y) - 50 - Targ.Y) > 50) then
+with PHedgehog(Me^.Hedgehog)^ do
     begin
-    if TestColl(hwRound(Me^.Y), hwRound(Me^.Y) - 16, 6)
-    and (RateShove(Me, hwRound(Me^.X) + 10 * hwSign(Me^.dX), hwRound(Me^.Y) - 40, 30, 30) = 0) then
+    x:= Me^.X + int2hwfloat(round(GetLaunchX(Ammo^[CurSlot, CurAmmo].AmmoType, hwSign(Me^.dX), Me^.Angle)));
+    y:= Me^.Y + int2hwfloat(round(GetLaunchY(Ammo^[CurSlot, CurAmmo].AmmoType, Me^.Angle)))
+    end;
+if (Abs(hwRound(x) - Targ.X) > 25)
+or (Abs(hwRound(y) - 50 - Targ.Y) > 50) then
+    begin
+    if TestColl(hwRound(x), hwRound(y) - 16, 6)
+    and (RateShove(Me, hwRound(x) + 10 * hwSign(Me^.dX), hwRound(y) - 40, 30, 30) = 0) then
         valueResult:= Succ(BadTurn)
     else
         valueResult:= BadTurn;
@@ -567,8 +603,8 @@
 
 valueResult:= 0;
 for i:= 0 to 4 do
-    valueResult:= valueResult + RateShove(Me, hwRound(Me^.X) + 10 * hwSign(int2hwFloat(Targ.X) - Me^.X),
-                                    hwRound(Me^.Y) - 20 * i - 5, 10, 30);
+    valueResult:= valueResult + RateShove(Me, hwRound(x) + 10 * hwSign(int2hwFloat(Targ.X) - x),
+                                    hwRound(y) - 20 * i - 5, 10, 30);
 if valueResult <= 0 then
     valueResult:= BadTurn
 else