hedgewars/uGearsHedgehog.pas
branchwebgl
changeset 9521 8054d9d775fd
parent 9160 fc46e75f6b72
parent 9509 5b3f2ea156c9
child 9950 2759212a27de
equal deleted inserted replaced
9282:92af50454cf2 9521:8054d9d775fd
    31 procedure AddPickup(HH: THedgehog; ammo: TAmmoType; cnt, X, Y: LongWord);
    31 procedure AddPickup(HH: THedgehog; ammo: TAmmoType; cnt, X, Y: LongWord);
    32 procedure CheckIce(Gear: PGear); inline;
    32 procedure CheckIce(Gear: PGear); inline;
    33 
    33 
    34 implementation
    34 implementation
    35 uses uConsts, uVariables, uFloat, uAmmos, uSound, uCaptions,
    35 uses uConsts, uVariables, uFloat, uAmmos, uSound, uCaptions,
    36     uCommands, uLocale, uUtils, uVisualGears, uStats, uIO, uScript,
    36     uCommands, uLocale, uUtils, uStats, uIO, uScript,
    37     uGearsList, uGears, uCollisions, uRandom, uStore, uTeams,
    37     uGearsList, uCollisions, uRandom, uStore, uTeams,
    38     uGearsUtils;
    38     uGearsUtils, uVisualGearsList;
    39 
    39 
    40 var GHStepTicks: LongWord = 0;
    40 var GHStepTicks: LongWord = 0;
    41 
    41 
    42 // Shouldn't more of this ammo switching stuff be moved to uAmmos ?
    42 // Shouldn't more of this ammo switching stuff be moved to uAmmos ?
    43 function ChangeAmmo(HHGear: PGear): boolean;
    43 function ChangeAmmo(HHGear: PGear): boolean;
   797 
   797 
   798     if (not cArtillery) and ((Gear^.Message and gmPrecise) = 0) then
   798     if (not cArtillery) and ((Gear^.Message and gmPrecise) = 0) then
   799         MakeHedgehogsStep(Gear);
   799         MakeHedgehogsStep(Gear);
   800 
   800 
   801     SetAllHHToActive(false);
   801     SetAllHHToActive(false);
   802     AddGearCI(Gear)
   802     AddCI(Gear)
   803     end
   803     end
   804 end;
   804 end;
   805 
   805 
   806 procedure HedgehogChAngle(HHGear: PGear);
   806 procedure HedgehogChAngle(HHGear: PGear);
   807 var da: LongWord;
   807 var da: LongWord;
   845 if isFalling then
   845 if isFalling then
   846     begin
   846     begin
   847     if (Gear^.dY.isNegative) and TestCollisionYKick(Gear, -1) then
   847     if (Gear^.dY.isNegative) and TestCollisionYKick(Gear, -1) then
   848         Gear^.dY:= _0;
   848         Gear^.dY:= _0;
   849     Gear^.State:= Gear^.State or gstMoving;
   849     Gear^.State:= Gear^.State or gstMoving;
   850     if (CurrentHedgehog^.Gear = Gear)
   850     if (CurrentHedgehog^.Gear = Gear) and (CurrentHedgehog^.Gear^.State and gstHHDriven <> 0) and
   851         and (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) > _0_003) then
   851        (not CurrentTeam^.ExtDriven) and (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) > _0_003) then
   852         begin
   852         begin
   853         // TODO: why so aggressive at setting FollowGear when falling?
   853         // TODO: why so aggressive at setting FollowGear when falling?
       
   854         // because hog was being yanked out of frame by other stuff when doing a complicated jump/chute/saucer/roping.
       
   855         // added a couple more conditions to make it a bit less aggressive, at cost of possibly spectator failing to follow a maneuver
   854         FollowGear:= Gear;
   856         FollowGear:= Gear;
   855         end;
   857         end;
   856     if isUnderwater then
   858     if isUnderwater then
   857        Gear^.dY:= Gear^.dY + cGravity / _2
   859        Gear^.dY:= Gear^.dY + cGravity / _2
   858     else
   860     else
  1147     if Hedgehog^.Gear <> nil then
  1149     if Hedgehog^.Gear <> nil then
  1148         doStepHedgehogMoving(HHGear);
  1150         doStepHedgehogMoving(HHGear);
  1149 
  1151 
  1150     if ((HHGear^.State and (gstMoving or gstDrowning)) = 0) then
  1152     if ((HHGear^.State and (gstMoving or gstDrowning)) = 0) then
  1151         begin
  1153         begin
  1152         AddGearCI(HHGear);
  1154         AddCI(HHGear);
  1153         if wasJumping then
  1155         if wasJumping then
  1154             GHStepTicks:= 410
  1156             GHStepTicks:= 410
  1155         else
  1157         else
  1156             GHStepTicks:= 95
  1158             GHStepTicks:= 95
  1157         end;
  1159         end;
  1229     begin
  1231     begin
  1230     if Gear^.Timer = 0 then
  1232     if Gear^.Timer = 0 then
  1231         begin
  1233         begin
  1232         Gear^.State:= Gear^.State and (not (gstWait or gstLoser or gstWinner or gstAttacked or gstNotKickable or gstHHChooseTarget));
  1234         Gear^.State:= Gear^.State and (not (gstWait or gstLoser or gstWinner or gstAttacked or gstNotKickable or gstHHChooseTarget));
  1233         if Gear^.Hedgehog^.Effects[heFrozen] = 0 then Gear^.Active:= false;
  1235         if Gear^.Hedgehog^.Effects[heFrozen] = 0 then Gear^.Active:= false;
  1234         AddGearCI(Gear);
  1236         AddCI(Gear);
  1235         exit
  1237         exit
  1236         end
  1238         end
  1237     else dec(Gear^.Timer)
  1239     else dec(Gear^.Timer)
  1238     end;
  1240     end;
  1239 
  1241 
  1276 end;
  1278 end;
  1277 
  1279 
  1278 ////////////////////////////////////////////////////////////////////////////////
  1280 ////////////////////////////////////////////////////////////////////////////////
  1279 procedure doStepHedgehog(Gear: PGear);
  1281 procedure doStepHedgehog(Gear: PGear);
  1280 begin
  1282 begin
       
  1283 if WorldWrap(Gear) and (WorldEdge <> weBounce) and 
       
  1284   (Gear = CurrentHedgehog^.Gear) and (CurAmmoGear <> nil) and (CurAmmoGear^.Kind =gtRope) then
       
  1285    CurAmmoGear^.PortalCounter:= 1;
       
  1286 
  1281 CheckSum:= CheckSum xor Gear^.Hedgehog^.BotLevel;
  1287 CheckSum:= CheckSum xor Gear^.Hedgehog^.BotLevel;
  1282 if (Gear^.Message and gmDestroy) <> 0 then
  1288 if (Gear^.Message and gmDestroy) <> 0 then
  1283     begin
  1289     begin
  1284     DeleteGear(Gear);
  1290     DeleteGear(Gear);
  1285     exit
  1291     exit