mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Implemented highlighting mod as a stand-alone global script with LOS and NoHighlight flag checks #53
This commit is contained in:
@@ -0,0 +1,52 @@
|
|||||||
|
#include "..\scripting\headers\sfall.h"
|
||||||
|
#include "..\scripting\headers\define_extra.h"
|
||||||
|
//#include "..\..\..\!SRC\headers\define.h"
|
||||||
|
|
||||||
|
#define it_flags (6)
|
||||||
|
#define CRITTER_IS_DEAD (1)
|
||||||
|
|
||||||
|
variable highlightKey;
|
||||||
|
variable highlightContainers;
|
||||||
|
|
||||||
|
procedure toggle_highlight_object(variable obj, variable color) begin
|
||||||
|
if obj
|
||||||
|
and (proto_data(obj_pid(obj), it_flags) bwand FLAG_NOHIGHLIGHT) == 0
|
||||||
|
and (color == 0 or not obj_blocking_line(dude_obj, tile_num(obj), BLOCKING_TYPE_SHOOT)) then begin
|
||||||
|
set_outline(obj, color);
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
procedure toggle_highlight(variable color) begin
|
||||||
|
variable obj;
|
||||||
|
foreach obj in list_as_array(LIST_GROUNDITEMS) begin
|
||||||
|
call toggle_highlight_object(obj, color);
|
||||||
|
end
|
||||||
|
foreach obj in list_as_array(LIST_CRITTERS) begin
|
||||||
|
if critter_state(obj) == CRITTER_IS_DEAD then begin
|
||||||
|
call toggle_highlight_object(obj, color);
|
||||||
|
end
|
||||||
|
end
|
||||||
|
tile_refresh_display;
|
||||||
|
end
|
||||||
|
|
||||||
|
procedure key_press_handler begin
|
||||||
|
variable pressed := get_sfall_arg,
|
||||||
|
scanCode := get_sfall_arg;
|
||||||
|
|
||||||
|
if scanCode == highlightKey then begin
|
||||||
|
if pressed then begin
|
||||||
|
call toggle_highlight(OUTLINE_DARK_YELLOW);
|
||||||
|
end else begin
|
||||||
|
call toggle_highlight(0);
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
procedure start begin
|
||||||
|
if game_loaded then begin
|
||||||
|
highlightKey := get_ini_setting("ddraw.ini|Input|ToggleItemHighlightsKey");
|
||||||
|
display_msg("key= " + highlightKey);
|
||||||
|
highlightContainers := get_ini_setting("ddraw.ini|Input|HighlightContainers");
|
||||||
|
register_hook_proc(HOOK_KEYPRESS, key_press_handler);
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -39,6 +39,32 @@
|
|||||||
#define ATKMODE_SEC_BURST 112 // 0x00000070
|
#define ATKMODE_SEC_BURST 112 // 0x00000070
|
||||||
#define ATKMODE_SEC_FLAME 128 // 0x00000080
|
#define ATKMODE_SEC_FLAME 128 // 0x00000080
|
||||||
|
|
||||||
|
/* Object flags */
|
||||||
|
#define FLAG_MOUSE_3D (0x1)
|
||||||
|
#define FLAG_WALKTHRU (0x4)
|
||||||
|
#define FLAG_FLAT (0x8)
|
||||||
|
#define FLAG_NOBLOCK (0x10)
|
||||||
|
#define FLAG_LIGHTING (0x20)
|
||||||
|
#define FLAG_TEMP (0x400)
|
||||||
|
#define FLAG_MULTIHEX (0x800)
|
||||||
|
#define FLAG_NOHIGHLIGHT (0x1000)
|
||||||
|
#define FLAG_USED (0x2000)
|
||||||
|
#define FLAG_TRANSRED (0x4000)
|
||||||
|
#define FLAG_TRANSNONE (0x8000)
|
||||||
|
#define FLAG_TRANSWALL (0x10000)
|
||||||
|
#define FLAG_TRANSGLASS (0x20000)
|
||||||
|
#define FLAG_TRANSSTEAM (0x40000)
|
||||||
|
#define FLAG_TRANSENERGY (0x80000)
|
||||||
|
#define FLAG_LEFT_HAND (0x1000000)
|
||||||
|
#define FLAG_RIGHT_HAND (0x2000000)
|
||||||
|
#define FLAG_WORN (0x4000000)
|
||||||
|
#define FLAG_HIDDENITEM (0x8000000)
|
||||||
|
#define FLAG_WALLTRANSEND (0x10000000)
|
||||||
|
#define FLAG_LIGHTTHRU (0x20000000)
|
||||||
|
#define FLAG_SEEN (0x40000000)
|
||||||
|
#define FLAG_SHOOTTHRU (0x80000000)
|
||||||
|
|
||||||
|
|
||||||
/* Critter Flags */
|
/* Critter Flags */
|
||||||
#define CFLG_BARTER 2 // 0x00000002 - Barter (can trade with)
|
#define CFLG_BARTER 2 // 0x00000002 - Barter (can trade with)
|
||||||
#define CFLG_NOSTEAL 32 // 0x00000020 - Steal (cannot steal from)
|
#define CFLG_NOSTEAL 32 // 0x00000020 - Steal (cannot steal from)
|
||||||
@@ -224,5 +250,4 @@
|
|||||||
#define WPN_ANIM_MINIGUN (0x09) // (L)
|
#define WPN_ANIM_MINIGUN (0x09) // (L)
|
||||||
#define WPN_ANIM_ROCKET_LAUNCHER (0x0A) // (M)
|
#define WPN_ANIM_ROCKET_LAUNCHER (0x0A) // (M)
|
||||||
|
|
||||||
|
|
||||||
#endif // DEFINE_EXTRA_H
|
#endif // DEFINE_EXTRA_H
|
||||||
|
|||||||
@@ -158,14 +158,14 @@
|
|||||||
#define GAME_MSG_PRO_TILE (0x1004)
|
#define GAME_MSG_PRO_TILE (0x1004)
|
||||||
#define GAME_MSG_PRO_MISC (0x1005)
|
#define GAME_MSG_PRO_MISC (0x1005)
|
||||||
|
|
||||||
#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_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 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))
|
||||||
@@ -206,4 +206,5 @@
|
|||||||
#define intface_is_hidden sfall_func0("intface_is_hidden")
|
#define intface_is_hidden sfall_func0("intface_is_hidden")
|
||||||
#define exec_map_update_scripts sfall_func0("exec_map_update_scripts")
|
#define exec_map_update_scripts sfall_func0("exec_map_update_scripts")
|
||||||
#define set_outline(obj, color) sfall_func2("set_outline", obj, color)
|
#define set_outline(obj, color) sfall_func2("set_outline", obj, color)
|
||||||
#define get_outline(obj) sfall_func1("get_outline", obj)
|
#define get_outline(obj) sfall_func1("get_outline", obj)
|
||||||
|
#define tile_refresh_display sfall_func0("tile_refresh_display")
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ DWORD GetCharGapWidth();
|
|||||||
// get maximum character width for current font
|
// get maximum character width for current font
|
||||||
DWORD GetMaxCharWidth();
|
DWORD GetMaxCharWidth();
|
||||||
|
|
||||||
// Redraw the given object on screen
|
// Redraw the given object on screen (does not always redraws the whole object)
|
||||||
void RedrawObject(GameObject* obj);
|
void RedrawObject(GameObject* obj);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -432,5 +432,9 @@ void sf_intface_is_hidden(OpcodeContext& ctx) {
|
|||||||
ctx.setReturn(isHidden);
|
ctx.setReturn(isHidden);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sf_tile_refresh_display(OpcodeContext& ctx) {
|
||||||
|
fo::func::tile_refresh_display();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,5 +81,7 @@ void sf_intface_hide(OpcodeContext&);
|
|||||||
|
|
||||||
void sf_intface_is_hidden(OpcodeContext&);
|
void sf_intface_is_hidden(OpcodeContext&);
|
||||||
|
|
||||||
|
void sf_tile_refresh_display(OpcodeContext&);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,7 +125,8 @@ static const SfallMetarule metaruleArray[] = {
|
|||||||
{"intface_is_hidden", sf_intface_is_hidden, 0, 0},
|
{"intface_is_hidden", sf_intface_is_hidden, 0, 0},
|
||||||
{"exec_map_update_scripts", sf_exec_map_update_scripts, 0, 0},
|
{"exec_map_update_scripts", sf_exec_map_update_scripts, 0, 0},
|
||||||
{"set_outline", sf_set_outline, 2, 2, {ARG_OBJECT, ARG_INT}},
|
{"set_outline", sf_set_outline, 2, 2, {ARG_OBJECT, ARG_INT}},
|
||||||
{"get_outline", sf_get_outline, 1, 1, {ARG_OBJECT}}
|
{"get_outline", sf_get_outline, 1, 1, {ARG_OBJECT}},
|
||||||
|
{"tile_refresh_display", sf_tile_refresh_display, 0, 0},
|
||||||
};
|
};
|
||||||
|
|
||||||
void InitMetaruleTable() {
|
void InitMetaruleTable() {
|
||||||
|
|||||||
@@ -401,7 +401,6 @@ void sf_set_outline(OpcodeContext& ctx) {
|
|||||||
auto obj = ctx.arg(0).asObject();
|
auto obj = ctx.arg(0).asObject();
|
||||||
int color = ctx.arg(1).asInt();
|
int color = ctx.arg(1).asInt();
|
||||||
obj->outline = color;
|
obj->outline = color;
|
||||||
fo::RedrawObject(obj);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void sf_get_outline(OpcodeContext& ctx) {
|
void sf_get_outline(OpcodeContext& ctx) {
|
||||||
|
|||||||
+3
-1
@@ -39,6 +39,7 @@
|
|||||||
#include "Modules\FileSystem.h"
|
#include "Modules\FileSystem.h"
|
||||||
#include "Modules\Graphics.h"
|
#include "Modules\Graphics.h"
|
||||||
#include "Modules\HighlightingMod.h"
|
#include "Modules\HighlightingMod.h"
|
||||||
|
#include "Modules\HookScripts.h"
|
||||||
#include "Modules\HeroAppearance.h"
|
#include "Modules\HeroAppearance.h"
|
||||||
#include "Modules\Input.h"
|
#include "Modules\Input.h"
|
||||||
#include "Modules\Inventory.h"
|
#include "Modules\Inventory.h"
|
||||||
@@ -136,6 +137,7 @@ static void InitModules() {
|
|||||||
manager.add<Worldmap>();
|
manager.add<Worldmap>();
|
||||||
manager.add<Stats>();
|
manager.add<Stats>();
|
||||||
manager.add<ScriptExtender>();
|
manager.add<ScriptExtender>();
|
||||||
|
manager.add<HookScripts>();
|
||||||
manager.add<LoadGameHook>();
|
manager.add<LoadGameHook>();
|
||||||
manager.add<MainLoopHook>();
|
manager.add<MainLoopHook>();
|
||||||
manager.add<Perks>();
|
manager.add<Perks>();
|
||||||
@@ -166,7 +168,7 @@ static void InitModules() {
|
|||||||
manager.add<AnimationsAtOnce>();
|
manager.add<AnimationsAtOnce>();
|
||||||
manager.add<BarBoxes>();
|
manager.add<BarBoxes>();
|
||||||
manager.add<HeroAppearance>();
|
manager.add<HeroAppearance>();
|
||||||
manager.add<HighlightingMod>();
|
//manager.add<HighlightingMod>();
|
||||||
manager.add<MiscPatches>();
|
manager.add<MiscPatches>();
|
||||||
|
|
||||||
manager.initAll();
|
manager.initAll();
|
||||||
|
|||||||
Reference in New Issue
Block a user