mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Added missing return values for HOOK_INVENWIELD.
Updated NPC armor appearance mod.
This commit is contained in:
Binary file not shown.
@@ -22,7 +22,9 @@ variable
|
||||
modIni := "npcarmor.ini",
|
||||
defaultFids,
|
||||
armorPidMap, // maps armor PID to it's "type" - leather armor, metal, power armor, etc.
|
||||
npcMap;
|
||||
npcMap,
|
||||
altWeapon,
|
||||
unWieldWeapon;
|
||||
|
||||
procedure check_armor_change(variable critter, variable item, variable isWorn) begin
|
||||
variable npc, armorType, fid;
|
||||
@@ -55,6 +57,8 @@ procedure check_weapon_change(variable critter, variable item, variable isWield)
|
||||
end
|
||||
return 0;
|
||||
end
|
||||
end else begin
|
||||
unWieldWeapon := obj_pid(item);
|
||||
end
|
||||
end
|
||||
return -1;
|
||||
@@ -65,15 +69,20 @@ procedure search_alt_weapon(variable critter) begin
|
||||
obj := inven_ptr(critter, 0);
|
||||
while (obj) do begin
|
||||
if (obj_item_subtype(obj) == item_type_weapon) then begin
|
||||
res := check_weapon_change(critter, obj, 1);
|
||||
if (res == -1) then begin
|
||||
wield_obj_critter(critter, obj);
|
||||
break;
|
||||
if (unWieldWeapon == 0 or unWieldWeapon != obj_pid(obj)) then begin
|
||||
res := check_weapon_change(critter, obj, 1);
|
||||
if (res == -1) then begin
|
||||
altWeapon := obj;
|
||||
wield_obj_critter(critter, obj);
|
||||
altWeapon := 0;
|
||||
break;
|
||||
end
|
||||
end
|
||||
end
|
||||
i++;
|
||||
obj := inven_ptr(critter, i);
|
||||
end
|
||||
unWieldWeapon := 0;
|
||||
end
|
||||
|
||||
// for NPCs when they change armor/weapon themselves
|
||||
@@ -89,9 +98,11 @@ procedure invenwield_handler begin
|
||||
if (fid != -1) then begin
|
||||
art_change_fid_num(critter, fid);
|
||||
end
|
||||
return;
|
||||
end
|
||||
|
||||
if (critter and item and slot == INVEN_TYPE_RIGHT_HAND) then begin
|
||||
if (altWeapon == item) then return;
|
||||
canWield := check_weapon_change(critter, item, isWorn);
|
||||
set_sfall_return(canWield);
|
||||
if (canWield != -1) then begin
|
||||
|
||||
@@ -288,7 +288,7 @@ static bool InvenWieldHook_Script(int flag) {
|
||||
bool result = (cRet == 0 || rets[0] == -1);
|
||||
EndHook();
|
||||
|
||||
return result;
|
||||
return result; // True - use engine handler
|
||||
}
|
||||
|
||||
static void _declspec(naked) InvenWieldFuncHook() {
|
||||
@@ -314,6 +314,7 @@ static void _declspec(naked) InvenWieldFuncHook() {
|
||||
jz skip;
|
||||
jmp funcoffs::invenWieldFunc_;
|
||||
skip:
|
||||
mov eax, -1;
|
||||
retn;
|
||||
}
|
||||
}
|
||||
@@ -341,6 +342,7 @@ static void _declspec(naked) InvenUnwieldFuncHook() {
|
||||
jz skip;
|
||||
jmp fo::funcoffs::invenUnwieldFunc_;
|
||||
skip:
|
||||
mov eax, -1;
|
||||
retn;
|
||||
}
|
||||
}
|
||||
@@ -371,6 +373,7 @@ static void _declspec(naked) CorrectFidForRemovedItemHook() {
|
||||
jz skip;
|
||||
jmp fo::funcoffs::correctFidForRemovedItem_;
|
||||
skip:
|
||||
mov eax, -1;
|
||||
retn;
|
||||
}
|
||||
}
|
||||
@@ -419,9 +422,19 @@ void Inject_InventoryMoveHook() {
|
||||
}
|
||||
|
||||
void Inject_InvenWieldHook() {
|
||||
HookCalls(InvenWieldFuncHook, { 0x47275E, 0x495FDF });
|
||||
HookCalls(InvenUnwieldFuncHook, { 0x45967D, 0x472A5A, 0x495F0B });
|
||||
HookCalls(CorrectFidForRemovedItemHook, { 0x45680C, 0x45C4EA });
|
||||
HookCalls(InvenWieldFuncHook, {
|
||||
0x47275E, // inven_wield_
|
||||
0x495FDF // partyMemberCopyLevelInfo_
|
||||
});
|
||||
HookCalls(InvenUnwieldFuncHook, {
|
||||
0x45967D, // op_metarule_
|
||||
0x472A5A, // inven_unwield_
|
||||
0x495F0B // partyMemberCopyLevelInfo_
|
||||
});
|
||||
HookCalls(CorrectFidForRemovedItemHook, {
|
||||
0x45680C, // op_rm_obj_from_inven_
|
||||
0x45C4EA // op_move_obj_inven_to_obj_
|
||||
});
|
||||
}
|
||||
|
||||
void InitInventoryHookScripts() {
|
||||
|
||||
@@ -345,7 +345,7 @@ static int __fastcall SuperStimFix2(fo::GameObject* item, fo::GameObject* target
|
||||
return 0;
|
||||
}
|
||||
|
||||
DWORD curr_hp, max_hp;
|
||||
long curr_hp, max_hp;
|
||||
curr_hp = fo::func::stat_level(target, fo::STAT_current_hp);
|
||||
max_hp = fo::func::stat_level(target, fo::STAT_max_hit_points);
|
||||
if (curr_hp < max_hp) return 0;
|
||||
@@ -646,7 +646,7 @@ end:
|
||||
// Differences from vanilla:
|
||||
// - doesn't use art_vault_guy_num as default art, uses current critter FID instead
|
||||
// - invokes onAdjustFid delegate that allows to hook into FID calculation
|
||||
DWORD __stdcall adjust_fid_replacement2() {
|
||||
DWORD __stdcall Inventory::adjust_fid_replacement() {
|
||||
using namespace fo;
|
||||
|
||||
DWORD fid;
|
||||
@@ -693,11 +693,11 @@ DWORD __stdcall adjust_fid_replacement2() {
|
||||
return var::i_fid;
|
||||
}
|
||||
|
||||
static void __declspec(naked) adjust_fid_replacement() {
|
||||
static void __declspec(naked) adjust_fid_hack_replacement() {
|
||||
__asm {
|
||||
push ecx;
|
||||
push edx;
|
||||
call adjust_fid_replacement2; // return fid
|
||||
call Inventory::adjust_fid_replacement; // return fid
|
||||
pop edx;
|
||||
pop ecx;
|
||||
retn;
|
||||
@@ -740,7 +740,7 @@ void Inventory::init() {
|
||||
OnKeyPressed() += InventoryKeyPressedHook;
|
||||
LoadGameHook::OnGameReset() += InventoryReset;
|
||||
|
||||
MakeJump(fo::funcoffs::adjust_fid_, adjust_fid_replacement);
|
||||
MakeJump(fo::funcoffs::adjust_fid_, adjust_fid_hack_replacement);
|
||||
|
||||
sizeLimitMode = GetConfigInt("Misc", "CritterInvSizeLimitMode", 0);
|
||||
if (sizeLimitMode > 0 && sizeLimitMode <= 7) {
|
||||
|
||||
@@ -31,6 +31,8 @@ public:
|
||||
|
||||
// Called after game calculated dude FID for displaying on inventory screen
|
||||
static Delegate<DWORD>& OnAdjustFid();
|
||||
|
||||
static DWORD __stdcall adjust_fid_replacement();
|
||||
};
|
||||
|
||||
void _stdcall SetInvenApCost(int cost);
|
||||
|
||||
@@ -176,7 +176,7 @@ static void __declspec(naked) SaveGame_hook() {
|
||||
call CombatSaveTest;
|
||||
test eax, eax;
|
||||
pop edx; // recall Mode parameter (pop eax)
|
||||
jz end;
|
||||
jz end;
|
||||
push edx;
|
||||
_InLoop2(1, SAVEGAME);
|
||||
pop eax;
|
||||
|
||||
Reference in New Issue
Block a user