From 79f7a2274092f892ec183ed11cc16609c3a2f180 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 28 Nov 2019 03:15:45 +0300 Subject: Add new version for packet ZC_NOTIFY_EFFECT3 and convert to structure --- src/map/clif.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'src/map/clif.c') diff --git a/src/map/clif.c b/src/map/clif.c index b9ca44dec..bfbb88c71 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -9087,21 +9087,26 @@ static void clif_specialeffect_single(struct block_list *bl, int type, int fd) /// @see doc/effect_list.txt /// num data: /// effect-dependent value -static void clif_specialeffect_value(struct block_list *bl, int effect_id, int num, send_target target) -{ - uint8 buf[14]; - - WBUFW(buf,0) = 0x284; - WBUFL(buf,2) = bl->id; - WBUFL(buf,6) = effect_id; - WBUFL(buf,10) = num; +static void clif_specialeffect_value(struct block_list *bl, int effect_id, uint64 num, send_target target) +{ +#if PACKETVER_MAIN_NUM >= 20060911 || PACKETVER_AD_NUM >= 20060911 || PACKETVER_SAK_NUM >= 20060911 || defined(PACKETVER_RE) || defined(PACKETVER_ZERO) + struct PACKET_ZC_NOTIFY_EFFECT3 packet; + packet.packetType = HEADER_ZC_NOTIFY_EFFECT3; + packet.aid = bl->id; + packet.effectId = effect_id; +#if PACKETVER >= 20191127 + packet.num = num; +#else + packet.num = (uint32)num; +#endif - clif->send(buf, packet_len(0x284), bl, target); + clif->send(&packet, sizeof(struct PACKET_ZC_NOTIFY_EFFECT3), bl, target); if (clif->isdisguised(bl)) { - WBUFL(buf,2) = -bl->id; - clif->send(buf, packet_len(0x284), bl, SELF); + packet.aid = -bl->id; + clif->send(&packet, sizeof(struct PACKET_ZC_NOTIFY_EFFECT3), bl, SELF); } +#endif } /// Remove special effects (ZC_REMOVE_EFFECT). -- cgit v1.2.3-70-g09d2 From 1f78dc3468f1a4afe1f8bd09ea340a715af1d206 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 28 Nov 2019 04:24:37 +0300 Subject: Add script function specialeffectnum --- doc/effect_list.md | 2 +- doc/script_commands.txt | 9 +++++++++ src/map/clif.c | 19 ++++++++++++++++++ src/map/clif.h | 1 + src/map/script.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 81 insertions(+), 1 deletion(-) (limited to 'src/map/clif.c') diff --git a/doc/effect_list.md b/doc/effect_list.md index 8ba8d36c9..b16839d41 100644 --- a/doc/effect_list.md +++ b/doc/effect_list.md @@ -21,7 +21,7 @@ The following is a compiled list of visual and sound effects which the client can produce. Each list entry contains a number and a short description of the effect. You can produce these effects ingame by using the `@effect` atcommand. It's also possible to attach effects to item/npc scripts by using the -`specialeffect()` script command. +`specialeffect()` or `specialeffectnum()` script commands. ID | Constant Name | Description --: | :----------------------------- | :---------------------------------- diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 45636f23b..b55afb0f2 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -6231,6 +6231,15 @@ Example usage: --------------------------------------- +*specialeffectnum(, , {, {, {, }}}) +*specialeffectnum(, , {, {, ""{, }}}) + +Works same as specialeffect but also send effect numbers to client. +For PACKETVER >= 20191127 support two numbers (num1, num2). +For older packet versions only num1 supported. + +--------------------------------------- + *removespecialeffect({, {, {, }}}) *removespecialeffect({, {, ""{, }}}) diff --git a/src/map/clif.c b/src/map/clif.c index bfbb88c71..ade56b53b 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -9109,6 +9109,24 @@ static void clif_specialeffect_value(struct block_list *bl, int effect_id, uint6 #endif } +static void clif_specialeffect_value_single(struct block_list *bl, int effect_id, uint64 num, int fd) +{ +#if PACKETVER_MAIN_NUM >= 20060911 || defined(PACKETVER_RE) || defined(PACKETVER_ZERO) + WFIFOHEAD(fd, sizeof(struct PACKET_ZC_NOTIFY_EFFECT3)); + + struct PACKET_ZC_NOTIFY_EFFECT3 *packet = WFIFOP(fd, 0); + packet->packetType = HEADER_ZC_NOTIFY_EFFECT3; + packet->aid = bl->id; + packet->effectId = effect_id; +#if PACKETVER >= 20191127 + packet->num = num; +#else + packet->num = (uint32)num; +#endif + WFIFOSET(fd, sizeof(struct PACKET_ZC_NOTIFY_EFFECT3)); +#endif +} + /// Remove special effects (ZC_REMOVE_EFFECT). /// 0b0d .L .L /// effect id: @@ -24069,6 +24087,7 @@ void clif_defaults(void) clif->specialeffect = clif_specialeffect; clif->specialeffect_single = clif_specialeffect_single; clif->specialeffect_value = clif_specialeffect_value; + clif->specialeffect_value_single = clif_specialeffect_value_single; clif->removeSpecialEffect = clif_removeSpecialEffect; clif->removeSpecialEffect_single = clif_removeSpecialEffect_single; clif->millenniumshield = clif_millenniumshield; diff --git a/src/map/clif.h b/src/map/clif.h index 498cbc046..14a7997a1 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -1031,6 +1031,7 @@ struct clif_interface { void (*specialeffect) (struct block_list* bl, int type, enum send_target target); void (*specialeffect_single) (struct block_list* bl, int type, int fd); void (*specialeffect_value) (struct block_list* bl, int effect_id, uint64 num, send_target target); + void (*specialeffect_value_single) (struct block_list *bl, int effect_id, uint64 num, int fd); void (*removeSpecialEffect) (struct block_list *bl, int effectId, enum send_target target); void (*removeSpecialEffect_single) (struct block_list *bl, int effectId, struct block_list *targetBl); void (*millenniumshield) (struct block_list *bl, short shields ); diff --git a/src/map/script.c b/src/map/script.c index 16336b46d..396d084a3 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -15815,6 +15815,56 @@ static BUILDIN(specialeffect) return true; } +/*========================================== + * Special effects with num [4144] + *------------------------------------------*/ +static BUILDIN(specialeffectnum) +{ + struct block_list *bl = NULL; + int type = script_getnum(st, 2); + int num = script_getnum(st, 3); + int num2 = script_getnum(st, 4); + enum send_target target = AREA; + + if (script_hasdata(st, 5)) { + target = script_getnum(st, 5); + } + + if (script_hasdata(st, 6)) { + if (script_isstringtype(st, 6)) { + struct npc_data *nd = npc->name2id(script_getstr(st, 6)); + if (nd != NULL) { + bl = &nd->bl; + } + } else { + bl = map->id2bl(script_getnum(st, 6)); + } + } else { + bl = map->id2bl(st->oid); + } + + if (bl == NULL) { + return true; + } + + uint64 bigNum = ((uint64)num2) * 0xffffffff + num; + if (target == SELF) { + struct map_session_data *sd; + if (script_hasdata(st, 7)) { + sd = map->id2sd(script_getnum(st, 7)); + } else { + sd = script->rid2sd(st); + } + if (sd != NULL) { + clif->specialeffect_value_single(bl, type, bigNum, sd->fd); + } + } else { + clif->specialeffect_value(bl, type, bigNum, target); + } + + return true; +} + static BUILDIN(specialeffect2) { struct map_session_data *sd; @@ -26369,6 +26419,7 @@ static void script_parse_builtin(void) BUILDIN_DEF(skilleffect,"vi"), // skill effect [Celest] BUILDIN_DEF(npcskilleffect,"viii"), // npc skill effect [Valaris] BUILDIN_DEF(specialeffect,"i???"), // npc skill effect [Valaris] + BUILDIN_DEF(specialeffectnum,"iii???"), // npc skill effect with num [4144] BUILDIN_DEF(removespecialeffect,"i???"), BUILDIN_DEF_DEPRECATED(specialeffect2,"i??"), // skill effect on players[Valaris] BUILDIN_DEF(nude,""), // nude command [Valaris] -- cgit v1.2.3-70-g09d2 From 3acb36c33e06a8a7e226e43ff8656c8cffa2eeb3 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 13 Dec 2019 08:23:29 +0300 Subject: Convert packet CZ_SE_CASHSHOP_OPEN to structure and add new packet version --- src/common/packetsstatic_len.h | 4 ++++ src/map/clif.c | 2 ++ src/map/packets.h | 10 +++++++++- src/map/packets_struct.h | 13 +++++++++++++ 4 files changed, 28 insertions(+), 1 deletion(-) (limited to 'src/map/clif.c') diff --git a/src/common/packetsstatic_len.h b/src/common/packetsstatic_len.h index 730516c27..f721ab882 100644 --- a/src/common/packetsstatic_len.h +++ b/src/common/packetsstatic_len.h @@ -32,6 +32,10 @@ #define DEFINE_PACKET_ID(name, id) \ enum { HEADER_##name = id }; +#define CHECK_PACKET_HEADER(name, id) \ + STATIC_ASSERT((int32)(PACKET_LEN_##id) == -1 || sizeof(struct PACKET_##name) == \ + (size_t)PACKET_LEN_##id, "Wrong size PACKET_"#name); \ + #define packetLen(id, len) PACKET_LEN_##id = (len), enum packet_lengths { #include "common/packets_len.h" diff --git a/src/map/clif.c b/src/map/clif.c index ade56b53b..a1c1bce19 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -19983,6 +19983,7 @@ static void clif_parse_dull(int fd, struct map_session_data *sd) static void clif_parse_CashShopOpen(int fd, struct map_session_data *sd) __attribute__((nonnull (2))); static void clif_parse_CashShopOpen(int fd, struct map_session_data *sd) { +#if PACKETVER >= 20100824 if (sd->state.trading || pc_isdead(sd) || pc_isvending(sd)) return; @@ -19996,6 +19997,7 @@ static void clif_parse_CashShopOpen(int fd, struct map_session_data *sd) WFIFOL(fd, 2) = sd->cashPoints; //[Ryuuzaki] - switched positions to reflect proper values WFIFOL(fd, 6) = sd->kafraPoints; WFIFOSET(fd, 10); +#endif } static void clif_parse_CashShopClose(int fd, struct map_session_data *sd) __attribute__((nonnull (2))); diff --git a/src/map/packets.h b/src/map/packets.h index 326f41791..48d937957 100644 --- a/src/map/packets.h +++ b/src/map/packets.h @@ -726,6 +726,11 @@ packet(0x96e,clif->ackmergeitems); packet(0x0843,clif->pGMRemove2,2); #endif +// all versions +#if PACKETVER >= 20100824 + packet(0x0844,clif->pCashShopOpen,2); +#endif + //2010-11-24aRagexeRE #if PACKETVER >= 20101124 packet(0x0288,clif->pcashshop_buy,4,8); @@ -776,7 +781,6 @@ packet(0x96e,clif->ackmergeitems); //2011-07-18aRagexe (Thanks to Yommy!) #if PACKETVER >= 20110718 // shuffle packets not added - packet(0x0844,clif->pCashShopOpen,2);/* tell server cashshop window is being open */ packet(0x084a,clif->pCashShopClose,2);/* tell server cashshop window is being closed */ packet(0x0846,clif->pCashShopReqTab,2); packet(0x0848,clif->pCashShopBuy,2); @@ -1975,4 +1979,8 @@ packet(0x96e,clif->ackmergeitems); packet(0x0b35,clif->pReqGearOff); #endif +#if PACKETVER >= 20190724 + packet(0x0b4c,clif->pCashShopOpen,2); +#endif + #endif /* MAP_PACKETS_H */ diff --git a/src/map/packets_struct.h b/src/map/packets_struct.h index fa9a0c873..a98317364 100644 --- a/src/map/packets_struct.h +++ b/src/map/packets_struct.h @@ -3748,6 +3748,19 @@ struct PACKET_ZC_NOTIFY_EFFECT3 { DEFINE_PACKET_HEADER(ZC_NOTIFY_EFFECT3, 0x0284); #endif +#if PACKETVER >= 20190724 +struct PACKET_CZ_SE_CASHSHOP_OPEN { + int16 packetType; +} __attribute__((packed)); +DEFINE_PACKET_HEADER(CZ_SE_CASHSHOP_OPEN, 0x0b4c); +CHECK_PACKET_HEADER(CZ_SE_CASHSHOP_OPEN, 0x0844); +#elif PACKETVER >= 20100824 +struct PACKET_CZ_SE_CASHSHOP_OPEN { + int16 packetType; +} __attribute__((packed)); +DEFINE_PACKET_HEADER(CZ_SE_CASHSHOP_OPEN, 0x0844); +#endif + #if !defined(sun) && (!defined(__NETBSD__) || __NetBSD_Version__ >= 600000000) // NetBSD 5 and Solaris don't like pragma pack but accept the packed attribute #pragma pack(pop) #endif // not NetBSD < 6 / Solaris -- cgit v1.2.3-70-g09d2 From c5a7fac25b79669253c1f7a3ef5775ac362b6491 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 13 Dec 2019 20:53:18 +0300 Subject: Send load confirm packet in clif_refresh --- src/map/clif.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/map/clif.c') diff --git a/src/map/clif.c b/src/map/clif.c index a1c1bce19..31fb00c37 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -9338,6 +9338,8 @@ static void clif_refresh(struct map_session_data *sd) mail->clear(sd); + clif->loadConfirm(sd); + if (clif->isdisguised(&sd->bl)) {/* refresh-da */ short disguise = sd->disguise; pc->disguise(sd, -1); -- cgit v1.2.3-70-g09d2