- Changed falling damage scoring
- Update version to 0.2
- Bots avoid explosions caused by their weapon
- Fix camera movement
--- a/hedgewars/GSHandlers.inc Fri Jun 23 20:02:41 2006 +0000
+++ b/hedgewars/GSHandlers.inc Wed Jun 28 18:27:42 2006 +0000
@@ -53,7 +53,7 @@
procedure CheckHHDamage(Gear: PGear);
begin
-if Gear.dY > 0.35 then Gear.Damage:= Gear.Damage + round(75 * (abs(Gear.dY) - 0.35));
+if Gear.dY > 0.40 then Gear.Damage:= Gear.Damage + 1 + round(70 * (abs(Gear.dY) - 0.40));
end;
////////////////////////////////////////////////////////////////////////////////
--- a/hedgewars/hwengine.dpr Fri Jun 23 20:02:41 2006 +0000
+++ b/hedgewars/hwengine.dpr Wed Jun 28 18:27:42 2006 +0000
@@ -192,7 +192,7 @@
////////////////////////////////////////////////////////////////////////////////
begin
-WriteLnToConsole('HedgeWars 0.1 alpha');
+WriteLnToConsole('HedgeWars 0.2');
WriteLnToConsole(' -= by unC0Rr =- ');
GetParams;
Randomize;
--- a/hedgewars/uAI.pas Fri Jun 23 20:02:41 2006 +0000
+++ b/hedgewars/uAI.pas Wed Jun 28 18:27:42 2006 +0000
@@ -58,7 +58,7 @@
procedure TestAmmos(var Actions: TActions; Me: PGear);
var Time: Longword;
- Angle, Power, Score: integer;
+ Angle, Power, Score, ExplX, ExplY, ExplR: integer;
i: integer;
a, aa: TAmmoType;
begin
@@ -73,7 +73,7 @@
repeat
if Assigned(AmmoTests[a]) then
begin
- Score:= AmmoTests[a](Me, Targets.ar[i].Point, Time, Angle, Power);
+ Score:= AmmoTests[a](Me, Targets.ar[i].Point, Time, Angle, Power, ExplX, ExplY, ExplR);
if Actions.Score + Score + Targets.ar[i].Score > BestActions.Score then
begin
BestActions:= Actions;
@@ -94,6 +94,8 @@
end;
AddAction(BestActions, aia_attack, aim_push, 800);
AddAction(BestActions, aia_attack, aim_release, Power);
+ if ExplR > 0 then
+ AddAction(BestActions, aia_AwareExpl, ExplR, 10, ExplX, ExplY);
end
end;
if a = High(TAmmoType) then a:= Low(TAmmoType)
--- a/hedgewars/uAIActions.pas Fri Jun 23 20:02:41 2006 +0000
+++ b/hedgewars/uAIActions.pas Wed Jun 28 18:27:42 2006 +0000
@@ -1,3 +1,36 @@
+(*
+ * Hedgewars, a worms-like game
+ * Copyright (c) 2005, 2006 Andrey Korotaev <unC0Rr@gmail.com>
+ *
+ * Distributed under the terms of the BSD-modified licence:
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * with the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+ * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *)
+
unit uAIActions;
interface
uses uGears;
@@ -15,6 +48,7 @@
aia_WaitY = $80000002;
aia_LookLeft = $80000003;
aia_LookRight = $80000004;
+ aia_AwareExpl = $80000005;
aim_push = $80000000;
aim_release = $80000001;
@@ -22,6 +56,7 @@
type TAction = record
Action, Param: Longword;
+ X, Y: integer;
Time: Longword;
end;
TActions = record
@@ -30,11 +65,11 @@
Score: integer;
end;
-procedure AddAction(var Actions: TActions; Action, Param, TimeDelta: Longword);
+procedure AddAction(var Actions: TActions; Action, Param, TimeDelta: Longword; const X: integer = 0; Y: integer = 0);
procedure ProcessAction(var Actions: TActions; Me: PGear);
implementation
-uses uMisc, uTeams, uConsts, uConsole;
+uses uMisc, uTeams, uConsts, uConsole, uAIMisc;
const ActionIdToStr: array[0..6] of string[16] = (
{aia_none} '',
@@ -46,12 +81,14 @@
{aia_Down} 'down'
);
-procedure AddAction(var Actions: TActions; Action, Param, TimeDelta: Longword);
+procedure AddAction(var Actions: TActions; Action, Param, TimeDelta: Longword; const X: integer = 0; Y: integer = 0);
begin
with Actions do
begin
actions[Count].Action:= Action;
actions[Count].Param:= Param;
+ actions[Count].X:= X;
+ actions[Count].Y:= Y;
if Count > 0 then actions[Count].Time:= TimeDelta
else actions[Count].Time:= GameTicks + TimeDelta;
inc(Count);
@@ -91,6 +128,7 @@
ParseCommand('+right');
exit
end else ParseCommand('-right');
+ aia_AwareExpl: AwareOfExplosion(X, Y, Param);
end else
begin
s:= ActionIdToStr[Action];
--- a/hedgewars/uAIAmmoTests.pas Fri Jun 23 20:02:41 2006 +0000
+++ b/hedgewars/uAIAmmoTests.pas Wed Jun 28 18:27:42 2006 +0000
@@ -1,12 +1,45 @@
+(*
+ * Hedgewars, a worms-like game
+ * Copyright (c) 2005, 2006 Andrey Korotaev <unC0Rr@gmail.com>
+ *
+ * Distributed under the terms of the BSD-modified licence:
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * with the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+ * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *)
+
unit uAIAmmoTests;
interface
uses SDLh, uGears, uConsts;
-function TestBazooka(Me: PGear; Targ: TPoint; out Time: Longword; out Angle, Power: integer): integer;
-function TestGrenade(Me: PGear; Targ: TPoint; out Time: Longword; out Angle, Power: integer): integer;
-function TestShotgun(Me: PGear; Targ: TPoint; out Time: Longword; out Angle, Power: integer): integer;
+function TestBazooka(Me: PGear; Targ: TPoint; out Time: Longword; out Angle, Power: integer; out ExplX, ExplY, ExplR: integer): integer;
+function TestGrenade(Me: PGear; Targ: TPoint; out Time: Longword; out Angle, Power: integer; out ExplX, ExplY, ExplR: integer): integer;
+function TestShotgun(Me: PGear; Targ: TPoint; out Time: Longword; out Angle, Power: integer; out ExplX, ExplY, ExplR: integer): integer;
-type TAmmoTestProc = function (Me: PGear; Targ: TPoint; out Time: Longword; out Angle, Power: integer): integer;
+type TAmmoTestProc = function (Me: PGear; Targ: TPoint; out Time: Longword; out Angle, Power: integer; out ExplX, ExplY, ExplR: integer): integer;
const AmmoTests: array[TAmmoType] of TAmmoTestProc =
(
{amGrenade} TestGrenade,
@@ -30,10 +63,10 @@
Result:= abs(x1 - x2) + abs(y1 - y2)
end;
-function TestBazooka(Me: PGear; Targ: TPoint; out Time: Longword; out Angle, Power: integer): integer;
+function TestBazooka(Me: PGear; Targ: TPoint; out Time: Longword; out Angle, Power: integer; out ExplX, ExplY, ExplR: integer): integer;
var Vx, Vy, r: real;
rTime: real;
- Score: integer;
+ Score, EX, EY: integer;
function CheckTrace: integer;
var x, y, dX, dY: real;
@@ -51,6 +84,8 @@
dY:= dY + cGravity;
dec(t)
until TestColl(round(x), round(y), 5) or (t <= 0);
+ EX:= round(x);
+ EY:= round(y);
Result:= RateExplosion(Me, round(x), round(y), 101);
if Result = 0 then Result:= - Metric(Targ.X, Targ.Y, round(x), round(y)) div 64
end;
@@ -58,6 +93,7 @@
begin
Time:= 0;
rTime:= 10;
+ExplR:= 0;
Result:= BadTurn;
repeat
rTime:= rTime + 100 + random*250;
@@ -72,16 +108,19 @@
r:= sqrt(r);
Angle:= DxDy2AttackAngle(Vx, Vy);
Power:= round(r * cMaxPower);
+ ExplR:= 50;
+ ExplX:= EX;
+ ExplY:= EY;
Result:= Score
end;
end
until (rTime >= 5000)
end;
-function TestGrenade(Me: PGear; Targ: TPoint; out Time: Longword; out Angle, Power: integer): integer;
+function TestGrenade(Me: PGear; Targ: TPoint; out Time: Longword; out Angle, Power: integer; out ExplX, ExplY, ExplR: integer): integer;
const tDelta = 24;
var Vx, Vy, r: real;
- Score: integer;
+ Score, EX, EY: integer;
TestTime: Longword;
function CheckTrace: integer;
@@ -98,6 +137,8 @@
dY:= dY + cGravity;
dec(t)
until TestColl(round(x), round(y), 5) or (t = 0);
+ EX:= round(x);
+ EY:= round(y);
if t < 50 then Result:= RateExplosion(Me, round(x), round(y), 101)
else Result:= Low(integer)
end;
@@ -105,6 +146,7 @@
begin
Result:= BadTurn;
TestTime:= 0;
+ExplR:= 0;
repeat
inc(TestTime, 1000);
Vx:= (Targ.X - Me.X) / (TestTime + tDelta);
@@ -119,13 +161,16 @@
Angle:= DxDy2AttackAngle(Vx, Vy);
Power:= round(r * cMaxPower);
Time:= TestTime;
+ ExplR:= 50;
+ ExplX:= EX;
+ ExplY:= EY;
Result:= Score
end;
end
until (TestTime = 5000)
end;
-function TestShotgun(Me: PGear; Targ: TPoint; out Time: Longword; out Angle, Power: integer): integer;
+function TestShotgun(Me: PGear; Targ: TPoint; out Time: Longword; out Angle, Power: integer; out ExplX, ExplY, ExplR: integer): integer;
var Vx, Vy, x, y: real;
begin
if Metric(round(Me.X), round(Me.Y), Targ.X, Targ.Y) < 80 then
@@ -135,6 +180,7 @@
end;
Time:= 0;
Power:= 1;
+ExplR:= 0;
Vx:= (Targ.X - Me.X)/1024;
Vy:= (Targ.Y - Me.Y)/1024;
x:= Me.X;
--- a/hedgewars/uAIMisc.pas Fri Jun 23 20:02:41 2006 +0000
+++ b/hedgewars/uAIMisc.pas Wed Jun 28 18:27:42 2006 +0000
@@ -1,3 +1,36 @@
+(*
+ * Hedgewars, a worms-like game
+ * Copyright (c) 2005, 2006 Andrey Korotaev <unC0Rr@gmail.com>
+ *
+ * Distributed under the terms of the BSD-modified licence:
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * with the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+ * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *)
+
unit uAIMisc;
interface
uses SDLh, uConsts, uGears;
@@ -13,6 +46,7 @@
procedure FillTargets;
procedure FillBonuses(isAfterAttack: boolean);
+procedure AwareOfExplosion(x, y, r: integer);
function RatePlace(Gear: PGear): integer;
function DxDy2AttackAngle(const _dY, _dX: Extended): integer;
function TestColl(x, y, r: integer): boolean;
@@ -36,6 +70,9 @@
Count: Longword;
ar: array[0..Pred(MAXBONUS)] of TBonus;
end;
+ KnownExplosion: record
+ X, Y, Radius: integer
+ end = (X: 0; Y: 0; Radius: 0);
procedure FillTargets;
var t: PTeam;
@@ -94,7 +131,20 @@
end;
end;
Gear:= Gear.NextGear
- end
+ end;
+if isAfterAttack and (KnownExplosion.Radius > 0) then
+ with KnownExplosion do
+ begin
+ AddBonus(X, Y, Radius, -Radius);
+ Radius:= 0
+ end
+end;
+
+procedure AwareOfExplosion(x, y, r: integer);
+begin
+KnownExplosion.X:= x;
+KnownExplosion.Y:= y;
+KnownExplosion.Radius:= r
end;
function RatePlace(Gear: PGear): integer;
@@ -175,7 +225,7 @@
if (Gear.State and gstFalling) <> 0 then
begin
Gear.dY:= Gear.dY + cGravity;
- if Gear.dY > 0.35 then exit;
+ if Gear.dY > 0.40 then exit;
Gear.Y:= Gear.Y + Gear.dY;
if TestCollisionYwithGear(Gear, 1) then
begin
--- a/hedgewars/uStore.pas Fri Jun 23 20:02:41 2006 +0000
+++ b/hedgewars/uStore.pas Wed Jun 28 18:27:42 2006 +0000
@@ -462,7 +462,7 @@
procedure AddProgress;
const Step: Longword = 0;
ProgrSurf: PSDL_Surface = nil;
- MaxCalls = 10; // MaxCalls should be the count of calls to AddProgress to prevent memory leakage
+ MaxCalls = 11; // MaxCalls should be the count of calls to AddProgress to prevent memory leakage
var r: TSDL_Rect;
begin
if Step = 0 then
@@ -476,7 +476,7 @@
r.x:= 0;
r.w:= 32;
r.h:= 32;
-r.y:= Step * 32;
+r.y:= (Step mod 10) * 32;
DrawFromRect(cScreenWidth div 2 - 16, cScreenHeight div 2 - 16, @r, ProgrSurf, SDLPrimSurface);
SDL_Flip(SDLPrimSurface);
inc(Step);
--- a/hedgewars/uWorld.pas Fri Jun 23 20:02:41 2006 +0000
+++ b/hedgewars/uWorld.pas Wed Jun 28 18:27:42 2006 +0000
@@ -318,8 +318,8 @@
exit
end
else begin
- CursorPoint.x:= (CursorPoint.x * 3 + (round(FollowGear.X + Sign(FollowGear.dX) * 100) + WorldDx)) div 4;
- CursorPoint.y:= (CursorPoint.y * 3 + (round(FollowGear.Y) + WorldDy)) div 4
+ CursorPoint.x:= (CursorPoint.x * 7 + (round(FollowGear.X + Sign(FollowGear.dX) * 100) + WorldDx)) div 8;
+ CursorPoint.y:= (CursorPoint.y * 7 + (round(FollowGear.Y) + WorldDy)) div 8
end;
if ((CursorPoint.X = prevPoint.X)and(CursorPoint.Y = prevpoint.Y)) then exit;