Skip to content

Commit

Permalink
Armor shops can enchant dragon scales via the enchant armor service now.
Browse files Browse the repository at this point in the history
  • Loading branch information
elunna committed Oct 14, 2023
1 parent 233f729 commit f7428ac
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 108 deletions.
3 changes: 2 additions & 1 deletion include/extern.h
Original file line number Diff line number Diff line change
Expand Up @@ -2388,12 +2388,13 @@ E void FDECL(set_lit, (int, int, genericptr_t));
#endif
E void FDECL(litroom, (BOOLEAN_P, struct obj *));
E void litroom_mon(boolean, struct obj *, int, int);
E void FDECL(do_genocide, (int,BOOLEAN_P));
E void FDECL(do_genocide, (int, BOOLEAN_P));
E void FDECL(punish, (struct obj *));
E void NDECL(unpunish);
E boolean FDECL(cant_revive, (int *, BOOLEAN_P, struct obj *));
E boolean NDECL(create_particular);
E int FDECL(mon_to_zombie, (int));
E boolean maybe_process_scales(struct obj *, struct obj *);

/* ### rect.c ### */

Expand Down
6 changes: 2 additions & 4 deletions src/artifact.c
Original file line number Diff line number Diff line change
Expand Up @@ -3426,10 +3426,8 @@ struct obj *obj;

switch (oart->inv_prop) {
case TAMING: {
struct obj pseudo;

pseudo =
zeroobj; /* neither cursed nor blessed, zero oextra too */
/* neither cursed nor blessed, zero oextra too */
struct obj pseudo = zeroobj;
pseudo.otyp = SCR_TAMING;
(void) seffects(&pseudo);
break;
Expand Down
198 changes: 103 additions & 95 deletions src/read.c
Original file line number Diff line number Diff line change
Expand Up @@ -1430,101 +1430,8 @@ struct obj *sobj; /* sobj - scroll or fake spellbook for spell */
You("cannot enchant armor that is not worn.");
otmp = getobj(clothes, "enchant");
}
/* Dragon scales that are worn over body armor will cause the armor to
* become scaled */
if (otmp && Is_dragon_scales(otmp)) { /* guarantees that worn cloak is scales,
but does NOT guarantee existence of uarm */
/* no body armor under the scales = the scales are enchanted
* directly onto you (no such thing as a scaled shirt). The wearer
* will polymorph. Also caused by a confused scroll, _after_ the
* scales meld. */
boolean poly_after_merge = (!uarm || confused);
int old_light = artifact_light(otmp) ? arti_light_radius(otmp) : 0;
if (uarm) {
struct obj *scales = uarmc;
struct obj *armor = uarm;
if (armor->oartifact) {
pline("%s refuses to meld into the %s.",
Yname2(scales), artiname(armor->oartifact));
break;
}
pline("%s hardens and melds into your %s%s", Yname2(scales),
suit_simple_name(armor),
Is_dragon_scaled_armor(armor) ? "." : "!");

if (Is_dragon_scaled_armor(armor)) {
if (Dragon_armor_to_scales(armor) == scales->otyp) {
/* scales match armor already; just use up scales */
pline("Its scales still seem %s.",
dragon_scales_color(armor));
} else {
/* armor is already scaled but the new scales are
* different and will replace the old ones */
pline("Its scales change from %s to %s!",
dragon_scales_color(armor),
dragon_scales_color(scales));
/* remove properties of old scales */
dragon_armor_handling(armor, FALSE);
}
}
setnotworn(armor);
/* don't allow a suit of armor with an object property
to co-exist with merged dragon scales */
if ((armor->oprops & ITEM_PROP_MASK) != 0) {
oprops_off(armor, W_ARM);
armor->oprops &= ~(ITEM_PROP_MASK);
}
armor->dragonscales = scales->otyp;
armor->cursed = 0;
if (sblessed) {
armor->oeroded = armor->oeroded2 = 0;
armor->blessed = 1;
}
setworn(armor, W_ARM);
check_wings(TRUE);
dragon_armor_handling(armor, TRUE);
known = TRUE;
if (otmp->unpaid)
alter_cost(otmp, 0L); /* shop bill */

/* handle gold dragon-scaled armor... */
if (scales->lamplit) {
if (armor->lamplit) {
/* if melding lit dragon scales onto already lit dragon-scaled
armor, avoid attaching a duplicate light source to the armor.
useup() won't take care of this, because it calls
setnotworn(), which will make artifact_light() return
false, so the regular check for deleting the light source
when an object is deallocated will do nothing */
del_light_source(LS_OBJECT, obj_to_any(scales));
} else {
/* this will set armor->lamplit */
obj_move_light_source(scales, armor);
}
/* may be different radius depending on BUC of armor */
maybe_adjust_light(armor, old_light);
} else if (armor->lamplit) {
/* scales not lit but armor is: melding non-gold scales onto
gold-scaled armor, which will no longer be a
light source */
end_burn(armor, FALSE);
}
useup(scales);
}
if (poly_after_merge) {
polyself(4);
/* adjust duration for scroll beatitude - a blessed scroll will
* give you more time as a dragon, a cursed scroll less */
u.mtimedone = (u.mtimedone * (bcsign(sobj) + 2) / 2);
}
if (!scursed || !uarm) {
break;
} else {
/* continue with regular cursed-enchant logic on the resulting
* armor piece */
otmp = uarm;
}
}
if (!maybe_process_scales(otmp, sobj))
break;
}
} else {
if (uarmc && Is_dragon_scales(uarmc))
Expand Down Expand Up @@ -4283,5 +4190,106 @@ static void do_acquirement() {
}
}

/* Return FALSE if failure, TRUE if success */
boolean maybe_process_scales(otmp, sobj)
struct obj *otmp, *sobj;
{
/* Dragon scales that are worn over body armor will cause the armor to
* become scaled */
if (otmp && Is_dragon_scales(otmp)) { /* guarantees that worn cloak is scales,
but does NOT guarantee existence of uarm */
/* no body armor under the scales = the scales are enchanted
* directly onto you (no such thing as a scaled shirt). The wearer
* will polymorph. Also caused by a confused scroll, _after_ the
* scales meld. */
boolean poly_after_merge = (!uarm || Confusion);
int old_light = artifact_light(otmp) ? arti_light_radius(otmp) : 0;
if (uarm) {
struct obj *scales = uarmc;
struct obj *armor = uarm;
if (armor->oartifact) {
pline("%s refuses to meld into the %s.",
Yname2(scales), artiname(armor->oartifact));
return FALSE;
}
pline("%s hardens and melds into your %s%s", Yname2(scales),
suit_simple_name(armor),
Is_dragon_scaled_armor(armor) ? "." : "!");

if (Is_dragon_scaled_armor(armor)) {
if (Dragon_armor_to_scales(armor) == scales->otyp) {
/* scales match armor already; just use up scales */
pline("Its scales still seem %s.",
dragon_scales_color(armor));
} else {
/* armor is already scaled but the new scales are
* different and will replace the old ones */
pline("Its scales change from %s to %s!",
dragon_scales_color(armor),
dragon_scales_color(scales));
/* remove properties of old scales */
dragon_armor_handling(armor, FALSE);
}
}
setnotworn(armor);
/* don't allow a suit of armor with an object property
to co-exist with merged dragon scales */
if ((armor->oprops & ITEM_PROP_MASK) != 0) {
oprops_off(armor, W_ARM);
armor->oprops &= ~(ITEM_PROP_MASK);
}
armor->dragonscales = scales->otyp;
armor->cursed = 0;
if (sobj->blessed) {
armor->oeroded = armor->oeroded2 = 0;
armor->blessed = 1;
}
setworn(armor, W_ARM);
check_wings(TRUE);
dragon_armor_handling(armor, TRUE);
known = TRUE;
if (otmp->unpaid)
alter_cost(otmp, 0L); /* shop bill */

/* handle gold dragon-scaled armor... */
if (scales->lamplit) {
if (armor->lamplit) {
/* if melding lit dragon scales onto already lit dragon-scaled
armor, avoid attaching a duplicate light source to the armor.
useup() won't take care of this, because it calls
setnotworn(), which will make artifact_light() return
false, so the regular check for deleting the light source
when an object is deallocated will do nothing */
del_light_source(LS_OBJECT, obj_to_any(scales));
} else {
/* this will set armor->lamplit */
obj_move_light_source(scales, armor);
}
/* may be different radius depending on BUC of armor */
maybe_adjust_light(armor, old_light);
} else if (armor->lamplit) {
/* scales not lit but armor is: melding non-gold scales onto
gold-scaled armor, which will no longer be a
light source */
end_burn(armor, FALSE);
}
useup(scales);
}
if (poly_after_merge) {
polyself(4);
/* adjust duration for scroll beatitude - a blessed scroll will
* give you more time as a dragon, a cursed scroll less */
u.mtimedone = (u.mtimedone * (bcsign(sobj) + 2) / 2);
}
if (!sobj->cursed || !uarm) {
return FALSE;
} else {
/* continue with regular cursed-enchant logic on the resulting
* armor piece */
otmp = uarm;
}
}
return TRUE;
}

/*read.c*/
19 changes: 11 additions & 8 deletions src/shk.c
Original file line number Diff line number Diff line change
Expand Up @@ -4165,7 +4165,6 @@ long svc_type;
return 1;
}


static int
shk_armor_works(slang, shkp, svc_type)
const char *slang;
Expand Down Expand Up @@ -4208,10 +4207,6 @@ long svc_type;
break;

case SHK_ARM_ENC:
if (Is_dragon_scales(obj)) {
verbalize("Sorry I don't handle dragon scales, allergic you see...");
return 0;
}
verbalize("Nobody will ever hit on you again.");

charge = (obj->spe + 1) * (obj->spe + 1) * 500;
Expand Down Expand Up @@ -4241,9 +4236,17 @@ long svc_type;

if (Hallucination)
Your("%s looks dented.", xname(obj));

obj->spe++;
adj_abon(obj, 1);

if (Is_dragon_scales(obj)) {
struct obj pseudo = zeroobj;
pseudo.otyp = SCR_ENCHANT_ARMOR;
maybe_process_scales(obj, &pseudo);
update_inventory();
return 1; /* obj is gone */
} else {
obj->spe++;
adj_abon(obj, 1);
}
update_inventory();
break;

Expand Down

0 comments on commit f7428ac

Please sign in to comment.