From 870fa2b6005efb046e12888eb2062a3ec611fe5a Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Thu, 25 Jun 2020 07:34:49 +0200 Subject: Add state using_megaphone to struct map_session_data and implement its (un)setting --- src/map/pc.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/map/pc.c') diff --git a/src/map/pc.c b/src/map/pc.c index c1261c839..4c3f56280 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -5320,6 +5320,9 @@ static int pc_useitem(struct map_session_data *sd, int n) // Update item use time. sd->canuseitem_tick = tick + battle_config.item_use_interval; + if (nameid == ITEMID_MEGAPHONE) + sd->state.using_megaphone = 1; + script->run_use_script(sd, sd->inventory_data[n], npc->fake_nd->bl.id); script->potion_flag = 0; -- cgit v1.2.3-70-g09d2 From c17eedc3e25b7fbd5beb051ae4b90bab65dd6eab Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Thu, 25 Jun 2020 07:43:00 +0200 Subject: Enable item consumption while Megaphone input box is present --- src/map/pc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/map/pc.c') diff --git a/src/map/pc.c b/src/map/pc.c index 4c3f56280..bb7ace84f 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -5163,7 +5163,7 @@ static int pc_useitem(struct map_session_data *sd, int n) nullpo_ret(sd); Assert_ret(n >= 0 && n < sd->status.inventorySize); - if ((sd->npc_id != 0 && (sd->npc_item_flag & ITEMENABLEDNPC_CONSUME) == 0) + if ((sd->npc_id != 0 && sd->state.using_megaphone == 0 && (sd->npc_item_flag & ITEMENABLEDNPC_CONSUME) == 0) || (sd->state.workinprogress & 1) != 0) { #if PACKETVER >= 20110308 clif->msgtable(sd, MSG_BUSY); -- cgit v1.2.3-70-g09d2 From cc2dcda6c77936634cec00a56649c2898cafd4f1 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Thu, 25 Jun 2020 08:16:14 +0200 Subject: Enable sending Megaphone message if character is dead --- src/map/clif.c | 2 +- src/map/pc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/map/pc.c') diff --git a/src/map/clif.c b/src/map/clif.c index 6b5e4a80e..b0c8fe027 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -13330,7 +13330,7 @@ static void clif_parse_NpcStringInput(int fd, struct map_session_data *sd) __att /// 01d5 .W .L .?B static void clif_parse_NpcStringInput(int fd, struct map_session_data *sd) { - if (((sd->state.trading != 0 || pc_isvending(sd)) && sd->state.using_megaphone == 0) || pc_isdead(sd)) + if ((sd->state.trading != 0 || pc_isvending(sd) || pc_isdead(sd)) && sd->state.using_megaphone == 0) return; int len = RFIFOW(fd, 2); diff --git a/src/map/pc.c b/src/map/pc.c index bb7ace84f..085b7c6bb 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -8176,7 +8176,7 @@ static int pc_dead(struct map_session_data *sd, struct block_list *src) duel->reject(sd->duel_invite, sd); } - if (sd->npc_id != 0 && sd->st != NULL && sd->st->state != RUN) + if (sd->npc_id != 0 && sd->state.using_megaphone == 0 && sd->st != NULL && sd->st->state != RUN) npc->event_dequeue(sd); pc_setglobalreg(sd, script->add_variable("PC_DIE_COUNTER"), sd->die_counter + 1); @@ -8199,7 +8199,7 @@ static int pc_dead(struct map_session_data *sd, struct block_list *src) npc->script_event(sd, NPCE_DIE); // Clear anything NPC-related if character died while interacting with one. - if ((sd->npc_id != 0 || sd->npc_shopid != 0) && sd->state.dialog != 0) { + if (((sd->npc_id != 0 && sd->state.using_megaphone == 0) || sd->npc_shopid != 0) && sd->state.dialog != 0) { if (sd->state.using_fake_npc != 0) { clif->clearunit_single(sd->npc_id, CLR_OUTSIGHT, sd->fd); sd->state.using_fake_npc = 0; -- cgit v1.2.3-70-g09d2 From 1ee5255bc81b5057dae57f4f1d91b7c70efeb143 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Thu, 25 Jun 2020 08:20:50 +0200 Subject: Disable using Megaphone while Rodex send mail window is present This also fixes the issue where the client freezes when talking to a NPC while Rodex send mail window is present. --- src/map/clif.c | 3 +++ src/map/pc.c | 9 +++++++++ src/map/rodex.c | 1 + 3 files changed, 13 insertions(+) (limited to 'src/map/pc.c') diff --git a/src/map/clif.c b/src/map/clif.c index f347a379a..fa01d31b5 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -22190,6 +22190,9 @@ static void clif_parse_rodex_open_write_mail(int fd, struct map_session_data *sd const struct PACKET_CZ_REQ_OPEN_WRITE_MAIL *rPacket = RFIFOP(fd, 0); int8 result = (rodex->isenabled() && (sd->npc_id == 0 || sd->state.using_megaphone != 0)) ? 1 : 0; + if (result == 1) + sd->state.workinprogress |= 2; + clif->rodex_open_write_mail(fd, rPacket->receiveName, result); } diff --git a/src/map/pc.c b/src/map/pc.c index 085b7c6bb..63d62467c 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -5190,6 +5190,15 @@ static int pc_useitem(struct map_session_data *sd, int n) // Store information for later use before it is lost (via pc->delitem) [Paradox924X] nameid = sd->inventory_data[n]->nameid; + if (nameid == ITEMID_MEGAPHONE && (sd->state.workinprogress & 2) != 0) { +#if PACKETVER >= 20110308 + clif->msgtable(sd, MSG_BUSY); +#else + clif->messagecolor_self(sd->fd, COLOR_WHITE, msg_sd(sd, 48)); +#endif + return 0; + } + if (nameid != ITEMID_NAUTHIZ && sd->sc.opt1 > 0 && sd->sc.opt1 != OPT1_STONEWAIT && sd->sc.opt1 != OPT1_BURNING) return 0; diff --git a/src/map/rodex.c b/src/map/rodex.c index 998066eca..f2bb8a0d4 100644 --- a/src/map/rodex.c +++ b/src/map/rodex.c @@ -575,6 +575,7 @@ static void rodex_clean(struct map_session_data *sd, int8 flag) if (flag == 0) VECTOR_CLEAR(sd->rodex.messages); + sd->state.workinprogress &= ~2; memset(&sd->rodex.tmp, 0x0, sizeof(sd->rodex.tmp)); } -- cgit v1.2.3-70-g09d2 From e7f6a8ad0baefe9827b42a01d99ce2e507bf9284 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Thu, 25 Jun 2020 08:21:57 +0200 Subject: Disable using Megaphone while Megaphone input box is present --- src/map/pc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/map/pc.c') diff --git a/src/map/pc.c b/src/map/pc.c index 63d62467c..ae746dab4 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -5190,7 +5190,7 @@ static int pc_useitem(struct map_session_data *sd, int n) // Store information for later use before it is lost (via pc->delitem) [Paradox924X] nameid = sd->inventory_data[n]->nameid; - if (nameid == ITEMID_MEGAPHONE && (sd->state.workinprogress & 2) != 0) { + if (nameid == ITEMID_MEGAPHONE && ((sd->state.workinprogress & 2) != 0 || sd->state.using_megaphone != 0)) { #if PACKETVER >= 20110308 clif->msgtable(sd, MSG_BUSY); #else -- cgit v1.2.3-70-g09d2 From 736b288594003e1e6e4aabf8bc72f82d03143bb2 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Sun, 28 Jun 2020 02:08:49 +0200 Subject: Disable using Megaphone while interacting with NPCs regardless of item_enabled_npc battle flag --- src/map/pc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/map/pc.c') diff --git a/src/map/pc.c b/src/map/pc.c index ae746dab4..6f3227ec9 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -5190,7 +5190,8 @@ static int pc_useitem(struct map_session_data *sd, int n) // Store information for later use before it is lost (via pc->delitem) [Paradox924X] nameid = sd->inventory_data[n]->nameid; - if (nameid == ITEMID_MEGAPHONE && ((sd->state.workinprogress & 2) != 0 || sd->state.using_megaphone != 0)) { + if (nameid == ITEMID_MEGAPHONE && ((sd->state.workinprogress & 2) != 0 || sd->state.using_megaphone != 0 + || sd->npc_id != 0)) { #if PACKETVER >= 20110308 clif->msgtable(sd, MSG_BUSY); #else -- cgit v1.2.3-70-g09d2