mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Refactor highlighting mod script, added check for outlined_object (via new scripting function), updated ddraw.ini to reflect the actual meaning of highighting-related settings (they way it worked for a long time); #53
HighlightMod is permanently removed from sfall code, it is now only a script.
This commit is contained in:
+1
-2
@@ -448,8 +448,7 @@ CritterInvSizeLimitMode=0
|
||||
CritterInvSizeLimit=200
|
||||
|
||||
;Some bit flags to alter behaviour of the motion sensor
|
||||
;1 - Allow sensor use on automap when motion sensor is in pack rather than hands
|
||||
;2 - Motion sensor doesn't require charges
|
||||
;2 - Motion sensor require charges when using highlight feature
|
||||
;4 - Motion sensor is required to use the item highlight feature
|
||||
MotionScannerFlags=1
|
||||
|
||||
|
||||
Binary file not shown.
@@ -1,14 +1,24 @@
|
||||
#include "..\scripting\headers\sfall.h"
|
||||
#include "..\scripting\headers\define_extra.h"
|
||||
/**
|
||||
|
||||
Item Highlight mod.
|
||||
|
||||
Previously was part of sfall itself, now a separate mod.
|
||||
Features:
|
||||
- highlighting items, containers (optional) and dead bodies on the ground
|
||||
- configurable hotkey is used to trigger highlight
|
||||
- only objects in direct line-of-sight of player are highlighted
|
||||
- motion scanner is required to enable highlight (optional)
|
||||
- motion scanner charges are decreesed on each use (optional)
|
||||
|
||||
**/
|
||||
|
||||
#include "main.h"
|
||||
//#include "..\..\..\!SRC\headers\define.h"
|
||||
|
||||
#define CRITTER_IS_DEAD (1)
|
||||
#define PID_MOTION_SENSOR (59)
|
||||
#define NO_HIGHLIGHT(obj) (get_flags(obj) bwand FLAG_NOHIGHLIGHT)
|
||||
#define TRANSLATE(id, default) (get_ini_string(translationIni + "|" id "|" default)
|
||||
|
||||
variable ini := "ddraw.ini";
|
||||
variable translationIni;
|
||||
variable highlightKey;
|
||||
variable highlightContainers;
|
||||
variable colorContainers;
|
||||
@@ -22,7 +32,7 @@ procedure toggle_highlight_object(variable obj, variable enable) begin
|
||||
and (highlightContainers or not NO_HIGHLIGHT(obj)) then begin
|
||||
set_outline(
|
||||
obj,
|
||||
enable and (NO_HIGHLIGHT(obj) and colorContainers or OUTLINE_YELLOW) or 0
|
||||
enable and (NO_HIGHLIGHT(obj) and colorContainers or OUTLINE_DARK_YELLOW) or 0
|
||||
);
|
||||
end
|
||||
end
|
||||
@@ -30,7 +40,9 @@ end
|
||||
procedure toggle_highlight(variable enable) begin
|
||||
variable obj;
|
||||
foreach obj in list_as_array(LIST_GROUNDITEMS) begin
|
||||
call toggle_highlight_object(obj, enable);
|
||||
if obj != outlined_object then begin
|
||||
call toggle_highlight_object(obj, enable);
|
||||
end
|
||||
end
|
||||
foreach obj in list_as_array(LIST_CRITTERS) begin
|
||||
if critter_state(obj) == CRITTER_IS_DEAD then begin
|
||||
@@ -74,26 +86,6 @@ procedure key_press_handler begin
|
||||
end
|
||||
end
|
||||
|
||||
procedure GetConfig(variable section, variable key, variable def) begin
|
||||
variable val := get_ini_setting(ini + "|" + section + "|" + key);
|
||||
if val == -1 then val := def;
|
||||
return val;
|
||||
end
|
||||
|
||||
procedure GetConfigStr(variable section, variable key, variable def) begin
|
||||
variable val := get_ini_string(ini + "|" + section + "|" + key);
|
||||
if val == -1 or val == "" then val := def;
|
||||
return val;
|
||||
end
|
||||
|
||||
procedure translate(variable id, variable def) begin
|
||||
variable str := get_ini_string(translationIni + "|Sfall|" + id);
|
||||
if not str or (strlen(str) == 0) then begin
|
||||
str := def;
|
||||
end
|
||||
return str;
|
||||
end
|
||||
|
||||
procedure start begin
|
||||
if game_loaded then begin
|
||||
translationIni := GetConfigStr("Main", "TranslationsINI", "./Translations.ini");
|
||||
@@ -102,7 +94,7 @@ procedure start begin
|
||||
display_msg("key= " + highlightKey);
|
||||
highlightContainers := GetConfig("Input", "HighlightContainers", 0);
|
||||
if highlightContainers == 1 then begin
|
||||
colorContainers := OUTLINE_YELLOW;
|
||||
colorContainers := OUTLINE_DARK_YELLOW;
|
||||
end else if highlightContainers == 2 then begin
|
||||
colorContainers := OUTLINE_PURPLE;
|
||||
end
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
|
||||
#include "..\scripting\headers\sfall.h"
|
||||
#include "..\scripting\headers\define_extra.h"
|
||||
|
||||
variable ini := "ddraw.ini";
|
||||
variable translationIni;
|
||||
|
||||
// Gets the integer value from ddraw.ini
|
||||
procedure GetConfig(variable section, variable key, variable def) begin
|
||||
variable val := get_ini_setting(ini + "|" + section + "|" + key);
|
||||
if val == -1 then val := def;
|
||||
return val;
|
||||
end
|
||||
|
||||
// Gets the string value from ddraw.ini
|
||||
procedure GetConfigStr(variable section, variable key, variable def) begin
|
||||
variable val := get_ini_string(ini + "|" + section + "|" + key);
|
||||
if val == -1 or val == "" then val := def;
|
||||
return val;
|
||||
end
|
||||
|
||||
// Translates given string using Translations.ini
|
||||
procedure translate(variable id, variable def) begin
|
||||
variable str := get_ini_string(translationIni + "|Sfall|" + id);
|
||||
if not str or (strlen(str) == 0) then begin
|
||||
str := def;
|
||||
end
|
||||
return str;
|
||||
end
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
To install each mod, copy *.int file into your <Fallout Dir>\data\scripts\ folder.
|
||||
@@ -210,3 +210,4 @@
|
||||
#define set_flags(obj, color) sfall_func2("set_flags", obj, color)
|
||||
#define get_flags(obj) sfall_func1("get_flags", obj)
|
||||
#define tile_refresh_display sfall_func0("tile_refresh_display")
|
||||
#define outlined_object sfall_func0("outlined_object")
|
||||
|
||||
@@ -114,7 +114,7 @@ VAR_(obj_dude, GameObject*)
|
||||
VAR_(objectTable, DWORD)
|
||||
VAR_(objItemOutlineState, DWORD)
|
||||
VAR_(optionRect, DWORD)
|
||||
VAR_(outlined_object, DWORD)
|
||||
VAR_(outlined_object, GameObject*)
|
||||
VAR_(partyMemberAIOptions, DWORD)
|
||||
VAR_(partyMemberCount, DWORD)
|
||||
VAR_(partyMemberLevelUpInfoList, DWORD)
|
||||
|
||||
@@ -1,160 +0,0 @@
|
||||
#include "..\main.h"
|
||||
#include "..\FalloutEngine\Fallout2.h"
|
||||
#include "..\InputFuncs.h"
|
||||
#include "MainLoopHook.h"
|
||||
|
||||
#include "HighlightingMod.h"
|
||||
|
||||
namespace sfall
|
||||
{
|
||||
|
||||
static DWORD highlightingToggled = 0;
|
||||
static DWORD motionSensorMode;
|
||||
static BYTE toggleHighlightsKey;
|
||||
static DWORD highlightContainers;
|
||||
static DWORD colorContainers;
|
||||
static std::string highlightFailMsg1;
|
||||
static std::string HighlightFailMsg2;
|
||||
|
||||
static void __declspec(naked) obj_outline_all_items_on() {
|
||||
__asm {
|
||||
pushad
|
||||
mov eax, dword ptr ds:[FO_VAR_map_elevation]
|
||||
call fo::funcoffs::obj_find_first_at_
|
||||
loopObject:
|
||||
test eax, eax
|
||||
jz end
|
||||
cmp eax, ds:[FO_VAR_outlined_object]
|
||||
je nextObject
|
||||
xchg ecx, eax
|
||||
mov eax, [ecx+0x20]
|
||||
and eax, 0xF000000
|
||||
sar eax, 0x18
|
||||
test eax, eax // This object is an item?
|
||||
jnz nextObject // No
|
||||
cmp dword ptr [ecx+0x7C], eax // Owned by someone?
|
||||
jnz nextObject // Yes
|
||||
test dword ptr [ecx+0x74], eax // Already outlined?
|
||||
jnz nextObject // Yes
|
||||
mov edx, 0x10 // yellow
|
||||
test byte ptr [ecx+0x25], dl // NoHighlight_ flag is set (is this a container)?
|
||||
jz NoHighlight // No
|
||||
cmp highlightContainers, eax // Highlight containers?
|
||||
je nextObject // No
|
||||
mov edx, colorContainers // NR: should be set to yellow or purple later
|
||||
NoHighlight:
|
||||
mov [ecx+0x74], edx
|
||||
nextObject:
|
||||
call fo::funcoffs::obj_find_next_at_
|
||||
jmp loopObject
|
||||
end:
|
||||
call fo::funcoffs::tile_refresh_display_
|
||||
popad
|
||||
retn
|
||||
}
|
||||
}
|
||||
|
||||
static void __declspec(naked) obj_outline_all_items_off() {
|
||||
__asm {
|
||||
pushad
|
||||
mov eax, dword ptr ds:[FO_VAR_map_elevation]
|
||||
call fo::funcoffs::obj_find_first_at_
|
||||
loopObject:
|
||||
test eax, eax
|
||||
jz end
|
||||
cmp eax, ds:[FO_VAR_outlined_object]
|
||||
je nextObject
|
||||
xchg ecx, eax
|
||||
mov eax, [ecx+0x20]
|
||||
and eax, 0xF000000
|
||||
sar eax, 0x18
|
||||
test eax, eax // Is this an item?
|
||||
jnz nextObject // No
|
||||
cmp dword ptr [ecx+0x7C], eax // Owned by someone?
|
||||
jnz nextObject // Yes
|
||||
mov dword ptr [ecx+0x74], eax
|
||||
nextObject:
|
||||
call fo::funcoffs::obj_find_next_at_
|
||||
jmp loopObject
|
||||
end:
|
||||
call fo::funcoffs::tile_refresh_display_
|
||||
popad
|
||||
retn
|
||||
}
|
||||
}
|
||||
|
||||
static void __declspec(naked) obj_remove_outline_hook() {
|
||||
__asm {
|
||||
call fo::funcoffs::obj_remove_outline_
|
||||
test eax, eax
|
||||
jnz end
|
||||
cmp highlightingToggled, 1
|
||||
jne end
|
||||
mov ds:[FO_VAR_outlined_object], eax
|
||||
call obj_outline_all_items_on
|
||||
end:
|
||||
retn
|
||||
}
|
||||
}
|
||||
|
||||
void ProcessMainLoop() {
|
||||
if (toggleHighlightsKey) {
|
||||
//0x48C294 to toggle
|
||||
if (KeyDown(toggleHighlightsKey)) {
|
||||
if (!highlightingToggled) {
|
||||
if (motionSensorMode&4) {
|
||||
fo::GameObject* scanner = fo::func::inven_pid_is_carried_ptr(fo::var::obj_dude, fo::PID_MOTION_SENSOR);
|
||||
if (scanner != nullptr) {
|
||||
if (motionSensorMode & 2) {
|
||||
highlightingToggled = fo::func::item_m_dec_charges(scanner) + 1;
|
||||
if (!highlightingToggled) {
|
||||
fo::func::display_print(HighlightFailMsg2.c_str());
|
||||
}
|
||||
} else highlightingToggled = 1;
|
||||
} else {
|
||||
fo::func::display_print(highlightFailMsg1.c_str());
|
||||
}
|
||||
} else {
|
||||
highlightingToggled = 1;
|
||||
}
|
||||
if (highlightingToggled) {
|
||||
obj_outline_all_items_on();
|
||||
} else {
|
||||
highlightingToggled = 2;
|
||||
}
|
||||
}
|
||||
} else if (highlightingToggled) {
|
||||
if (highlightingToggled == 1) {
|
||||
obj_outline_all_items_off();
|
||||
}
|
||||
highlightingToggled = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void HighlightingMod::init() {
|
||||
toggleHighlightsKey = GetConfigInt("Input", "ToggleItemHighlightsKey", 0);
|
||||
if (toggleHighlightsKey) {
|
||||
motionSensorMode = GetConfigInt("Misc", "MotionScannerFlags", 1);
|
||||
highlightContainers = GetConfigInt("Input", "HighlightContainers", 0);
|
||||
switch (highlightContainers) {
|
||||
case 1:
|
||||
colorContainers = 0x10; // yellow
|
||||
break;
|
||||
case 2:
|
||||
colorContainers = 0x40; // purple
|
||||
break;
|
||||
}
|
||||
//HookCall(0x44B9BA, &gmouse_bk_process_hook);
|
||||
HookCall(0x44BD1C, &obj_remove_outline_hook);
|
||||
HookCall(0x44E559, &obj_remove_outline_hook);
|
||||
|
||||
highlightFailMsg1 = Translate("Sfall", "HighlightFail1", "You aren't carrying a motion sensor.");
|
||||
HighlightFailMsg2 = Translate("Sfall", "HighlightFail2", "Your motion sensor is out of charge.");
|
||||
|
||||
MainLoopHook::OnCombatLoop() += ProcessMainLoop;
|
||||
MainLoopHook::OnMainLoop() += ProcessMainLoop;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Module.h"
|
||||
|
||||
namespace sfall
|
||||
{
|
||||
|
||||
class HighlightingMod : public Module
|
||||
{
|
||||
public:
|
||||
const char* name() { return "HighlightingMod"; }
|
||||
|
||||
void init();
|
||||
};
|
||||
|
||||
}
|
||||
@@ -129,6 +129,7 @@ static const SfallMetarule metaruleArray[] = {
|
||||
{"set_flags", sf_set_flags, 2, 2, {ARG_OBJECT, ARG_INT}},
|
||||
{"get_flags", sf_get_flags, 1, 1, {ARG_OBJECT}},
|
||||
{"tile_refresh_display", sf_tile_refresh_display, 0, 0},
|
||||
{"outlined_object", sf_outlined_object, 0, 0},
|
||||
};
|
||||
|
||||
void InitMetaruleTable() {
|
||||
|
||||
@@ -419,5 +419,9 @@ void sf_get_flags(OpcodeContext& ctx) {
|
||||
ctx.setReturn(obj->flags);
|
||||
}
|
||||
|
||||
void sf_outlined_object(OpcodeContext& ctx) {
|
||||
ctx.setReturn(fo::var::outlined_object);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,5 +75,7 @@ void sf_set_flags(OpcodeContext&);
|
||||
|
||||
void sf_get_flags(OpcodeContext&);
|
||||
|
||||
void sf_outlined_object(OpcodeContext&);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,7 +223,6 @@
|
||||
<ClInclude Include="FalloutEngine\Variables.h" />
|
||||
<ClInclude Include="FalloutEngine\Functions.h" />
|
||||
<ClInclude Include="FalloutEngine\Functions_def.h" />
|
||||
<ClInclude Include="Modules\HighlightingMod.h" />
|
||||
<ClInclude Include="Modules\Input.h" />
|
||||
<ClInclude Include="ModuleManager.h" />
|
||||
<ClInclude Include="Modules\MainLoopHook.h" />
|
||||
@@ -305,7 +304,6 @@
|
||||
<ClCompile Include="FalloutEngine\FunctionOffsets.cpp" />
|
||||
<ClCompile Include="FalloutEngine\Variables.cpp" />
|
||||
<ClCompile Include="FalloutEngine\Functions.cpp" />
|
||||
<ClCompile Include="Modules\HighlightingMod.cpp" />
|
||||
<ClCompile Include="Modules\Input.cpp" />
|
||||
<ClCompile Include="ModuleManager.cpp" />
|
||||
<ClCompile Include="Modules\AI.cpp" />
|
||||
|
||||
@@ -247,9 +247,6 @@
|
||||
<ClInclude Include="Modules\MainLoopHook.h">
|
||||
<Filter>Modules</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Modules\HighlightingMod.h">
|
||||
<Filter>Modules</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp" />
|
||||
@@ -461,9 +458,6 @@
|
||||
<ClCompile Include="Modules\MainLoopHook.cpp">
|
||||
<Filter>Modules</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Modules\HighlightingMod.cpp">
|
||||
<Filter>Modules</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="version.rc" />
|
||||
|
||||
@@ -39,7 +39,6 @@
|
||||
#include "Modules\FileSystem.h"
|
||||
#include "Modules\Graphics.h"
|
||||
#include "Modules\HookScripts.h"
|
||||
#include "Modules\HighlightingMod.h"
|
||||
#include "Modules\HeroAppearance.h"
|
||||
#include "Modules\Input.h"
|
||||
#include "Modules\Inventory.h"
|
||||
@@ -168,7 +167,6 @@ static void InitModules() {
|
||||
manager.add<AnimationsAtOnce>();
|
||||
manager.add<BarBoxes>();
|
||||
manager.add<HeroAppearance>();
|
||||
//manager.add<HighlightingMod>();
|
||||
manager.add<MiscPatches>();
|
||||
|
||||
manager.initAll();
|
||||
|
||||
Reference in New Issue
Block a user