summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormekolat <mekolat@users.noreply.github.com>2016-05-01 20:27:30 -0400
committermekolat <mekolat@users.noreply.github.com>2016-05-01 20:31:47 -0400
commit1aa0c7f8ed925a181809fb72ed531b0981435537 (patch)
treedb3b70630840346de86c4ca3dda9b8beb33cb209 /src
parent0384d11f9b92d1368a87d5351db983a7b94b5042 (diff)
downloadtmwa-1aa0c7f8ed925a181809fb72ed531b0981435537.tar.gz
tmwa-1aa0c7f8ed925a181809fb72ed531b0981435537.tar.bz2
tmwa-1aa0c7f8ed925a181809fb72ed531b0981435537.tar.xz
tmwa-1aa0c7f8ed925a181809fb72ed531b0981435537.zip
allow addtimer to have a target
Diffstat (limited to 'src')
-rw-r--r--src/map/script-fun.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/map/script-fun.cpp b/src/map/script-fun.cpp
index 90eb557..849bffa 100644
--- a/src/map/script-fun.cpp
+++ b/src/map/script-fun.cpp
@@ -2640,11 +2640,23 @@ void builtin_donpcevent(ScriptState *st)
static
void builtin_addtimer(ScriptState *st)
{
+ dumb_ptr<map_session_data> sd;
interval_t tick = static_cast<interval_t>(conv_num(st, &AARG(0)));
ZString event_ = ZString(conv_str(st, &AARG(1)));
NpcEvent event;
extract(event_, &event);
- pc_addeventtimer(script_rid2sd(st), tick, event);
+
+ if (HARG(2))
+ sd = map_id_is_player(wrap<BlockId>(conv_num(st, &AARG(2))));
+ else if (st->rid)
+ sd = script_rid2sd(st);
+
+ if (sd == nullptr)
+ {
+ PRINTF("builtin_addtimer: player not attached.\n"_fmt);
+ }
+
+ pc_addeventtimer(sd, tick, event);
}
/*==========================================
@@ -4736,7 +4748,7 @@ BuiltinFunction builtin_functions[] =
BUILTIN(areamonster, "Mxyxysmi?"_s, '\0'),
BUILTIN(killmonster, "ME"_s, '\0'),
BUILTIN(donpcevent, "E"_s, '\0'),
- BUILTIN(addtimer, "tE"_s, '\0'),
+ BUILTIN(addtimer, "tE?"_s, '\0'),
BUILTIN(addnpctimer, "tE"_s, '\0'),
BUILTIN(initnpctimer, "?"_s, '\0'),
BUILTIN(startnpctimer, "?"_s, '\0'),