From f0c8b228746f62123e2c4d53bcf0808f6c4e3c3a Mon Sep 17 00:00:00 2001 From: mekolat Date: Sun, 21 Jun 2015 21:41:37 -0400 Subject: add getdir builtin, add addnpctimer builtin allow npcs to have multiple timers --- src/map/script-fun.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/map/script-fun.cpp') diff --git a/src/map/script-fun.cpp b/src/map/script-fun.cpp index bef3619..6fe77bf 100644 --- a/src/map/script-fun.cpp +++ b/src/map/script-fun.cpp @@ -2155,6 +2155,20 @@ void builtin_addtimer(ScriptState *st) pc_addeventtimer(script_rid2sd(st), tick, event); } +/*========================================== + * NPCイベントタイマー追加 + *------------------------------------------ + */ +static +void builtin_addnpctimer(ScriptState *st) +{ + interval_t tick = static_cast(conv_num(st, &AARG(0))); + ZString event_ = ZString(conv_str(st, &AARG(1))); + NpcEvent event; + extract(event_, &event); + npc_addeventtimer(map_id2bl(st->oid), tick, event); +} + /*========================================== * NPCタイマー初期化 *------------------------------------------ @@ -3925,6 +3939,18 @@ void builtin_gety(ScriptState *st) push_int(st->stack, sd->bl_y); } +/*============================ + * Gets the PC's direction + *---------------------------- + */ +static +void builtin_getdir(ScriptState *st) +{ + dumb_ptr sd = script_rid2sd(st); + + push_int(st->stack, static_cast(sd->dir)); +} + /* * Get the PC's current map's name */ @@ -4108,6 +4134,7 @@ BuiltinFunction builtin_functions[] = BUILTIN(killmonster, "ME"_s, '\0'), BUILTIN(donpcevent, "E"_s, '\0'), BUILTIN(addtimer, "tE"_s, '\0'), + BUILTIN(addnpctimer, "tE"_s, '\0'), BUILTIN(initnpctimer, "?"_s, '\0'), BUILTIN(startnpctimer, "?"_s, '\0'), BUILTIN(stopnpctimer, "?"_s, '\0'), @@ -4183,6 +4210,7 @@ BuiltinFunction builtin_functions[] = BUILTIN(destroy, "?"_s, '\0'), BUILTIN(getx, ""_s, 'i'), BUILTIN(gety, ""_s, 'i'), + BUILTIN(getdir, ""_s, 'i'), BUILTIN(getnpcx, "?"_s, 'i'), BUILTIN(getnpcy, "?"_s, 'i'), BUILTIN(strnpcinfo, "i?"_s, 's'), -- cgit v1.2.3-60-g2f50