what am i doing wrong?this works perfectly all cept for the LOS checks,it displays al item regardless,tho if i swap obj_blocking_line to obj_can_see_obj,objects are filtered
edit : missed setting the check los var,now it works with items on ground, containers and corpses,but critters dont highlight at all
edit : got it,was block mode problem,works with mode BLOCKING_TYPE_SIGHT
Code:
variable translationIni;
procedure GetConfig(variable arg0, variable arg1, variable arg2);
procedure GetConfigStr(variable arg0, variable arg1, variable arg2);
procedure Translate(variable arg0, variable arg1);
procedure InitConfigs;
variable highlightKey;
variable isHighlight;
variable alsoContainer;
variable alsoCorpse;
variable CheckLOS;
variable ItemsOutlineColor;
variable ContainersOutlineColor;
variable CorpsesOutlineColor;
variable CrittersOutlineColor;
variable motionScanner;
variable highlightFailMsg1;
variable highlightFailMsg2;
procedure ToggleHighlightObject(variable arg0, variable arg1,variable outlineColor);
procedure ToggleHighlight(variable arg0);
procedure KeyPressHandler;
procedure CombatTurnHandler;
procedure GameModeChangeHandler;
procedure InventoryMoveHandler;
procedure start;
procedure ItemColor(variable Highlight);
procedure ContainerColor(variable Highlight);
procedure CorpseColor(variable Highlight);
procedure CritterColor(variable Highlight);
procedure GetConfig(variable arg0, variable arg1, variable arg2)
begin
variable LVar3 := 0;
LVar3 := get_ini_setting("sfall-mods.ini" + "|" + arg0 + "|" + arg1);
if (LVar3 == -1) then begin
LVar3 := arg2;
end
return LVar3;
end
procedure GetConfigStr(variable arg0, variable arg1, variable arg2)
begin
variable LVar3 := 0;
LVar3 := get_ini_string("sfall-mods.ini" + "|" + arg0 + "|" + arg1);
if ((LVar3 == -1) or (LVar3 == "")) then begin
LVar3 := arg2;
end
return LVar3;
end
procedure Translate(variable arg0, variable arg1)
begin
variable LVar2 := 0;
LVar2 := get_ini_string(translationIni + "|Sfall|" + arg0);
if (not(LVar2) or (strlen(LVar2) == 0)) then begin
LVar2 := arg1;
end
return LVar2;
end
procedure InitConfigs
begin
translationIni := GetConfigStr("Main", "TranslationsINI", "./Translations.ini");
end
procedure ToggleHighlightObject(variable arg0, variable arg1,variable outlineColor)
begin
if (arg0 and (not(CheckLOS) or not(obj_blocking_line(dude_obj, tile_num(arg0), 1)))) then begin
if (ContainersOutlineColor and (obj_item_subtype(arg0) == 1) or not(sfall_func1("get_flags", arg0) bwand 4096)) then begin
if (arg1) then begin
sfall_func2("set_outline", arg0, outlineColor);
end
else begin
sfall_func2("set_outline", arg0, 0);
end
end
end
end
procedure ItemColor(variable Highlight)
begin
variable object := 0;
variable object_list := 0;
variable object_list_len := 0;
variable list_object_counter := 0;
variable current_list_object := 0;
object_list := list_as_array(1);
list_object_counter := 0;
object_list_len := len_array(object_list);
while (list_object_counter < object_list_len) do begin
current_list_object := array_key(object_list, list_object_counter);
object := get_array(object_list, current_list_object);
if (object != sfall_func0("outlined_object")) then begin
if (obj_item_subtype(object) != 1) then begin
call ToggleHighlightObject(object, Highlight, ItemsOutlineColor);
//display_msg("item");
end
end
list_object_counter := list_object_counter + 1;
end
end
procedure ContainerColor(variable Highlight)
begin
variable object := 0;
variable object_list := 0;
variable object_list_len := 0;
variable list_object_counter := 0;
variable current_list_object := 0;
object_list := list_as_array(1);
list_object_counter := 0;
object_list_len := len_array(object_list);
while (list_object_counter < object_list_len) do begin
current_list_object := array_key(object_list, list_object_counter);
object := get_array(object_list, current_list_object);
if (object != sfall_func0("outlined_object")) then begin
if (obj_item_subtype(object) == 1) then begin
call ToggleHighlightObject(object, Highlight, ContainersOutlineColor);
//display_msg("container");
end
end
list_object_counter := list_object_counter + 1;
end
end
procedure CorpseColor(variable Highlight)
begin
variable object := 0;
variable object_list := 0;
variable object_list_len := 0;
variable list_object_counter := 0;
variable current_list_object := 0;
object_list := list_as_array(0);
list_object_counter := 0;
object_list_len := len_array(object_list);
while (list_object_counter < object_list_len) do begin
current_list_object := array_key(object_list, list_object_counter);
object := get_array(object_list, current_list_object);
if (object != sfall_func0("outlined_object")) then begin
if ((critter_state(object) bwand 1) and not(get_proto_data(obj_pid(object), 32) bwand 32)) then begin
call ToggleHighlightObject(object, Highlight, CorpsesOutlineColor);
//display_msg("corpse");
end
end
list_object_counter := list_object_counter + 1;
end
end
procedure CritterColor(variable Highlight)
begin
variable object := 0;
variable object_list := 0;
variable object_list_len := 0;
variable list_object_counter := 0;
variable current_list_object := 0;
object_list := list_as_array(0);
list_object_counter := 0;
object_list_len := len_array(object_list);
while (list_object_counter < object_list_len) do begin
current_list_object := array_key(object_list, list_object_counter);
object := get_array(object_list, current_list_object);
if (object != sfall_func0("outlined_object")) then begin
if (not(critter_state(object) bwand 1)) then begin
call ToggleHighlightObject(object, Highlight, CrittersOutlineColor);
//display_msg("critter");
end
end
list_object_counter := list_object_counter + 1;
end
end
procedure ToggleHighlight(variable Highlight)
begin
call ItemColor(Highlight);
if (ContainersOutlineColor) then begin
call ContainerColor(Highlight);
end
if (CorpsesOutlineColor) then begin
call CorpseColor(Highlight);
end
if (CrittersOutlineColor) then begin
call CritterColor(Highlight);
end
sfall_func0("tile_refresh_display");
end
procedure KeyPressHandler
begin
variable LVar0 := 0;
variable LVar1 := 0;
variable LVar2 := 0;
variable LVar3 := 0;
LVar0 := get_sfall_arg;
LVar1 := get_sfall_arg;
if ((LVar1 == highlightKey) and not(get_game_mode bwand 196608)) then begin
if (LVar0) then begin
isHighlight := 1;
if (motionScanner) then begin
LVar2 := obj_carrying_pid_obj(dude_obj, 59);
if (LVar2) then begin
if (motionScanner >= 2) then begin
LVar3 := get_weapon_ammo_count(LVar2);
if (LVar3 > 0) then begin
set_weapon_ammo_count(LVar2, LVar3 - 1);
sfall_func0("intface_redraw");
call ToggleHighlight(1);
end
else begin
display_msg(highlightFailMsg2);
end
end
else begin
call ToggleHighlight(1);
end
end
else begin
display_msg(highlightFailMsg1);
end
end
else begin
call ToggleHighlight(1);
end
end
else begin
isHighlight := 0;
call ToggleHighlight(0);
end
end
end
procedure CombatTurnHandler
begin
if (isHighlight) then begin
isHighlight := 0;
call ToggleHighlight(0);
end
end
procedure GameModeChangeHandler
begin
if (isHighlight and (get_game_mode bwand 196608)) then begin
isHighlight := 0;
call ToggleHighlight(0);
end
end
procedure InventoryMoveHandler
begin
if (isHighlight and (get_sfall_arg == 7)) then begin
sfall_func2("set_outline", get_sfall_arg, 0);
end
end
procedure start
begin
if (game_loaded and (sfall_ver_major >= 4)) then begin
call InitConfigs();
highlightKey := GetConfig("Highlighting", "Key", 0);
ItemsOutlineColor := GetConfig("Highlighting", "ItemsOutlineColor", 0);
ContainersOutlineColor := GetConfig("Highlighting", "ContainersOutlineColor", 0);
CorpsesOutlineColor := GetConfig("Highlighting", "CorpsesOutlineColor", 0);
CrittersOutlineColor := GetConfig("Highlighting", "CrittersOutlineColor", 0);
CheckLOS := GetConfig("Highlighting", "CheckLOS", 0);
motionScanner := GetConfig("Highlighting", "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(19, KeyPressHandler);
register_hook_proc(27, CombatTurnHandler);
register_hook_proc(31, GameModeChangeHandler);
register_hook_proc(24, InventoryMoveHandler);
end
end
edit : missed setting the check los var,now it works with items on ground, containers and corpses,but critters dont highlight at all
edit : got it,was block mode problem,works with mode BLOCKING_TYPE_SIGHT
Code:
#define BLOCKING_TYPE_BLOCK (0)
#define BLOCKING_TYPE_SHOOT (1)
#define BLOCKING_TYPE_AI (2)
#define BLOCKING_TYPE_SIGHT (3)
Last edited: