瀏覽代碼

Add drop highlighting effect feature (#3710)

Fixes #3610

Thanks to @Balferian, @admkakaroto and credits to @Asheraf
Lemongrass3110 6 年之前
父節點
當前提交
bde580fdbd
共有 11 個文件被更改,包括 71 次插入12 次删除
  1. 6 0
      db/import-tmpl/item_flag.txt
  2. 6 0
      db/pre-re/item_flag.txt
  3. 6 0
      db/re/item_flag.txt
  4. 25 5
      src/map/clif.cpp
  5. 1 1
      src/map/clif.hpp
  6. 5 0
      src/map/clif_packetdb.hpp
  7. 15 1
      src/map/itemdb.cpp
  8. 2 0
      src/map/itemdb.hpp
  9. 2 2
      src/map/map.cpp
  10. 1 1
      src/map/map.hpp
  11. 2 2
      src/map/mob.cpp

+ 6 - 0
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

+ 6 - 0
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

+ 6 - 0
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

+ 25 - 5
src/map/clif.cpp

@@ -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
@@ -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);
 }

+ 1 - 1
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);

+ 5 - 0
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 */

+ 15 - 1
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;
 }
 

+ 2 - 0
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);

+ 2 - 2
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;
 }

+ 1 - 1
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);

+ 2 - 2
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)