diff options
Diffstat (limited to 'src/map/script-fun.cpp')
-rw-r--r-- | src/map/script-fun.cpp | 131 |
1 files changed, 110 insertions, 21 deletions
diff --git a/src/map/script-fun.cpp b/src/map/script-fun.cpp index 3949627..2822550 100644 --- a/src/map/script-fun.cpp +++ b/src/map/script-fun.cpp @@ -66,21 +66,6 @@ namespace tmwa { namespace map { -static -Array<LString, 11> pos_str //= -{{ - "Head"_s, - "Body"_s, - "Left hand"_s, - "Right hand"_s, - "Robe"_s, - "Shoes"_s, - "Accessory 1"_s, - "Accessory 2"_s, - "Head 2"_s, - "Head 3"_s, - "Not Equipped"_s, -}}; #define AARG(n) (st->stack->stack_datav[st->start + 2 + (n)]) #define HARG(n) (st->end > st->start + 2 + (n)) @@ -1630,6 +1615,30 @@ void builtin_setnpctimer(ScriptState *st) } static +void builtin_npcaction(ScriptState *st) +{ + dumb_ptr<map_session_data> sd = script_rid2sd(st); + short command = conv_num(st, &AARG(0)); + int id = 0; + short x = HARG(2) ? conv_num(st, &AARG(2)) : 0; + short y = HARG(3) ? conv_num(st, &AARG(3)) : 0; + + if(HARG(1)) + { + if(command == 2) + { + dumb_ptr<npc_data> nd_; + nd_ = npc_name2id(stringish<NpcName>(ZString(conv_str(st, &AARG(1))))); + id = unwrap<BlockId>(nd_->bl_id); + } + else + id = conv_num(st, &AARG(1)); + } + + clif_npc_action(sd, st->oid, command, id, x, y); +} + +static void builtin_setnpcdirection(ScriptState *st) { dumb_ptr<npc_data> nd_; @@ -2675,6 +2684,70 @@ void builtin_message(ScriptState *st) } +static +void builtin_title(ScriptState *st) +{ + dumb_ptr<map_session_data> sd = script_rid2sd(st); + ZString msg = ZString(conv_str(st, &AARG(0))); + if (sd == nullptr) + return; + clif_npc_send_title(sd->sess, st->oid, msg); +} + +static +void builtin_music(ScriptState *st) +{ + dumb_ptr<map_session_data> sd = script_rid2sd(st); + ZString msg = ZString(conv_str(st, &AARG(0))); + if (sd == nullptr) + return; + clif_change_music(sd, msg); +} + +static +void builtin_mapmask(ScriptState *st) +{ + dumb_ptr<npc_data> nd; + dumb_ptr<map_session_data> sd; + int map_mask = conv_num(st, &AARG(0)); + + if(st->oid) + nd = map_id_is_npc(st->oid); + if(st->rid) + sd = script_rid2sd(st); + + if(HARG(1) && sd != nullptr) + sd->bl_m->mask = map_mask; + else if(HARG(1) && nd) + nd->bl_m->mask = map_mask; + + if (sd == nullptr) + return; + clif_send_mask(sd, map_mask); +} + +static +void builtin_getmask(ScriptState *st) +{ + dumb_ptr<npc_data> nd; + dumb_ptr<map_session_data> sd; + int map_mask; + + if(st->oid) + nd = map_id_is_npc(st->oid); + if(st->rid) + sd = script_rid2sd(st); + + if(sd != nullptr) + map_mask = sd->bl_m->mask; + else if(nd) + map_mask = nd->bl_m->mask; + else + map_mask = -1; + + push_int<ScriptDataInt>(st->stack, map_mask); +} + /*========================================== * npctalk (sends message to surrounding * area) [Valaris] @@ -2684,13 +2757,24 @@ void builtin_message(ScriptState *st) static void builtin_npctalk(ScriptState *st) { - dumb_ptr<npc_data> nd = map_id_is_npc(st->oid); - RString str = conv_str(st, &AARG(0)); + dumb_ptr<npc_data> nd; + RString str = conv_str(st, &AARG(1)); - if (nd) - { - clif_message(nd, str); + dumb_ptr<npc_data> nd_ = npc_name2id(stringish<NpcName>(ZString(conv_str(st, &AARG(0))))); + assert (nd_ && nd_->npc_subtype == NpcSubtype::SCRIPT); + nd = nd_->is_script(); + + + if(HARG(2)){ + CharName player = stringish<CharName>(ZString(conv_str(st, &AARG(2)))); + dumb_ptr<map_session_data> pl_sd = map_nick2sd(player); + if (pl_sd == nullptr) + return; + clif_message_towards(pl_sd, nd, str); } + + else + clif_message(nd, str); } /*========================================== @@ -3098,6 +3182,7 @@ BuiltinFunction builtin_functions[] = BUILTIN(getnpctimer, "i?"_s, 'i'), BUILTIN(setnpctimer, "i?"_s, '\0'), BUILTIN(setnpcdirection, "iii?"_s, '\0'), + BUILTIN(npcaction, "i???"_s, '\0'), BUILTIN(announce, "si"_s, '\0'), BUILTIN(mapannounce, "Msi"_s, '\0'), BUILTIN(getusers, "i"_s, 'i'), @@ -3144,7 +3229,11 @@ BuiltinFunction builtin_functions[] = BUILTIN(npcwarp, "xys"_s, '\0'), BUILTIN(npcareawarp, "xyxyis"_s, '\0'), BUILTIN(message, "Ps"_s, '\0'), - BUILTIN(npctalk, "s"_s, '\0'), + BUILTIN(npctalk, "ss?"_s, '\0'), + BUILTIN(title, "s"_s, '\0'), + BUILTIN(music, "s"_s, '\0'), + BUILTIN(mapmask, "i?"_s, '\0'), + BUILTIN(getmask, ""_s, 'i'), BUILTIN(getlook, "i"_s, 'i'), BUILTIN(getsavepoint, "i"_s, '.'), BUILTIN(areatimer, "MxyxytE"_s, '\0'), |