hedgewars/GSHandlers.inc
changeset 305 1c1cd66ffcdc
parent 304 8096e69e839e
child 306 7b61834edcf6
equal deleted inserted replaced
304:8096e69e839e 305:1c1cd66ffcdc
   422 doStepPickHammerWork(Gear);
   422 doStepPickHammerWork(Gear);
   423 Gear.doStep:= doStepPickHammerWork
   423 Gear.doStep:= doStepPickHammerWork
   424 end;
   424 end;
   425 
   425 
   426 ////////////////////////////////////////////////////////////////////////////////
   426 ////////////////////////////////////////////////////////////////////////////////
       
   427 var BTPrevAngle, BTSteps: Longword;
   427 
   428 
   428 procedure doStepBlowTorchWork(Gear: PGear);
   429 procedure doStepBlowTorchWork(Gear: PGear);
   429 var HHGear: PGear;
   430 var HHGear: PGear;
   430     yy: Double;
   431     b: boolean;
   431 begin
   432 begin
   432 AllInactive:= false;
   433 AllInactive:= false;
   433 dec(Gear.Timer);
   434 dec(Gear.Timer);
   434 HHGear:= PHedgehog(Gear.Hedgehog).Gear;
   435 HHGear:= PHedgehog(Gear.Hedgehog).Gear;
   435 
   436 
   436 HedgehogChAngle(HHGear);
   437 HedgehogChAngle(HHGear);
   437 
   438 
       
   439 b:= false;
       
   440 
       
   441 if (HHGear.Angle <> BTPrevAngle) then
       
   442    begin
       
   443    Gear.dX:= hwSign(HHGear.dX) * Sin(HHGear.Angle * pi / cMaxAngle) * 0.5;
       
   444    Gear.dY:= Cos(HHGear.Angle * pi / cMaxAngle) * (-0.5);
       
   445    BTPrevAngle:= HHGear.Angle;
       
   446    b:= true
       
   447    end;
       
   448 
   438 if Gear.Timer mod cHHStepTicks = 0 then
   449 if Gear.Timer mod cHHStepTicks = 0 then
   439    begin
   450    begin
   440    yy:= Cos(HHGear.Angle*pi/cMaxAngle) * (-0.5);
   451    b:= true;
   441    DrawTunnel(HHGear.X, HHGear.Y - 2 + yy * cHHRadius,
       
   442               Gear.dX, yy,
       
   443               cHHRadius * 3, cHHRadius * 2 + 2);
       
   444    if Gear.dX < 0 then HHGear.Message:= (HHGear.Message or gm_Left) and not gm_Right
   452    if Gear.dX < 0 then HHGear.Message:= (HHGear.Message or gm_Left) and not gm_Right
   445                   else HHGear.Message:= (HHGear.Message or gm_Right) and not gm_Left;
   453                   else HHGear.Message:= (HHGear.Message or gm_Right) and not gm_Left;
   446    HedgehogStep(HHGear);
   454    HedgehogStep(HHGear);
       
   455 
       
   456    inc(BTSteps);
       
   457    if BTSteps = 8 then
       
   458       begin
       
   459       BTSteps:= 0;
       
   460       Gear.X:= HHGear.X + Gear.dX * cHHRadius * 2;
       
   461       Gear.Y:= HHGear.Y + Gear.dY * cHHRadius * 2;
       
   462       HHGear.State:= HHGear.State or gstNoDamage;
       
   463       AmmoShove(Gear, 3, 14);
       
   464       HHGear.State:= HHGear.State and not gstNoDamage
       
   465       end;
       
   466 
   447    if (HHGear.State and gstFalling) <> 0 then Gear.Timer:= 0
   467    if (HHGear.State and gstFalling) <> 0 then Gear.Timer:= 0
   448    end;
   468    end;
   449    
   469 
       
   470 if b then
       
   471    DrawTunnel(HHGear.X - Gear.dX * cHHRadius, HHGear.Y - 4 - Gear.dY * cHHRadius + abs(Gear.dY) * 7,
       
   472               Gear.dX, Gear.dY,
       
   473               cHHRadius * 6, cHHRadius * 2 + 6);
       
   474 
   450 if (Gear.Timer = 0) or ((HHGear.Message and gm_Attack) <> 0) then
   475 if (Gear.Timer = 0) or ((HHGear.Message and gm_Attack) <> 0) then
   451    begin
   476    begin
   452    HHGear.Message:= 0;
   477    HHGear.Message:= 0;
   453    DeleteGear(Gear);
   478    DeleteGear(Gear);
   454    AfterAttack
   479    AfterAttack
   456 end;
   481 end;
   457 
   482 
   458 procedure doStepBlowTorch(Gear: PGear);
   483 procedure doStepBlowTorch(Gear: PGear);
   459 var HHGear: PGear;
   484 var HHGear: PGear;
   460 begin
   485 begin
       
   486 BTPrevAngle:= High(Longword);
       
   487 BTSteps:= 0;
   461 HHGear:= PHedgehog(Gear.Hedgehog).Gear;
   488 HHGear:= PHedgehog(Gear.Hedgehog).Gear;
   462 HHGear.State:= HHGear.State and not gstAttacking;
   489 HHGear.State:= HHGear.State and not gstAttacking;
   463 HHGear.Message:= 0;
   490 HHGear.Message:= 0;
   464 Gear.doStep:= doStepBlowTorchWork
   491 Gear.doStep:= doStepBlowTorchWork
   465 end;
   492 end;