From 7d545db1cc52a9aefd5cfbe12a66fa83fbcde4cc Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Fri, 31 Jul 2020 23:21:25 -0300 Subject: [TMW2] MARKET FIX --- src/map/npc.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'src/map') diff --git a/src/map/npc.c b/src/map/npc.c index fea82c873..84d292415 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -2070,9 +2070,6 @@ static int npc_buylist(struct map_session_data *sd, struct itemlist *item_list) w += itemdb_weight(entry->id) * entry->amount; } - if (nd->master_nd != NULL) //Script-based shops. - return npc->buylist_sub(sd, item_list, nd->master_nd); - if (z > sd->status.zeny) return 1; // Not enough Zeny if( w + sd->weight > sd->max_weight ) @@ -2109,6 +2106,9 @@ static int npc_buylist(struct map_session_data *sd, struct itemlist *item_list) } } + if (nd->master_nd != NULL) // TMW2 Script-based shops. + return npc->buylist_sub(sd, item_list, nd->master_nd); + return 0; } @@ -2179,6 +2179,9 @@ static int npc_market_buylist(struct map_session_data *sd, struct itemlist *item return 1; } + // Apply player discout cupon (TMW2 Custom) + value = pc->modifybuyvalue(sd,value); + z += (int64)value * entry->amount; w += itemdb_weight(entry->id) * entry->amount; } @@ -2218,6 +2221,9 @@ static int npc_market_buylist(struct map_session_data *sd, struct itemlist *item } } + if (nd->master_nd != NULL) // TMW2 Script-based shops. + return npc->buylist_sub(sd, item_list, nd->master_nd); + return 0; } @@ -2463,7 +2469,7 @@ static int npc_selllist(struct map_session_data *sd, struct itemlist *item_list) z = 0; - if (sd->status.zeny >= MAX_ZENY && nd->master_nd == NULL) + if (sd->status.zeny >= MAX_ZENY) return 1; // verify the sell list @@ -2487,20 +2493,11 @@ static int npc_selllist(struct map_session_data *sd, struct itemlist *item_list) return 1; } - if (nd->master_nd) { - // Script-controlled shops decide by themselves, what can be sold and at what price. - continue; - } - value = pc->modifysellvalue(sd, sd->inventory_data[idx]->value_sell); z += (int64)value * entry->amount; } - if( nd->master_nd ) { // Script-controlled shops - return npc->selllist_sub(sd, item_list, nd->master_nd); - } - // delete items for (i = 0; i < VECTOR_LENGTH(*item_list); i++) { struct itemlist_entry *entry = &VECTOR_INDEX(*item_list, i); @@ -2519,7 +2516,7 @@ static int npc_selllist(struct map_session_data *sd, struct itemlist *item_list) } - if (z + sd->status.zeny > MAX_ZENY && nd->master_nd == NULL) + if (z + sd->status.zeny > MAX_ZENY) return 1; if (z > MAX_ZENY) @@ -2540,6 +2537,10 @@ static int npc_selllist(struct map_session_data *sd, struct itemlist *item_list) } } + if( nd->master_nd ) { // Script-controlled shops + return npc->selllist_sub(sd, item_list, nd->master_nd); + } + return 0; } -- cgit v1.2.3-60-g2f50