More stable blowtorch:
- Isn't affected by flying around hedgehogs
- Doesn't turn off when hedgehog falls a bit
--- a/hedgewars/GSHandlers.inc Thu Dec 04 21:17:03 2008 +0000
+++ b/hedgewars/GSHandlers.inc Thu Dec 04 21:59:25 2008 +0000
@@ -542,7 +542,8 @@
procedure doStepBlowTorchWork(Gear: PGear);
var HHGear: PGear;
- b: boolean;
+ b: boolean;
+ prevX: LongInt;
begin
AllInactive:= false;
dec(Gear^.Timer);
@@ -553,36 +554,49 @@
b:= false;
if abs(LongInt(HHGear^.Angle) - BTPrevAngle) > 7 then
- begin
- Gear^.dX:= SignAs(AngleSin(HHGear^.Angle) * _0_5, HHGear^.dX);
- Gear^.dY:= AngleCos(HHGear^.Angle) * ( - _0_5);
- BTPrevAngle:= HHGear^.Angle;
- b:= true
- end;
+ begin
+ Gear^.dX:= SignAs(AngleSin(HHGear^.Angle) * _0_5, HHGear^.dX);
+ Gear^.dY:= AngleCos(HHGear^.Angle) * ( - _0_5);
+ BTPrevAngle:= HHGear^.Angle;
+ b:= true
+ end;
+
+if ((HHGear^.State and gstMoving) <> 0) then
+ begin
+ doStepHedgehogMoving(HHGear);
+ if (HHGear^.Damage > 0) then Gear^.Timer:= 0
+ end;
if Gear^.Timer mod cHHStepTicks = 0 then
- begin
- b:= true;
- if Gear^.dX.isNegative then HHGear^.Message:= (HHGear^.Message or gm_Left) and not gm_Right
- else HHGear^.Message:= (HHGear^.Message or gm_Right) and not gm_Left;
-
- HHGear^.State:= HHGear^.State and not gstAttacking;
- HedgehogStep(HHGear);
- HHGear^.State:= HHGear^.State or gstAttacking;
+ begin
+ b:= true;
+ if Gear^.dX.isNegative then
+ HHGear^.Message:= (HHGear^.Message or gm_Left) and not gm_Right
+ else
+ HHGear^.Message:= (HHGear^.Message or gm_Right) and not gm_Left;
- inc(BTSteps);
- if BTSteps = 7 then
- begin
- BTSteps:= 0;
- Gear^.X:= HHGear^.X + Gear^.dX * (cHHRadius + cBlowTorchC);
- Gear^.Y:= HHGear^.Y + Gear^.dY * (cHHRadius + cBlowTorchC);
- HHGear^.State:= HHGear^.State or gstNoDamage;
- AmmoShove(Gear, 2, 10);
- HHGear^.State:= HHGear^.State and not gstNoDamage
- end;
+ if ((HHGear^.State and gstMoving) = 0) then
+ begin
+ HHGear^.State:= HHGear^.State and not gstAttacking;
+ prevX:= hwRound(HHGear^.X);
+
+ HedgehogStep(HHGear);
+
+ if (prevX = hwRound(HHGear^.X)) then HHGear^.X:= HHGear^.X + SignAs(_1, HHGear^.dX);
+ HHGear^.State:= HHGear^.State or gstAttacking
+ end;
- if (HHGear^.State and gstMoving) <> 0 then Gear^.Timer:= 0
- end;
+ inc(BTSteps);
+ if BTSteps = 7 then
+ begin
+ BTSteps:= 0;
+ Gear^.X:= HHGear^.X + Gear^.dX * (cHHRadius + cBlowTorchC);
+ Gear^.Y:= HHGear^.Y + Gear^.dY * (cHHRadius + cBlowTorchC);
+ HHGear^.State:= HHGear^.State or gstNoDamage;
+ AmmoShove(Gear, 2, 10);
+ HHGear^.State:= HHGear^.State and not gstNoDamage
+ end;
+ end;
if b then
DrawTunnel(HHGear^.X - Gear^.dX * cHHRadius, HHGear^.Y - _4 - Gear^.dY * cHHRadius + hwAbs(Gear^.dY) * 7,
@@ -590,11 +604,12 @@
cHHRadius * 5, cHHRadius * 2 + 7);
if (Gear^.Timer = 0) or ((HHGear^.Message and gm_Attack) <> 0) then
- begin
- HHGear^.Message:= 0;
- DeleteGear(Gear);
- AfterAttack
- end
+ begin
+ HHGear^.Message:= 0;
+ HHGear^.State:= HHGear^.State and (not gstNotKickable);
+ DeleteGear(Gear);
+ AfterAttack
+ end
end;
procedure doStepBlowTorch(Gear: PGear);
@@ -604,6 +619,7 @@
BTSteps:= 0;
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear;
HHGear^.Message:= 0;
+HHGear^.State:= HHGear^.State or gstNotKickable;
Gear^.doStep:= @doStepBlowTorchWork
end;
@@ -1111,7 +1127,7 @@
end else begin
if Gear^.Timer > 0 then dec(Gear^.Timer)
else begin
- Gear^.Radius:= 5;
+ Gear^.Radius:= 7;
AmmoShove(Gear, 3, 100);
Gear^.Radius:= 1;
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 4, EXPLNoDamage);
--- a/hedgewars/HHHandlers.inc Thu Dec 04 21:17:03 2008 +0000
+++ b/hedgewars/HHHandlers.inc Thu Dec 04 21:59:25 2008 +0000
@@ -355,8 +355,8 @@
if not (TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX))
or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1;
end;
+
if not TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then Gear^.X:= Gear^.X + SignAs(_1, Gear^.dX);
-
SetAllHHToActive;
if not TestCollisionYwithGear(Gear, 1) then
--- a/hedgewars/uCollisions.pas Thu Dec 04 21:17:03 2008 +0000
+++ b/hedgewars/uCollisions.pas Thu Dec 04 21:59:25 2008 +0000
@@ -203,7 +203,7 @@
if (Gear <> cGear) and
(sqr(mx - x) + sqr(my - y) <= sqr(Radius + Gear^.Radius + 2)) and
((mx > x) xor (Dir > 0)) then
- if (cGear^.Kind in [gtHedgehog, gtMine]) then
+ if (cGear^.Kind in [gtHedgehog, gtMine]) and ((Gear^.State and gstNotKickable) = 0) then
begin
with cGear^ do
begin
@@ -255,7 +255,7 @@
if (Gear <> cGear) and
(sqr(mx - x) + sqr(my - y) <= sqr(Radius + Gear^.Radius + 2)) and
((my > y) xor (Dir > 0)) then
- if (cGear^.Kind in [gtHedgehog, gtMine]) then
+ if (cGear^.Kind in [gtHedgehog, gtMine]) and ((Gear^.State and gstNotKickable) = 0) then
begin
with cGear^ do
begin
--- a/hedgewars/uConsts.pas Thu Dec 04 21:17:03 2008 +0000
+++ b/hedgewars/uConsts.pas Thu Dec 04 21:59:25 2008 +0000
@@ -191,6 +191,7 @@
gstHHDeath = $00008000;
gstWinner = $00010000;
gstWait = $00020000;
+ gstNotKickable = $00040000;
gm_Left = $00000001;
gm_Right = $00000002;
--- a/hedgewars/uGears.pas Thu Dec 04 21:17:03 2008 +0000
+++ b/hedgewars/uGears.pas Thu Dec 04 21:59:25 2008 +0000
@@ -95,6 +95,7 @@
procedure AfterAttack; forward;
procedure FindPlace(var Gear: PGear; withFall: boolean; Left, Right: LongInt); forward;
procedure HedgehogStep(Gear: PGear); forward;
+procedure doStepHedgehogMoving(Gear: PGear); forward;
procedure HedgehogChAngle(Gear: PGear); forward;
procedure ShotgunShot(Gear: PGear); forward;