summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormekolat <mekolat@users.noreply.github.com>2015-06-21 19:48:14 -0400
committermekolat <mekolat@users.noreply.github.com>2016-04-15 11:45:07 -0400
commite8e5fb8831be2d549b0d2fa3a3353133b5dccf37 (patch)
treee33e119cc9e17daeeed2f40ff781f62a1b2bae2b /src
parent98e5e62ef7a04977146fdbfbc3166dad5d082da0 (diff)
downloadtmwa-e8e5fb8831be2d549b0d2fa3a3353133b5dccf37.tar.gz
tmwa-e8e5fb8831be2d549b0d2fa3a3353133b5dccf37.tar.bz2
tmwa-e8e5fb8831be2d549b0d2fa3a3353133b5dccf37.tar.xz
tmwa-e8e5fb8831be2d549b0d2fa3a3353133b5dccf37.zip
allow to specify npc in strnpcinfo
Diffstat (limited to 'src')
-rw-r--r--src/map/script-fun.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/map/script-fun.cpp b/src/map/script-fun.cpp
index f215d73..bef3619 100644
--- a/src/map/script-fun.cpp
+++ b/src/map/script-fun.cpp
@@ -3947,11 +3947,23 @@ void builtin_strnpcinfo(ScriptState *st)
dumb_ptr<npc_data> nd;
if(HARG(1)){
- NpcName npc = stringish<NpcName>(ZString(conv_str(st, &AARG(1))));
- nd = npc_name2id(npc);
+ struct script_data *sdata = &AARG(1);
+ get_val(st, sdata);
+
+ if (sdata->is<ScriptDataStr>())
+ {
+ NpcName name = stringish<NpcName>(ZString(conv_str(st, sdata)));
+ nd = npc_name2id(name);
+ }
+ else
+ {
+ BlockId id = wrap<BlockId>(conv_num(st, sdata));
+ nd = map_id2bl(id)->is_npc();
+ }
+
if (!nd)
{
- PRINTF("builtin_strnpcinfo: no such npc: '%s'\n"_fmt, npc);
+ PRINTF("builtin_strnpcinfo: npc not found\n"_fmt);
return;
}
} else {