summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2020-07-31 23:21:25 -0300
committerJesusaves <cpntb1@ymail.com>2020-07-31 23:21:25 -0300
commit7d545db1cc52a9aefd5cfbe12a66fa83fbcde4cc (patch)
treea9865521fb493e364606cb65872cba0fbb2c0bd0
parent6d595819ea947f6f3c3d89d39a2649f3767f7581 (diff)
downloadhercules-7d545db1cc52a9aefd5cfbe12a66fa83fbcde4cc.tar.gz
hercules-7d545db1cc52a9aefd5cfbe12a66fa83fbcde4cc.tar.bz2
hercules-7d545db1cc52a9aefd5cfbe12a66fa83fbcde4cc.tar.xz
hercules-7d545db1cc52a9aefd5cfbe12a66fa83fbcde4cc.zip
[TMW2] MARKET FIX
-rw-r--r--src/map/npc.c29
1 files changed, 15 insertions, 14 deletions
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;
}