Skip to content

Commit

Permalink
Implemented object properties for rings. This is influenced by FIQhac…
Browse files Browse the repository at this point in the history
…k, which allows properties on all jewelry, but for now we'll just go with rings.
  • Loading branch information
elunna committed Oct 3, 2023
1 parent 8ea9e38 commit 08e6a2b
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 26 deletions.
40 changes: 37 additions & 3 deletions src/artifact.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,9 +425,10 @@ boolean allow_detrimental;
else if is_bomb(otmp)
return otmp;

/* properties only added to weapons and armor */
/* properties only added to weapons, armor, and rings */
if (otmp->oclass != WEAPON_CLASS && !is_weptool(otmp)
&& otmp->oclass != ARMOR_CLASS)
&& otmp->oclass != ARMOR_CLASS
&& otmp->oclass != RING_CLASS)
return otmp;

/* it is possible to have an object spawn with more
Expand Down Expand Up @@ -456,7 +457,8 @@ boolean allow_detrimental;
&& (j & (NON_WEP_PROPS | ITEM_OILSKIN)))
continue;

if ((otmp->oclass == ARMOR_CLASS) && (j & ONLY_WEP_PROPS))
if ((otmp->oclass == ARMOR_CLASS && otmp->oclass == RING_CLASS)
&& (j & ONLY_WEP_PROPS))
continue;

if ((otmp->oprops & ITEM_RES_PROPS) && (j & ITEM_RES_PROPS))
Expand Down Expand Up @@ -519,6 +521,38 @@ int prop;
return TRUE;
if (otmp->otyp == ELVEN_BOOTS && (prop & ITEM_STEALTH))
return TRUE;

if (otmp->oclass == RING_CLASS) {
/* TODO: Figure out how to loop over the props
* and use obj_has_prop(obj, which) */
if (otmp->otyp == RIN_SEARCHING && (prop & ITEM_SEARCHING))
return TRUE;
if (otmp->otyp == RIN_STEALTH && (prop & ITEM_STEALTH))
return TRUE;
if (otmp->otyp == RIN_SUSTAIN_ABILITY && (prop & ITEM_SUSTAIN))
return TRUE;;
if (otmp->otyp == RIN_HUNGER && (prop & ITEM_HUNGER))
return TRUE;
if (otmp->otyp == RIN_AGGRAVATE_MONSTER && (prop & ITEM_STENCH))
return TRUE;
if (otmp->otyp == RIN_WARNING && (prop & ITEM_VIGIL))
return TRUE;
if (otmp->otyp == RIN_POISON_RESISTANCE && (prop & ITEM_VENOM))
return TRUE;
if (otmp->otyp == RIN_FIRE_RESISTANCE && (prop & ITEM_FIRE))
return TRUE;
if (otmp->otyp == RIN_COLD_RESISTANCE && (prop & ITEM_FROST))
return TRUE;
if (otmp->otyp == RIN_SONIC_RESISTANCE && (prop & ITEM_SCREAM))
return TRUE;
if (otmp->otyp == RIN_SHOCK_RESISTANCE && (prop & ITEM_SHOCK))
return TRUE;
if (otmp->otyp == RIN_TELEPORTATION && (prop & ITEM_TELE))
return TRUE;
if (otmp->otyp == RIN_SEE_INVISIBLE && (prop & ITEM_INSIGHT))
return TRUE;
}

return FALSE;
}

Expand Down
42 changes: 39 additions & 3 deletions src/objnam.c
Original file line number Diff line number Diff line change
Expand Up @@ -1124,6 +1124,9 @@ unsigned cxn_flags; /* bitmask of CXN_xxx values */
Sprintf(buf, "%s ring", actualn);
else
Sprintf(eos(buf), "ring of %s", actualn);

propnames(buf, obj->oprops, obj->oprops_known,
FALSE, FALSE);
}
else if (un)
xcalled(buf, BUFSZ - PREFIX, "ring", un);
Expand Down Expand Up @@ -5373,7 +5376,8 @@ struct obj *no_wish;

/* object property restrictions */
if (otmp->oclass == WEAPON_CLASS || is_weptool(otmp)
|| otmp->oclass == ARMOR_CLASS) {
|| otmp->oclass == ARMOR_CLASS
|| otmp->oclass == RING_CLASS) {

/* TODO: This refactor is better but... can it be consolidated more? */
if (objprops & ITEM_FROST)
Expand Down Expand Up @@ -5421,13 +5425,13 @@ struct obj *no_wish;
else if (otmp->oclass == WEAPON_CLASS || is_weptool(otmp))
objprops &= ~(ITEM_OILSKIN | NON_WEP_PROPS);

if (otmp->oclass == ARMOR_CLASS)
if (otmp->oclass == ARMOR_CLASS || otmp->oclass == RING_CLASS)
objprops &= ~ONLY_WEP_PROPS;

objprops = rm_redundant_oprops(otmp, objprops);

/* The player cannot wish for properties */
/*if (wizard)*/
if (wizard)
otmp->oprops |= objprops;
}

Expand Down Expand Up @@ -5742,6 +5746,38 @@ long objprops;
objprops &= ~ITEM_STEALTH;
if (otmp->otyp == ALCHEMY_SMOCK)
objprops &= ~(ITEM_ACID | ITEM_VENOM);

if (otmp->oclass == RING_CLASS) {
/* TODO: Figure out how to loop over the props
* and use obj_has_prop(obj, which) */
if (otmp->otyp == RIN_SEARCHING)
objprops &= ~ITEM_SEARCHING;
if (otmp->otyp == RIN_STEALTH)
objprops &= ~ITEM_STEALTH;
if (otmp->otyp == RIN_SUSTAIN_ABILITY)
objprops &= ~ITEM_SUSTAIN;
if (otmp->otyp == RIN_HUNGER)
objprops &= ~ITEM_HUNGER;
if (otmp->otyp == RIN_AGGRAVATE_MONSTER)
objprops &= ~ITEM_STENCH;
if (otmp->otyp == RIN_WARNING)
objprops &= ~ITEM_VIGIL;
if (otmp->otyp == RIN_POISON_RESISTANCE)
objprops &= ~ITEM_VENOM;
if (otmp->otyp == RIN_FIRE_RESISTANCE)
objprops &= ~ITEM_FIRE;
if (otmp->otyp == RIN_COLD_RESISTANCE)
objprops &= ~ITEM_FROST;
if (otmp->otyp == RIN_SONIC_RESISTANCE)
objprops &= ~ITEM_SCREAM;
if (otmp->otyp == RIN_SHOCK_RESISTANCE)
objprops &= ~ITEM_SHOCK;
if (otmp->otyp == RIN_TELEPORTATION)
objprops &= ~ITEM_TELE;
if (otmp->otyp == RIN_SEE_INVISIBLE)
objprops &= ~ITEM_INSIGHT;
}

return objprops;
}
/*objnam.c*/
39 changes: 19 additions & 20 deletions src/pager.c
Original file line number Diff line number Diff line change
Expand Up @@ -1276,27 +1276,26 @@ char *usr_text;
oc.oc_delay == 0 ? 1 : oc.oc_delay,
(oc.oc_delay == 1 ? "" : "s"));
OBJPUTSTR(buf);

if (dummy.oprops_known) {
if (obj->oprops & ITEM_FIRE) OBJPUTSTR("Grants fire resistance");
if (obj->oprops & ITEM_FROST) OBJPUTSTR("Grants cold resistance");
if (obj->oprops & ITEM_SHOCK) OBJPUTSTR("Grants shock resistance");
if (obj->oprops & ITEM_SCREAM) OBJPUTSTR("Grants sonic resistance");
if (obj->oprops & ITEM_VENOM) OBJPUTSTR("Grants poison resistance");
if (obj->oprops & ITEM_ACID) OBJPUTSTR("Grants acid resistance");
if (obj->oprops & ITEM_DRLI) OBJPUTSTR("Grants drain resistance");
if (obj->oprops & ITEM_SLEEP) OBJPUTSTR("Grants sleep resistance");
if (obj->oprops & ITEM_STONE) OBJPUTSTR("Grants petrification resistance");
if (obj->oprops & ITEM_SICK) OBJPUTSTR("Grants sickness resistance");
if (obj->oprops & ITEM_STUN) OBJPUTSTR("Grants stun resistance");
if (obj->oprops & ITEM_RAGE) OBJPUTSTR("Grants rage and fearlessness");
if (obj->oprops & ITEM_PROWESS) OBJPUTSTR("Grants prowess in technical skills");
if (obj->oprops & ITEM_TOUGH) OBJPUTSTR("Grants withering resistance");
if (obj->oprops & ITEM_OILSKIN) OBJPUTSTR("Permanently greased");
if (obj->oprops & ITEM_FUMBLING) OBJPUTSTR("Grants fumbling");
}
}

if (dummy.oprops_known &&
(oc.oc_class == ARMOR_CLASS || oc.oc_class == RING_CLASS)) {
if (obj->oprops & ITEM_FIRE) OBJPUTSTR("Grants fire resistance");
if (obj->oprops & ITEM_FROST) OBJPUTSTR("Grants cold resistance");
if (obj->oprops & ITEM_SHOCK) OBJPUTSTR("Grants shock resistance");
if (obj->oprops & ITEM_SCREAM) OBJPUTSTR("Grants sonic resistance");
if (obj->oprops & ITEM_VENOM) OBJPUTSTR("Grants poison resistance");
if (obj->oprops & ITEM_ACID) OBJPUTSTR("Grants acid resistance");
if (obj->oprops & ITEM_DRLI) OBJPUTSTR("Grants drain resistance");
if (obj->oprops & ITEM_SLEEP) OBJPUTSTR("Grants sleep resistance");
if (obj->oprops & ITEM_STONE) OBJPUTSTR("Grants petrification resistance");
if (obj->oprops & ITEM_SICK) OBJPUTSTR("Grants sickness resistance");
if (obj->oprops & ITEM_STUN) OBJPUTSTR("Grants stun resistance");
if (obj->oprops & ITEM_RAGE) OBJPUTSTR("Grants rage and fearlessness");
if (obj->oprops & ITEM_PROWESS) OBJPUTSTR("Grants prowess in technical skills");
if (obj->oprops & ITEM_TOUGH) OBJPUTSTR("Grants withering resistance");
if (obj->oprops & ITEM_OILSKIN) OBJPUTSTR("Permanently greased");
if (obj->oprops & ITEM_FUMBLING) OBJPUTSTR("Grants fumbling");
}
/* PROPERTY INFO */

if (dummy.oprops_known
Expand Down

0 comments on commit 08e6a2b

Please sign in to comment.