summaryrefslogtreecommitdiff
path: root/src/map/script-fun.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/script-fun.cpp')
-rw-r--r--src/map/script-fun.cpp48
1 files changed, 42 insertions, 6 deletions
diff --git a/src/map/script-fun.cpp b/src/map/script-fun.cpp
index 25c7736..8fa4ea4 100644
--- a/src/map/script-fun.cpp
+++ b/src/map/script-fun.cpp
@@ -2990,9 +2990,21 @@ void builtin_getmap(ScriptState *st)
static
void builtin_strnpcinfo(ScriptState *st)
{
- dumb_ptr<npc_data> nd = map_id_is_npc(st->oid);
int num = conv_num(st, &AARG(0));
RString name;
+ dumb_ptr<npc_data> nd;
+
+ if(HARG(1)){
+ NpcName npc = stringish<NpcName>(ZString(conv_str(st, &AARG(1))));
+ nd = npc_name2id(npc);
+ if (!nd)
+ {
+ PRINTF("builtin_strnpcinfo: no such npc: %s\n"_fmt, npc);
+ return;
+ }
+ } else {
+ nd = map_id_is_npc(st->oid);
+ }
switch(num)
{
@@ -3020,7 +3032,19 @@ void builtin_strnpcinfo(ScriptState *st)
static
void builtin_getnpcx(ScriptState *st)
{
- dumb_ptr<npc_data> nd = map_id_is_npc(st->oid);
+ dumb_ptr<npc_data> nd;
+
+ if(HARG(0)){
+ NpcName name = stringish<NpcName>(ZString(conv_str(st, &AARG(0))));
+ nd = npc_name2id(name);
+ if (!nd)
+ {
+ PRINTF("builtin_getnpcx: no such npc: %s\n"_fmt, name);
+ return;
+ }
+ } else {
+ nd = map_id_is_npc(st->oid);
+ }
push_int<ScriptDataInt>(st->stack, nd->bl_x);
}
@@ -3032,7 +3056,19 @@ void builtin_getnpcx(ScriptState *st)
static
void builtin_getnpcy(ScriptState *st)
{
- dumb_ptr<npc_data> nd = map_id_is_npc(st->oid);
+ dumb_ptr<npc_data> nd;
+
+ if(HARG(0)){
+ NpcName name = stringish<NpcName>(ZString(conv_str(st, &AARG(0))));
+ nd = npc_name2id(name);
+ if (!nd)
+ {
+ PRINTF("builtin_getnpcy: no such npc: %s\n"_fmt, name);
+ return;
+ }
+ } else {
+ nd = map_id_is_npc(st->oid);
+ }
push_int<ScriptDataInt>(st->stack, nd->bl_y);
}
@@ -3165,9 +3201,9 @@ 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(strnpcinfo, "i"_s, 's'),
+ BUILTIN(getnpcx, "?"_s, 'i'),
+ BUILTIN(getnpcy, "?"_s, 'i'),
+ BUILTIN(strnpcinfo, "i?"_s, 's'),
BUILTIN(getmap, ""_s, 's'),
BUILTIN(mapexit, ""_s, '\0'),
BUILTIN(freeloop, "i"_s, '\0'),