From 6c0348dc296f9c038a0ca5d6e600c1d802981dc4 Mon Sep 17 00:00:00 2001 From: mekolat Date: Wed, 22 Apr 2015 20:29:11 -0400 Subject: make emotion send to a single rid --- src/map/script-fun.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src/map/script-fun.cpp') diff --git a/src/map/script-fun.cpp b/src/map/script-fun.cpp index 3b814aa..c4cf129 100644 --- a/src/map/script-fun.cpp +++ b/src/map/script-fun.cpp @@ -2179,11 +2179,22 @@ void builtin_getpvpflag(ScriptState *st) static void builtin_emotion(ScriptState *st) { - int type; - type = conv_num(st, &AARG(0)); + ZString str; + dumb_ptr pl_sd = nullptr; + int type = conv_num(st, &AARG(0)); + if (HARG(1)) { + str = ZString(conv_str(st, &AARG(1))); + CharName player = stringish(str); + pl_sd = map_nick2sd(player); + } if (type < 0 || type > 200) return; - clif_emotion(map_id2bl(st->oid), type); + if (pl_sd != nullptr) + clif_emotion_towards(map_id2bl(st->oid), pl_sd, type); + else if (st->rid && str == "self"_s) + clif_emotion(map_id2sd(st->rid), type); + else + clif_emotion(map_id2bl(st->oid), type); } static @@ -3178,7 +3189,7 @@ BuiltinFunction builtin_functions[] = BUILTIN(pvpoff, "M"_s, '\0'), BUILTIN(setpvpchannel, "i"_s, '\0'), BUILTIN(getpvpflag, "i"_s, 'i'), - BUILTIN(emotion, "i"_s, '\0'), + BUILTIN(emotion, "i?"_s, '\0'), BUILTIN(mapwarp, "MMxy"_s, '\0'), BUILTIN(mobcount, "ME"_s, 'i'), BUILTIN(marriage, "P"_s, 'i'), -- cgit v1.2.3-70-g09d2