Example #1
0
/*
	function to set the desired hardness
	enter with hard= -1 for default hardness, else any desired hardness
 */
void
sethard(int hard)
{
	int j, k, i;
	j = c[HARDGAME];
	hashewon();
	if (restorflag == 0) {	/* don't set c[HARDGAME] if restoring game */
		if (hard >= 0)
			c[HARDGAME] = hard;
	} else
		c[HARDGAME] = j;	/* set c[HARDGAME] to proper value if restoring game */

	if ((k = c[HARDGAME]) != 0)
		for (j = 0; j <= MAXMONST + 8; j++) {
			i = ((6 + k) * monster[j].hitpoints + 1) / 6;
			monster[j].hitpoints = (i < 0) ? 32767 : i;
			i = ((6 + k) * monster[j].damage + 1) / 5;
			monster[j].damage = (i > 127) ? 127 : i;
			i = (10 * monster[j].gold) / (10 + k);
			monster[j].gold = (i > 32767) ? 32767 : i;
			i = monster[j].armorclass - k;
			monster[j].armorclass = (i < -127) ? -127 : i;
			i = (7 * monster[j].experience) / (7 + k) + 1;
			monster[j].experience = (i <= 0) ? 1 : i;
		}
}
Example #2
0
/*
function to set the desired hardness
enter with hard= -1 for default hardness, else any desired hardness
*/
void sethard(int hard)
{
	int j, k;
	int i;
	struct monst *mp;

	j = cdesc[HARDGAME];
	hashewon();

	/* don't set cdesc[HARDGAME] if restoring game */
	if (restorflag == 0) {

		if (hard >= 0) {

			cdesc[HARDGAME] = hard;
		}

	} else {

		/* set cdesc[HARDGAME] to proper value if restoring game */
		cdesc[HARDGAME] = j; 
	}

	k = cdesc[HARDGAME];

	if (k == 0) {

		return;
	}

	for (j = 0; j <= MAXMONST + 8; j++) {

		mp = &monster[j];

		i = ((6 + k) * mp->hitpoints + 1) / 6;
		mp->hitpoints = (i < 0) ? 32767 : i;

		i = ((6 + k) * mp->damage + 1) / 5;
		mp->damage = (i > 127) ? 127 : i;

		i = (10 * mp->gold) / (10 + k);
		mp->gold = (i > 32767) ? 32767 : i;

		i = mp->armorclass - k;
		mp->armorclass = (i < -127) ? -127 : i;

		i = (7 * mp->experience) / (7 + k) + 1;
		mp->experience = (i <= 0) ? 1 : i;
	}
}