diff options
author | Wushin <pasekei@gmail.com> | 2015-05-19 21:50:41 -0500 |
---|---|---|
committer | Wushin <pasekei@gmail.com> | 2015-05-19 21:50:41 -0500 |
commit | 29ce27e1557404b6cd03eaab2367c5a698e6ab44 (patch) | |
tree | 28da27416f52edaa41c049a60ebcc4869ddde1f2 /src/map/script-fun.cpp | |
parent | 20cbf97dbaded8c2bead5b4f1a4838528c63a2a5 (diff) | |
parent | 4166a53fa3ced75afa25bd5bfb20ca87eca0e25f (diff) | |
download | tmwa-15.5.19.tar.gz tmwa-15.5.19.tar.bz2 tmwa-15.5.19.tar.xz tmwa-15.5.19.zip |
Merge pull request #89 from mekolat/sitv15.5.19
allow to make npcs sit
Diffstat (limited to 'src/map/script-fun.cpp')
-rw-r--r-- | src/map/script-fun.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/map/script-fun.cpp b/src/map/script-fun.cpp index 9020203..7617e0d 100644 --- a/src/map/script-fun.cpp +++ b/src/map/script-fun.cpp @@ -1631,6 +1631,43 @@ void builtin_setnpctimer(ScriptState *st) npc_settimerevent_tick(nd, tick); } +static +void builtin_setnpcdirection(ScriptState *st) +{ + dumb_ptr<npc_data> nd_; + DIR dir = static_cast<DIR>(conv_num(st, &AARG(0))); + bool save = bool(conv_num(st, &AARG(2))); + DamageType action; + + if (HARG(3)) + nd_ = npc_name2id(stringish<NpcName>(ZString(conv_str(st, &AARG(3))))); + else + nd_ = map_id_is_npc(st->oid); + + if (bool(conv_num(st, &AARG(1)))) + action = DamageType::SIT; + else + action = DamageType::STAND; + + if (save) + { + nd_->dir = dir; + nd_->sit = action; + } + + if (st->rid) + { + dumb_ptr<map_session_data> sd = script_rid2sd(st); + clif_sitnpc_towards(sd, nd_, action); + clif_setnpcdirection_towards(sd, nd_, dir); + } + else + { + clif_sitnpc(nd_, action); + clif_setnpcdirection(nd_, dir); + } +} + /*========================================== * 天の声アナウンス *------------------------------------------ @@ -3062,6 +3099,7 @@ BuiltinFunction builtin_functions[] = BUILTIN(stopnpctimer, "?"_s, '\0'), BUILTIN(getnpctimer, "i?"_s, 'i'), BUILTIN(setnpctimer, "i?"_s, '\0'), + BUILTIN(setnpcdirection, "iii?"_s, '\0'), BUILTIN(announce, "si"_s, '\0'), BUILTIN(mapannounce, "Msi"_s, '\0'), BUILTIN(getusers, "i"_s, 'i'), |