mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Added a new value to AIDrugUsePerfFix
This commit is contained in:
+4
-1
@@ -428,11 +428,14 @@ NPCsTryToSpendExtraAP=0
|
||||
AIBestWeaponFix=0
|
||||
|
||||
;Set to 1 to fix NPCs not taking chem_primary_desire in AI.txt as drug use preference when using drugs in their inventory
|
||||
;Set to 2 to allow NPCs to use only the drugs listed in chem_primary_desire and healing drugs (stimpaks and healing powder)
|
||||
;Note: chem_primary_desire w/o fixes prevents the specified item PID from being consumed if all three PIDs in the list are the same
|
||||
;chem_primary_desire also works as a priority list of drug items the NPC will try to pick up in combat when they are on the ground
|
||||
AIDrugUsePerfFix=0
|
||||
|
||||
;Allows the use of tiles over 80x36 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
|
||||
;Set to 2 if you provide a XLtiles.lst file in art\tiles\ containing a list of the tile IDs that need checking
|
||||
AllowLargeTiles=0
|
||||
|
||||
;Set to 1 to boost the maximum number of tile FRMs from 4096 to 16383
|
||||
|
||||
+21
-16
@@ -1984,34 +1984,35 @@ skip:
|
||||
}
|
||||
|
||||
static DWORD firstItemDrug = -1;
|
||||
|
||||
static void __declspec(naked) ai_check_drugs_hack_break() {
|
||||
static const DWORD ai_check_drugs_hack_Ret = 0x42878B;
|
||||
__asm {
|
||||
mov eax, -1;
|
||||
cmp firstItemDrug, eax;
|
||||
jnz firstDrugs;
|
||||
jne firstDrugs; // pid != -1
|
||||
add esp, 4;
|
||||
jmp ai_check_drugs_hack_Ret; // break loop
|
||||
firstDrugs:
|
||||
mov dword ptr [esp + 4], eax; // buf
|
||||
mov dword ptr [esp + 4], eax; // slot set -1
|
||||
mov edi, firstItemDrug;
|
||||
mov ebx, edi;
|
||||
mov firstItemDrug, eax;
|
||||
mov firstItemDrug, eax; // set -1
|
||||
retn; // use drug
|
||||
}
|
||||
}
|
||||
|
||||
static void __declspec(naked) ai_check_drugs_hack_check() {
|
||||
__asm {
|
||||
test [esp + 0x34 - 0x30 + 4], 1; // check NoInvenItem flag
|
||||
test [esp + 0x34 - 0x30 + 4], 0; // check NoInvenItem != 0
|
||||
jnz skip;
|
||||
cmp dword ptr [edx + 0xAC], -1; // Chemical Preference Number (cap.chem_primary_desire)
|
||||
cmp dword ptr [edx + 0xAC], -1; // cap.chem_primary_desire (Chemical Preference Number)
|
||||
jnz checkDrugs;
|
||||
skip:
|
||||
xor ebx, ebx; // set zero flag for skipping preference list check
|
||||
xor ebx, ebx; // set ZF for skipping preference list check
|
||||
retn;
|
||||
checkDrugs:
|
||||
cmp ebx, [edx + 0xAC]; // Chemical Preference Number
|
||||
cmp ebx, [edx + 0xAC]; // check item.pid against cap.chem_primary_desire
|
||||
retn;
|
||||
}
|
||||
}
|
||||
@@ -2019,16 +2020,16 @@ checkDrugs:
|
||||
static void __declspec(naked) ai_check_drugs_hack_use() {
|
||||
static const DWORD ai_check_drugs_hack_Loop = 0x428675;
|
||||
__asm {
|
||||
cmp eax, 3;
|
||||
cmp eax, 3; // counter
|
||||
jge beginLoop;
|
||||
retn; // use drug
|
||||
beginLoop:
|
||||
cmp firstItemDrug, -1;
|
||||
jnz skip;
|
||||
mov firstItemDrug, edi; // keep drug item
|
||||
jne skip;
|
||||
mov firstItemDrug, edi; // keep first found drug item
|
||||
skip:
|
||||
add esp, 4;
|
||||
jmp ai_check_drugs_hack_Loop; // goto begin loop
|
||||
jmp ai_check_drugs_hack_Loop; // goto begin loop, search next item
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3493,14 +3494,18 @@ void BugFixes_Init()
|
||||
// Display a pop-up message box about death from radiation
|
||||
HookCall(0x42D733, process_rads_hook_msg);
|
||||
|
||||
// Fix for AI not taking chem_primary_desire in AI.txt as drug use preference when using drugs in their inventory
|
||||
if (GetConfigInt("Misc", "AIDrugUsePerfFix", 0)) {
|
||||
int drugUsePerfFix = GetConfigInt("Misc", "AIDrugUsePerfFix", 0);
|
||||
if (drugUsePerfFix > 0) {
|
||||
dlog("Applying AI drug use preference fix.", DL_FIX);
|
||||
if (drugUsePerfFix == 1) {
|
||||
// Fix for AI not taking chem_primary_desire in AI.txt as drug use preference when using drugs in their inventory
|
||||
MakeCall(0x42869D, ai_check_drugs_hack_break);
|
||||
MakeCall(0x4286AB, ai_check_drugs_hack_check);
|
||||
SafeWrite16(0x4286B0, 0x7490); // jnz > jz
|
||||
SafeWrite8(0x4286C5, CODETYPE_JumpNZ); // jz > jnz
|
||||
MakeCall(0x4286AB, ai_check_drugs_hack_check, 1);
|
||||
MakeCall(0x4286C7, ai_check_drugs_hack_use);
|
||||
}
|
||||
// Fix to allow using only the drugs listed in chem_primary_desire and healing drugs (stimpaks and healing powder)
|
||||
SafeWrite8(0x4286B1, CODETYPE_JumpZ); // jnz > jz (ai_check_drugs_)
|
||||
SafeWrite8(0x4286C5, CODETYPE_JumpNZ); // jz > jnz (ai_check_drugs_)
|
||||
dlogr(" Done", DL_FIX);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user