From e5471b1890bae50c36ccf8a8c7e1fee868c156b1 Mon Sep 17 00:00:00 2001 From: mekolat Date: Sat, 28 Mar 2015 16:06:29 -0400 Subject: add getnpcx and getnpcy --- src/map/script-fun.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/map/script-fun.cpp') diff --git a/src/map/script-fun.cpp b/src/map/script-fun.cpp index 8c25266..eea8797 100644 --- a/src/map/script-fun.cpp +++ b/src/map/script-fun.cpp @@ -2984,6 +2984,30 @@ void builtin_getmap(ScriptState *st) push_str(st->stack, sd->bl_m->name_); } +/*============================ + * Gets the NPC's x pos + *---------------------------- + */ +static +void builtin_getnpcx(ScriptState *st) +{ + dumb_ptr nd = map_id_is_npc(st->oid); + + push_int(st->stack, nd->bl_x); +} + +/*============================ + * Gets the NPC's y pos + *---------------------------- + */ +static +void builtin_getnpcy(ScriptState *st) +{ + dumb_ptr nd = map_id_is_npc(st->oid); + + push_int(st->stack, nd->bl_y); +} + static void builtin_mapexit(ScriptState *) { @@ -3112,6 +3136,8 @@ BuiltinFunction builtin_functions[] = BUILTIN(fakenpcname, "ssi"_s, '\0'), BUILTIN(getx, ""_s, 'i'), BUILTIN(gety, ""_s, 'i'), + BUILTIN(getnpcx, ""_s, 'i'), + BUILTIN(getnpcy, ""_s, 'i'), BUILTIN(getmap, ""_s, 's'), BUILTIN(mapexit, ""_s, '\0'), BUILTIN(freeloop, "i"_s, '\0'), -- cgit v1.2.3-60-g2f50