From 548057e189f0cb222833036836d5cda76e9f69c0 Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Sun, 25 Aug 2019 00:35:15 -0300 Subject: [TMW2 Patch] --- src/emap/script_buildins.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'src/emap/script_buildins.c') diff --git a/src/emap/script_buildins.c b/src/emap/script_buildins.c index 99bae19..7393da8 100644 --- a/src/emap/script_buildins.c +++ b/src/emap/script_buildins.c @@ -187,7 +187,8 @@ BUILDIN(npcTalk3) BUILDIN(closeDialog) { getSD(); - send_npccommand(sd, st->oid, 5); + //send_npccommand(sd, st->oid, 5); + send_npccommand(sd, st->oid, 14); return true; } @@ -198,6 +199,32 @@ BUILDIN(closeClientDialog) return true; } +// npcshopattach(npc) will tell the scripts to run an event +// Enabling OnBuyItem and OnSellItem events of npc +BUILDIN(npcshopattach) +{ + const char* npcname = script_getstr(st,2); + struct npc_data* nd = npc->name2id(npcname); + int flag = 1; + + if( script_hasdata(st,3) ) + flag = script_getnum(st,3); + + if( !nd ) { + //Not found. + script_pushint(st,0); + return true; + } + + if (flag) + nd->master_nd = map->id2nd(st->oid); + else + nd->master_nd = NULL; + + script_pushint(st,1); + return true; +} + BUILDIN(shop) { getSD(); @@ -209,8 +236,14 @@ BUILDIN(shop) return false; } + // TMW2 Shops + /* + Move this to a new function, and comment the autoclose + Skip the forced check of SHOP type because I don't like it. + st->state = sd->state.dialog == 1 ? CLOSE : END; clif->scriptclose(sd, st->oid); + */ clif->npcbuysell (sd, nd->bl.id); return true; -- cgit v1.2.3-60-g2f50