From bceb50502414701f62370cca7d5e6abf7f6ec0d7 Mon Sep 17 00:00:00 2001 From: NovaRain Date: Tue, 16 Oct 2018 10:05:25 +0800 Subject: [PATCH] Added displaying party member's current level & AC & addict flag info to the combat control panel (from Mr.Stalin) Changed highlighting containers/corpses to be default on in sfall-mods.ini. --- artifacts/config_files/Translations.ini | 3 ++ artifacts/config_files/sfall-mods.ini | 4 +-- sfall/FalloutEngine/Functions_def.h | 1 + sfall/FalloutEngine/VariableOffsets.h | 1 + sfall/FalloutEngine/Variables_def.h | 1 + sfall/Modules/PartyControl.cpp | 43 +++++++++++++++++++++++++ 6 files changed, 51 insertions(+), 2 deletions(-) diff --git a/artifacts/config_files/Translations.ini b/artifacts/config_files/Translations.ini index 5221ebe4..67dfd81b 100644 --- a/artifacts/config_files/Translations.ini +++ b/artifacts/config_files/Translations.ini @@ -7,6 +7,9 @@ HighlightFail2=Your motion sensor is out of charge. SuperStimExploitMsg=You cannot use a super stim on someone who is not injured! BlockedCombat=You cannot enter combat at this time. SaveSfallDataFail=ERROR saving extended savegame information! Check if other programs interfere with savegame files/folders and try again. +PartyLvlMsg=Lvl: +PartyACMsg=AC: +PartyAddictMsg=Addict [AppearanceMod] RaceText=Race diff --git a/artifacts/config_files/sfall-mods.ini b/artifacts/config_files/sfall-mods.ini index 20c9cb24..76970d54 100644 --- a/artifacts/config_files/sfall-mods.ini +++ b/artifacts/config_files/sfall-mods.ini @@ -5,10 +5,10 @@ Key=42 ; Set to 1 to also highlight containers -Containers=0 +Containers=1 ; Set to 1 to also highlight lootable corpses -Corpses=0 +Corpses=1 ; Set to 1 to only highlight objects in the player's line-of-sight CheckLOS=0 diff --git a/sfall/FalloutEngine/Functions_def.h b/sfall/FalloutEngine/Functions_def.h index 99648947..0bebefbe 100644 --- a/sfall/FalloutEngine/Functions_def.h +++ b/sfall/FalloutEngine/Functions_def.h @@ -74,6 +74,7 @@ WRAP_WATCOM_FUNC2(long, obj_pid_new, fo::GameObject*, object, long, pid) WRAP_WATCOM_FUNC1(long, obj_lock_is_jammed, GameObject*, object) WRAP_WATCOM_FUNC1(void, obj_unjam_lock, GameObject*, object) WRAP_WATCOM_FUNC6(long, pick_death, GameObject*, attacker, GameObject*, target, GameObject*, weapon, long, amount, long, anim, long, hitFromBack) +WRAP_WATCOM_FUNC2(long, queue_find_first, GameObject*, object, long, qType) WRAP_WATCOM_FUNC3(long, register_object_animate, GameObject*, object, long, anim, long, delay) WRAP_WATCOM_FUNC3(long, register_object_animate_and_hide, GameObject*, object, long, anim, long, delay) // WRAP_WATCOM_FUNC3(long, register_object_animate_and_move_straight_, GameObject*, object; diff --git a/sfall/FalloutEngine/VariableOffsets.h b/sfall/FalloutEngine/VariableOffsets.h index 33dd9899..a4e70838 100644 --- a/sfall/FalloutEngine/VariableOffsets.h +++ b/sfall/FalloutEngine/VariableOffsets.h @@ -42,6 +42,7 @@ #define FO_VAR_curr_pc_stat 0x6681AC #define FO_VAR_curr_stack 0x59E96C #define FO_VAR_cursor_line 0x664514 +#define FO_VAR_DarkGreenColor 0x6A3A90 #define FO_VAR_dialogue_state 0x518714 #define FO_VAR_dialogue_switch_mode 0x518718 #define FO_VAR_dialog_target 0x518848 diff --git a/sfall/FalloutEngine/Variables_def.h b/sfall/FalloutEngine/Variables_def.h index f0761384..51147a36 100644 --- a/sfall/FalloutEngine/Variables_def.h +++ b/sfall/FalloutEngine/Variables_def.h @@ -33,6 +33,7 @@ VAR_(curr_font_num, DWORD) VARA(curr_pc_stat, long, PCSTAT_max_pc_stat) VAR_(curr_stack, DWORD) VAR_(cursor_line, DWORD) +VAR_(DarkGreenColor, BYTE) VAR_(dialogue_state, DWORD) VAR_(dialogue_switch_mode, DWORD) VAR_(dialog_target, DWORD) diff --git a/sfall/Modules/PartyControl.cpp b/sfall/Modules/PartyControl.cpp index e8dc3f63..c658fe91 100644 --- a/sfall/Modules/PartyControl.cpp +++ b/sfall/Modules/PartyControl.cpp @@ -230,11 +230,54 @@ fo::GameObject* PartyControl::RealDudeObject() { : fo::var::obj_dude; } +static char levelMsg[12], armorClassMsg[12], addictMsg[16]; +static void __fastcall PartyMemberPrintStat(BYTE* surface, DWORD toWidth) { + const char* fmt = "%s %d"; + char lvlMsg[16], acMsg[16]; + + fo::GameObject* partyMember = (fo::GameObject*)fo::var::dialog_target; + int xPos = 350; + + int level = fo::func::partyMemberGetCurLevel(partyMember); + sprintf_s(lvlMsg, fmt, levelMsg, level); + + BYTE color = fo::var::GreenColor; + int widthText = fo::GetTextWidth(lvlMsg); + fo::PrintText(lvlMsg, color, xPos - widthText, 96, widthText, toWidth, surface); + + int ac = fo::func::stat_level(partyMember, fo::STAT_ac); + sprintf_s(acMsg, fmt, armorClassMsg, ac); + + xPos -= fo::GetTextWidth(armorClassMsg) + 20; + fo::PrintText(acMsg, color, xPos, 167, fo::GetTextWidth(acMsg), toWidth, surface); + + color = (fo::func::queue_find_first(partyMember, 2)) ? fo::var::RedColor : fo::var::DarkGreenColor; + widthText = fo::GetTextWidth(addictMsg); + fo::PrintText(addictMsg, color, 350 - widthText, 148, widthText, toWidth, surface); +} + +static void __declspec(naked) gdControlUpdateInfo_hook() { + __asm { + mov edi, eax; // keep fontnum + mov ecx, ebp; + mov edx, esi; + call PartyMemberPrintStat; + mov eax, edi; + jmp fo::funcoffs::text_font_; + } +} + void PartyControl::init() { LoadGameHook::OnGameReset() += PartyControlReset; HookCall(0x454218, stat_pc_add_experience_hook); // call inside op_give_exp_points_hook HookCalls(pc_flag_toggle_hook, { 0x4124F1, 0x41279A }); + + // display party member's current level & AC & addict flag + HookCall(0x44926F, gdControlUpdateInfo_hook); + Translate("sfall", "PartyLvlMsg", "Lvl:", levelMsg, 12); + Translate("sfall", "PartyACMsg", "AC:", armorClassMsg, 12); + Translate("sfall", "PartyAddictMsg", "Addict", addictMsg, 16); } }