mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Changed the fix for multihex critter moving in combat to a more proper one (from Mr.Stalin)
Added AIBestWeaponFix option to ddraw.ini.
This commit is contained in:
@@ -362,6 +362,10 @@ SkipOpeningMovies=0
|
||||
;Set to 0 to disable
|
||||
NPCsTryToSpendExtraAP=0
|
||||
|
||||
;Set to 1 to fix NPCs not checking weapon perks properly when searching for the best weapon
|
||||
;Note that enabling this option can significantly affect the weapon choice of some NPCs in combat
|
||||
AIBestWeaponFix=0
|
||||
|
||||
;Allows the use of tiles over 80*36 in size. sfall will just split and resave them at startup
|
||||
;Set to 1 to check all tiles on started (slow)
|
||||
;Set to 2 if you provide a XLtiles.lst file in art/tiles/ containing a list of the tile ids that need checking
|
||||
|
||||
+44
-2
@@ -619,6 +619,42 @@ end:
|
||||
}
|
||||
}
|
||||
|
||||
static const DWORD ai_move_steps_closer_run_object_ret = 0x42A169;
|
||||
static void __declspec(naked) MultiHexCombatRunFix() {
|
||||
__asm {
|
||||
test byte ptr ds:[edi + 0x25], 0x08; // is target multihex?
|
||||
jnz multiHex;
|
||||
test byte ptr ds:[esi + 0x25], 0x08; // is source multihex?
|
||||
jz runTile;
|
||||
multiHex:
|
||||
mov edx, dword ptr ds:[esp + 0x4]; // source's destination tilenum
|
||||
cmp dword ptr ds:[edi + 0x4], edx; // target's tilenum
|
||||
jnz runTile;
|
||||
add esp, 4;
|
||||
jmp ai_move_steps_closer_run_object_ret;
|
||||
runTile:
|
||||
retn;
|
||||
}
|
||||
}
|
||||
|
||||
static const DWORD ai_move_steps_closer_move_object_ret = 0x42A192;
|
||||
static void __declspec(naked) MultiHexCombatMoveFix() {
|
||||
__asm {
|
||||
test byte ptr ds:[edi + 0x25], 0x08; // is target multihex?
|
||||
jnz multiHex;
|
||||
test byte ptr ds:[esi + 0x25], 0x08; // is source multihex?
|
||||
jz moveTile;
|
||||
multiHex:
|
||||
mov edx, dword ptr ds:[esp + 0x4]; // source's destination tilenum
|
||||
cmp dword ptr ds:[edi + 0x4], edx; // target's tilenum
|
||||
jnz moveTile;
|
||||
add esp, 4;
|
||||
jmp ai_move_steps_closer_move_object_ret;
|
||||
moveTile:
|
||||
retn;
|
||||
}
|
||||
}
|
||||
|
||||
//checks if an attacked object is a critter before attempting dodge animation
|
||||
static void __declspec(naked) action_melee_hack() {
|
||||
__asm {
|
||||
@@ -1360,8 +1396,10 @@ void BugsInit()
|
||||
MakeCall(0x42901F, MultiHexFix);
|
||||
MakeCall(0x429170, MultiHexFix);
|
||||
// Fix for multihex critters moving too close and overlapping their targets in combat
|
||||
SafeWrite8(0x42A153, 0xEB); // jmp loc_42A169 (skip register_object_run_to_tile_)
|
||||
SafeWrite8(0x42A17C, 0xEB); // jmp loc_42A192 (skip register_object_move_to_tile_)
|
||||
MakeCall(0x42A14F, MultiHexCombatRunFix);
|
||||
SafeWrite8(0x42A154, 0x90);
|
||||
MakeCall(0x42A178, MultiHexCombatMoveFix);
|
||||
SafeWrite8(0x42A17D, 0x90);
|
||||
dlogr(" Done", DL_INIT);
|
||||
//}
|
||||
|
||||
@@ -1509,5 +1547,9 @@ void BugsInit()
|
||||
SafeWrite16(0x456B76, 0x23EB); // jmp loc_456B9B (skip unused engine code)
|
||||
|
||||
// Fix for critters not checking weapon perks properly when searching for the best weapon
|
||||
if (GetPrivateProfileIntA("Misc", "AIBestWeaponFix", 0, ini)) {
|
||||
dlog("Applying AI best weapon choice fix.", DL_INIT);
|
||||
HookCall(0x42954B, ai_best_weapon_hook);
|
||||
dlogr(" Done", DL_INIT);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user