mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
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.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user