Ignore:
Timestamp:
Jul 5, 2025, 10:57:12 AM (5 hours ago)
Author:
chronos
Message:
  • Fixed: Fixed unit move style hostile calculation in StdAI. Engineers don't take hostile damage on hostile terrain.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UnitProcessing.pas

    r558 r663  
    2121  Worked: array [0 .. nPl - 1] of Integer; { settler work statistics }
    2222
    23   // Moving/Combat
     23// Moving/Combat
    2424function HostileDamage(P, mix, Loc, MP: Integer): Integer;
    2525function CalculateMove(P, uix, ToLoc, MoveLength: Integer; TestOnly: Boolean;
     
    7979  ToWork: ^TToWorkList; { work left for each tile and job }
    8080
    81   {
    82     Moving/Combat
    83     ____________________________________________________________________
    84   }
     81{
     82  Moving/Combat
     83  ____________________________________________________________________
     84}
    8585function HostileDamage(P, mix, Loc, MP: Integer): Integer;
    8686var
     
    9797  begin
    9898    Assert((Tile and fTerImp <> tiIrrigation) and (Tile and fTerImp <> tiFarm));
    99     Result := (DesertThurst * MP - 1) div RW[P].Model[mix].Speed + 1
     99    Result := (DesertThurst * MP - 1) div RW[P].Model[mix].Speed + 1;
    100100  end
    101101  else if Tile and fTerrain = fArctic then
    102102  begin
    103103    Assert((Tile and fTerImp <> tiIrrigation) and (Tile and fTerImp <> tiFarm));
    104     Result := (ArcticThurst * MP - 1) div RW[P].Model[mix].Speed + 1
     104    Result := (ArcticThurst * MP - 1) div RW[P].Model[mix].Speed + 1;
    105105  end
    106106  else
     
    346346        begin
    347347          Result := eOK;
    348           MoveInfo.MountainDelay := True
     348          MoveInfo.MountainDelay := True;
    349349        end;
    350350      end;
     
    748748        Recovery := FastRecovery { city has baracks/shipyard/airport }
    749749      else
    750         Recovery := CityRecovery
     750        Recovery := CityRecovery;
    751751    end
    752752    else if (RealMap[Loc] and fTerrain >= fGrass) and (Model[mix].Domain <> dAir)
     
    778778  gmaAlpine = 8;
    779779var
    780   I, FromLoc, EndLoc, T, T1, maxmov, initmov, Loc, Loc1, FromTile, ToTile, V8,
     780  I, FromLoc, EndLoc, T, T1, MaxMov, InitMov, Loc, Loc1, FromTile, ToTile, V8,
    781781    MoveInfo, HeavyCost, RailCost, MoveCost, AddDamage, MaxDamage,
    782782    MovementLeft: Integer;
     
    867867  Damage[FromLoc] := 0;
    868868  Q := TIPQ.Create(MapSize);
    869   Q.Put(FromLoc, (maxmov - RW[P].Un[uix].Movement) shl 8);
     869  Q.Put(FromLoc, (MaxMov - RW[P].Un[uix].Movement) shl 8);
    870870  while Q.Get(Loc, T) do
    871871  begin
     
    955955                  3:
    956956                    begin
    957                       MoveCost := maxmov;
     957                      MoveCost := MaxMov;
    958958                      MountainDelay := True;
    959959                    end;
     
    967967                  if V8 and 1 <> 0 then
    968968                    AddDamage := ((DesertThurst * 3) * MoveCost - 1)
    969                       div maxmov + 1
     969                      div MaxMov + 1
    970970                  else
    971971                    AddDamage := ((DesertThurst * 2) * MoveCost - 1)
    972                       div maxmov + 1
     972                      div MaxMov + 1;
    973973                end
    974974                else if ToTile and (fTerrain or fCity or fRiver or fCanal) = fArctic
     
    977977                  if V8 and 1 <> 0 then
    978978                    AddDamage := ((ArcticThurst * 3) * MoveCost - 1)
    979                       div maxmov + 1
     979                      div MaxMov + 1
    980980                  else
    981981                    AddDamage := ((ArcticThurst * 2) * MoveCost - 1)
    982                       div maxmov + 1
     982                      div MaxMov + 1;
    983983                end;
    984             end
    985             else
    986               MoveCost := -1;
    987 
     984            end else MoveCost := -1;
    988985          end;
    989986
     
    998995            fOwned) // assume ship/airplane is transport -- load!
    999996            or (MoveCost >= 0) and (FromTile and fTerrain < fGrass)) then
    1000             MoveCost := maxmov; // transport load or unload
     997            MoveCost := MaxMov; // transport load or unload
    1001998
    1002999          if MoveCost >= 0 then
    10031000          begin { valid move }
    1004             MovementLeft := maxmov - T shr 8 and $FFF - MoveCost;
     1001            MovementLeft := MaxMov - T shr 8 and $FFF - MoveCost;
    10051002            if (MovementLeft < 0) or ((MoveCost = 0) and (MovementLeft = 0))
    10061003            then
     
    10111008                if FromTile and (fTerrain or fCity or fRiver or fCanal or
    10121009                  fSpecial1 { Oasis } ) = fDesert then
    1013                   Inc(AddDamage, (DesertThurst * (maxmov - T shr 8 and $FFF) -
    1014                     1) div maxmov + 1)
     1010                  Inc(AddDamage, (DesertThurst * (MaxMov - T shr 8 and $FFF) -
     1011                    1) div MaxMov + 1)
    10151012                else if FromTile and (fTerrain or fCity or fRiver or fCanal) = fArctic
    10161013                then
    1017                   Inc(AddDamage, (ArcticThurst * (maxmov - T shr 8 and $FFF) -
    1018                     1) div maxmov + 1);
    1019 
    1020               T1 := T and $7FF000FF + $100000 + (initmov + MoveCost) shl 8;
     1014                  Inc(AddDamage, (ArcticThurst * (MaxMov - T shr 8 and $FFF) -
     1015                    1) div MaxMov + 1);
     1016
     1017              T1 := T and $7FF000FF + $100000 + (InitMov + MoveCost) shl 8;
    10211018            end
    10221019            else
     
    10621059            mod (2 * lx) - lx;
    10631060          A.dy[I] := Loc div lx - From[Loc] div lx;
    1064         end
     1061        end;
    10651062      end;
    10661063      Loc := From[Loc];
    10671064    end;
    1068     A.MaxHostile_MovementLeft := maxmov - Time[EndLoc] shr 8 and $FFF;
     1065    A.MaxHostile_MovementLeft := MaxMov - Time[EndLoc] shr 8 and $FFF;
    10691066    if A.nStep > 25 then
    10701067      A.nStep := 25;
    1071     Result := eOK
     1068    Result := eOK;
    10721069  end
    10731070  else
     
    14121409          for uix1 := 0 to RW[P].nUn - 1 do
    14131410            if (RW[P].Un[uix1].Loc = Loc) and (RW[P].Un[uix1].Job = j0) then
    1414               RW[P].Un[uix1].Job := jNone
     1411              RW[P].Un[uix1].Job := jNone;
    14151412        end
    14161413        else
     
    14211418          Health := Health - HostileDamage(P, mix, Loc, Movement);
    14221419          Movement := 0;
    1423         end
    1424     end
     1420        end;
     1421    end;
    14251422end;
    14261423
Note: See TracChangeset for help on using the changeset viewer.