Welcome to the Builder Academy

Question cheaper shop prices for humans

More
01 Nov 2016 20:12 - 01 Nov 2016 20:27 #6222 by JTP
I would like it to be cheaper for humans to buy from shops.

Anyone who made something similar, and can tell me how and where i need to add that in ?

Maybe also that humans get double coins from killing mobs
Last edit: 01 Nov 2016 20:27 by JTP.

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

More
01 Nov 2016 21:49 #6223 by thomas
This is actually relatively easy. In shop.c, all code dealing with shops is collected in one place and the code for determining prices is just one place. The function you will be needing to alter is buy_price() at github.com/tbamud/tbamud/blob/master/src/shop.c#L442
Code:
/* Shop purchase adjustment, based on charisma-difference from buyer to keeper. for i in `seq 15 -15`; do printf " * %3d: %6.4f\n" $i \ `echo "scale=4; 1+$i/70" | bc`; done Shopkeeper higher charisma (markup) ^ 15: 1.2142 14: 1.2000 13: 1.1857 12: 1.1714 11: 1.1571 | 10: 1.1428 9: 1.1285 8: 1.1142 7: 1.1000 6: 1.0857 | 5: 1.0714 4: 1.0571 3: 1.0428 2: 1.0285 1: 1.0142 + 0: 1.0000 | -1: 0.9858 -2: 0.9715 -3: 0.9572 -4: 0.9429 -5: 0.9286 | -6: 0.9143 -7: 0.9000 -8: 0.8858 -9: 0.8715 -10: 0.8572 v -11: 0.8429 -12: 0.8286 -13: 0.8143 -14: 0.8000 -15: 0.7858 Player higher charisma (discount) Most mobiles have 11 charisma so an 18 charisma player would get a 10% discount beyond the basic price. That assumes they put a lot of points into charisma, because on the flip side they'd get 11% inflation by having a 3. */ static int buy_price(struct obj_data *obj, int shop_nr, struct char_data *keeper, struct char_data *buyer) { return (int) (GET_OBJ_COST(obj) * SHOP_BUYPROFIT(shop_nr) * (1 + (GET_CHA(keeper) - GET_CHA(buyer)) / (float)70)); }

Here, you'll want to multiply with some factor between 0 and 1 if the buyer is a human:
Code:
static int buy_price(struct obj_data *obj, int shop_nr, struct char_data *keeper, struct char_data *buyer) { int HUMAN_FACTOR = .7; 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); }

The code for dropping gold might be slightly more difficult. This needs some design decisions first, because the gold is currently created on mob death, based on the Gold the mopb was carrying. If the player is alone in the fight, the solution is relatively easy - just add a little more gold to the corpse. But what happens if the player is grouped? And one of the other group members get the kill? OR the loot?
To avoid a gold duplicationg loophole, you want to avoid altering how much gold a player can pick up from a pile once it has been created with a certain amount. Or a player would just become a gazillionaire by dropping and getting the same pile of gold.

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

More
01 Nov 2016 21:52 #6224 by JTP
Replied by JTP on topic cheaper shop prices for humans
So the charisma and race_human can stack or will the human disregard the charisma ?

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

More
01 Nov 2016 21:59 #6225 by thomas
The bonuses will stack. The calculation will in practice be cost * profit * charismabonus * race bonus

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

More
01 Nov 2016 22:06 #6226 by JTP
Replied by JTP on topic cheaper shop prices for humans
Ouch that made the prices be 0

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

More
01 Nov 2016 22:43 #6227 by thomas
ACK my bad - the human factor should be a float instead of an int (.7 = 0 as an int)

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

Time to create page: 0.638 seconds