Better blowtorch
authorunc0rr
Tue, 19 Dec 2006 17:20:14 +0000
changeset 305 1c1cd66ffcdc
parent 304 8096e69e839e
child 306 7b61834edcf6
Better blowtorch
hedgewars/GSHandlers.inc
hedgewars/uConsts.pas
hedgewars/uGears.pas
--- a/hedgewars/GSHandlers.inc	Sun Dec 17 20:50:49 2006 +0000
+++ b/hedgewars/GSHandlers.inc	Tue Dec 19 17:20:14 2006 +0000
@@ -424,10 +424,11 @@
 end;
 
 ////////////////////////////////////////////////////////////////////////////////
+var BTPrevAngle, BTSteps: Longword;
 
 procedure doStepBlowTorchWork(Gear: PGear);
 var HHGear: PGear;
-    yy: Double;
+    b: boolean;
 begin
 AllInactive:= false;
 dec(Gear.Timer);
@@ -435,18 +436,42 @@
 
 HedgehogChAngle(HHGear);
 
+b:= false;
+
+if (HHGear.Angle <> BTPrevAngle) then
+   begin
+   Gear.dX:= hwSign(HHGear.dX) * Sin(HHGear.Angle * pi / cMaxAngle) * 0.5;
+   Gear.dY:= Cos(HHGear.Angle * pi / cMaxAngle) * (-0.5);
+   BTPrevAngle:= HHGear.Angle;
+   b:= true
+   end;
+
 if Gear.Timer mod cHHStepTicks = 0 then
    begin
-   yy:= Cos(HHGear.Angle*pi/cMaxAngle) * (-0.5);
-   DrawTunnel(HHGear.X, HHGear.Y - 2 + yy * cHHRadius,
-              Gear.dX, yy,
-              cHHRadius * 3, cHHRadius * 2 + 2);
+   b:= true;
    if Gear.dX < 0 then HHGear.Message:= (HHGear.Message or gm_Left) and not gm_Right
                   else HHGear.Message:= (HHGear.Message or gm_Right) and not gm_Left;
    HedgehogStep(HHGear);
+
+   inc(BTSteps);
+   if BTSteps = 8 then
+      begin
+      BTSteps:= 0;
+      Gear.X:= HHGear.X + Gear.dX * cHHRadius * 2;
+      Gear.Y:= HHGear.Y + Gear.dY * cHHRadius * 2;
+      HHGear.State:= HHGear.State or gstNoDamage;
+      AmmoShove(Gear, 3, 14);
+      HHGear.State:= HHGear.State and not gstNoDamage
+      end;
+
    if (HHGear.State and gstFalling) <> 0 then Gear.Timer:= 0
    end;
-   
+
+if b then
+   DrawTunnel(HHGear.X - Gear.dX * cHHRadius, HHGear.Y - 4 - Gear.dY * cHHRadius + abs(Gear.dY) * 7,
+              Gear.dX, Gear.dY,
+              cHHRadius * 6, cHHRadius * 2 + 6);
+
 if (Gear.Timer = 0) or ((HHGear.Message and gm_Attack) <> 0) then
    begin
    HHGear.Message:= 0;
@@ -458,6 +483,8 @@
 procedure doStepBlowTorch(Gear: PGear);
 var HHGear: PGear;
 begin
+BTPrevAngle:= High(Longword);
+BTSteps:= 0;
 HHGear:= PHedgehog(Gear.Hedgehog).Gear;
 HHGear.State:= HHGear.State and not gstAttacking;
 HHGear.Message:= 0;
--- a/hedgewars/uConsts.pas	Sun Dec 17 20:50:49 2006 +0000
+++ b/hedgewars/uConsts.pas	Tue Dec 19 17:20:14 2006 +0000
@@ -170,6 +170,7 @@
       EXPLAutoSound         = $00000002;
       EXPLNoDamage          = $00000004;
       EXPLDoNotTouchHH      = $00000008;
+      EXPLDontDraw          = $00000010;
 
       posCaseAmmo    = $00000001;
       posCaseHealth  = $00000002;
@@ -454,8 +455,8 @@
                                           AmmoType: amBlowTorch);
                                    Slot: 6;
                                    TimeAfterTurn: 3000;
-                                   minAngle: 510;
-                                   maxAngle: 1400));
+                                   minAngle: 768;
+                                   maxAngle: 1280));
 
 implementation
 
--- a/hedgewars/uGears.pas	Sun Dec 17 20:50:49 2006 +0000
+++ b/hedgewars/uGears.pas	Tue Dec 19 17:20:14 2006 +0000
@@ -266,6 +266,7 @@
                 Result.Radius:= 10;
                 end;
    gtBlowTorch: begin
+                Result.Radius:= cHHRadius + 6;
                 Result.Timer:= 7500;
                 end;
      end;
@@ -633,7 +634,7 @@
 begin
 TargetPoint.X:= NoPointX;
 {$IFDEF DEBUGFILE}if Radius > 3 then AddFileLog('Explosion: at (' + inttostr(x) + ',' + inttostr(y) + ')');{$ENDIF}
-DrawExplosion(X, Y, Radius);
+if (Mask and EXPLDontDraw) = 0 then DrawExplosion(X, Y, Radius);
 if Radius = 50 then AddGear(X, Y, gtExplosion, 0);
 if (Mask and EXPLAutoSound)<>0 then PlaySound(sndExplosion);
 if (Mask and EXPLAllDamageInRadius)=0 then Radius:= Radius shl 1;