From: Pasi Kallinen Date: Sun, 5 Feb 2023 14:46:49 +0000 (+0200) Subject: Prevent certain items from random erosion X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d3430bed9f4289c3abf6c969fec69c1b5bafcceb;p=nethack Prevent certain items from random erosion Prevent wished for items (unless specified), artifacts, armor and weapons of NPC heroes, and ammo from Longbow of Diana being generated eroded. --- diff --git a/src/artifact.c b/src/artifact.c index 82e8bbd37..216c08e93 100644 --- a/src/artifact.c +++ b/src/artifact.c @@ -213,6 +213,8 @@ mk_artifact( otmp = mksobj((int) a->otyp, TRUE, FALSE); if (otmp) { + /* prevent erosion from generating */ + otmp->oeroded = otmp->oeroded2 = 0; otmp = oname(otmp, a->name, ONAME_NO_FLAGS); otmp->oartifact = m; /* set existence and reason for creation bits */ @@ -1819,6 +1821,7 @@ arti_invoke(struct obj *obj) otmp->blessed = obj->blessed; otmp->cursed = obj->cursed; otmp->bknown = obj->bknown; + otmp->oeroded = otmp->oeroded2 = 0; if (obj->blessed) { if (otmp->spe < 0) otmp->spe = 0; diff --git a/src/mplayer.c b/src/mplayer.c index 49f87d720..30870c89d 100644 --- a/src/mplayer.c +++ b/src/mplayer.c @@ -99,6 +99,7 @@ mk_mplayer_armor(struct monst* mon, short typ) if (typ == STRANGE_OBJECT) return; obj = mksobj(typ, FALSE, FALSE); + obj->oeroded = obj->oeroded2 = 0; if (!rn2(3)) obj->oerodeproof = 1; if (!rn2(3)) @@ -254,6 +255,7 @@ mk_mplayer(struct permonst *ptr, coordxy x, coordxy y, boolean special) if (weapon != STRANGE_OBJECT) { otmp = mksobj(weapon, TRUE, FALSE); + otmp->oeroded = otmp->oeroded2 = 0; otmp->spe = (special ? rn1(5, 4) : rn2(4)); if (!rn2(3)) otmp->oerodeproof = 1; diff --git a/src/objnam.c b/src/objnam.c index 707d022f4..185314c4f 100644 --- a/src/objnam.c +++ b/src/objnam.c @@ -4829,6 +4829,8 @@ readobjnam(char *bp, struct obj *no_wish) /* set eroded and erodeproof */ if (erosion_matters(d.otmp)) { + /* wished-for item shouldn't be eroded unless specified */ + d.otmp->oeroded = d.otmp->oeroded2 = 0; if (d.eroded && (is_flammable(d.otmp) || is_rustprone(d.otmp))) d.otmp->oeroded = d.eroded; if (d.eroded2 && (is_corrodeable(d.otmp) || is_rottable(d.otmp)))