Welcome to the Builder Academy

Question cheaper shop prices for humans

More
02 Nov 2016 21:37 - 02 Nov 2016 21:38 #6241 by JTP
Replied by JTP on topic cheaper shop prices for humans
Code:
I tried this: static int sell_price(struct obj_data *obj, int shop_nr, struct char_data *keeper, struct char_data *seller) { float HUMAN_FACTOR = 1.1; float sell_cost_modifier = SHOP_SELLPROFIT(shop_nr) * (1 - (GET_CHA(keeper) - GET_CHA(seller)) / (float)70); float buy_cost_modifier = SHOP_BUYPROFIT(shop_nr) * (1 + (GET_CHA(keeper) - GET_CHA(seller)) / (float)70); if (sell_cost_modifier > buy_cost_modifier) sell_cost_modifier = buy_cost_modifier; return (int) (GET_OBJ_COST(obj) * sell_cost_modifier) * (!IS_NPC(seller) && GET_RACE(seller) == RACE_HUMAN ? HUMAN_FACTOR : 1); }

With a human with cha 18 and another race with cha 18
The human only gained extra 7-8 coins more when selling the same item. So seems to Work, but i can try your version, if you think its will be better.
Last edit: 02 Nov 2016 21:38 by JTP.

Please Log in or Create an account to join the conversation.

More
02 Nov 2016 23:05 #6249 by JTP
Replied by JTP on topic cheaper shop prices for humans
Could you try explain to me what the difference is between the way i did it, and the way you just showed it ?

I just had 2 chars with cha 18 sell the same small sword, the non human got 37 coins, the human got 40.

Much apreciated

Please Log in or Create an account to join the conversation.

More
03 Nov 2016 21:54 #6250 by thomas
I will try :)

Let's assume you have a very "cheap" shop, with 10% profit on sales and buying things at price.
This means that SHOP_SELLPROFIT() = 1.1 and SHOP_BUYPROFIT() = 1.
The shopkeeper is an ordinary mob, and thus has CHA = 11.
The player has high CHA, 18, with all spells and items.

The original calculation in sell_price would be like this:
sell_cost_modifier = 1.1 * (1 - (11 - 18) / 70) = 1.21
buy_cost_modifier = 1 * (1 + (11 -18) / 70) = 0.9

Now, this means, if we just stop there, that the player will sell an item with value 100 for 121, and buy it for 90. This is a goldmaking loophole - a player can sell/buy the same item over and over again, making a profit each time. With triggers, a player can be a millionaire in seconds.
So, the code makes sure that you can't sell for more than you buy for, with the next check.

So before actually calculating the price, we have sell_cost_modifier = buy_cost_modifier = 0.9. This way, the player will get the same amount of money when selling as he spends when buying.

If we at this point change the sell price based on race, we reopen the loophole:
(return) sell_price_for_humans = cost * 0.9 * 1.1 = cost * .99
buy price is lower, too.
So we need to change the sell_price_modifier BEFORE the loophole check.

And, because we've changed the calculation in buy_price(), we need to change it here as well.

I suspect this may be muddying the waters even more, but I hope it helps.

Please Log in or Create an account to join the conversation.

More
03 Nov 2016 23:01 #6252 by JTP
Replied by JTP on topic cheaper shop prices for humans
With .7 in both sell and buy Price.

Then as human i could sell it for the same as i could rebuy it for..

So i had to do .6 in sell_price

.5 gave me same sell Price as a non human

Please Log in or Create an account to join the conversation.

More
28 Oct 2017 20:58 #7037 by JTP
Replied by JTP on topic cheaper shop prices for humans
Code:
static int buy_price(struct obj_data *obj, int shop_nr, struct char_data *keeper, struct char_data *buyer) { float HUMAN_FACTOR = .8; return (int) (GET_OBJ_COST(obj) * SHOP_BUYPROFIT(shop_nr) * (1 + (GET_CHA(keeper) - GET_CHA(buyer)) / (float)70)) * (!IS_NPC(buyer) && GET_RACE(buyer) == RACE_HUMAN ? HUMAN_FACTOR : 1); } /* When the shopkeeper is buying, we reverse the discount. Also make sure we don't buy for more than we sell for, to prevent infinite money-making. */ static int sell_price(struct obj_data *obj, int shop_nr, struct char_data *keeper, struct char_data *seller) { float HUMAN_FACTOR = .6; float sell_cost_modifier = SHOP_SELLPROFIT(shop_nr) * (1 - (GET_CHA(keeper) - GET_CHA(seller)) / (float)70) / (!IS_NPC(seller) && GET_RACE(seller) == RACE_HUMAN ? HUMAN_FACTOR : 1); float buy_cost_modifier = SHOP_BUYPROFIT(shop_nr) * (1 + (GET_CHA(keeper) - GET_CHA(seller)) / (float)70) * (!IS_NPC(seller) && GET_RACE(seller) == RACE_HUMAN ? HUMAN_FACTOR : 1);

If i wanted to add on to this so that is buyer or seller has the skill haggle, they also get better prices.

Would it just be:
* (!IS_NPC(seller) && GET_SKILL(seller) == SKILL_HAGGLE || GET_RACE(seller) == RACE_HUMAN ? HUMAN_FACTOR : 1);

?

Please Log in or Create an account to join the conversation.

More
28 Oct 2017 21:12 #7038 by thomas
Almost - you'd need a parenthesis there, to prevent GET_RACE() from triggering on an npc:
Code:
* (!IS_NPC(seller) && (GET_SKILL(seller, SKILL_HAGGLE) > 0 || GET_RACE(seller) == RACE_HUMAN) ? HUMAN_FACTOR : 1);
The following user(s) said Thank You: JTP

Please Log in or Create an account to join the conversation.

Time to create page: 0.269 seconds