Talk:Cold resistance

From NetHackWiki
Jump to navigation Jump to search

I just dove through the source code for two hours and conducted a small trial and I think this Corpses For Food And Intrinsics is wrong. Here is the basis for my argument:

The relevant portion of eat.c#640

654.  	switch (type) {
655.  		case POISON_RES:
656.  			if ((ptr == &mons[PM_KILLER_BEE] ||
657.  					ptr == &mons[PM_SCORPION]) && !rn2(4))
658.  				chance = 1;
659.  			else
660.  				chance = 15;
661.  			break;
662.  		case TELEPORT:
663.  			chance = 10;
664.  			break;
665.  		case TELEPORT_CONTROL:
666.  			chance = 12;
667.  			break;
668.  		case TELEPAT:
669.  			chance = 1;
670.  			break;
671.  		default:
672.  			chance = 15;
673.  			break;
674.  	}
676.  	if (ptr->mlevel <= rn2(chance))
677.  		return;		/* failed die roll */

And an example from Monst.c#1532:

1532.     MON("frost giant", S_GIANT,
1533. 	LVL(10, 12, 3, 10, -3), (G_NOHELL|G_GENO|G_SGROUP|1),
1534. 	A(ATTK(AT_WEAP, AD_PHYS, 2,12),
1536. 	SIZ(2250, 750, 0, MS_BOAST, MZ_HUGE), MR_COLD, MR_COLD,

So we have a frost giant corpse with mlevel 10. Line 676 above states that if mlevel is less than or equal to rn2(chance) (the default 15 in this case for cold resistance) then we fail to gain the intrinsic which happens later on in eat.c.

rn2 is stated in the comments as rnd.c#22:

22.   rn2(x)		/* 0 <= rn2(x) < x */

Which means it produces integers from 0 to x-1 with (in theory) equal probability. In our case it will produce numbers from 0 to chance-1 or 0 to 14 with equal probability. Frost giant's mlevel is 10 so that statement will be false for numbers 0-9 and true for 10-14. When the statement is true we see that you DON'T gain the intrinsic and when it is false you DO gain the intrinsic. This means that you will gain the intrinsic two thirds of the time (on rolls 0-9). A little test I conducted in Wizard mode by deleting the save file after every game:

Eating a frost giant corpse 17 times, I gained the intrinsic 11 times Eating a tin of frost giant 27 times, I gained the intrinsic 20 times (11+20)/(17+27) = 0.73 which is closer to 67% than 33%.

I know I'm responding to a post that is almost four years old... but yes, I think you are correct. I would guess that the person who wrote the spoiler thought that eating giants is like eating mind flayers, where you have a 50% change of telepathy and a 50% chance of +1 intelligence. For giants, you always get the strength increase, and you have a mlevel/15 chance of gaining the fire/cold/shock resistance. I am going to correct other pages based on this (Frost giant, Fire giant). --Erica 04:06, 22 August 2011 (UTC)