hedgewars/GSHandlers.inc
changeset 3733 447860ec0093
parent 3728 9478d13b2f9b
child 3751 a70c61c076ae
equal deleted inserted replaced
3719:9b38c2c99c48 3733:447860ec0093
   852         HHGear^.State := HHGear^.State and not gstNoDamage
   852         HHGear^.State := HHGear^.State and not gstNoDamage
   853     end;
   853     end;
   854 
   854 
   855     if (Gear^.Timer mod 47) = 0 then
   855     if (Gear^.Timer mod 47) = 0 then
   856     begin
   856     begin
       
   857         for i:= 0 to 1 do
       
   858             AddVisualGear(hwRound(Gear^.X) - 5 + Random(10), hwRound(Gear^.Y) + 12, vgtDust);
   857         i := hwRound(Gear^.X) - Gear^.Radius - LongInt(GetRandom(2));
   859         i := hwRound(Gear^.X) - Gear^.Radius - LongInt(GetRandom(2));
   858         ei := hwRound(Gear^.X) + Gear^.Radius + LongInt(GetRandom(2));
   860         ei := hwRound(Gear^.X) + Gear^.Radius + LongInt(GetRandom(2));
   859         while i <= ei do
   861         while i <= ei do
   860         begin
   862         begin
   861             DrawExplosion(i, hwRound(Gear^.Y) + 3, 3);
   863             DrawExplosion(i, hwRound(Gear^.Y) + 3, 3);
  1471     begin
  1473     begin
  1472         AllInactive := false;
  1474         AllInactive := false;
  1473         if (Gear^.Timer and $FF) = 0 then PlaySound(sndMineTick);
  1475         if (Gear^.Timer and $FF) = 0 then PlaySound(sndMineTick);
  1474         if Gear^.Timer = 0 then
  1476         if Gear^.Timer = 0 then
  1475         begin
  1477         begin
  1476             doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound);
  1478             doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound);
  1477             DeleteGear(Gear);
  1479             DeleteGear(Gear);
  1478             exit
  1480             exit
  1479         end;
  1481         end;
  1480         dec(Gear^.Timer);
  1482         dec(Gear^.Timer);
  1481     end
  1483     end
  3577 end;
  3579 end;
  3578 
  3580 
  3579 procedure doStepPiano(Gear: PGear);
  3581 procedure doStepPiano(Gear: PGear);
  3580 var 
  3582 var 
  3581     r0, r1: LongInt;
  3583     r0, r1: LongInt;
       
  3584     odY: hwFloat;
  3582 begin
  3585 begin
  3583     AllInactive := false;
  3586     AllInactive := false;
  3584     if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil) and ((CurrentHedgehog^.Gear^.
  3587     if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil) and ((CurrentHedgehog^.Gear^.
  3585        Message and gm_Slot) <> 0) then
  3588        Message and gm_Slot) <> 0) then
  3586     begin
  3589     begin
  3598         AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtNote);
  3601         AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtNote);
  3599         CurrentHedgehog^.Gear^.MsgParam := 0;
  3602         CurrentHedgehog^.Gear^.MsgParam := 0;
  3600         CurrentHedgehog^.Gear^.Message := CurrentHedgehog^.Gear^.Message and not gm_Slot;
  3603         CurrentHedgehog^.Gear^.Message := CurrentHedgehog^.Gear^.Message and not gm_Slot;
  3601     end;
  3604     end;
  3602 
  3605 
  3603     if ((Gear^.Pos = 3) and ((GameFlags and gfSolidLand) <> 0)) or (Gear^.Pos = 20) then
  3606     if (*((Gear^.Pos = 3) and ((GameFlags and gfSolidLand) <> 0)) or*) (Gear^.Pos = 5) then
  3604         // bounce up to 20 times (3 times on gameflagged solid land) before dropping past landscape
  3607         // bounce up to 10 times (3 times on gameflagged solid land) before dropping past landscape
  3605     begin
  3608     begin
  3606         Gear^.dY := Gear^.dY + cGravity * 3;
  3609         Gear^.dY := Gear^.dY + cGravity * 2;
  3607         Gear^.Y := Gear^.Y + Gear^.dY;
  3610         Gear^.Y := Gear^.Y + Gear^.dY;
  3608         CheckGearDrowning(Gear);
  3611         CheckGearDrowning(Gear);
  3609         if (Gear^.State and gstDrowning) <> 0 then
  3612         if (Gear^.State and gstDrowning) <> 0 then
  3610         begin
  3613         begin
  3611             if CurrentHedgehog^.Gear <> nil then
  3614             if CurrentHedgehog^.Gear <> nil then
  3619             ResumeMusic
  3622             ResumeMusic
  3620         end;
  3623         end;
  3621         exit
  3624         exit
  3622     end;
  3625     end;
  3623 
  3626 
       
  3627     odY:= Gear^.dY;
  3624     doStepFallingGear(Gear);
  3628     doStepFallingGear(Gear);
  3625 
  3629 
  3626     if (Gear^.State and gstDrowning) <> 0 then
  3630     if (Gear^.State and gstDrowning) <> 0 then
  3627     begin
  3631     begin
  3628         if CurrentHedgehog^.Gear <> nil then
  3632         if CurrentHedgehog^.Gear <> nil then
  3642             doMakeExplosion(hwRound(Gear^.X) - 30 - r0, hwRound(Gear^.Y) + 40, 40 + r1, 0);
  3646             doMakeExplosion(hwRound(Gear^.X) - 30 - r0, hwRound(Gear^.Y) + 40, 40 + r1, 0);
  3643             doMakeExplosion(hwRound(Gear^.X) + 30 + r1, hwRound(Gear^.Y) + 40, 40 + r0, 0);
  3647             doMakeExplosion(hwRound(Gear^.X) + 30 + r1, hwRound(Gear^.Y) + 40, 40 + r0, 0);
  3644             doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 80 + r0, EXPLAutoSound);
  3648             doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 80 + r0, EXPLAutoSound);
  3645             for r0:= 0 to 4 do
  3649             for r0:= 0 to 4 do
  3646                 AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtNote);
  3650                 AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtNote);
  3647             Gear^.dY := -_1;
  3651             Gear^.dY := odY * -1 + cGravity * 2;
  3648             Gear^.Pos := Gear^.Pos + 1;
  3652             Gear^.Pos := Gear^.Pos + 1;
  3649         end
  3653         end
  3650     else
  3654     else
  3651         Gear^.dY := Gear^.dY + cGravity * 2;
  3655         Gear^.dY := Gear^.dY + cGravity * 2;
  3652     // let it fall faster so itdoesn't take too long for the whole attack
  3656     // let it fall faster so itdoesn't take too long for the whole attack
  3880     AllInactive:= false;
  3884     AllInactive:= false;
  3881 end;
  3885 end;
  3882 
  3886 
  3883 ////////////////////////////////////////////////////////////////////////////////
  3887 ////////////////////////////////////////////////////////////////////////////////
  3884 procedure doStepHammer(Gear: PGear);
  3888 procedure doStepHammer(Gear: PGear);
  3885 var HHGear, tmp: PGear;
  3889 var HHGear, tmp, tmp2: PGear;
  3886          t: PGearArray;
  3890          t: PGearArray;
  3887          i: LongInt;
  3891          i: LongInt;
  3888          dust: PVisualGear;
       
  3889 begin
  3892 begin
  3890 HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear;
  3893 HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear;
  3891 HHGear^.State:= HHGear^.State or gstNoDamage;
  3894 HHGear^.State:= HHGear^.State or gstNoDamage;
  3892 DeleteCI(HHGear);
  3895 DeleteCI(HHGear);
  3893 
  3896 
  3894 t:= CheckGearsCollision(Gear);
  3897 t:= CheckGearsCollision(Gear);
       
  3898 
       
  3899 for i:= 5 downto 0 do
       
  3900     AddVisualGear(hwRound(Gear^.X) - 5 + Random(10), hwRound(Gear^.Y) + 12, vgtDust);
       
  3901 
  3895 i:= t^.Count;
  3902 i:= t^.Count;
  3896 while i > 0 do
  3903 while i > 0 do
  3897     begin
  3904     begin
  3898     dec(i);
  3905     dec(i);
  3899     tmp:= t^.ar[i];
  3906     tmp:= t^.ar[i];
  3900     if (tmp^.State and gstNoDamage) = 0 then
  3907     if (tmp^.State and gstNoDamage) = 0 then
  3901         if (tmp^.Kind = gtHedgehog) then
  3908         if (tmp^.Kind = gtHedgehog) then
  3902             begin
  3909             begin
  3903             //tmp^.State:= tmp^.State or gstFlatened;
  3910             //tmp^.State:= tmp^.State or gstFlatened;
  3904             ApplyDamage(tmp, tmp^.Health div 2, dsUnknown);
  3911             ApplyDamage(tmp, tmp^.Health div 3, dsUnknown);
  3905             DrawTunnel(tmp^.X, tmp^.Y - _1, _0, _0_5, cHHRadius * 6, cHHRadius * 3);
  3912             //DrawTunnel(tmp^.X, tmp^.Y - _1, _0, _0_5, cHHRadius * 6, cHHRadius * 3);
  3906             for i:= 5 downto 0 do
  3913             tmp2:= AddGear(hwRound(tmp^.X), hwRound(tmp^.Y), gtHammerHit, 0, _0, _0, 0);
  3907                 dust := AddVisualGear(hwRound(tmp^.X) - 5 + Random(10), hwRound(tmp^.Y) + 12, vgtDust);
  3914             tmp2^.Hedgehog:= tmp^.Hedgehog;
  3908             SetAllToActive
  3915             SetAllToActive
  3909             end
  3916             end
  3910         else
  3917         else
  3911             begin
  3918             begin
  3912             end
  3919             end
  3914 
  3921 
  3915 HHGear^.State:= HHGear^.State and not gstNoDamage;
  3922 HHGear^.State:= HHGear^.State and not gstNoDamage;
  3916 Gear^.Timer:= 250;
  3923 Gear^.Timer:= 250;
  3917 Gear^.doStep:= @doStepIdle
  3924 Gear^.doStep:= @doStepIdle
  3918 end;
  3925 end;
       
  3926 
       
  3927 ////////////////////////////////////////////////////////////////////////////////
       
  3928 procedure doStepHammerHitWork(Gear: PGear);
       
  3929 var 
       
  3930     i, ei: LongInt;
       
  3931     HHGear: PGear;
       
  3932 begin
       
  3933     AllInactive := false;
       
  3934     HHGear := PHedgehog(Gear^.Hedgehog)^.Gear;
       
  3935     dec(Gear^.Timer);
       
  3936     if (Gear^.Timer = 0)or((Gear^.Message and gm_Destroy) <> 0) then
       
  3937     begin
       
  3938         DeleteGear(Gear);
       
  3939         exit
       
  3940     end;
       
  3941 
       
  3942     if (Gear^.Timer mod 5) = 0 then
       
  3943     begin
       
  3944         AddVisualGear(hwRound(Gear^.X) - 5 + Random(10), hwRound(Gear^.Y) + 12, vgtDust);
       
  3945 
       
  3946         i := hwRound(Gear^.X) - Gear^.Radius - LongInt(GetRandom(2));
       
  3947         ei := hwRound(Gear^.X) + Gear^.Radius + LongInt(GetRandom(2));
       
  3948         while i <= ei do
       
  3949         begin
       
  3950             DrawExplosion(i, hwRound(Gear^.Y) + 3, 3);
       
  3951             inc(i, 1)
       
  3952         end;
       
  3953 
       
  3954         if CheckLandValue(hwRound(Gear^.X + Gear^.dX + SignAs(_6,Gear^.dX)), hwRound(Gear^.Y + _1_9)
       
  3955            , lfIndestructible) then
       
  3956         begin
       
  3957             Gear^.X := Gear^.X + Gear^.dX;
       
  3958             Gear^.Y := Gear^.Y + _1_9;
       
  3959         end;
       
  3960         SetAllHHToActive;
       
  3961     end;
       
  3962     if TestCollisionYwithGear(Gear, 1) then
       
  3963     begin
       
  3964         Gear^.dY := _0;
       
  3965         SetLittle(HHGear^.dX);
       
  3966         HHGear^.dY := _0;
       
  3967     end
       
  3968     else
       
  3969     begin
       
  3970         Gear^.dY := Gear^.dY + cGravity;
       
  3971         Gear^.Y := Gear^.Y + Gear^.dY;
       
  3972         if hwRound(Gear^.Y) > cWaterLine then Gear^.Timer := 1
       
  3973     end;
       
  3974 
       
  3975     Gear^.X := Gear^.X + HHGear^.dX;
       
  3976     HHGear^.X := Gear^.X;
       
  3977     HHGear^.Y := Gear^.Y - int2hwFloat(cHHRadius);
       
  3978 
       
  3979     if (Gear^.Message and gm_Attack) <> 0 then
       
  3980         if (Gear^.State and gsttmpFlag) <> 0 then Gear^.Timer := 1
       
  3981     else
       
  3982     else
       
  3983         if (Gear^.State and gsttmpFlag) = 0 then Gear^.State := Gear^.State or gsttmpFlag;
       
  3984     if ((Gear^.Message and gm_Left) <> 0) then Gear^.dX := - _0_3
       
  3985     else
       
  3986         if ((Gear^.Message and gm_Right) <> 0) then Gear^.dX := _0_3
       
  3987     else Gear^.dX := _0;
       
  3988 end;
       
  3989 
       
  3990 procedure doStepHammerHit(Gear: PGear);
       
  3991 var 
       
  3992     i, y: LongInt;
       
  3993     ar: TRangeArray;
       
  3994     HHGear: PGear;
       
  3995 begin
       
  3996     i := 0;
       
  3997     HHGear := PHedgehog(Gear^.Hedgehog)^.Gear;
       
  3998 
       
  3999     y := hwRound(Gear^.Y) - cHHRadius * 2;
       
  4000     while y < hwRound(Gear^.Y) do
       
  4001     begin
       
  4002         ar[i].Left := hwRound(Gear^.X) - Gear^.Radius - LongInt(GetRandom(2));
       
  4003         ar[i].Right := hwRound(Gear^.X) + Gear^.Radius + LongInt(GetRandom(2));
       
  4004         inc(y, 2);
       
  4005         inc(i)
       
  4006     end;
       
  4007 
       
  4008     DrawHLinesExplosions(@ar, 3, hwRound(Gear^.Y) - cHHRadius * 2, 2, Pred(i));
       
  4009     Gear^.dY := HHGear^.dY;
       
  4010     DeleteCI(HHGear);
       
  4011 
       
  4012     doStepHammerHitWork(Gear);
       
  4013     Gear^.doStep := @doStepHammerHit
       
  4014 end;