Added scripting functions: get/set_flags. This allows, for example, to turn character into a ghost dynamically from script.

This commit is contained in:
phobos2077
2017-03-13 04:12:52 +07:00
parent c63ddf3e9c
commit fa583d41d7
6 changed files with 21 additions and 3 deletions
+1 -2
View File
@@ -2,7 +2,6 @@
#include "..\scripting\headers\define_extra.h" #include "..\scripting\headers\define_extra.h"
//#include "..\..\..\!SRC\headers\define.h" //#include "..\..\..\!SRC\headers\define.h"
#define it_flags (6)
#define CRITTER_IS_DEAD (1) #define CRITTER_IS_DEAD (1)
variable highlightKey; variable highlightKey;
@@ -10,7 +9,7 @@ variable highlightContainers;
procedure toggle_highlight_object(variable obj, variable color) begin procedure toggle_highlight_object(variable obj, variable color) begin
if obj if obj
and (proto_data(obj_pid(obj), it_flags) bwand FLAG_NOHIGHLIGHT) == 0 and (get_flags(obj) bwand FLAG_NOHIGHLIGHT) == 0
and (color == 0 or not obj_blocking_line(dude_obj, tile_num(obj), BLOCKING_TYPE_SHOOT)) then begin and (color == 0 or not obj_blocking_line(dude_obj, tile_num(obj), BLOCKING_TYPE_SHOOT)) then begin
set_outline(obj, color); set_outline(obj, color);
end end
+2
View File
@@ -207,4 +207,6 @@
#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 set_flags(obj, color) sfall_func2("set_flags", obj, color)
#define get_flags(obj) sfall_func1("get_flags", obj)
#define tile_refresh_display sfall_func0("tile_refresh_display") #define tile_refresh_display sfall_func0("tile_refresh_display")
@@ -126,6 +126,8 @@ static const SfallMetarule metaruleArray[] = {
{"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}},
{"set_flags", sf_set_flags, 2, 2, {ARG_OBJECT, ARG_INT}},
{"get_flags", sf_get_flags, 1, 1, {ARG_OBJECT}},
{"tile_refresh_display", sf_tile_refresh_display, 0, 0}, {"tile_refresh_display", sf_tile_refresh_display, 0, 0},
}; };
@@ -408,5 +408,16 @@ void sf_get_outline(OpcodeContext& ctx) {
ctx.setReturn(obj->outline); ctx.setReturn(obj->outline);
} }
void sf_set_flags(OpcodeContext& ctx) {
auto obj = ctx.arg(0).asObject();
int flags = ctx.arg(1).asInt();
obj->flags = flags;
}
void sf_get_flags(OpcodeContext& ctx) {
auto obj = ctx.arg(0).asObject();
ctx.setReturn(obj->flags);
}
} }
} }
@@ -71,5 +71,9 @@ void sf_set_outline(OpcodeContext&);
void sf_get_outline(OpcodeContext&); void sf_get_outline(OpcodeContext&);
void sf_set_flags(OpcodeContext&);
void sf_get_flags(OpcodeContext&);
} }
} }
+1 -1
View File
@@ -38,8 +38,8 @@
#include "Modules\Explosions.h" #include "Modules\Explosions.h"
#include "Modules\FileSystem.h" #include "Modules\FileSystem.h"
#include "Modules\Graphics.h" #include "Modules\Graphics.h"
#include "Modules\HighlightingMod.h"
#include "Modules\HookScripts.h" #include "Modules\HookScripts.h"
#include "Modules\HighlightingMod.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"