Moved highlighting-related settings into new "sfall-mods.ini", dedicated for scripted sfall mods;

Reverted description for MotionScannerFlags 1 and 2, it was actually correct before.
This commit is contained in:
phobos2077
2017-03-16 01:21:20 +07:00
parent 943561ea65
commit adf8dd13dd
6 changed files with 62 additions and 46 deletions
+2 -9
View File
@@ -127,13 +127,6 @@ SpeedKey9=0x00
;Set to -1 for either ctrl key, -2 for either alt key or -3 for either shift key ;Set to -1 for either ctrl key, -2 for either alt key or -3 for either shift key
WindowScrollKey=0 WindowScrollKey=0
;A key to press to toggle the highlighting of all items on the ground on the current map
ToggleItemHighlightsKey=42
;Set to 1 to also highlight containers
;Set to 2 for purple outlines
HighlightContainers=0
;A key to press to reload your currently equipped weapon ;A key to press to reload your currently equipped weapon
ReloadWeaponKey=0 ReloadWeaponKey=0
@@ -448,8 +441,8 @@ CritterInvSizeLimitMode=0
CritterInvSizeLimit=200 CritterInvSizeLimit=200
;Some bit flags to alter behaviour of the motion sensor ;Some bit flags to alter behaviour of the motion sensor
;2 - Motion sensor require charges when using highlight feature ;1 - Allow sensor use on automap when motion sensor is in pack rather than hands
;4 - Motion sensor is required to use the item highlight feature ;2 - Motion sensor doesn't require charges
MotionScannerFlags=1 MotionScannerFlags=1
;Set to non-0 to adjust the maximum encounter table size ;Set to non-0 to adjust the maximum encounter table size
Binary file not shown.
+30 -34
View File
@@ -8,7 +8,10 @@
- configurable hotkey is used to trigger highlight - configurable hotkey is used to trigger highlight
- only objects in direct line-of-sight of player are highlighted - only objects in direct line-of-sight of player are highlighted
- motion scanner is required to enable highlight (optional) - motion scanner is required to enable highlight (optional)
- motion scanner charges are decreesed on each use (optional) - motion scanner charges are decreased on each use (optional)
NOTE: this script requires compiler from sfall modderspack with -s option
(short circuit evaluation)
**/ **/
@@ -19,91 +22,84 @@
#define PID_MOTION_SENSOR (59) #define PID_MOTION_SENSOR (59)
#define NO_HIGHLIGHT(obj) (get_flags(obj) bwand FLAG_NOHIGHLIGHT) #define NO_HIGHLIGHT(obj) (get_flags(obj) bwand FLAG_NOHIGHLIGHT)
variable configSection := "Highlighting";
variable highlightKey; variable highlightKey;
variable highlightContainers; variable ignoreFlags;
variable colorContainers; variable outlineColor;
variable motionScannerFlags; variable motionScanner;
variable highlightFailMsg1; variable highlightFailMsg1;
variable highlightFailMsg2; variable highlightFailMsg2;
procedure toggle_highlight_object(variable obj, variable enable) begin procedure ToggleHighlightObject(variable obj, variable enable) begin
if obj if obj
and (not enable or not obj_blocking_line(dude_obj, tile_num(obj), BLOCKING_TYPE_SHOOT)) 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 and (ignoreFlags or not NO_HIGHLIGHT(obj)) then begin
set_outline( if (enable) then set_outline(obj, outlineColor);
obj, else set_outline(obj, 0);
enable and (NO_HIGHLIGHT(obj) and colorContainers or OUTLINE_DARK_YELLOW) or 0
);
end end
end end
procedure toggle_highlight(variable enable) begin procedure ToggleHighlight(variable enable) begin
variable obj; variable obj;
foreach obj in list_as_array(LIST_GROUNDITEMS) begin foreach obj in list_as_array(LIST_GROUNDITEMS) begin
if obj != outlined_object then begin if obj != outlined_object then begin
call toggle_highlight_object(obj, enable); call ToggleHighlightObject(obj, enable);
end end
end end
foreach obj in list_as_array(LIST_CRITTERS) begin foreach obj in list_as_array(LIST_CRITTERS) begin
if critter_state(obj) == CRITTER_IS_DEAD then begin if critter_state(obj) == CRITTER_IS_DEAD then begin
call toggle_highlight_object(obj, enable); call ToggleHighlightObject(obj, enable);
end end
end end
tile_refresh_display; tile_refresh_display;
end end
procedure key_press_handler begin procedure KeyPressHandler begin
variable pressed := get_sfall_arg, variable pressed := get_sfall_arg,
scanCode := get_sfall_arg, scanCode := get_sfall_arg,
scanner, charges; scanner, charges;
if scanCode == highlightKey then begin if scanCode == highlightKey then begin
if pressed then begin if pressed then begin
if motionScannerFlags bwand 4 then begin if motionScanner then begin
scanner := obj_carrying_pid_obj(dude_obj, PID_MOTION_SENSOR); scanner := obj_carrying_pid_obj(dude_obj, PID_MOTION_SENSOR);
if scanner then begin if scanner then begin
if motionScannerFlags bwand 2 then begin if motionScanner >= 2 then begin
charges := get_weapon_ammo_count(scanner); charges := get_weapon_ammo_count(scanner);
if charges > 0 then begin if charges > 0 then begin
set_weapon_ammo_count(scanner, charges - 1); set_weapon_ammo_count(scanner, charges - 1);
intface_redraw; intface_redraw;
call toggle_highlight(true); call ToggleHighlight(true);
end else begin end else begin
display_msg(highlightFailMsg2); display_msg(highlightFailMsg2);
end end
end else begin end else begin
call toggle_highlight(true); call ToggleHighlight(true);
end end
end else begin end else begin
display_msg(highlightFailMsg1); display_msg(highlightFailMsg1);
end end
end else begin end else begin
call toggle_highlight(true); call ToggleHighlight(true);
end end
end else begin end else begin
call toggle_highlight(false); call ToggleHighlight(false);
end end
end end
end end
procedure start begin procedure start begin
if game_loaded then begin if game_loaded then begin
translationIni := GetConfigStr("Main", "TranslationsINI", "./Translations.ini"); call InitConfigs;
highlightKey := GetConfig("Input", "ToggleItemHighlightsKey", 0); highlightKey := GetConfig(configSection, "Key", 0);
display_msg("key= " + highlightKey); ignoreFlags := GetConfig(configSection, "IgnoreFlags", 0);
highlightContainers := GetConfig("Input", "HighlightContainers", 0); outlineColor := GetConfig(configSection, "OutlineColor", 0);
if highlightContainers == 1 then begin motionScanner := GetConfig(configSection, "MotionScanner", 1);
colorContainers := OUTLINE_DARK_YELLOW;
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."); highlightFailMsg1 := Translate("HighlightFail1", "You aren't carrying a motion sensor.");
highlightFailMsg2 := translate("HighlightFail2", "Your motion sensor is out of charge."); highlightFailMsg2 := Translate("HighlightFail2", "Your motion sensor is out of charge.");
register_hook_proc(HOOK_KEYPRESS, key_press_handler); register_hook_proc(HOOK_KEYPRESS, KeyPressHandler);
end end
end end
+5 -2
View File
@@ -2,7 +2,7 @@
#include "..\scripting\headers\sfall.h" #include "..\scripting\headers\sfall.h"
#include "..\scripting\headers\define_extra.h" #include "..\scripting\headers\define_extra.h"
variable ini := "ddraw.ini"; variable ini := "sfall-mods.ini";
variable translationIni; variable translationIni;
// Gets the integer value from ddraw.ini // Gets the integer value from ddraw.ini
@@ -20,7 +20,7 @@ procedure GetConfigStr(variable section, variable key, variable def) begin
end end
// Translates given string using Translations.ini // Translates given string using Translations.ini
procedure translate(variable id, variable def) begin procedure Translate(variable id, variable def) begin
variable str := get_ini_string(translationIni + "|Sfall|" + id); variable str := get_ini_string(translationIni + "|Sfall|" + id);
if not str or (strlen(str) == 0) then begin if not str or (strlen(str) == 0) then begin
str := def; str := def;
@@ -28,3 +28,6 @@ procedure translate(variable id, variable def) begin
return str; return str;
end end
procedure InitConfigs begin
translationIni := GetConfigStr("Main", "TranslationsINI", "./Translations.ini");
end
+1 -1
View File
@@ -161,11 +161,11 @@
#define OUTLINE_NONE (0) #define OUTLINE_NONE (0)
#define OUTLINE_RED_GLOW (0x01) #define OUTLINE_RED_GLOW (0x01)
#define OUTLINE_RED (0x02) #define OUTLINE_RED (0x02)
#define OUTLINE_PURPLE (0x03)
#define OUTLINE_GREY (0x04) #define OUTLINE_GREY (0x04)
#define OUTLINE_GREEN_GLOW (0x08) #define OUTLINE_GREEN_GLOW (0x08)
#define OUTLINE_YELLOW (0x10) #define OUTLINE_YELLOW (0x10)
#define OUTLINE_DARK_YELLOW (0x20) #define OUTLINE_DARK_YELLOW (0x20)
#define OUTLINE_PURPLE (0x40)
#define mstr_combat(x) (message_str_game(GAME_MSG_COMBAT, x)) #define mstr_combat(x) (message_str_game(GAME_MSG_COMBAT, x))
#define mstr_ai(x) (message_str_game(GAME_MSG_AI, x)) #define mstr_ai(x) (message_str_game(GAME_MSG_AI, x))
+24
View File
@@ -0,0 +1,24 @@
[Highlighting]
; DX scandode of a key to press to highlight items on the ground
; 207 - END key
Key=207
; Set to 1 to ignore NO_HIGHLIGHT flag present on most containers
IgnoreFlags=1
; Set the color of outlines, available colors:
; 1 - glowing red
; 2 - red
; 4 - grey
; 8 - glowing green
; 16 - bright yellow
; 32 - dark yellow
; 64 - purple
OutlineColor=32
; Motion Scanner mode:
; 0 - ignored
; 1 - requires Motion Scanner present in player inventory to activate highlighting
; 2 - requires Motion Scanner and also requires 1 charge on every use (depleted scanner will not work anymore)
MotionScanner=2