Added OutlineColorContainers/Corpses to the built-in item highlighting

Minor code refactor of the built-in item highlighting.
Updated version number.
This commit is contained in:
NovaRain
2024-06-28 22:11:00 +08:00
parent 81f4af927b
commit 33943bb6ff
3 changed files with 71 additions and 51 deletions
+8 -2
View File
@@ -1,5 +1,5 @@
;sfall configuration settings
;v3.8.44
;v3.8.44.1
[Main]
;Set to 1 if you want to use command line arguments to tell sfall to use another ini file
@@ -223,7 +223,7 @@ HighlightContainers=0
;Set to 1 to also highlight lootable corpses
HighlightCorpses=0
;Set the color of outlines, available colors:
;Set the color of outlines for items, available colors:
;1 - glowing red
;2 - red
;4 - grey
@@ -234,6 +234,12 @@ HighlightCorpses=0
;You can set a custom color from the game palette by multiplying the color index value by 256 (in 3.8.27 or later)
OutlineColor=16
;Set the color of outlines for containers
OutlineColorContainers=4
;Set the color of outlines for corpses
OutlineColorCorpses=4
;A key to press to reload your currently equipped weapon or use the active item
;Set to 0 if you don't want a reload key, or a DX scancode otherwise
ReloadWeaponKey=0
+61 -47
View File
@@ -53,6 +53,8 @@ static DWORD highlightContainers;
static DWORD highlightCorpses;
static DWORD motionScanner;
static int outlineColor;
static int outlineColorContainers;
static int outlineColorCorpses;
static char highlightFail1[128];
static char highlightFail2[128];
@@ -441,20 +443,33 @@ static __declspec(naked) void obj_outline_all_items_on() {
pushadc;
mov eax, ds:[FO_VAR_map_elevation];
call fo::funcoffs::obj_find_first_at_;
loopObject:
jmp checkObject;
nextObject:
call fo::funcoffs::obj_find_next_at_;
checkObject:
test eax, eax;
jz end;
cmp eax, ds:[FO_VAR_outlined_object];
je nextObject;
xchg ecx, eax;
mov eax, [ecx + artFid];
and eax, 0xF000000;
sar eax, 0x18;
test eax, eax; // Is this an item?
jz skip; // Yes
dec eax; // Is this a critter?
jnz nextObject; // No
cmp highlightCorpses, eax; // Highlight corpses?
cmp dword ptr [eax + owner], 0; // Owned by someone?
jne nextObject; // Yes
cmp dword ptr [eax + outline], 0; // Already outlined?
jne nextObject; // Yes
mov ecx, [eax + artFid];
and ecx, 0xF000000;
sar ecx, 0x18;
cmp ecx, OBJ_TYPE_CRITTER; // Is this a critter?
mov ecx, eax;
je isCritter; // Yes
ja nextObject; // Neither an item nor a critter
test byte ptr [eax + flags + 1], 0x10; // Is NoHighlight_ flag set?
jz normalItem; // No
call fo::funcoffs::item_get_type_;
cmp eax, item_type_container; // Is this item a container?
je isContainer; // Yes
jmp nextObject;
isCritter:
cmp highlightCorpses, 0; // Highlight corpses?
je nextObject; // No
test byte ptr [ecx + damageFlags], DAM_DEAD; // source.results & DAM_DEAD?
jz nextObject; // No
@@ -463,25 +478,21 @@ loopObject:
call fo::funcoffs::critter_flag_check_;
test eax, eax; // Can't be stolen from?
jnz nextObject; // Yes
skip:
cmp [ecx + owner], eax; // Owned by someone?
jnz nextObject; // Yes
test [ecx + outline], eax; // Already outlined?
jnz nextObject; // Yes
test byte ptr [ecx + flags + 1], 0x10; // Is NoHighlight_ flag set (is this a container)?
jz NoHighlight; // No
cmp highlightContainers, eax; // Highlight containers?
je nextObject; // No
NoHighlight:
mov edx, outlineColor;
mov [ecx + outline], edx;
nextObject:
call fo::funcoffs::obj_find_next_at_;
jmp loopObject;
mov eax, outlineColorCorpses; // Set outline color for corpses
jmp setOutline;
isContainer:
cmp highlightContainers, 0; // Highlight containers?
je nextObject;
mov eax, outlineColorContainers; // Set outline color for containers
jmp setOutline;
normalItem:
mov eax, outlineColor; // Set outline color for items
setOutline:
mov [ecx + outline], eax;
jmp nextObject;
end:
call fo::funcoffs::tile_refresh_display_;
popadc;
retn;
jmp fo::funcoffs::tile_refresh_display_;
}
}
@@ -492,32 +503,31 @@ static __declspec(naked) void obj_outline_all_items_off() {
pushadc;
mov eax, ds:[FO_VAR_map_elevation];
call fo::funcoffs::obj_find_first_at_;
loopObject:
jmp checkObject;
nextObject:
call fo::funcoffs::obj_find_next_at_;
checkObject:
test eax, eax;
jz end;
cmp eax, ds:[FO_VAR_outlined_object];
je nextObject;
xchg ecx, eax;
mov eax, [ecx + artFid];
and eax, 0xF000000;
sar eax, 0x18;
test eax, eax; // Is this an item?
jz skip; // Yes
dec eax; // Is this a critter?
mov ecx, [eax + artFid];
and ecx, 0xF000000;
sar ecx, 0x18;
test ecx, ecx; // Is this an item?
jz isItem; // Yes
dec ecx; // Is this a critter?
jnz nextObject; // No
test byte ptr [ecx + damageFlags], DAM_DEAD; // source.results & DAM_DEAD?
test byte ptr [eax + damageFlags], DAM_DEAD; // source.results & DAM_DEAD?
jz nextObject; // No
skip:
cmp [ecx + owner], eax; // Owned by someone?
jnz nextObject; // Yes
mov [ecx + outline], eax;
nextObject:
call fo::funcoffs::obj_find_next_at_;
jmp loopObject;
isItem:
cmp [eax + owner], ecx; // Owned by someone? (ecx = 0)
jne nextObject; // Yes
mov [eax + outline], ecx; // Remove outline
jmp nextObject;
end:
call fo::funcoffs::tile_refresh_display_;
popadc;
retn;
jmp fo::funcoffs::tile_refresh_display_;
}
}
@@ -1058,8 +1068,12 @@ void ScriptExtender::init() {
if (toggleHighlightsKey) {
highlightContainers = IniReader::GetConfigInt("Input", "HighlightContainers", 0);
highlightCorpses = IniReader::GetConfigInt("Input", "HighlightCorpses", 0);
outlineColor = IniReader::GetConfigInt("Input", "OutlineColor", 0x10);
if (outlineColor < 1) outlineColor = 0x40;
outlineColor = IniReader::GetConfigInt("Input", "OutlineColor", 16);
if (outlineColor < 1) outlineColor = 64;
outlineColorContainers = IniReader::GetConfigInt("Input", "OutlineColorContainers", 16);
if (outlineColorContainers < 1) outlineColorContainers = 64;
outlineColorCorpses = IniReader::GetConfigInt("Input", "OutlineColorCorpses", 16);
if (outlineColorCorpses < 1) outlineColorCorpses = 64;
motionScanner = IniReader::GetConfigInt("Misc", "MotionScannerFlags", 1);
Translate::Get("Sfall", "HighlightFail1", "You aren't carrying a motion sensor.", highlightFail1);
Translate::Get("Sfall", "HighlightFail2", "Your motion sensor is out of charge.", highlightFail2);
+2 -2
View File
@@ -25,6 +25,6 @@
#define VERSION_MAJOR 3
#define VERSION_MINOR 8
#define VERSION_BUILD 44
#define VERSION_REV 0
#define VERSION_REV 1
#define VERSION_STRING "3.8.44"
#define VERSION_STRING "3.8.44.1"