NetHack--"luck" patches

Izchak Miller izchak at linc.cis.upenn.edu
Wed Feb 3 15:30:54 AEST 1988


I was making preparations to post context differences for "luck"
managment when David Albert's appeared. Some of the ideas are similar.
I also introduced a "Lk" entry in the bottom status line, though without
changing anything else there (I converged the spaces between items instead).

The main difference consists in the general thinking about "luck",
and it led to different actions. My conviction is that there are too many
(easy) ways of reducing one's luck, and too few (hard) ways of improving it.
Consequently I did as follows: I reduced a bit the damage to luck in a few
places. I added a (rather rare) "scroll of self enchantment" to the game
(it can be "cursed"). Next, I added a moves%1000 incrementation of u.uluck,
if it is less than 0. The idea behind the latter step is that if a player
survives despite bad luck, he/she deserves some reward (albeit slowly granted).

Finally, I centralized changes in u.uluck to a single routine. The
code was unnecessarily repetitive in guarding against exceeding LUCKMIN and
LUCKMAX whenever a change in u.uluck was called, and in some places the code
failed to guard against such excess altogether. The way I have it, a
routine, change_luck(n), is called in all places where a change in the value 
of u.uluck is desired.

In the context differences that follow I do not include my changes
in the status line (in pri.c), for I think that David's are fine. Also, I
made quite a few other changes in the files, therefore my line numbers may 
not match yours. I suggest making the changes (if pleasing) manually. Enjoy.

	--Izchak (Isaac) Miller

------------------------------- Cut Here ----------------------------------
*** hack.c.orig	Mon Dec  7 02:07:16 1987
--- hack.c	Tue Feb  2 20:16:28 1988
***************
*** 1044,1046
  {
  	return(10*(1L << (u.ulevel-1)));
  }

--- 1045,1056 -----
  {
  	return(10*(1L << (u.ulevel-1)));
  }
+ 
+ change_luck(n)  /* Added, Izchak Miller */
+     register schar n;
+ {	u.uluck = u.uluck + n;
+ 	if (u.uluck < 0 && u.uluck < LUCKMIN) u.uluck = LUCKMIN;
+ 	if (u.uluck > 0 && u.uluck > LUCKMAX) u.uluck = LUCKMAX;
+ 	flags.botl = 1;
+ }
+ 
***************
*** 281,286
  	u = zerou;
  	u.usym = '@';
  	u.ulevel = 1;
  	init_uhunger();
  	uarm = uarm2 = uarmh = uarms = uarmg = uwep =
  	uball = uchain = uleft = uright = 0;

--- 288,294 -----
  	u = zerou;
  	u.usym = '@';
  	u.ulevel = 1;
+ 	u.uluck = 0; 	/* added, IM */
  	init_uhunger();
  	uarm = uarm2 = uarmh = uarms = uarmg = uwep =
  	uball = uchain = uleft = uright = 0;
*** mon.c.orig	Wed Dec  9 17:48:35 1987
--- mon.c	Tue Feb  2 20:28:04 1988
***************
*** 483,489
  	/* punish bad behaviour */
  	if(mdat->mlet == '@') {
  		HTelepat = 0;
! 		u.uluck -= 2;
  	}
  	if(mtmp->mpeaceful || mtmp->mtame) u.uluck--;
  	if(mdat->mlet == 'u') u.uluck -= 5;

--- 483,489 -----
  	/* punish bad behaviour */
  	if(mdat->mlet == '@') {
  		HTelepat = 0;
! 		change_luck(-2);
  	}
  	if(mtmp->mpeaceful || mtmp->mtame) change_luck(-1);
  	if(mdat->mlet == 'u') change_luck(-5); 
***************
*** 485,493
  		HTelepat = 0;
  		u.uluck -= 2;
  	}
! 	if(mtmp->mpeaceful || mtmp->mtame) u.uluck--;
! 	if(mdat->mlet == 'u') u.uluck -= 5;
! 	if((int)u.uluck < LUCKMIN) u.uluck = LUCKMIN;
  
  	/* give experience points */
  	tmp = 1 + mdat->mlevel * mdat->mlevel;

--- 485,492 -----
  		HTelepat = 0;
  		change_luck(-2);
  	}
! 	if(mtmp->mpeaceful || mtmp->mtame) change_luck(-1);
! 	if(mdat->mlet == 'u') change_luck(-5); 
  
  	/* give experience points */
  	tmp = 1 + mdat->mlevel * mdat->mlevel;
*** pray.c.orig	Mon Dec  7 02:07:25 1987
--- pray.c	Tue Feb  2 20:30:42 1988
***************
*** 12,19
  	if (u.ublesscnt > 0)  {		/* disturbing the gods too much */
  
  		u.ublesscnt += 200;
! 		u.uluck -= 3;
! 		if (u.uluck < LUCKMIN)  u.uluck = LUCKMIN;
  #ifdef HARD
  		u.ugangr++;
  		angrygods();

--- 12,18 -----
  	if (u.ublesscnt > 0)  {		/* disturbing the gods too much */
  
  		u.ublesscnt += 200;
! 		change_luck(-2);
  #ifdef HARD
  		u.ugangr++;
  		angrygods();
***************
*** 121,127
  			u.uhp = u.uhpmax += 5;
  			u.ustr = u.ustrmax;
  			if (u.uhunger < 900)	init_uhunger();
! 			if (u.uluck < 0)	u.uluck = 0;
  			if (Blinded)		Blinded = 1;
  			flags.botl = 1;
  			break;

--- 120,126 -----
  			u.uhp = u.uhpmax += 5;
  			u.ustr = u.ustrmax;
  			if (u.uhunger < 900)	init_uhunger();
! 			if (u.uluck < 0) u.uluck = 1; /* was 0, IM */ 
  			if (Blinded)		Blinded = 1;
  			flags.botl = 1;
  			break;
*** sit.c.orig	Mon Dec  7 02:07:28 1987
--- sit.c	Tue Feb  2 20:36:28 1988
***************
*** 64,70
  				break;
  			    case 6:
  				if(u.uluck + rn2(5) < 0) {
- 
  				    pline("you feel your luck is changing.");
  				    u.uluck++;
  				} else	    makewish();

--- 64,69 -----
  				break;
  			    case 6:
  				if(u.uluck + rn2(5) < 0) {
  				    pline("you feel your luck is changing.");
  				    change_luck(1);
  				} else	    makewish();
***************
*** 66,72
  				if(u.uluck + rn2(5) < 0) {
  
  				    pline("you feel your luck is changing.");
! 				    u.uluck++;
  				} else	    makewish();
  				break;
  			    case 7:

--- 65,71 -----
  			    case 6:
  				if(u.uluck + rn2(5) < 0) {
  				    pline("you feel your luck is changing.");
! 				    change_luck(1);
  				} else	    makewish();
  				break;
  			    case 7:
*** fight.c.orig	Wed Dec  9 17:48:38 1987
--- fight.c	Tue Feb  2 20:21:47 1988
***************
*** 14,20
  extern struct monst *mkmon_at();
  #endif
  #ifdef RPH
! extern struct obj *mk_named_obj();
  #endif
  
  static boolean far_noise;

--- 14,20 -----
  extern struct monst *mkmon_at();
  #endif
  #ifdef RPH
! extern struct obj *mk_named_obj_at(); /* '_at' was missing, IM */
  #endif
  
  static boolean far_noise;
***************
*** 329,336
  #ifdef RPH
  		case MIRROR:
  			pline("You break your mirror.  That's bad luck!");
! 		        u.uluck -= 2;
! 		        if ((int)u.uluck < LUCKMIN) u.uluck = LUCKMIN;
  			freeinv(obj);
  			if(obj->owornmask)
  				setworn((struct obj *) 0, obj->owornmask);

--- 329,335 -----
  #ifdef RPH
  		case MIRROR:
  			pline("You break your mirror.  That's bad luck!");
! 			change_luck(-2); /* IM */
  			freeinv(obj);
  			if(obj->owornmask)
  				setworn((struct obj *) 0, obj->owornmask);
***************
*** 615,621
  	      nomul((u.ulevel > 6 || rn2(4)) ? rn1(20,-21) : -200);
  	    } else {
  	      pline("%s cannot defend itself.", Amonnam(mtmp,"blinded"));
! 	      if(!rn2(500)) if((int)u.uluck > LUCKMIN) u.uluck--;
  	    }
  	}
  	return(TRUE);

--- 619,626 -----
  	      nomul((u.ulevel > 6 || rn2(4)) ? rn1(20,-21) : -200);
  	    } else {
  	      pline("%s cannot defend itself.", Amonnam(mtmp,"blinded"));
! 	      if(!rn2(500)) change_luck(-1); /* IM */
  	    }
  	}
  	return(TRUE);
*** dothrow.c.orig	Mon Dec  7 02:07:14 1987
--- dothrow.c	Tue Feb  2 20:18:11 1988
***************
*** 158,165
  	} else	if(obj->otyp == MIRROR) {
  	    	pline ("The mirror shatters.  That's seven years bad luck!");
  		obfree(obj, Null(obj));
! 		u.uluck -= 2;
! 		if ((int)u.uluck < LUCKMIN) u.uluck = LUCKMIN;
  #endif	
  	} else	if(obj->otyp == EGG) {
  		pline("\"Splash!\"");

--- 158,164 -----
  	} else	if(obj->otyp == MIRROR) {
  	    	pline ("The mirror shatters.  That's seven years bad luck!");
  		obfree(obj, Null(obj));
! 		change_luck(-2);  /* IM */
  #endif	
  	} else	if(obj->otyp == EGG) {
  		pline("\"Splash!\"");
***************
*** 254,260
  			if(obj->dknown &&
  			   objects[obj->otyp].oc_name_known)  {
  				if(objects[obj->otyp].g_val > 0)  {
! 					u.uluck += 5;
  					strcat(buf,addluck);
  				}  else
  					strcat(buf,nogood);

--- 253,259 -----
  			if(obj->dknown &&
  			   objects[obj->otyp].oc_name_known)  {
  				if(objects[obj->otyp].g_val > 0)  {
! 					change_luck(5); /* IM */
  					strcat(buf,addluck);
  				}  else
  					strcat(buf,nogood);
***************
*** 259,265
  				}  else
  					strcat(buf,nogood);
  			}  else  {  /* value unknown to @ */
! 				u.uluck++;
  				strcat(buf,addluck);
  			}
  			if(u.uluck > LUCKMAX)   /* dan at ut-ngp */

--- 258,264 -----
  				}  else
  					strcat(buf,nogood);
  			}  else  {  /* value unknown to @ */
! 				change_luck(1); /* IM */
  				strcat(buf,addluck);
  			}
***************
*** 262,269
  				u.uluck++;
  				strcat(buf,addluck);
  			}
- 			if(u.uluck > LUCKMAX)   /* dan at ut-ngp */
- 				u.uluck = LUCKMAX;
  			pline(buf);
  			mpickobj(mon, obj);
  			rloc(mon);

--- 261,268 -----
  				change_luck(1); /* IM */
  				strcat(buf,addluck);
  			}
  			pline(buf);
  			mpickobj(mon, obj);
  			rloc(mon);
*** unixmain.c.orig	Mon Dec  7 02:07:32 1987
--- unixmain.c	Tue Feb  2 20:24:03 1988
***************
*** 248,254
  	flags.moonphase = phase_of_the_moon();
  	if(flags.moonphase == FULL_MOON) {
  		pline("You are lucky! Full moon tonight.");
! 		if(!u.uluck) u.uluck++;
  	} else if(flags.moonphase == NEW_MOON) {
  		pline("Be careful! New moon tonight.");
  	}

--- 253,259 -----
  	flags.moonphase = phase_of_the_moon();
  	if(flags.moonphase == FULL_MOON) {
  		pline("You are lucky! Full moon tonight.");
! 		change_luck(1); /* IM */
  	} else if(flags.moonphase == NEW_MOON) {
  		pline("Be careful! New moon tonight.");
  	}
***************
*** 315,322
  				}
  			    }
  			}
! #endif
! 			if(u.uhp < u.uhpmax) {
  				if(u.ulevel > 9) {
  					if(HRegeneration || !(moves%3)) {
  					    flags.botl = 1;

--- 320,335 -----
  				}
  			    }
  			}
! #endif		/* If less then 0, increment uluck with moves, IM */
! 			if (u.uluck < 0 && !(moves%1000)) {
! 				if (u.uluck == -1)
! 				    pline("You feel elated.");
! 				else
! 				    pline("Your insecurity decreases.");
! 				change_luck(1);
! 			}
! 			if (u.uhp < u.uhpmax) {
  				if(u.ulevel > 9) {
  					if(HRegeneration || !(moves%3)) {
  					    flags.botl = 1;
*** onames.h.orig	Mon Dec  7 02:08:19 1987
--- onames.h	Wed Jan 20 13:48:39 1988
***************
*** 184,189
  #define	SCR_AMNESIA	185
  #define	SCR_FIRE	186
  #define	SCR_PUNISHMENT	187
  #define	WAN_LIGHT	192
  #define	WAN_SECRET_DOOR_DETECTION	193
  #define	WAN_CREATE_MONSTER	194

--- 184,191 -----
  #define	SCR_AMNESIA	185
  #define	SCR_FIRE	186
  #define	SCR_PUNISHMENT	187
+ #define	SCR_SELF_ENCHANTMENT	188
  #define	WAN_LIGHT	192
  #define	WAN_SECRET_DOOR_DETECTION	193
  #define	WAN_CREATE_MONSTER	194
*** objects.h.orig	Mon Dec  7 02:08:19 1987
--- objects.h	Wed Jan 20 13:48:34 1988
***************
*** 258,264
  	SCROLL("create monster", "LEP GEX VEN ZEA", 5),
  	SCROLL("taming", "PRIRUTSENIE", 1),
  	SCROLL("genocide", "ELBIB YLOH",2),
! 	SCROLL("light", "VERR YED HORRE", 10),
  	SCROLL("teleportation", "VENZAR BORGAVVE", 5),
  	SCROLL("gold detection", "THARR", 4),
  	SCROLL("food detection", "YUM YUM", 1),

--- 258,264 -----
  	SCROLL("create monster", "LEP GEX VEN ZEA", 5),
  	SCROLL("taming", "PRIRUTSENIE", 1),
  	SCROLL("genocide", "ELBIB YLOH",2),
! 	SCROLL("light", "VERR YED HORRE", 9), /* Was 10, IM */
  	SCROLL("teleportation", "VENZAR BORGAVVE", 5),
  	SCROLL("gold detection", "THARR", 4),
  	SCROLL("food detection", "YUM YUM", 1),
***************
*** 267,274
  	SCROLL("amnesia", "DUAM XNAHT", 3),
  	SCROLL("fire", "ANDOVA BEGARIN", 5),
  	SCROLL("punishment", "VE FORBRYDERNE", 1),
! 	SCROLL(NULL, "VELOX NEB", 0),
 	SCROLL(NULL, "FOOBIE BLETCH", 0),
  	SCROLL(NULL, "TEMOV", 0),
  	SCROLL(NULL, "GARVEN DEH", 0),
  

--- 267,274 -----
  	SCROLL("amnesia", "DUAM XNAHT", 3),
  	SCROLL("fire", "ANDOVA BEGARIN", 5),
  	SCROLL("punishment", "VE FORBRYDERNE", 1),
! 	SCROLL("self enchantment", "VELOX NEB", 1),  /* Added, IM */
 	SCROLL(NULL, "FOOBIE BLETCH", 0),
  	SCROLL(NULL, "TEMOV", 0),
  	SCROLL(NULL, "GARVEN DEH", 0),
*** read.c.orig	Mon Dec  7 02:07:26 1987
--- read.c	Sat Jan 16 00:02:43 1988
***************
*** 6,11
  extern struct monst *makemon();
  extern struct permonst pm_eel;
  extern struct obj *mkobj_at();
  char *hcolor();
  boolean	known; 
  int identify();

--- 6,12 -----
  extern struct monst *makemon();
  extern struct permonst pm_eel;
  extern struct obj *mkobj_at();
+ extern char *xname();
  char *hcolor();
  boolean	known; 
  int identify();
***************
*** 472,477
  		}
  		break;
  	    }
  	case SCR_PUNISHMENT:
  		known = TRUE;
  		if(confused) {

--- 473,603 -----
  		}
  		break;
  	    }
+ 	case SCR_SELF_ENCHANTMENT:  /* Added, Izchak Miller */
+ 	    {   register schar n;
+ 		known = TRUE;
+ 		n = rnd(3);
+ 		if (!rn2(5) || u.uluck == LUCKMAX) n = -1*n;
+ 		if (n < 0 && u.uluck == LUCKMIN) n = -1*n;
+ 		if (n > 0) {
+ 		  if (u.uluck < 0) {
+ 		    if ((u.uluck+n) < 0)
+ 		        if (Hallucination)
+ 			    pline("Hey, small comfort.");
+ 		        else
+ 			    pline("You're less apprehensive."); 
+ 		    if ((u.uluck+n) == 0)
+ 		        if (Hallucination)
+ 			    pline("Ain't bad at all!");
+ 		        else
+ 			    pline("You feel calm."); 
+ 		    if ((u.uluck+n) > 0)
+ 		        if (Hallucination)
+ 			    pline("Yeh! Yeh!");
+ 		        else
+ 			    pline("You feel elated."); 
+ 		  } 
+ 		  else {
+ 		    if ((u.uluck+n) >= LUCKMAX)
+ 			if (Hallucination)
+ 			    pline("Waoo! I dig, I dig!");
+ 			else
+ 			    pline("You're supremely confident!");
+ 		    else
+ 			if (Hallucination)
+ 			    pline("What a trip!");
+ 			else
+ 			    pline("Your confidence increases.");
+ 		  }
+ 		}
+ 		if (n == 0) pline("Nothing happens.");
+ 		if (n < 0) {
+ 		  if (u.uluck <= 0) {
+ 		    if ((u.uluck+n) <= LUCKMIN)
+ 			if (Hallucination)
+ 			    pline("Bummer! Get me out!");
+ 			else
+ 			    pline("Your feel total hopelesness. Seek help!");
+ 		    else
+ 			if (Hallucination)
+ 			    pline("Jeepers! I need to vomit.");
+ 			else
+ 			    pline("Your insecurity increases.");
+ 		  } 
+ 		  else {
+ 		    if ((u.uluck+n) <= 0)
+ 			if (Hallucination)
+ 			    pline("I don't feel so good.");
+ 			else
+ 			    pline("Your heart sinks.");
+ 		    else
+ 			if (Hallucination)
+ 			    pline("It's a drag!");
+ 			else
+ 			    pline("Your confidence decreases.");
+ 		  }
+ 		}
+ 		change_luck(n);
+ 		flags.botl = 1;
+ 		break;
+ 	    }
  	case SCR_PUNISHMENT:
  		known = TRUE;
  		if(confused) {
*** write.c.orig	Mon Dec  7 02:07:34 1987
--- write.c	Sat Jan 16 00:19:19 1988
***************
*** 54,59
  		return(30);
  		break;
  	case SCR_BLANK_PAPER:
  	default:
  		impossible("You can't write such a weird scroll!");
  	}

--- 54,61 -----
  		return(30);
  		break;
  	case SCR_BLANK_PAPER:
+ 	case SCR_SELF_ENCHANTMENT:     /* Added, IM */
  	default:
  		impossible("You can't write such a weird scroll!");
  	}
***************
*** 115,120
  		pline("You can't write that!");
  		pline("It's obscene!");
  		return(0);
  	}
  	
  	/* see if there's enough ink */

--- 117,130 -----
  		pline("You can't write that!");
  		pline("It's obscene!");
  		return(0);
+ 	}
+ #ifdef WIZARD		/* Added, IM */
+ 	if (!wizard) 
+ #endif
+ 	if(newscroll->otyp == SCR_SELF_ENCHANTMENT) {  
+ 		    pline("Your marker leaves no trace!");
+ 		    return(0);
  	}
  	
  	/* see if there's enough ink */



More information about the Comp.sources.bugs mailing list