From 13b728ea427c4cd6ae7456987d896d2b2634998d Mon Sep 17 00:00:00 2001 From: Lemongrass3110 Date: Thu, 29 Nov 2018 22:34:57 +0100 Subject: [PATCH] Add drop highlighting effect feature (#3710) Fixes #3610 Thanks to @Balferian, @admkakaroto and credits to @Asheraf --- db/import-tmpl/item_flag.txt | 6 ++++++ db/pre-re/item_flag.txt | 6 ++++++ db/re/item_flag.txt | 6 ++++++ src/map/clif.cpp | 30 +++++++++++++++++++++++++----- src/map/clif.hpp | 2 +- src/map/clif_packetdb.hpp | 5 +++++ src/map/itemdb.cpp | 16 +++++++++++++++- src/map/itemdb.hpp | 2 ++ src/map/map.cpp | 4 ++-- src/map/map.hpp | 2 +- src/map/mob.cpp | 4 ++-- 11 files changed, 71 insertions(+), 12 deletions(-) diff --git a/db/import-tmpl/item_flag.txt b/db/import-tmpl/item_flag.txt index b86479885fe..1c1779b8954 100644 --- a/db/import-tmpl/item_flag.txt +++ b/db/import-tmpl/item_flag.txt @@ -8,4 +8,10 @@ // 8 - Item will be bound item when equipped // 16 - Special Broadcast: When item dropped by monster and player loot it, will be broadcasted! // 32 - Item will not be removed on consumption. Also supports 'itemskill' +// 64 - Item will be displayed with a client side defined drop +// 128 - Item will be displayed with a white pillar drop effect +// 256 - Item will be displayed with a blue pillar drop effect +// 512 - Item will be displayed with a yellow pillar drop effect +// 1024 - Item will be displayed with a purple pillar drop effect +// 2048 - Item will be displayed with a orange pillar drop effect // NOTE: For removing flag by import file, use "-" to remove the flag. Example, 604,-1 will removes flag 1 from Branch_Of_Dead_Tree diff --git a/db/pre-re/item_flag.txt b/db/pre-re/item_flag.txt index ef9cce5b800..760da451cdb 100644 --- a/db/pre-re/item_flag.txt +++ b/db/pre-re/item_flag.txt @@ -8,6 +8,12 @@ // 8 - Item will be bound item when equipped // 16 - Special Broadcast: When item dropped by monster and player loot it, will be broadcasted! // 32 - Item will not be removed on consumption. Also supports 'itemskill' +// 64 - Item will be displayed with a client side defined drop +// 128 - Item will be displayed with a white pillar drop effect +// 256 - Item will be displayed with a blue pillar drop effect +// 512 - Item will be displayed with a yellow pillar drop effect +// 1024 - Item will be displayed with a purple pillar drop effect +// 2048 - Item will be displayed with a orange pillar drop effect // NOTE: For removing flag by import file, use "-" to remove the flag. Example, 604,-1 will removes flag 1 from Branch_Of_Dead_Tree // Logged as Dead Branch item diff --git a/db/re/item_flag.txt b/db/re/item_flag.txt index 911a8fddfcc..2f46a1517c9 100644 --- a/db/re/item_flag.txt +++ b/db/re/item_flag.txt @@ -8,6 +8,12 @@ // 8 - Item will be bound item when equipped // 16 - Special Broadcast: When item dropped by monster and player loot it, will be broadcasted! // 32 - Item will not be removed on consumption. Also supports 'itemskill' +// 64 - Item will be displayed with a client side defined drop +// 128 - Item will be displayed with a white pillar drop effect +// 256 - Item will be displayed with a blue pillar drop effect +// 512 - Item will be displayed with a yellow pillar drop effect +// 1024 - Item will be displayed with a purple pillar drop effect +// 2048 - Item will be displayed with a orange pillar drop effect // NOTE: For removing flag by import file, use "-" to remove the flag. Example, 604,-1 will removes flag 1 from Branch_Of_Dead_Tree // Logged as Dead Branch item diff --git a/src/map/clif.cpp b/src/map/clif.cpp index 995fae11e3d..d5d704cf71b 100644 --- a/src/map/clif.cpp +++ b/src/map/clif.cpp @@ -764,11 +764,15 @@ void clif_charselectok(int id, uint8 ok) } /// Makes an item appear on the ground. -/// 009e .L .W .B .W .W .B .B .W (ZC_ITEM_FALL_ENTRY) -/// 084b .L .W .W .B .W .W .B .B .W (ZC_ITEM_FALL_ENTRY4) -void clif_dropflooritem(struct flooritem_data* fitem) -{ -#if PACKETVER >= 20130000 +/// 009E .L .W .B .W .W .B .B .W (ZC_ITEM_FALL_ENTRY) +/// 084B .L .W .W .B .W .W .B .B .W (ZC_ITEM_FALL_ENTRY4) +/// 0ADD .L .W .W .B .W .W .B .B .W .B .W (ZC_ITEM_FALL_ENTRY5) +void clif_dropflooritem(struct flooritem_data* fitem, bool canShowEffect) +{ +#if PACKETVER >= 20180418 + uint8 buf[22]; + uint32 header = 0xadd; +#elif PACKETVER >= 20130000 uint8 buf[19]; uint32 header=0x84b; #else @@ -795,6 +799,22 @@ void clif_dropflooritem(struct flooritem_data* fitem) WBUFB(buf, offset+13) = fitem->subx; WBUFB(buf, offset+14) = fitem->suby; WBUFW(buf, offset+15) = fitem->item.amount; +#if PACKETVER >= 20180418 + if( canShowEffect ){ + uint8 dropEffect = itemdb_dropeffect(fitem->item.nameid); + + if( dropEffect > 0 ){ + WBUFB(buf, offset+17) = 1; + WBUFW(buf, offset+18) = dropEffect - 1; + }else{ + WBUFB(buf, offset+17) = 0; + WBUFW(buf, offset+18) = 0; + } + }else{ + WBUFB(buf, offset+17) = 0; + WBUFW(buf, offset+18) = 0; + } +#endif clif_send(buf, packet_len(header), &fitem->bl, AREA); } diff --git a/src/map/clif.hpp b/src/map/clif.hpp index abfcdd618b8..a171564a277 100644 --- a/src/map/clif.hpp +++ b/src/map/clif.hpp @@ -564,7 +564,7 @@ void clif_authok(struct map_session_data *sd); void clif_authrefuse(int fd, uint8 error_code); void clif_authfail_fd(int fd, int type); void clif_charselectok(int id, uint8 ok); -void clif_dropflooritem(struct flooritem_data* fitem); +void clif_dropflooritem(struct flooritem_data* fitem, bool canShowEffect); void clif_clearflooritem(struct flooritem_data *fitem, int fd); void clif_clearunit_single(int id, clr_type type, int fd); diff --git a/src/map/clif_packetdb.hpp b/src/map/clif_packetdb.hpp index f1352bd852b..54eaf97b817 100644 --- a/src/map/clif_packetdb.hpp +++ b/src/map/clif_packetdb.hpp @@ -2407,4 +2407,9 @@ packet(0x0A4C,28); #endif +// 2018-04-18bRagexeRE +#if PACKETVER >= 20180418 + packet(0x0ADD, 22); +#endif + #endif /* CLIF_PACKETDB_HPP */ diff --git a/src/map/itemdb.cpp b/src/map/itemdb.cpp index 1fcf090e254..70a47e5f223 100644 --- a/src/map/itemdb.cpp +++ b/src/map/itemdb.cpp @@ -914,7 +914,7 @@ static bool itemdb_read_nouse(char* fields[], int columns, int current) { */ static bool itemdb_read_flag(char* fields[], int columns, int current) { unsigned short nameid = atoi(fields[0]); - uint8 flag; + uint16 flag; bool set; struct item_data *id; @@ -933,6 +933,20 @@ static bool itemdb_read_flag(char* fields[], int columns, int current) { if (flag&16) id->flag.broadcast = 1; if (flag&32) id->flag.delay_consume = 2; + if( flag & 64 ){ + id->flag.dropEffect = 1; + }else if( flag & 128 ){ + id->flag.dropEffect = 2; + }else if( flag & 256 ){ + id->flag.dropEffect = 3; + }else if( flag & 512 ){ + id->flag.dropEffect = 4; + }else if( flag & 1024 ){ + id->flag.dropEffect = 5; + }else if( flag & 2048 ){ + id->flag.dropEffect = 6; + } + return true; } diff --git a/src/map/itemdb.hpp b/src/map/itemdb.hpp index 819169d0cf8..f1b4c046030 100644 --- a/src/map/itemdb.hpp +++ b/src/map/itemdb.hpp @@ -839,6 +839,7 @@ struct item_data unsigned guid : 1; // This item always be attached with GUID and make it as bound item! [Cydh] unsigned broadcast : 1; ///< Will be broadcasted if someone obtain the item [Cydh] bool bindOnEquip; ///< Set item as bound when equipped + uint8 dropEffect; ///< Drop Effect Mode } flag; struct {// item stacking limitation unsigned short amount; @@ -904,6 +905,7 @@ struct item_data* itemdb_exists(unsigned short nameid); #define itemdb_traderight(n) (itemdb_search(n)->flag.trade_restriction) #define itemdb_viewid(n) (itemdb_search(n)->view_id) #define itemdb_autoequip(n) (itemdb_search(n)->flag.autoequip) +#define itemdb_dropeffect(n) (itemdb_search(n)->flag.dropEffect) const char* itemdb_typename(enum item_types type); const char *itemdb_typename_ammo (enum e_item_ammo ammo); bool itemdb_is_spellbook2(unsigned short nameid); diff --git a/src/map/map.cpp b/src/map/map.cpp index 59b12d899e7..570233f2bac 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -1791,7 +1791,7 @@ bool map_closest_freecell(int16 m, int16 *x, int16 *y, int type, int flag) * @param mob_id: Monster ID if dropped by monster * @return 0:failure, x:item_gid [MIN_FLOORITEM;MAX_FLOORITEM]==[2;START_ACCOUNT_NUM] *------------------------------------------*/ -int map_addflooritem(struct item *item, int amount, int16 m, int16 x, int16 y, int first_charid, int second_charid, int third_charid, int flags, unsigned short mob_id) +int map_addflooritem(struct item *item, int amount, int16 m, int16 x, int16 y, int first_charid, int second_charid, int third_charid, int flags, unsigned short mob_id, bool canShowEffect) { int r; struct flooritem_data *fitem = NULL; @@ -1834,7 +1834,7 @@ int map_addflooritem(struct item *item, int amount, int16 m, int16 x, int16 y, i map_addiddb(&fitem->bl); if (map_addblock(&fitem->bl)) return 0; - clif_dropflooritem(fitem); + clif_dropflooritem(fitem,canShowEffect); return fitem->bl.id; } diff --git a/src/map/map.hpp b/src/map/map.hpp index fb2275593a4..5124029d095 100644 --- a/src/map/map.hpp +++ b/src/map/map.hpp @@ -1031,7 +1031,7 @@ bool map_addnpc(int16 m,struct npc_data *); TIMER_FUNC(map_clearflooritem_timer); TIMER_FUNC(map_removemobs_timer); void map_clearflooritem(struct block_list* bl); -int map_addflooritem(struct item *item, int amount, int16 m, int16 x, int16 y, int first_charid, int second_charid, int third_charid, int flags, unsigned short mob_id); +int map_addflooritem(struct item *item, int amount, int16 m, int16 x, int16 y, int first_charid, int second_charid, int third_charid, int flags, unsigned short mob_id, bool canShowEffect = false); // instances int map_addinstancemap(const char *name, unsigned short instance_id); diff --git a/src/map/mob.cpp b/src/map/mob.cpp index 10b8692170b..52adf3d67e6 100644 --- a/src/map/mob.cpp +++ b/src/map/mob.cpp @@ -2146,7 +2146,7 @@ static TIMER_FUNC(mob_delay_item_drop){ struct item_drop *ditem_prev; map_addflooritem(&ditem->item_data,ditem->item_data.amount, list->m,list->x,list->y, - list->first_charid,list->second_charid,list->third_charid,4,ditem->mob_id); + list->first_charid,list->second_charid,list->third_charid,4,ditem->mob_id,true); ditem_prev = ditem; ditem = ditem->next; ers_free(item_drop_ers, ditem_prev); @@ -2919,7 +2919,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) if((temp = pc_additem(mvp_sd,&item,1,LOG_TYPE_PICKDROP_PLAYER)) != 0) { clif_additem(mvp_sd,0,0,temp); - map_addflooritem(&item,1,mvp_sd->bl.m,mvp_sd->bl.x,mvp_sd->bl.y,mvp_sd->status.char_id,(second_sd?second_sd->status.char_id:0),(third_sd?third_sd->status.char_id:0),1,0); + map_addflooritem(&item,1,mvp_sd->bl.m,mvp_sd->bl.x,mvp_sd->bl.y,mvp_sd->status.char_id,(second_sd?second_sd->status.char_id:0),(third_sd?third_sd->status.char_id:0),1,0,true); } if (i_data->flag.broadcast)