From 274904f9be5931c692fc50ec63ee1cccbf511e6b Mon Sep 17 00:00:00 2001 From: PatR Date: Fri, 1 May 2015 18:01:12 -0700 Subject: [PATCH] stabilize loss of gold When gold is stolen by a leprechaun or lost when being "overwhelmed by an urge to take a bath" while dipping in a fountain, if you had 99 gold pieces or less, you'd lose all of it (in the bath case, only if it was at least 10 to start with), but if you had 100 or more, you would lose a random amount which could be as little as 1. And in the bath case, if the random amount was less than 10, you would lose nothing but be told that "you lost some of your money in the fountain". After this change, it is still possible to lose less when starting with more, but not as likely and not as extreme a case as maybe losing only 1 when starting with thousands. The fountain-dip bath case has code to handle mutiple denominations of coins, possibly the only place in the program where that exists. I've left that alone although it should probably be taken out.... --- src/steal.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/src/steal.c b/src/steal.c index f803ae4da..e3f09f524 100644 --- a/src/steal.c +++ b/src/steal.c @@ -1,4 +1,4 @@ -/* NetHack 3.5 steal.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */ +/* NetHack 3.5 steal.c $NHDT-Date: 1430528463 2015/05/02 01:01:03 $ $NHDT-Branch: master $:$NHDT-Revision: 1.53 $ */ /* NetHack 3.5 steal.c $Date: 2012/02/05 04:26:48 $ $Revision: 1.41 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -23,15 +23,31 @@ register struct obj *otmp; } long /* actually returns something that fits in an int */ -somegold(umoney) -long umoney; +somegold(lmoney) +long lmoney; { #ifdef LINT /* long conv. ok */ - return(0L); + int igold = 0; #else - return (long)( (umoney < 100) ? umoney : - (umoney > 10000) ? rnd(10000) : rnd((int) umoney) ); + int igold = (lmoney >= (long)LARGEST_INT) ? LARGEST_INT : (int)lmoney; #endif + + if (igold < 50) + ; /* all gold */ + else if (igold < 100) + igold = rn1(igold - 25 + 1, 25); + else if (igold < 500) + igold = rn1(igold - 50 + 1, 50); + else if (igold < 1000) + igold = rn1(igold - 100 + 1, 100); + else if (igold < 5000) + igold = rn1(igold - 500 + 1, 500); + else if (igold < 10000) + igold = rn1(igold - 1000 + 1, 1000); + else + igold = rn1(igold - 5000 + 1, 5000); + + return (long)igold; } /* -- 2.40.0