Added lootable corpses to the built-in item highlighting

This commit is contained in:
NovaRain
2019-12-23 21:22:15 +08:00
parent 3a24d0bdfd
commit 310c392759
3 changed files with 88 additions and 66 deletions
+3
View File
@@ -153,6 +153,9 @@ ToggleItemHighlightsKey=42
;Set to 1 to also highlight containers
HighlightContainers=1
;Set to 1 to also highlight lootable corpses
HighlightCorpses=1
;Set the color of outlines, available colors:
;0x01 - glowing red
;0x02 - red
+1 -1
View File
@@ -138,7 +138,7 @@ enum ScriptTypes : long
};
/* 24 */
enum ObjectTypes : char
enum ObjType : char
{
OBJ_TYPE_ITEM = 0,
OBJ_TYPE_CRITTER = 1,
+84 -65
View File
@@ -452,9 +452,10 @@ static void InitOpcodeMetaTable() {
typedef void (_stdcall *regOpcodeProc)(WORD opcode, void* ptr);
static DWORD highlightingToggled = 0;
static DWORD MotionSensorMode;
static DWORD motionScanner;
static BYTE toggleHighlightsKey;
static DWORD highlightContainers = 0;
static DWORD highlightCorpses = 0;
static int outlineColor = 0x10;
static int idle;
static char HighlightFail1[128];
@@ -1181,81 +1182,98 @@ static void __declspec(naked) CombatOverHook() {
static void __declspec(naked) obj_outline_all_items_on() {
__asm {
pushad
mov eax, dword ptr ds:[_map_elevation]
call obj_find_first_at_
pushad;
mov eax, ds:[_map_elevation];
call obj_find_first_at_;
loopObject:
test eax, eax
jz end
cmp eax, ds:[_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
test dword ptr [ecx+0x74], eax // Already outlined?
jnz nextObject // Yes
test byte ptr [ecx+0x25], 0x10 // Is NoHighlight_ flag set (is this a container)?
jz NoHighlight // No
cmp highlightContainers, eax // Highlight containers?
je nextObject // No
test eax, eax;
jz end;
cmp eax, ds:[_outlined_object];
je nextObject;
xchg ecx, eax;
mov eax, [ecx + 0x20];
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?
je nextObject; // No
test byte ptr [ecx + 0x44], DAM_DEAD; // source.results & DAM_DEAD?
jz nextObject; // No
mov edx, 0x20; // _Steal flag
mov eax, [ecx + 0x64]; // eax = source.pid
call critter_flag_check_;
test eax, eax; // Can't be stolen from?
jnz nextObject; // Yes
skip:
cmp [ecx + 0x7C], eax; // Owned by someone?
jnz nextObject; // Yes
test [ecx + 0x74], eax; // Already outlined?
jnz nextObject; // Yes
test byte ptr [ecx + 0x25], 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+0x74], edx
mov edx, outlineColor;
mov [ecx + 0x74], edx;
nextObject:
call obj_find_next_at_
jmp loopObject
call obj_find_next_at_;
jmp loopObject;
end:
call tile_refresh_display_
popad
retn
call tile_refresh_display_;
popad;
retn;
}
}
static void __declspec(naked) obj_outline_all_items_off() {
__asm {
pushad
mov eax, dword ptr ds:[_map_elevation]
call obj_find_first_at_
pushad;
mov eax, ds:[_map_elevation];
call obj_find_first_at_;
loopObject:
test eax, eax
jz end
cmp eax, ds:[_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
test eax, eax;
jz end;
cmp eax, ds:[_outlined_object];
je nextObject;
xchg ecx, eax;
mov eax, [ecx + 0x20];
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
test byte ptr [ecx + 0x44], DAM_DEAD; // source.results & DAM_DEAD?
jz nextObject; // No
skip:
cmp [ecx + 0x7C], eax; // Owned by someone?
jnz nextObject; // Yes
mov [ecx + 0x74], eax;
nextObject:
call obj_find_next_at_
jmp loopObject
call obj_find_next_at_;
jmp loopObject;
end:
call tile_refresh_display_
popad
retn
call tile_refresh_display_;
popad;
retn;
}
}
static void __declspec(naked) obj_remove_outline_hook() {
__asm {
call obj_remove_outline_
test eax, eax
jnz end
cmp highlightingToggled, 1
jne end
mov ds:[_outlined_object], eax
call obj_outline_all_items_on
call obj_remove_outline_;
test eax, eax;
jnz end;
cmp highlightingToggled, 1;
jne end;
mov ds:[_outlined_object], eax;
call obj_outline_all_items_on;
end:
retn
retn;
}
}
@@ -1283,15 +1301,16 @@ static void _stdcall ClearEventsOnMapExit() {
void ScriptExtenderInit() {
toggleHighlightsKey = GetConfigInt("Input", "ToggleItemHighlightsKey", 0);
if (toggleHighlightsKey) {
MotionSensorMode = GetConfigInt("Misc", "MotionScannerFlags", 1);
highlightContainers = GetConfigInt("Input", "HighlightContainers", 0);
highlightCorpses = GetConfigInt("Input", "HighlightCorpses", 0);
outlineColor = GetConfigInt("Input", "OutlineColor", 0x10);
if (outlineColor < 1) outlineColor = 0x40;
HookCall(0x44BD1C, &obj_remove_outline_hook);
HookCall(0x44E559, &obj_remove_outline_hook);
motionScanner = GetConfigInt("Misc", "MotionScannerFlags", 1);
Translate("Sfall", "HighlightFail1", "You aren't carrying a motion sensor.", HighlightFail1);
Translate("Sfall", "HighlightFail2", "Your motion sensor is out of charge.", HighlightFail2);
HookCall(0x44BD1C, obj_remove_outline_hook); // gmouse_bk_process_
HookCall(0x44E559, obj_remove_outline_hook); // gmouse_remove_item_outline_
}
Translate("Sfall", "HighlightFail1", "You aren't carrying a motion sensor.", HighlightFail1);
Translate("Sfall", "HighlightFail2", "Your motion sensor is out of charge.", HighlightFail2);
idle = GetConfigInt("Misc", "ProcessorIdle", -1);
if (idle > -1) {
@@ -1849,7 +1868,7 @@ static void RunGlobalScripts1() {
//0x48C294 to toggle
if (KeyDown(toggleHighlightsKey)) {
if (!highlightingToggled) {
if (MotionSensorMode & 4) {
if (motionScanner & 4) {
DWORD scanner;
__asm {
mov eax, ds:[_obj_dude];
@@ -1858,7 +1877,7 @@ static void RunGlobalScripts1() {
mov scanner, eax;
}
if (scanner) {
if (!(MotionSensorMode & 2)) {
if (!(motionScanner & 2)) {
__asm {
mov eax, scanner;
call item_m_dec_charges_; //Returns -1 if the item has no charges