2017-03-14 00:20:34 +07:00
|
|
|
/**
|
|
|
|
|
|
|
|
|
|
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"
|
2017-03-13 03:36:02 +07:00
|
|
|
//#include "..\..\..\!SRC\headers\define.h"
|
|
|
|
|
|
|
|
|
|
#define CRITTER_IS_DEAD (1)
|
2017-03-13 23:54:54 +07:00
|
|
|
#define PID_MOTION_SENSOR (59)
|
|
|
|
|
#define NO_HIGHLIGHT(obj) (get_flags(obj) bwand FLAG_NOHIGHLIGHT)
|
2017-03-13 03:36:02 +07:00
|
|
|
|
|
|
|
|
variable highlightKey;
|
|
|
|
|
variable highlightContainers;
|
2017-03-13 23:54:54 +07:00
|
|
|
variable colorContainers;
|
|
|
|
|
variable motionScannerFlags;
|
|
|
|
|
variable highlightFailMsg1;
|
|
|
|
|
variable highlightFailMsg2;
|
2017-03-13 03:36:02 +07:00
|
|
|
|
2017-03-13 23:54:54 +07:00
|
|
|
procedure toggle_highlight_object(variable obj, variable enable) begin
|
2017-03-13 03:36:02 +07:00
|
|
|
if obj
|
2017-03-13 23:54:54 +07:00
|
|
|
and (not enable or not obj_blocking_line(dude_obj, tile_num(obj), BLOCKING_TYPE_SHOOT))
|
|
|
|
|
and (highlightContainers or not NO_HIGHLIGHT(obj)) then begin
|
|
|
|
|
set_outline(
|
|
|
|
|
obj,
|
2017-03-14 00:20:34 +07:00
|
|
|
enable and (NO_HIGHLIGHT(obj) and colorContainers or OUTLINE_DARK_YELLOW) or 0
|
2017-03-13 23:54:54 +07:00
|
|
|
);
|
2017-03-13 03:36:02 +07:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2017-03-13 23:54:54 +07:00
|
|
|
procedure toggle_highlight(variable enable) begin
|
2017-03-13 03:36:02 +07:00
|
|
|
variable obj;
|
|
|
|
|
foreach obj in list_as_array(LIST_GROUNDITEMS) begin
|
2017-03-14 00:20:34 +07:00
|
|
|
if obj != outlined_object then begin
|
|
|
|
|
call toggle_highlight_object(obj, enable);
|
|
|
|
|
end
|
2017-03-13 03:36:02 +07:00
|
|
|
end
|
|
|
|
|
foreach obj in list_as_array(LIST_CRITTERS) begin
|
|
|
|
|
if critter_state(obj) == CRITTER_IS_DEAD then begin
|
2017-03-13 23:54:54 +07:00
|
|
|
call toggle_highlight_object(obj, enable);
|
2017-03-13 03:36:02 +07:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
tile_refresh_display;
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
procedure key_press_handler begin
|
|
|
|
|
variable pressed := get_sfall_arg,
|
2017-03-13 23:54:54 +07:00
|
|
|
scanCode := get_sfall_arg,
|
|
|
|
|
scanner, charges;
|
2017-03-13 03:36:02 +07:00
|
|
|
|
|
|
|
|
if scanCode == highlightKey then begin
|
|
|
|
|
if pressed then begin
|
2017-03-13 23:54:54 +07:00
|
|
|
if motionScannerFlags bwand 4 then begin
|
|
|
|
|
scanner := obj_carrying_pid_obj(dude_obj, PID_MOTION_SENSOR);
|
|
|
|
|
if scanner then begin
|
|
|
|
|
if motionScannerFlags bwand 2 then begin
|
|
|
|
|
charges := get_weapon_ammo_count(scanner);
|
|
|
|
|
if charges > 0 then begin
|
|
|
|
|
set_weapon_ammo_count(scanner, charges - 1);
|
|
|
|
|
intface_redraw;
|
|
|
|
|
call toggle_highlight(true);
|
|
|
|
|
end else begin
|
|
|
|
|
display_msg(highlightFailMsg2);
|
|
|
|
|
end
|
|
|
|
|
end else begin
|
|
|
|
|
call toggle_highlight(true);
|
|
|
|
|
end
|
|
|
|
|
end else begin
|
|
|
|
|
display_msg(highlightFailMsg1);
|
|
|
|
|
end
|
|
|
|
|
end else begin
|
|
|
|
|
call toggle_highlight(true);
|
|
|
|
|
end
|
2017-03-13 03:36:02 +07:00
|
|
|
end else begin
|
2017-03-13 23:54:54 +07:00
|
|
|
call toggle_highlight(false);
|
2017-03-13 03:36:02 +07:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
procedure start begin
|
|
|
|
|
if game_loaded then begin
|
2017-03-13 23:54:54 +07:00
|
|
|
translationIni := GetConfigStr("Main", "TranslationsINI", "./Translations.ini");
|
|
|
|
|
|
|
|
|
|
highlightKey := GetConfig("Input", "ToggleItemHighlightsKey", 0);
|
2017-03-13 03:36:02 +07:00
|
|
|
display_msg("key= " + highlightKey);
|
2017-03-13 23:54:54 +07:00
|
|
|
highlightContainers := GetConfig("Input", "HighlightContainers", 0);
|
|
|
|
|
if highlightContainers == 1 then begin
|
2017-03-14 00:20:34 +07:00
|
|
|
colorContainers := OUTLINE_DARK_YELLOW;
|
2017-03-13 23:54:54 +07:00
|
|
|
end else if highlightContainers == 2 then begin
|
|
|
|
|
colorContainers := OUTLINE_PURPLE;
|
|
|
|
|
end
|
|
|
|
|
motionScannerFlags := GetConfig("Misc", "MotionScannerFlags", 1);
|
|
|
|
|
debug_msg("Flags=" + motionScannerFlags + ", ini=" + translationIni);
|
|
|
|
|
|
|
|
|
|
highlightFailMsg1 := translate("HighlightFail1", "You aren't carrying a motion sensor.");
|
|
|
|
|
highlightFailMsg2 := translate("HighlightFail2", "Your motion sensor is out of charge.");
|
|
|
|
|
|
2017-03-13 03:36:02 +07:00
|
|
|
register_hook_proc(HOOK_KEYPRESS, key_press_handler);
|
|
|
|
|
end
|
|
|
|
|
end
|