hedgewars/uGearsHedgehog.pas
changeset 7028 0f60591f3a16
parent 7010 10a0a31804f3
child 7053 8c9dcaedc7a8
equal deleted inserted replaced
7027:f264ad9d8965 7028:0f60591f3a16
    32 implementation
    32 implementation
    33 uses uConsts, uVariables, uFloat, uAmmos, uSound, uCaptions, 
    33 uses uConsts, uVariables, uFloat, uAmmos, uSound, uCaptions, 
    34     uCommands, uLocale, uUtils, uVisualGears, uStats, uIO, uScript,
    34     uCommands, uLocale, uUtils, uVisualGears, uStats, uIO, uScript,
    35     uGearsList, uGears, uCollisions, uRandom, uStore, uTeams, 
    35     uGearsList, uGears, uCollisions, uRandom, uStore, uTeams, 
    36     uGearsUtils;
    36     uGearsUtils;
       
    37 
       
    38 var GHStepTicks: LongWord = 0;
    37 
    39 
    38 // Shouldn't more of this ammo switching stuff be moved to uAmmos ?
    40 // Shouldn't more of this ammo switching stuff be moved to uAmmos ?
    39 function ChangeAmmo(HHGear: PGear): boolean;
    41 function ChangeAmmo(HHGear: PGear): boolean;
    40 var slot, i: Longword;
    42 var slot, i: Longword;
    41     ammoidx: LongInt;
    43     ammoidx: LongInt;
   652                 else
   654                 else
   653                     if (Gear^.Message and gmRight ) <> 0 then
   655                     if (Gear^.Message and gmRight ) <> 0 then
   654                         Pos:= (Pos + 1) mod Ammoz[AmmoType].PosCount
   656                         Pos:= (Pos + 1) mod Ammoz[AmmoType].PosCount
   655     else
   657     else
   656         exit;
   658         exit;
   657     StepTicks:= 200;
   659     GHStepTicks:= 200;
   658     exit
   660     exit
   659     end;
   661     end;
   660 
   662 
   661     if ((Gear^.Message and gmAnimate) <> 0) then
   663     if ((Gear^.Message and gmAnimate) <> 0) then
   662         begin
   664         begin
   710     if (Gear^.Message and (gmLeft or gmRight)) <> 0 then
   712     if (Gear^.Message and (gmLeft or gmRight)) <> 0 then
   711         begin
   713         begin
   712         StepSoundTimer:= cHHStepTicks;
   714         StepSoundTimer:= cHHStepTicks;
   713         end;
   715         end;
   714    
   716    
   715     StepTicks:= cHHStepTicks;
   717     GHStepTicks:= cHHStepTicks;
   716     if PrevdX <> hwSign(Gear^.dX) then
   718     if PrevdX <> hwSign(Gear^.dX) then
   717         begin
   719         begin
   718         FollowGear:= Gear;
   720         FollowGear:= Gear;
   719         exit
   721         exit
   720         end;
   722         end;
  1036         end;
  1038         end;
  1037     exit
  1039     exit
  1038     end;
  1040     end;
  1039 
  1041 
  1040 if ((HHGear^.State and gstMoving) <> 0)
  1042 if ((HHGear^.State and gstMoving) <> 0)
  1041 or (StepTicks = cHHStepTicks)
  1043 or (GHStepTicks = cHHStepTicks)
  1042 or (CurAmmoGear <> nil) then // we are moving
  1044 or (CurAmmoGear <> nil) then // we are moving
  1043     begin
  1045     begin
  1044     with Hedgehog^ do
  1046     with Hedgehog^ do
  1045         if (CurAmmoGear = nil)
  1047         if (CurAmmoGear = nil)
  1046         and (HHGear^.dY > _0_39)
  1048         and (HHGear^.dY > _0_39)
  1114 
  1116 
  1115     if ((HHGear^.State and (gstMoving or gstDrowning)) = 0) then
  1117     if ((HHGear^.State and (gstMoving or gstDrowning)) = 0) then
  1116         begin
  1118         begin
  1117         AddGearCI(HHGear);
  1119         AddGearCI(HHGear);
  1118         if wasJumping then
  1120         if wasJumping then
  1119             StepTicks:= 410
  1121             GHStepTicks:= 410
  1120         else
  1122         else
  1121             StepTicks:= 95
  1123             GHStepTicks:= 95
  1122         end;
  1124         end;
  1123     exit
  1125     exit
  1124     end;
  1126     end;
  1125 
  1127 
  1126     if not isInMultiShoot and (Hedgehog^.Gear <> nil) then
  1128     if not isInMultiShoot and (Hedgehog^.Gear <> nil) then
  1127         begin
  1129         begin
  1128         if StepTicks > 0 then
  1130         if GHStepTicks > 0 then
  1129             dec(StepTicks);
  1131             dec(GHStepTicks);
  1130         if (StepTicks = 0) then
  1132         if (GHStepTicks = 0) then
  1131             HedgehogStep(HHGear)
  1133             HedgehogStep(HHGear)
  1132         end
  1134         end
  1133 end;
  1135 end;
  1134 
  1136 
  1135 ////////////////////////////////////////////////////////////////////////////////
  1137 ////////////////////////////////////////////////////////////////////////////////