hedgewars/uGearsHandlersMess.pas
branchtransitional_engine
changeset 15975 2146cb7be36f
parent 15901 f39f0f614dbf
parent 15956 7125918637e9
equal deleted inserted replaced
15928:772a43d88e6b 15975:2146cb7be36f
   262         end;
   262         end;
   263 end;
   263 end;
   264 
   264 
   265 procedure HideHog(HH: PHedgehog);
   265 procedure HideHog(HH: PHedgehog);
   266 begin
   266 begin
       
   267     if HH^.Gear = nil then exit;
   267     ScriptCall('onHogHide', HH^.Gear^.Uid);
   268     ScriptCall('onHogHide', HH^.Gear^.Uid);
   268     DeleteCI(HH^.Gear);
   269     DeleteCI(HH^.Gear);
   269     if FollowGear = HH^.Gear then
   270     if FollowGear = HH^.Gear then
   270         FollowGear:= nil;
   271         FollowGear:= nil;
   271 
   272 
  6407 *)
  6408 *)
  6408 
  6409 
  6409 procedure doStepTardisWarp(Gear: PGear);
  6410 procedure doStepTardisWarp(Gear: PGear);
  6410 var HH: PHedgehog;
  6411 var HH: PHedgehog;
  6411     i,j,cnt: LongWord;
  6412     i,j,cnt: LongWord;
       
  6413     restoreBottomY: LongInt;
  6412     s: ansistring;
  6414     s: ansistring;
  6413 begin
  6415 begin
  6414 HH:= Gear^.Hedgehog;
  6416 HH:= Gear^.Hedgehog;
  6415 if Gear^.Tag = 0 then
  6417 if Gear^.Tag = 0 then
  6416     begin
  6418     begin
  6503                 and ((Hedgehogs[i].Gear^.State and gstDrowning) = 0)
  6505                 and ((Hedgehogs[i].Gear^.State and gstDrowning) = 0)
  6504                 and (Hedgehogs[i].Gear^.Health > Hedgehogs[i].Gear^.Damage) then
  6506                 and (Hedgehogs[i].Gear^.Health > Hedgehogs[i].Gear^.Damage) then
  6505                     inc(cnt);
  6507                     inc(cnt);
  6506     if (cnt = 0) or SuddenDeathDmg or (Gear^.Timer = 0) then
  6508     if (cnt = 0) or SuddenDeathDmg or (Gear^.Timer = 0) then
  6507         begin
  6509         begin
       
  6510         // Place tardis
  6508         if HH^.GearHidden <> nil then
  6511         if HH^.GearHidden <> nil then
  6509             FindPlace(HH^.GearHidden, false, 0, LAND_WIDTH, true, false);
  6512             begin
       
  6513             restoreBottomY:= cWaterLine;
       
  6514             // Place tardis at a random safe position
       
  6515             FindPlace(HH^.GearHidden, false, 0, LAND_WIDTH, restoreBottomY, true, false);
       
  6516 
       
  6517             // If in Sudden Death, rise the minimum possible spawn position to make
       
  6518             // it less likely for the hog to drown before its turn
       
  6519             if SuddenDeathActive and (cWaterRise > 0) then
       
  6520                 begin
       
  6521                 // Enough space to survive the water rise of 1 round.
       
  6522                 // Also limit the highest spawn height to topY plus a small buffer zone
       
  6523                 restoreBottomY:= max(topY + cHHRadius * 5, cWaterLine - cWaterRise * (TeamsCount + 1));
       
  6524                 // If gear is below the safe spawn height, place it again,
       
  6525                 // but this time with the height limit in place
       
  6526                 if (HH^.GearHidden <> nil) and (hwRound(HH^.GearHidden^.Y) > restoreBottomY) then
       
  6527                     // Due to the reduced Y range, this one might fail for very aggressive SD water rise
       
  6528                     begin
       
  6529                     FindPlace(HH^.GearHidden, false, 0, LAND_WIDTH, restoreBottomY, true, false);
       
  6530                     end;
       
  6531                 // Still unsafe? Relax the height limit to a third of the map height above cWaterLine
       
  6532                 if (HH^.GearHidden <> nil) and (hwRound(HH^.GearHidden^.Y) > restoreBottomY) then
       
  6533                     begin
       
  6534                     restoreBottomY:= cWaterLine - ((cWaterLine - topY) div 3);
       
  6535                     // Even this might fail, but it's much less likely. If it fails, we still have the
       
  6536                     // position of the first FindPlace as a fallback.
       
  6537                     FindPlace(HH^.GearHidden, false, 0, LAND_WIDTH, restoreBottomY, true, false);
       
  6538                     end;
       
  6539                 end;
       
  6540             end;
  6510 
  6541 
  6511         if HH^.GearHidden <> nil then
  6542         if HH^.GearHidden <> nil then
  6512             begin
  6543             begin
  6513             Gear^.X:= HH^.GearHidden^.X;
  6544             Gear^.X:= HH^.GearHidden^.X;
  6514             Gear^.Y:= HH^.GearHidden^.Y;
  6545             Gear^.Y:= HH^.GearHidden^.Y;