Changeset 663 for trunk/AI/StdAI


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

Legend:

Unmodified
Added
Removed
  • trunk/AI/StdAI/CustomAI.pas

    r592 r663  
    177177
    178178procedure Loc_to_ab(Loc0, Loc: Integer; var A, B: Integer);
    179 {$IFDEF FPC}// freepascal
    180179var
    181180  dx, dy: Integer;
     
    187186  B := (dy - dx) div 2;
    188187end;
    189 
    190 {$ELSE}// delphi
    191 register;
    192 asm
    193 push ebx
    194 
    195 // calculate
    196 push ecx
    197 div Byte ptr [G]
    198 xor ebx,ebx
    199 mov bl,ah  // ebx:=Loc0 mod G.lx
    200 mov ecx,eax
    201 and ecx,$000000FF // ecx:=Loc0 div G.lx
    202 mov eax,edx
    203 div Byte ptr [G]
    204 xor edx,edx
    205 mov dl,ah // edx:=Loc mod G.lx
    206 and eax,$000000FF // eax:=Loc div G.lx
    207 sub edx,ebx // edx:=Loc mod G.lx-Loc0 mod G.lx
    208 mov ebx,eax
    209 sub ebx,ecx // ebx:=dy
    210 and eax,1
    211 and ecx,1
    212 add edx,edx
    213 add eax,edx
    214 sub eax,ecx // eax:=dx, not normalized
    215 pop ecx
    216 
    217 // normalize
    218 mov edx,dword ptr [G]
    219 cmp eax,edx
    220 jl @A
    221   sub eax,edx
    222   sub eax,edx
    223   jmp @ok
    224 @A:
    225 neg edx
    226 cmp eax,edx
    227 jnl @ok
    228   sub eax,edx
    229   sub eax,edx
    230 
    231 // return results
    232 @ok:
    233 mov edx,ebx
    234 sub edx,eax
    235 add eax,ebx
    236 sar edx,1 // edx:=b
    237 mov ebx,[B]
    238 mov [ebx],edx
    239 sar eax,1 // eax:=a
    240 mov [A],eax
    241 
    242 pop ebx
    243 end;
    244 {$ENDIF}
    245188
    246189procedure ab_to_V8(A, B: Integer; var V8: Integer);
  • trunk/AI/StdAI/ToolAI.pas

    r592 r663  
    613613      dGround:
    614614      begin
    615         Inc(Result, (50 + (Speed - 150) * 13 shr 7) shl 8); //HeavyCost
     615        Inc(Result, (50 + (Speed - 150) * 13 shr 7) shl 8); // HeavyCost
    616616        if RO.Wonder[woShinkansen].EffectiveOwner <> Me then
    617617          Inc(Result, Speed * (4 * 1311) shr 17); // RailCost
    618         if (RO.Wonder[woGardens].EffectiveOwner <> Me) or
    619           (Kind = mkSettler) and (Speed >= 200) then
     618        if (RO.Wonder[woGardens].EffectiveOwner <> Me) and
     619          not ((Kind = mkSettler) and (Speed >= 200)) then
    620620          Inc(Result, msHostile);
    621621        if Kind = mkDiplomat then
Note: See TracChangeset for help on using the changeset viewer.