Bug - Fixed Mafia reduces NPC prices incorrectly

heeheehee

Developer
Staff member
I'm not entirely entirely sure what's going on here, but for context: I have a character with the AT passive (Five Finger Discount) and Travoltan Trousers, each of which gives a 5% additive discount at NPC stores. However, Mafia somewhat consistently thinks whatever item I'm buying costs 1 meat less than it does (one exception so far: forged ID documents were correctly predicted to cost 4500 meat).

> buy can of black paint

Searching for "can of black paint"...
Search complete.
Purchasing can of black paint (1 @ 899)...
You acquire an item: can of black paint
You spent 900 Meat
Purchases complete.

Also, Mafia doesn't take into account Black Day (effect from pantsgiving drop, post-holiday sale coupon), although there is currently an in-game bug where that doesn't work with shop.php.
> buy soda water

Searching for "soda water"...
Search complete.
Purchasing soda water (1 @ 62)...
You acquire an item: soda water
You spent 56 Meat
Purchases complete.
 
I imagine we're casting to int (ie truncating/flooring) rather than rounding, and floating-point errors yada yada.
 
Code:
	private static int currentPrice( final int price )
	{
		double factor = 1.0;
		if ( NPCPurchaseRequest.usingTrousers() ) factor -= 0.05;
		if ( KoLCharacter.hasSkill( "Five Finger Discount" ) ) factor -= 0.05;
		return (int) ( price * factor );
	}
 
Also, Mafia doesn't take into account Black Day (effect from pantsgiving drop, post-holiday sale coupon)

That's a weird case. If someone wants 10 cans of black paint and only has 1 turn of Black Day, then reducing the reported price isn't quite right. I don't know that there's a good way to handle it, which I guess is why it isn't handled at all.
 
Actually, looking at the actual solution, that's not quite right. With just one of the two sources,
> buy soda water

Searching for "soda water"...
Search complete.
Purchasing soda water (1 @ 67)...
You acquire an item: soda water
You spent 66 Meat
Purchases complete.

KoL itself truncates if the result would be a float.

Might I suggest:
> ashq print((100 - 5 - 5) / 100.0)

0.9
?
 
The most expensive NPC item costs 100 million. ASH uses long int internally.

> ashq print( ( 100000000 * 95 ) / 100 )

95000000
given that, I like:

Code:
	private static int currentPrice( final int price )
	{
		long factor = 100;
		if ( NPCPurchaseRequest.usingTrousers() ) factor -= 5;
		if ( KoLCharacter.hasSkill( "Five Finger Discount" ) ) factor -= 5;
		return (int) ( ( price * factor ) / 100 );
	}
Try revision 15301.
 
Last edited:
Back
Top