From a185a08be08bf790141b3aa1b6fcecaea5915a7e Mon Sep 17 00:00:00 2001 From: mekolat Date: Tue, 14 Jul 2015 16:23:09 -0400 Subject: misc modifications --- src/map/pc.cpp | 6 ++++++ src/map/script-call.cpp | 2 -- src/map/script-fun.cpp | 25 ++++++++++++++++++++++++- src/mmo/clif.t.hpp | 2 ++ 4 files changed, 32 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/map/pc.cpp b/src/map/pc.cpp index 4f0c8d2..96e0cac 100644 --- a/src/map/pc.cpp +++ b/src/map/pc.cpp @@ -3517,6 +3517,12 @@ int pc_readparam(dumb_ptr bl, SP type) case SP::POS_Y: val = bl->bl_y; break; + case SP::PVP_CHANNEL: + val = sd ? sd->state.pvpchannel : 0; + break; + case SP::BL_ID: + val = unwrap(bl->bl_id); + break; } return val; diff --git a/src/map/script-call.cpp b/src/map/script-call.cpp index 8d2f58f..b9a098a 100644 --- a/src/map/script-call.cpp +++ b/src/map/script-call.cpp @@ -84,8 +84,6 @@ void get_val(dumb_ptr sd, struct script_data *data) { MATCH_CASE (const ScriptDataParam&, u) { - if (sd == nullptr) - PRINTF("get_val error param SP::%d\n"_fmt, u.reg.sp()); int numi = 0; if (sd) numi = pc_readparam(sd, u.reg.sp()); diff --git a/src/map/script-fun.cpp b/src/map/script-fun.cpp index 53b4526..51039ad 100644 --- a/src/map/script-fun.cpp +++ b/src/map/script-fun.cpp @@ -545,7 +545,7 @@ void builtin_distance(ScriptState *st) // TODO implement case 1 (walk distance) case 0: default: - if (source->bl_m->name_ != target->bl_m->name_) + if (source->bl_m != target->bl_m) { // FIXME make it work even if source and target are not in the same map distance = 0x7fffffff; @@ -1600,6 +1600,28 @@ void builtin_getcharid(ScriptState *st) push_int(st->stack, unwrap(sd->status_key.account_id)); } +/*========================================== + * + *------------------------------------------ + */ +static +void builtin_getnpcid(ScriptState *st) +{ + dumb_ptr nd; + + if (HARG(0)) + nd = npc_name2id(stringish(ZString(conv_str(st, &AARG(0))))); + else + nd = map_id2bl(st->oid)->is_npc(); + if (nd == nullptr) + { + push_int(st->stack, -1); + return; + } + + push_int(st->stack, unwrap(nd->bl_id)); +} + /*========================================== *指定IDのPT名取得 *------------------------------------------ @@ -4170,6 +4192,7 @@ BuiltinFunction builtin_functions[] = BUILTIN(makeitem, "IiMxy"_s, '\0'), BUILTIN(delitem, "Ii"_s, '\0'), BUILTIN(getcharid, "i?"_s, 'i'), + BUILTIN(getnpcid, "?"_s, 'i'), BUILTIN(getversion, ""_s, 'i'), BUILTIN(strcharinfo, "i"_s, 's'), BUILTIN(getequipid, "i?"_s, 'i'), diff --git a/src/mmo/clif.t.hpp b/src/mmo/clif.t.hpp index f2ff583..377e953 100644 --- a/src/mmo/clif.t.hpp +++ b/src/mmo/clif.t.hpp @@ -472,6 +472,8 @@ enum class SP : uint16_t POS_X = 1074, POS_Y = 1075, + PVP_CHANNEL = 1076, + BL_ID = 1077, }; constexpr -- cgit v1.2.3-60-g2f50