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/init.c | 1 + src/emap/script_buildins.c | 35 ++++++++++++++++++++++++++++++++++- src/emap/script_buildins.h | 1 + 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/emap/init.c b/src/emap/init.c index 1ea0ae9..266e6cf 100644 --- a/src/emap/init.c +++ b/src/emap/init.c @@ -223,6 +223,7 @@ HPExport void plugin_init (void) addScriptCommand("deployhomunculus","",deployhomunculus); addScriptCommand("recallhomunculus","",recallhomunculus); addScriptCommand("homstatus","",homstatus); + addScriptCommand("npcshopattach","s?",npcshopattach); do_init_langs(); 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; diff --git a/src/emap/script_buildins.h b/src/emap/script_buildins.h index 269df3a..96fdf35 100644 --- a/src/emap/script_buildins.h +++ b/src/emap/script_buildins.h @@ -13,6 +13,7 @@ BUILDIN(restoreCam); BUILDIN(npcTalk3); BUILDIN(closeDialog); BUILDIN(closeClientDialog); +BUILDIN(npcshopattach); BUILDIN(shop); BUILDIN(getItemLink); BUILDIN(requestLang); -- cgit v1.2.3-70-g09d2