hedgewars/uAIMisc.pas
changeset 15690 c4d7eb75fd8a
parent 15685 78e383fff605
child 15693 2aedd8ca836c
equal deleted inserted replaced
15689:975232e840c7 15690:c4d7eb75fd8a
   106       ResurrectScore = 100;
   106       ResurrectScore = 100;
   107 var friendlyfactor: LongInt = 300;
   107 var friendlyfactor: LongInt = 300;
   108 var dmgMod: real = 1.0;
   108 var dmgMod: real = 1.0;
   109 
   109 
   110 implementation
   110 implementation
   111 uses uCollisions, uVariables, uUtils, uGearsUtils;
   111 uses uCollisions, uVariables, uUtils, uGearsUtils, uAIAmmoTests;
   112 
   112 
   113 var
   113 var
   114     KnownExplosion: record
   114     KnownExplosion: record
   115         X, Y, Radius: LongInt
   115         X, Y, Radius: LongInt
   116         end = (X: 0; Y: 0; Radius: 0);
   116         end = (X: 0; Y: 0; Radius: 0);
   445     while true do
   445     while true do
   446         begin
   446         begin
   447         x:= CheckWrap(x);
   447         x:= CheckWrap(x);
   448         x:= x + dX;
   448         x:= x + dX;
   449         y:= y + dY;
   449         y:= y + dY;
   450         dY:= dY + cGravityf;
   450         dY:= dY + aiGravityf;
   451         skipLandCheck:= skipLandCheck and (r <> 0) and (abs(eX-x) + abs(eY-y) < r) and ((abs(eX-x) < rCorner) or (abs(eY-y) < rCorner));
   451         skipLandCheck:= skipLandCheck and (r <> 0) and (abs(eX-x) + abs(eY-y) < r) and ((abs(eX-x) < rCorner) or (abs(eY-y) < rCorner));
   452         if not skipLandCheck and TestCollExcludingObjects(trunc(x), trunc(y), Target.Radius) then
   452         if not skipLandCheck and TestCollExcludingObjects(trunc(x), trunc(y), Target.Radius) then
   453             with Target do
   453             with Target do
   454                 begin
   454                 begin
   455                 if (Kind = gtHedgehog) and (0.4 < dY) then
   455                 if (Kind = gtHedgehog) and (0.4 < dY) then
   492     while true do
   492     while true do
   493         begin
   493         begin
   494         x:= CheckWrap(x);
   494         x:= CheckWrap(x);
   495         x:= x + dX;
   495         x:= x + dX;
   496         y:= y + dY;
   496         y:= y + dY;
   497         dY:= dY + cGravityf;
   497         dY:= dY + aiGravityf;
   498 
   498 
   499 {        if ((trunc(y) and LAND_HEIGHT_MASK) = 0) and ((trunc(x) and LAND_WIDTH_MASK) = 0) then
   499 {        if ((trunc(y) and LAND_HEIGHT_MASK) = 0) and ((trunc(x) and LAND_WIDTH_MASK) = 0) then
   500             begin
   500             begin
   501             LandPixels[trunc(y), trunc(x)]:= v;
   501             LandPixels[trunc(y), trunc(x)]:= v;
   502             UpdateLandTexture(trunc(X), 1, trunc(Y), 1, true);
   502             UpdateLandTexture(trunc(X), 1, trunc(Y), 1, true);
   883                 r:= trunc(sqrt(sqr(abs(pX - hwRound(meX)))+sqr(abs(pY - hwRound(meY)))));
   883                 r:= trunc(sqrt(sqr(abs(pX - hwRound(meX)))+sqr(abs(pY - hwRound(meY)))));
   884                 if r < cSeductionDist then
   884                 if r < cSeductionDist then
   885                     begin
   885                     begin
   886 
   886 
   887                     if (WorldEdge <> weWrap) or (not (hwAbs(meX - int2hwFloat(pX)) > int2hwFloat(cSeductionDist))) then
   887                     if (WorldEdge <> weWrap) or (not (hwAbs(meX - int2hwFloat(pX)) > int2hwFloat(cSeductionDist))) then
   888                         dX:= _50 * cGravity * (meX - int2hwFloat(pX)) / _25
   888                         dX:= _50 * aiGravity * (meX - int2hwFloat(pX)) / _25
   889                     else if (not (hwAbs(meX + int2hwFloat((RightX-LeftX) - pX)) > int2hwFloat(cSeductionDist))) then
   889                     else if (not (hwAbs(meX + int2hwFloat((RightX-LeftX) - pX)) > int2hwFloat(cSeductionDist))) then
   890                         dX:= _50 * cGravity * (meX + (int2hwFloat((RightX-LeftX) - pX))) / _25
   890                         dX:= _50 * aiGravity * (meX + (int2hwFloat((RightX-LeftX) - pX))) / _25
   891                     else
   891                     else
   892                         dX:= _50 * cGravity * (meX - (int2hwFloat((RightX-LeftX) - pX))) / _25;
   892                         dX:= _50 * aiGravity * (meX - (int2hwFloat((RightX-LeftX) - pX))) / _25;
   893                     dY:= -_450 * cMaxWindSpeed * 2;
   893                     dY:= -_450 * cMaxWindSpeed * 2;
   894 
   894 
   895 
   895 
   896                     pXr:= pX;
   896                     pXr:= pX;
   897                     pYr:= pY;
   897                     pYr:= pY;
  1067                 Gear^.dX:= SignAs(_0_02, Gear^.dX)
  1067                 Gear^.dX:= SignAs(_0_02, Gear^.dX)
  1068             end;
  1068             end;
  1069         if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) <> 0 then SetLittle(Gear^.dX);
  1069         if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) <> 0 then SetLittle(Gear^.dX);
  1070             Gear^.X:= Gear^.X + Gear^.dX;
  1070             Gear^.X:= Gear^.X + Gear^.dX;
  1071         inc(GoInfo.Ticks);
  1071         inc(GoInfo.Ticks);
  1072         Gear^.dY:= Gear^.dY + cGravity;
  1072         Gear^.dY:= Gear^.dY + aiGravity;
  1073         if Gear^.dY > _0_4 then
  1073         if Gear^.dY > _0_4 then
  1074             exit(false);
  1074             exit(false);
  1075         if (Gear^.dY.isNegative) and (TestCollisionYwithGear(Gear, -1) <> 0) then
  1075         if (Gear^.dY.isNegative) and (TestCollisionYwithGear(Gear, -1) <> 0) then
  1076             Gear^.dY:= _0;
  1076             Gear^.dY:= _0;
  1077         Gear^.Y:= Gear^.Y + Gear^.dY;
  1077         Gear^.Y:= Gear^.Y + Gear^.dY;
  1133 
  1133 
  1134     // hog is falling
  1134     // hog is falling
  1135     if (Gear^.State and gstMoving) <> 0 then
  1135     if (Gear^.State and gstMoving) <> 0 then
  1136         begin
  1136         begin
  1137         inc(GoInfo.Ticks);
  1137         inc(GoInfo.Ticks);
  1138         Gear^.dY:= Gear^.dY + cGravity;
  1138         Gear^.dY:= Gear^.dY + aiGravity;
  1139         if Gear^.dY > _0_4 then
  1139         if Gear^.dY > _0_4 then
  1140             begin
  1140             begin
  1141             GoInfo.FallPix:= 0;
  1141             GoInfo.FallPix:= 0;
  1142             // try ljump instead of fall with damage
  1142             // try ljump instead of fall with damage
  1143             HHJump(AltGear, jmpLJump, GoInfo);
  1143             HHJump(AltGear, jmpLJump, GoInfo);