hedgewars/uGearsUtils.pas
changeset 9473 a51a69094c24
parent 9285 8e8b908970c2
child 9477 0463f747e839
equal deleted inserted replaced
9470:9ed07a96349d 9473:a51a69094c24
    50 procedure SetAllHHToActive; inline;
    50 procedure SetAllHHToActive; inline;
    51 procedure SetAllHHToActive(Ice: boolean);
    51 procedure SetAllHHToActive(Ice: boolean);
    52 
    52 
    53 function  GetAmmo(Hedgehog: PHedgehog): TAmmoType;
    53 function  GetAmmo(Hedgehog: PHedgehog): TAmmoType;
    54 function  GetUtility(Hedgehog: PHedgehog): TAmmoType;
    54 function  GetUtility(Hedgehog: PHedgehog): TAmmoType;
       
    55 
       
    56 function WorldWrap(var Gear: PGear): boolean;
    55 
    57 
    56 
    58 
    57 
    59 
    58 function MakeHedgehogsStep(Gear: PGear) : boolean;
    60 function MakeHedgehogsStep(Gear: PGear) : boolean;
    59 
    61 
   484             end;
   486             end;
   485         if isSubmersible and (Gear = CurAmmoGear) and (CurAmmoGear^.Pos = 0) then
   487         if isSubmersible and (Gear = CurAmmoGear) and (CurAmmoGear^.Pos = 0) then
   486             CurAmmoGear^.Pos := 1000
   488             CurAmmoGear^.Pos := 1000
   487         end
   489         end
   488     else
   490     else
   489         CheckGearDrowning := false;
   491         begin
       
   492         if Gear^.Kind = gtHedgehog then Gear^.State:= Gear^.State and not gstSubmersible;
       
   493         CheckGearDrowning := false
       
   494         end
   490 end;
   495 end;
   491 
   496 
   492 
   497 
   493 procedure ResurrectHedgehog(var gear: PGear);
   498 procedure ResurrectHedgehog(var gear: PGear);
   494 var tempTeam : PTeam;
   499 var tempTeam : PTeam;
  1196         end
  1201         end
  1197     end;
  1202     end;
  1198 GetUtility:= i
  1203 GetUtility:= i
  1199 end;
  1204 end;
  1200 
  1205 
       
  1206 (*
       
  1207 Intended to check Gear X/Y against the map left/right edges and apply one of the world modes
       
  1208 * Normal - infinite world, do nothing
       
  1209 * Wrap (entering left edge exits at same height on right edge)
       
  1210 * Bounce (striking edge is treated as a 100% elasticity bounce)
       
  1211 * From the depths (same as from sky, but from sea, with submersible flag set)
       
  1212 
       
  1213 Trying to make the checks a little broader than on first pass to catch things that don't move normally.
       
  1214 *)
       
  1215 function WorldWrap(var Gear: PGear): boolean;
       
  1216 var tdx: hwFloat;
       
  1217 begin
       
  1218 WorldWrap:= false;
       
  1219 // for playing around since it isn't hooked up yet
       
  1220 //WorldEdge:= weBounce;
       
  1221 if WorldEdge = weNone then exit(false);
       
  1222 if (hwRound(Gear^.X)-Gear^.Radius < leftX) or
       
  1223    (hwRound(Gear^.X)+Gear^.Radius > rightX) then
       
  1224     begin
       
  1225     if WorldEdge = weWrap then
       
  1226         begin
       
  1227         if (hwRound(Gear^.X)-Gear^.Radius < leftX) then
       
  1228              Gear^.X:= int2hwfloat(rightX-Gear^.Radius)
       
  1229         else Gear^.X:= int2hwfloat(leftX+Gear^.Radius)
       
  1230         end
       
  1231     else if WorldEdge = weBounce then
       
  1232         begin
       
  1233         if (hwRound(Gear^.X)-Gear^.Radius < leftX) then
       
  1234             begin
       
  1235             Gear^.dX.isNegative:= false;
       
  1236             Gear^.X:= int2hwfloat(leftX+Gear^.Radius)
       
  1237             end
       
  1238         else 
       
  1239             begin
       
  1240             Gear^.dX.isNegative:= true;
       
  1241             Gear^.X:= int2hwfloat(rightX-Gear^.Radius)
       
  1242             end
       
  1243         end
       
  1244     else if WorldEdge = weSea then
       
  1245         begin
       
  1246         if (hwRound(Gear^.Y) > cWaterLine) and (Gear^.State and gstSubmersible <> 0) then
       
  1247             Gear^.State:= Gear^.State and not gstSubmersible
       
  1248         else
       
  1249             begin
       
  1250             Gear^.State:= Gear^.State or gstSubmersible;
       
  1251             Gear^.X:= int2hwFloat(PlayWidth)*int2hwFloat(min(max(0,hwRound(Gear^.Y)),PlayHeight))/PlayHeight;
       
  1252             Gear^.Y:= int2hwFloat(cWaterLine+cVisibleWater+Gear^.Radius*2);
       
  1253             tdx:= Gear^.dX;
       
  1254             Gear^.dX:= Gear^.dY;
       
  1255             Gear^.dY:= tdx;
       
  1256             Gear^.dY.isNegative:= true
       
  1257             end
       
  1258         end;
       
  1259 (*
       
  1260 * Window in the sky (Gear moved high into the sky, Y is used to determine X) [unfortunately, not a safe thing to do. shame, I thought aerial bombardment would be kinda neat
       
  1261 This one would be really easy to freeze game unless it was flagged unfortunately.
       
  1262 
       
  1263     else 
       
  1264         begin
       
  1265         Gear^.X:= int2hwFloat(PlayWidth)*int2hwFloat(min(max(0,hwRound(Gear^.Y)),PlayHeight))/PlayHeight;
       
  1266         Gear^.Y:= -_2048-_256-_256;
       
  1267         tdx:= Gear^.dX;
       
  1268         Gear^.dX:= Gear^.dY;
       
  1269         Gear^.dY:= tdx;
       
  1270         Gear^.dY.isNegative:= false
       
  1271         end
       
  1272 *)
       
  1273     WorldWrap:= true
       
  1274     end;
       
  1275 end;
  1201 
  1276 
  1202 end.
  1277 end.