Skip to content

Commit

Permalink
Add drop highlighting effect feature (rathena#3710)
Browse files Browse the repository at this point in the history
Fixes rathena#3610

Thanks to @Balferian, @admkakaroto and credits to @Asheraf
  • Loading branch information
Lemongrass3110 authored and SeravySensei committed Jan 26, 2019
1 parent 02e86bb commit 13b728e
Show file tree
Hide file tree
Showing 11 changed files with 71 additions and 12 deletions.
6 changes: 6 additions & 0 deletions db/import-tmpl/item_flag.txt
Expand Up @@ -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
6 changes: 6 additions & 0 deletions db/pre-re/item_flag.txt
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions db/re/item_flag.txt
Expand Up @@ -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
Expand Down
30 changes: 25 additions & 5 deletions src/map/clif.cpp
Expand Up @@ -764,11 +764,15 @@ void clif_charselectok(int id, uint8 ok)
}

/// Makes an item appear on the ground.
/// 009e <id>.L <name id>.W <identified>.B <x>.W <y>.W <subX>.B <subY>.B <amount>.W (ZC_ITEM_FALL_ENTRY)
/// 084b <id>.L <name id>.W <type>.W <identified>.B <x>.W <y>.W <subX>.B <subY>.B <amount>.W (ZC_ITEM_FALL_ENTRY4)
void clif_dropflooritem(struct flooritem_data* fitem)
{
#if PACKETVER >= 20130000
/// 009E <id>.L <name id>.W <identified>.B <x>.W <y>.W <subX>.B <subY>.B <amount>.W (ZC_ITEM_FALL_ENTRY)
/// 084B <id>.L <name id>.W <type>.W <identified>.B <x>.W <y>.W <subX>.B <subY>.B <amount>.W (ZC_ITEM_FALL_ENTRY4)
/// 0ADD <id>.L <name id>.W <type>.W <identified>.B <x>.W <y>.W <subX>.B <subY>.B <amount>.W <show drop effect>.B <drop effect mode>.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
Expand All @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/map/clif.hpp
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions src/map/clif_packetdb.hpp
Expand Up @@ -2407,4 +2407,9 @@
packet(0x0A4C,28);
#endif

// 2018-04-18bRagexeRE
#if PACKETVER >= 20180418
packet(0x0ADD, 22);
#endif

#endif /* CLIF_PACKETDB_HPP */
16 changes: 15 additions & 1 deletion src/map/itemdb.cpp
Expand Up @@ -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;

Expand All @@ -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;
}

Expand Down
2 changes: 2 additions & 0 deletions src/map/itemdb.hpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/map/map.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/map/map.hpp
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/map/mob.cpp
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 13b728e

Please sign in to comment.