Purchase Price Modification

Anyone has any idea what I'm doing wrong? I'm trying to change the code for item purchases in VX Ace, but it's not taking it into account (the vabiable mentioned is a haggling stat the player can raise). It's the last part of the OG script in Scene_Shop

def buying_price
(@buy_window.price(@ItEm) * (100/(100 - $game_variables[161] * 2) ) ).to_i
end

The haggle stat (variable 161) can be raised up to 8, so the idea is the player can get up to 16% discount. This code is not crashing the game, it just doesn't seem to be working and I have no idea why.
'ItEm' ??

Maybe a user script is overwriting the OG function?
Try to use a floating number. In your case, it would be using 100.0 instead of integer (100)
Ruby does not automatically convert an integer to a decimal.
Try to use a floating number. In your case, it would be using 100.0 instead of integer (100)
Ruby does not automatically convert an integer to a decimal.
Thanks, that seemed to do the trick, though now for some reason it is increasing the prices instead of lowering them. Hm... Oh well, ty.
Thanks, that seemed to do the trick, though now for some reason it is increasing the prices instead of lowering them. Hm... Oh well, ty.
You are reducing the denominator, so for example if a Potion normally costs 500 and Var #161 is equal to 8, then your potion now costs 500 * (100 / 84) = 500 * 1.19 = 595 Gold (approximately). Changing it to a + instead of a - in the denominator, or moving the "- Var * 2" part to the 100 in the numerator, would give you something that makes more sense as a discount.
I personally prefer a formula like this
Code:
original_value * ((100.0 - discount)/100.0)
putting the actual value
original_value = 500
discount = 16
will be
Code:
500 * ((100.0 - 16)/100)
500 * (84/100)
500 * 0.84
Damn, I guess I should have paid more attention to math class (or maybe not stayed awake the hours I have). Oh well, thanks anyway. Admin, you can lock the post now.
Damn, I guess I should have paid more attention to math class (or maybe not stayed awake the hours I have). Oh well, thanks anyway. Admin, you can lock the post now.
No problem. But in the future, to make sure we see it, if you want your thread locked then Report your own post and just say you want it locked (or "thread solved") in the Report Reason.

Thread Closed at OP's Request.

Original thread: https://forums.rpgmakerweb.com/threads/purchase-price-modification.133204/