From dc785d010e7b172e5402d2595612355aef4ee258 Mon Sep 17 00:00:00 2001 From: NovaRain Date: Sun, 9 Apr 2017 20:58:36 +0800 Subject: [PATCH] Added options for toggling corpse highlighting and LOS check. Changed default settings in sfall-mod.ini to be in line with the default ddraw.ini in previous versions of sfall. --- artifacts/config_files/sfall-mods.ini | 14 ++++-- artifacts/mods/gl_highlighting.int | Bin 3176 -> 3648 bytes artifacts/mods/gl_highlighting.ssl | 65 ++++++++++++++++---------- artifacts/mods/main.h | 10 ++-- 4 files changed, 55 insertions(+), 34 deletions(-) diff --git a/artifacts/config_files/sfall-mods.ini b/artifacts/config_files/sfall-mods.ini index 042967a7..79bc0e28 100644 --- a/artifacts/config_files/sfall-mods.ini +++ b/artifacts/config_files/sfall-mods.ini @@ -4,8 +4,14 @@ ; 42 - SHIFT key Key=42 -; Set to 1 also highlight containers -Containers=1 +; Set to 1 to also highlight containers +Containers=0 + +; Set to 1 to also highlight corpses +Corpses=0 + +; Set to 1 to only highlight objects in the player's line-of-sight +CheckLOS=0 ; Set the color of outlines, available colors: ; 1 - glowing red @@ -15,13 +21,13 @@ Containers=1 ; 16 - bright yellow ; 32 - dark yellow ; 64 - purple -OutlineColor=32 +OutlineColor=16 ; 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=1 +MotionScanner=0 [CombatControl] diff --git a/artifacts/mods/gl_highlighting.int b/artifacts/mods/gl_highlighting.int index 600c83d22c0288379b9d580d78d77beb493aa2a5..3edec4709134ad1940818e427732534f59e027ca 100644 GIT binary patch delta 1568 zcmaDMaX?0(f$0Dv0|SFl122eXk((%BSYN~d0R|8XMzVm!nHd-uY+xb~nw5=#fdM4$ z1L4C+)?Ew?3``6R3=uF92+bA-p&5QaX(+|E0HQvcQ2;6er8p`W7#J8C7#NkH0#J%; z5rn~L0-<3fPaK5BXvQF*hXNQTD>F7o@FeCG=R4;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-yi9BYlee)-`)0LjUW03cJuI%EdRQ8Sz_JVtMhz#yEXD@o2D{02?9!a}kXYqNnw-Ec%gfpz)Kme9 zPmZd|UF>p`Q#cwKS51D#;Vaz*)d}&+y{57T6Np~Uj>&$UvW#q#b2t@PI2jsPCNJPL zW$c=Kjnh{;3#O^zH1c*1-)49=6FA+{%oHCdY7F*YAKPC`b~5 zknFI;%zdVT1#ALGgHXc`5R3a0M1=bTK7Bka5LFE9Fnv5)5D^{?RDF6NLmA)}@&rJY Q`9YOIau?iLljAs~03}A|{r~^~ diff --git a/artifacts/mods/gl_highlighting.ssl b/artifacts/mods/gl_highlighting.ssl index 2e825d33..a0576e30 100644 --- a/artifacts/mods/gl_highlighting.ssl +++ b/artifacts/mods/gl_highlighting.ssl @@ -1,42 +1,53 @@ /** - - Item Highlight mod. - + + Item Highlight mod. + Previously was part of sfall itself, now a separate mod. Features: - - highlighting items, containers (optional) and dead bodies on the ground + - highlighting items, containers (optional) and dead bodies (optional) on the ground - 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 (optional) - motion scanner is required to enable highlight (optional) - motion scanner charges are decreased on each use (optional) - + NOTE: this script requires compiler from sfall modderspack with -s option (short circuit evaluation) - + version 1.0 - + **/ #include "main.h" //#include "..\..\..\!SRC\headers\define.h" -#define CRITTER_IS_DEAD (1) +#define CRITTER_IS_DEAD (1) #define PID_MOTION_SENSOR (59) #define NO_HIGHLIGHT(obj) (get_flags(obj) bwand FLAG_NOHIGHLIGHT) variable configSection := "Highlighting"; variable highlightKey; variable alsoContainer; +variable alsoCorpse; +variable checkLOS; variable outlineColor; variable motionScanner; variable highlightFailMsg1; variable highlightFailMsg2; procedure ToggleHighlightObject(variable obj, variable enable) begin - if obj and (not enable or not obj_blocking_line(dude_obj, tile_num(obj), BLOCKING_TYPE_SHOOT)) then begin - if (alsoContainer and obj_item_subtype(obj) == item_type_container) or (not NO_HIGHLIGHT(obj)) then begin - if (enable) then set_outline(obj, outlineColor); - else set_outline(obj, 0); + if (checkLOS) then begin + if obj and (not enable or not obj_blocking_line(dude_obj, tile_num(obj), BLOCKING_TYPE_SHOOT)) then begin + if (alsoContainer and obj_item_subtype(obj) == item_type_container) or (not NO_HIGHLIGHT(obj)) then begin + if (enable) then set_outline(obj, outlineColor); + else set_outline(obj, 0); + end + end + end else begin + if obj then begin + if (alsoContainer and obj_item_subtype(obj) == item_type_container) or (not NO_HIGHLIGHT(obj)) then begin + if (enable) then set_outline(obj, outlineColor); + else set_outline(obj, 0); + end end end end @@ -48,9 +59,11 @@ procedure ToggleHighlight(variable enable) begin call ToggleHighlightObject(obj, enable); end end - foreach obj in list_as_array(LIST_CRITTERS) begin - if critter_state(obj) == CRITTER_IS_DEAD then begin - call ToggleHighlightObject(obj, enable); + if (alsoCorpse) then begin + foreach obj in list_as_array(LIST_CRITTERS) begin + if critter_state(obj) == CRITTER_IS_DEAD then begin + call ToggleHighlightObject(obj, enable); + end end end tile_refresh_display; @@ -60,7 +73,7 @@ procedure KeyPressHandler begin variable pressed := get_sfall_arg, scanCode := get_sfall_arg, scanner, charges; - + if scanCode == highlightKey then begin if pressed then begin if motionScanner then begin @@ -72,7 +85,7 @@ procedure KeyPressHandler begin set_weapon_ammo_count(scanner, charges - 1); intface_redraw; call ToggleHighlight(true); - end else begin + end else begin display_msg(highlightFailMsg2); end end else begin @@ -80,10 +93,10 @@ procedure KeyPressHandler begin end end else begin display_msg(highlightFailMsg1); - end + end end else begin call ToggleHighlight(true); - end + end end else begin call ToggleHighlight(false); end @@ -93,15 +106,17 @@ end procedure start begin if game_loaded and (sfall_ver_major >= 4) then begin call InitConfigs; - + highlightKey := GetConfig(configSection, "Key", 0); alsoContainer := GetConfig(configSection, "Containers", 0); - outlineColor := GetConfig(configSection, "OutlineColor", 0); - motionScanner := GetConfig(configSection, "MotionScanner", 1); - + alsoCorpse := GetConfig(configSection, "Corpses", 0); + checkLOS := GetConfig(configSection, "CheckLOS", 0); + outlineColor := GetConfig(configSection, "OutlineColor", 16); + motionScanner := GetConfig(configSection, "MotionScanner", 0); + highlightFailMsg1 := Translate("HighlightFail1", "You aren't carrying a motion sensor."); highlightFailMsg2 := Translate("HighlightFail2", "Your motion sensor is out of charge."); - + register_hook_proc(HOOK_KEYPRESS, KeyPressHandler); end end diff --git a/artifacts/mods/main.h b/artifacts/mods/main.h index 6cde0ab3..8b769a4c 100644 --- a/artifacts/mods/main.h +++ b/artifacts/mods/main.h @@ -14,7 +14,7 @@ variable translationIni; 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; + return val; end // Gets the string value from ddraw.ini @@ -28,14 +28,14 @@ end procedure GetConfigList(variable section, variable key) begin variable val := get_ini_string(ini + "|" + section + "|" + key); if val == -1 or val == "" then return []; - + return string_split(val, ","); end // Gets the value from ddraw.ini as a temp array of ints procedure GetConfigListInt(variable section, variable key) begin variable arr, i, item; - + arr := GetConfigList(section, key); for (i := 0; i < len_array(arr); i++) begin arr[i] := atoi(arr[i]); @@ -45,10 +45,10 @@ end // Translates given string using Translations.ini 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 str := def; - end + end return str; end