浏览代码

Added the ability to make dynamic cash/item/point shops (#5213)

Daegaladh 4 年之前
父节点
当前提交
187aa852be
共有 2 个文件被更改,包括 8 次插入0 次删除
  1. 7 0
      src/map/npc.cpp
  2. 1 0
      src/map/npc.hpp

+ 7 - 0
src/map/npc.cpp

@@ -1699,6 +1699,10 @@ int npc_cashshop_buylist(struct map_session_data *sd, int points, int count, str
 			amount = item_list[i].amount = 1;
 		}
 
+		if( nd->master_nd ) { // Script-controlled shops decide by themselves, what can be bought and for what price.
+			continue;
+		}
+
 		switch( pc_checkadditem(sd,nameid,amount) )
 		{
 			case CHKADDITEM_NEW:
@@ -1712,6 +1716,9 @@ int npc_cashshop_buylist(struct map_session_data *sd, int points, int count, str
 		w += itemdb_weight(nameid) * amount;
 	}
 
+	if (nd->master_nd) //Script-based shops.
+		return npc_buylist_sub(sd,count,(struct s_npc_buy_list*)item_list,nd->master_nd);
+
 	if( w + sd->weight > sd->max_weight )
 		return ERROR_TYPE_INVENTORY_WEIGHT;
 	if( pc_inventoryblank(sd) < new_ )

+ 1 - 0
src/map/npc.hpp

@@ -1237,6 +1237,7 @@ bool npc_scriptcont(struct map_session_data* sd, int id, bool closing);
 struct npc_data* npc_checknear(struct map_session_data* sd, struct block_list* bl);
 int npc_buysellsel(struct map_session_data* sd, int id, int type);
 uint8 npc_buylist(struct map_session_data* sd, uint16 n, struct s_npc_buy_list *item_list);
+static int npc_buylist_sub(struct map_session_data* sd, uint16 n, struct s_npc_buy_list *item_list, struct npc_data* nd);
 uint8 npc_selllist(struct map_session_data* sd, int n, unsigned short *item_list);
 void npc_parse_mob2(struct spawn_data* mob);
 struct npc_data* npc_add_warp(char* name, short from_mapid, short from_x, short from_y, short xs, short ys, unsigned short to_mapindex, short to_x, short to_y);