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.
This commit is contained in:
Pasi Kallinen
2023-02-05 16:46:49 +02:00
parent ee3daba8c9
commit d3430bed9f
3 changed files with 7 additions and 0 deletions

View File

@@ -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;

View File

@@ -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;

View File

@@ -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)))