diff --git a/artifacts/mods/gl_partycontrol.int b/artifacts/mods/gl_partycontrol.int index a45c5279..44b75053 100644 Binary files a/artifacts/mods/gl_partycontrol.int and b/artifacts/mods/gl_partycontrol.int differ diff --git a/artifacts/mods/gl_partycontrol.ssl b/artifacts/mods/gl_partycontrol.ssl index c1145ec3..d6f7aae3 100644 --- a/artifacts/mods/gl_partycontrol.ssl +++ b/artifacts/mods/gl_partycontrol.ssl @@ -36,9 +36,9 @@ procedure combatturn_handler begin variable status := get_sfall_arg, critter := get_sfall_arg, - pid, perkID, level, i; + pid, perkID, level; - //display_msg("Combat Turn: " + status + ", by " + obj_name(critter) + ", arg3: " + get_sfall_arg); + //display_msg("Combat Turn: " + status + ", by " + obj_name(critter) + "/" + critter + ", arg3: " + get_sfall_arg); if npcControl then begin if lightInt then lightInt := round((lightInt / 65536.0) * 100); // calc percent of intensity obj_set_light_level(npcControl, lightInt, lightDist); // restore light for prev. controlled NPC @@ -55,9 +55,7 @@ procedure combatturn_handler begin foreach (perkID in perksList) begin level := has_trait(TRAIT_PERK, real_dude_obj, perkID); if (level) then begin - for (i := 0; i < level; i++) begin - critter_add_trait(critter, TRAIT_PERK, perkID, 1); - end + critter_add_trait(critter, TRAIT_PERK, perkID, level); end end intface_redraw; @@ -70,6 +68,8 @@ procedure combatturn_handler begin npcControl := 0; // dude control end if inControl then begin + // check preference setting _combat_highlight + if (read_byte(0x56D38C)) then set_outline(critter, OUTLINE_GREY); // center the screen on the controlled critter/dude and remove roof tiles move_to(dude_obj, dude_tile, dude_elevation); if (displayName and critter != real_dude_obj) then begin diff --git a/artifacts/scripting/headers/sfall.h b/artifacts/scripting/headers/sfall.h index 999c1b57..490d995a 100644 --- a/artifacts/scripting/headers/sfall.h +++ b/artifacts/scripting/headers/sfall.h @@ -270,6 +270,7 @@ #define get_flags(obj) sfall_func1("get_flags", obj) #define get_ini_section(file, sect) sfall_func2("get_ini_section", file, sect) #define get_ini_sections(file) sfall_func1("get_ini_sections", file) +#define get_inven_ap_cost sfall_func0("get_inven_ap_cost") #define get_map_enter_position sfall_func0("get_map_enter_position") #define get_metarule_table sfall_func0("get_metarule_table") #define get_object_ai_data(obj, aiParam) sfall_func2("get_object_ai_data", obj, aiParam) diff --git a/artifacts/scripting/sfall function notes.txt b/artifacts/scripting/sfall function notes.txt index 549b66fb..52132f1c 100644 --- a/artifacts/scripting/sfall function notes.txt +++ b/artifacts/scripting/sfall function notes.txt @@ -630,6 +630,9 @@ optional argument: > void sfall_func1("add_trait", int traitId) - adds the specified trait to the player +> int sfall_func0("get_inven_ap_cost") +- returns the current AP cost to access the inventory in combat + ------------------------ ------ MORE INFO ------- ------------------------ diff --git a/sfall/Modules/BarBoxes.cpp b/sfall/Modules/BarBoxes.cpp index c67e106e..8aefbcf2 100644 --- a/sfall/Modules/BarBoxes.cpp +++ b/sfall/Modules/BarBoxes.cpp @@ -146,6 +146,7 @@ static void ReconstructBarBoxes(int count) { } } +//static BYTE restoreData[] = {0x31, 0xD2, 0x89, 0x94, 0x24}; // xor edx, edx; mov... static void ResetBoxes() { for (int i = 0; i < actualBoxCount; i++) { boxText[i].isActive = false; @@ -158,8 +159,7 @@ static void ResetBoxes() { setBoxIndex = 5; // set start //SafeWrite32(0x461343, 0x00023D05); // call getmsg_ ReconstructBarBoxes(totalBoxCount); - //SafeWrite8(0x461243, 0x31); - //SafeWrite32(0x461244, 0x249489D2); + //SafeWriteBytes(0x461243, restoreData, 5); } void BarBoxes::SetText(int box, const char* text, DWORD color) { @@ -258,7 +258,6 @@ static void __declspec(naked) refresh_box_bar_win_hack() { } void BarBoxes::init() { - initCount += GetConfigInt("Misc", "BoxBarCount", 5); if (initCount < 5) initCount = 5; // exclude the influence of negative values from the config if (initCount > 100) initCount = 100; diff --git a/sfall/Modules/BarBoxes.h b/sfall/Modules/BarBoxes.h index 078f2f66..6fff8be0 100644 --- a/sfall/Modules/BarBoxes.h +++ b/sfall/Modules/BarBoxes.h @@ -1,3 +1,5 @@ +#pragma once + #include "Module.h" namespace sfall diff --git a/sfall/Modules/Interface.cpp b/sfall/Modules/Interface.cpp index 5c5ef47b..01fdc574 100644 --- a/sfall/Modules/Interface.cpp +++ b/sfall/Modules/Interface.cpp @@ -115,11 +115,11 @@ static void __declspec(naked) intface_redraw_items_hack0() { newArt: mov costAP, edx; cmp edx, 10; - jae skip; + je noShift; + ja skip; mov edx, 10; // width retn; skip: - je noShift; // ap == 10 sub edx, 10; imul edx, 5; // shift add ebx, edx; // add width shift to 'from' diff --git a/sfall/Modules/Inventory.cpp b/sfall/Modules/Inventory.cpp index 05e515e6..233852aa 100644 --- a/sfall/Modules/Inventory.cpp +++ b/sfall/Modules/Inventory.cpp @@ -686,16 +686,15 @@ inline static void ApplyInvenApCostPatch() { onlyOnceAP = true; } -void _stdcall SetInvenApCost(int cost) { +void __fastcall Inventory::SetInvenApCost(int cost) { invenApCost = cost; if (!onlyOnceAP) ApplyInvenApCostPatch(); } -// TODO: Make GetInvenApCost() function -/*long GetInvenApCost() { - long plevel = fo::func::perk_level(fo::var::obj_dude, fo::PERK_quick_pockets); - return invenApCost - (invenApQPReduction * plevel); -}*/ +long Inventory::GetInvenApCost() { + long perkLevel = fo::func::perk_level(fo::var::obj_dude, fo::PERK_quick_pockets); + return invenApCost - (invenApQPReduction * perkLevel); +} void InventoryReset() { invenApCost = invenApCostDef; diff --git a/sfall/Modules/Inventory.h b/sfall/Modules/Inventory.h index c7ce19e1..798ddd67 100644 --- a/sfall/Modules/Inventory.h +++ b/sfall/Modules/Inventory.h @@ -33,9 +33,11 @@ public: static Delegate& OnAdjustFid(); static DWORD __stdcall adjust_fid_replacement(); + + static long GetInvenApCost(); + static void __fastcall SetInvenApCost(int cost); }; -void _stdcall SetInvenApCost(int cost); DWORD __stdcall sf_item_total_size(fo::GameObject* critter); } diff --git a/sfall/Modules/Scripting/Handlers/Interface.cpp b/sfall/Modules/Scripting/Handlers/Interface.cpp index 8a778538..8af61eaa 100644 --- a/sfall/Modules/Scripting/Handlers/Interface.cpp +++ b/sfall/Modules/Scripting/Handlers/Interface.cpp @@ -200,8 +200,8 @@ void sf_add_iface_tag(OpcodeContext &ctx) { void sf_show_iface_tag(OpcodeContext &ctx) { int tag = ctx.arg(0).asInt(); if (tag == 3 || tag == 4) { - _asm mov eax, tag; - _asm call fo::funcoffs::pc_flag_on_; + __asm mov eax, tag; + __asm call fo::funcoffs::pc_flag_on_; } else { BarBoxes::AddBox(tag); } @@ -210,8 +210,8 @@ void sf_show_iface_tag(OpcodeContext &ctx) { void sf_hide_iface_tag(OpcodeContext &ctx) { int tag = ctx.arg(0).asInt(); if (tag == 3 || tag == 4) { - _asm mov eax, tag; - _asm call fo::funcoffs::pc_flag_off_; + __asm mov eax, tag; + __asm call fo::funcoffs::pc_flag_off_; } else { BarBoxes::RemoveBox(tag); } @@ -272,7 +272,7 @@ void sf_get_cursor_mode(OpcodeContext& ctx) { int cursorMode; __asm { call fo::funcoffs::gmouse_3d_get_mode_; - mov cursorMode, eax; + mov cursorMode, eax; } ctx.setReturn(cursorMode); } diff --git a/sfall/Modules/Scripting/Handlers/Metarule.cpp b/sfall/Modules/Scripting/Handlers/Metarule.cpp index ac30ed0a..b65209b1 100644 --- a/sfall/Modules/Scripting/Handlers/Metarule.cpp +++ b/sfall/Modules/Scripting/Handlers/Metarule.cpp @@ -80,6 +80,7 @@ static const SfallMetarule metarules[] = { {"get_flags", sf_get_flags, 1, 1, {ARG_OBJECT}}, {"get_ini_section", sf_get_ini_section, 2, 2, {ARG_STRING, ARG_STRING}}, {"get_ini_sections", sf_get_ini_sections, 1, 1, {ARG_STRING}}, + {"get_inven_ap_cost", sf_get_inven_ap_cost, 0, 0}, {"get_map_enter_position", sf_get_map_enter_position, 0, 0}, {"get_metarule_table", sf_get_metarule_table, 0, 0}, {"get_object_ai_data", sf_get_object_ai_data, 2, 2, {ARG_OBJECT, ARG_INT}}, diff --git a/sfall/Modules/Scripting/Handlers/Misc.cpp b/sfall/Modules/Scripting/Handlers/Misc.cpp index f75aa176..ce06d7fc 100644 --- a/sfall/Modules/Scripting/Handlers/Misc.cpp +++ b/sfall/Modules/Scripting/Handlers/Misc.cpp @@ -1113,14 +1113,18 @@ void __declspec(naked) op_set_inven_ap_cost() { __asm { push ecx; _GET_ARG_INT(end); - push eax; - call SetInvenApCost; + mov ecx, eax; + call Inventory::SetInvenApCost; end: pop ecx; retn; } } +void sf_get_inven_ap_cost(OpcodeContext& ctx) { + ctx.setReturn(Inventory::GetInvenApCost()); +} + void sf_attack_is_aimed(OpcodeContext& ctx) { DWORD isAimed, unused; ctx.setReturn(!fo::func::intface_get_attack(&unused, &isAimed) ? isAimed : 0); diff --git a/sfall/Modules/Scripting/Handlers/Misc.h b/sfall/Modules/Scripting/Handlers/Misc.h index 998c2504..dfbf73a8 100644 --- a/sfall/Modules/Scripting/Handlers/Misc.h +++ b/sfall/Modules/Scripting/Handlers/Misc.h @@ -137,6 +137,8 @@ void __declspec() op_gdialog_get_barter_mod(); void __declspec() op_set_inven_ap_cost(); +void sf_get_inven_ap_cost(OpcodeContext&); + void sf_attack_is_aimed(OpcodeContext&); void sf_sneak_success(OpcodeContext&);