From e8e5fb8831be2d549b0d2fa3a3353133b5dccf37 Mon Sep 17 00:00:00 2001
From: mekolat <mekolat@users.noreply.github.com>
Date: Sun, 21 Jun 2015 19:48:14 -0400
Subject: allow to specify npc in strnpcinfo

---
 src/map/script-fun.cpp | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

(limited to 'src/map')

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 {
-- 
cgit v1.2.3-70-g09d2