[Merchants] Add New Classic Greed/Faction/Charisma Prices Rule (#4301)

* [Merchants] Add New Classic Greed/Faction/Charisma Prices Rule

* Fix size of greed field.

* Fix { formatting and add {} to one liners

* Fix return type of GetGreedPercent

* Remove code that slipped in from another patch

* Fix greed to be unsigned

* Update client.cpp

* Update client_packet.cpp

* Update client.cpp

Fix bad name in extra log message added manually from merge.

* Update client_packet.cpp

Spacing.

* Update client.cpp

---------

Co-authored-by: Kinglykrab <kinglykrab@gmail.com>
This commit is contained in:
Paul Coene
2024-05-17 11:16:02 -04:00
committed by GitHub
parent a80ab75260
commit c0a8fd097e
11 changed files with 605 additions and 457 deletions
+37 -16
View File
@@ -14041,16 +14041,21 @@ void Client::Handle_OP_ShopPlayerBuy(const EQApplicationPacket *app)
EQ::ItemInstance* inst = database.CreateItem(item, charges);
int SinglePrice = 0;
if (RuleB(Merchant, UsePriceMod))
SinglePrice = (item->Price * (RuleR(Merchant, SellCostMod)) * item->SellRate * Client::CalcPriceMod(tmp, false));
else
SinglePrice = (item->Price * (RuleR(Merchant, SellCostMod)) * item->SellRate);
int single_price = (item->Price * item->SellRate);
// Don't use SellCostMod if using UseClassicPriceMod
if (!RuleB(Merchant, UseClassicPriceMod)) {
single_price *= RuleR(Merchant, SellCostMod);
}
if (RuleB(Merchant, UsePriceMod)) {
single_price *= Client::CalcPriceMod(tmp, false);
}
if (item->MaxCharges > 1)
mpo->price = SinglePrice;
mpo->price = single_price;
else
mpo->price = SinglePrice * mp->quantity;
mpo->price = single_price * mp->quantity;
if (mpo->price < 0)
{
@@ -14131,7 +14136,7 @@ void Client::Handle_OP_ShopPlayerBuy(const EQApplicationPacket *app)
else {
// Update the charges/quantity in the merchant window
inst->SetCharges(new_charges);
inst->SetPrice(SinglePrice);
inst->SetPrice(single_price);
inst->SetMerchantSlot(mp->itemslot);
inst->SetMerchantCount(new_charges);
@@ -14310,7 +14315,15 @@ void Client::Handle_OP_ShopPlayerSell(const EQApplicationPacket *app)
if (RuleB(Merchant, UsePriceMod)) {
for (i = 1; i <= cost_quantity; i++) {
price = (uint32)((item->Price * i)*(RuleR(Merchant, BuyCostMod))*Client::CalcPriceMod(vendor, true) + 0.5); // need to round up, because client does it automatically when displaying price
price = (uint32)(item->Price * i) * Client::CalcPriceMod(vendor, true);
// Don't use SellCostMod if using UseClassicPriceMod
if (!RuleB(Merchant, UseClassicPriceMod)) {
price *= RuleR(Merchant, BuyCostMod);
}
price += 0.5; // need to round up, because client does it automatically when displaying price
if (price > 4000000000) {
cost_quantity = i;
mp->quantity = i;
@@ -14360,11 +14373,12 @@ void Client::Handle_OP_ShopPlayerSell(const EQApplicationPacket *app)
break;
}
uint32 price = (
item->Price *
RuleR(Merchant, SellCostMod) *
item->SellRate
);
uint32 price = (item->Price * item->SellRate);
// Don't use SellCostMod if using UseClassicPriceMod
if (!RuleB(Merchant, UseClassicPriceMod)) {
price *= RuleR(Merchant, SellCostMod);
}
if (RuleB(Merchant, UsePriceMod)) {
price *= Client::CalcPriceMod(vendor, false);
@@ -14571,11 +14585,18 @@ void Client::Handle_OP_ShopRequest(const EQApplicationPacket *app)
mco->command = action; // Merchant command 0x01 = open
mco->tab_display = tabs_to_display;
float buy_cost_mod = 1;
// Only use the BuyCostMod if we're not using the classic function.
if (!RuleB(Merchant, UseClassicPriceMod)) {
buy_cost_mod = RuleR(Merchant, BuyCostMod);
}
if (RuleB(Merchant, UsePriceMod)) {
mco->rate = 1 / ((RuleR(Merchant, BuyCostMod)) * Client::CalcPriceMod(tmp, true)); // works
mco->rate = 1 / (buy_cost_mod * Client::CalcPriceMod(tmp, true));
}
else {
mco->rate = 1 / (RuleR(Merchant, BuyCostMod));
mco->rate = 1 / buy_cost_mod;
}
outapp->priority = 6;