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/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);
Note: See TracChangeset for help on using the changeset viewer.