--- a/hedgewars/GSHandlers.inc Fri Sep 09 21:45:31 2005 +0000
+++ b/hedgewars/GSHandlers.inc Sun Sep 11 11:45:01 2005 +0000
@@ -590,7 +590,7 @@
if (Gear.Tag = 0) then
begin
Gear.Tag:= 10;
- if isGearNear(Gear, gtHedgehog, 46, 32) then Gear.State:= Gear.State or gstAttacking
+ if CheckGearNear(Gear, gtHedgehog, 46, 32) <> nil then Gear.State:= Gear.State or gstAttacking
end else dec(Gear.Tag)
end else // gstAttacking <> 0
begin
@@ -607,8 +607,15 @@
if TurnTimeLeft = 0 then Gear.State:= Gear.State or gsttmpFlag;
end;
+////////////////////////////////////////////////////////////////////////////////
procedure doStepCase(Gear: PGear);
begin
+if (Gear.Message and gm_Destroy) > 0 then
+ begin
+ DeleteGear(Gear);
+ exit
+ end;
+
if (Gear.dY <> 0) or (not TestCollisionY(Gear, 1)) then
begin
AllInactive:= false;
@@ -627,17 +634,6 @@
if (Gear.CollIndex = High(Longword)) and (Gear.dY = 0) then AddGearCR(Gear)
else if (Gear.CollIndex < High(Longword)) and (Gear.dY <> 0) then DeleteCR(Gear);
-if (Gear.Tag = 0) then
- begin
- Gear.Tag:= 10;
- if isGearNear(Gear, gtHedgehog, 25, 25) then
- begin
- ;//give ammo to hedgehog
- DeleteGear(Gear);
- SetAllToActive;
- end;
- end else dec(Gear.Tag);
-
if Gear.Damage > 0 then
begin
DeleteGear(Gear);
--- a/hedgewars/HHHandlers.inc Fri Sep 09 21:45:31 2005 +0000
+++ b/hedgewars/HHHandlers.inc Sun Sep 11 11:45:01 2005 +0000
@@ -35,6 +35,7 @@
////////////////////////////////////////////////////////////////////////////////
procedure doStepHedgehogDriven(Gear: PGear);
const StepTicks: LongWord = 0;
+var t: PGear;
begin
if isinMultiShoot and (Gear.Damage = 0) then exit;
AllInactive:= false;
@@ -47,6 +48,14 @@
Gear.State:= Gear.State and not gstHHJumping;
exit
end;
+
+// check for case with ammo
+t:= CheckGearNear(Gear, gtCase, 25, 25);
+if t <> nil then
+ begin
+ t.Message:= gm_Destroy;
+ ; // take ammo from it
+ end;
if CurAmmoGear <> nil then
begin
--- a/hedgewars/uGears.pas Fri Sep 09 21:45:31 2005 +0000
+++ b/hedgewars/uGears.pas Sun Sep 11 11:45:01 2005 +0000
@@ -88,7 +88,8 @@
procedure DeleteGear(Gear: PGear); forward;
procedure doMakeExplosion(X, Y, Radius: integer; Mask: LongWord); forward;
-function isGearNear(Gear: PGear; Kind: TGearType; rX, rY: integer): boolean; forward;
+function CheckGearNear(Gear: PGear; Kind: TGearType; rX, rY: integer): PGear; forward;
+procedure SpawnBoxOfSmth; forward;
{$INCLUDE GSHandlers.inc}
{$INCLUDE HHHandlers.inc}
@@ -257,6 +258,7 @@
procedure ProcessGears;
const delay: integer = cInactDelay;
+ step: (stDelay, stChDmg, stSpawn, stNTurn) = stDelay;
var Gear, t: PGear;
{$IFDEF COUNTTICKS}
tickcntA, tickcntB: LongWord;
@@ -283,17 +285,27 @@
if Gear.Active then Gear.doStep(Gear);
end;
if AllInactive then
- if (delay > 0)and not isInMultiShoot then
- begin
- if delay = cInactDelay then SetAllToActive;
- dec(delay)
- end
- else begin
- delay:= cInactDelay;
- if CheckNoDamage then
- if isInMultiShoot then isInMultiShoot:= false
- else ParseCommand('/nextturn');
- end;
+ case step of
+ stDelay: begin
+ dec(delay);
+ if delay = 0 then
+ begin
+ inc(step);
+ delay:= cInactDelay
+ end
+ end;
+ stChDmg: if CheckNoDamage then inc(step) else step:= stDelay;
+ stSpawn: begin
+ if not isInMultiShoot then SpawnBoxOfSmth;
+ inc(step)
+ end;
+ stNTurn: begin
+ if isInMultiShoot then isInMultiShoot:= false
+ else ParseCommand('/nextturn');
+ step:= Low(step)
+ end;
+ end;
+
if TurnTimeLeft > 0 then
if CurrentTeam <> nil then
if CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear <> nil then
@@ -541,7 +553,7 @@
end
end;
-function isGearNear(Gear: PGear; Kind: TGearType; rX, rY: integer): boolean;
+function CheckGearNear(Gear: PGear; Kind: TGearType; rX, rY: integer): PGear;
var t: PGear;
begin
t:= GearsList;
@@ -552,12 +564,16 @@
if (t <> Gear) and (t.Kind = Kind) then
if sqr(Gear.X - t.X) / rX + sqr(Gear.Y - t.Y) / rY <= 1 then
begin
- Result:= true;
+ Result:= t;
exit
end;
t:= t.NextGear
end;
-Result:= false
+Result:= nil
+end;
+
+procedure SpawnBoxOfSmth;
+begin
end;
initialization