Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git c/include/extern.h w/include/extern.h
- index 6959e24..3848a9e 100644
- --- c/include/extern.h
- +++ w/include/extern.h
- @@ -60,8 +60,8 @@ E void FDECL(restore_artifacts, (int));
- E const char *FDECL(artiname, (int));
- E struct obj *FDECL(mk_artifact, (struct obj *, ALIGNTYP_P));
- E const char *FDECL(artifact_name, (const char *, short *));
- -E boolean FDECL(exist_artifact, (int, const char *));
- -E void FDECL(artifact_exists, (struct obj *, const char *, BOOLEAN_P));
- +E int FDECL(exist_artifact, (int, const char *));
- +E void FDECL(artifact_exists, (struct obj *, const char *, int));
- E int NDECL(nartifact_exist);
- E boolean FDECL(arti_immune, (struct obj *, int));
- E boolean FDECL(spec_ability, (struct obj *, unsigned long));
- @@ -413,7 +413,7 @@ E void FDECL(new_oname, (struct obj *, int));
- E void FDECL(free_oname, (struct obj *));
- E const char *FDECL(safe_oname, (struct obj *));
- E struct monst *FDECL(christen_monst, (struct monst *, const char *));
- -E struct obj *FDECL(oname, (struct obj *, const char *));
- +E struct obj *FDECL(oname, (struct obj *, const char *, int));
- E boolean FDECL(objtyp_is_callable, (int));
- E int NDECL(docallcmd);
- E void FDECL(docall, (struct obj *));
- diff --git c/include/hack.h w/include/hack.h
- index f686f7a..5e091d7 100644
- --- c/include/hack.h
- +++ w/include/hack.h
- @@ -440,6 +440,26 @@ enum bodypart_types {
- #define BALL_IN_MON (u.uswallow && uball && uball->where == OBJ_FREE)
- #define NODIAG(monnum) ((monnum) == PM_GRID_BUG)
- +/* Flags to track artifact generation */
- +enum artifact_background {
- + ARTIFROM_GONE = -1,
- + ARTIFROM_NONE = 0,
- + ARTIFROM_FOUND,
- + ARTIFROM_NAMED,
- + ARTIFROM_BONES,
- + ARTIFROM_GIFTED_CHAOTIC,
- + ARTIFROM_GIFTED_NEUTRAL,
- + ARTIFROM_GIFTED_LAWFUL,
- + ARTIFROM_WISHED
- +};
- +#define ARTIFROM_GIFTED(alignment) ((alignment == A_NONE) ? ARTIFROM_NONE \
- + : ARTIFROM_GIFTED_NEUTRAL + sgn(alignment))
- +#define ARTIFROM_IS_GIFTED(bg) ((bg) == ARTIFROM_GIFTED_CHAOTIC \
- + || (bg) == ARTIFROM_GIFTED_NEUTRAL \
- + || (bg) == ARTIFROM_GIFTED_LAWFUL)
- +#define ARTIFROM_GIFTED_BY(bg) (ARTIFROM_IS_GIFTED(bg) \
- + ? (bg) - ARTIFROM_GIFTED_NEUTRAL : A_NONE)
- +
- /* Flags to control menus */
- #define MENUTYPELEN sizeof("traditional ")
- #define MENU_TRADITIONAL 0
- diff --git c/src/artifact.c w/src/artifact.c
- index f5c3afe..468867f 100644
- --- c/src/artifact.c
- +++ w/src/artifact.c
- @@ -44,8 +44,10 @@ STATIC_DCL int FDECL(count_surround_traps, (int, int));
- /* coordinate effects from spec_dbon() with messages in artifact_hit() */
- STATIC_OVL int spec_dbon_applies = 0;
- -/* flags including which artifacts have already been created */
- -static boolean artiexist[1 + NROFARTIFACTS + 1];
- +/* flags including which artifacts have already been created
- + * used to be boolean, now is an enum; but declared as schar
- + * to hopefully preserve savefile compatibility as much as possible */
- +static schar artiexist[1 + NROFARTIFACTS + 1];
- /* and a discovery list for them (no dummy first entry here) */
- STATIC_OVL xchar artidisco[NROFARTIFACTS];
- @@ -195,11 +197,9 @@ aligntyp alignment; /* target alignment, or A_NONE */
- if (by_align)
- otmp = mksobj((int) a->otyp, TRUE, FALSE);
- - if (otmp) {
- - otmp = oname(otmp, a->name);
- - otmp->oartifact = m;
- - artiexist[m] = TRUE;
- - }
- + if (otmp)
- + otmp = oname(otmp, a->name, by_align ? ARTIFROM_GIFTED(alignment)
- + : ARTIFROM_FOUND);
- } else {
- /* nothing appropriate could be found; return original object */
- if (by_align)
- @@ -239,26 +239,26 @@ short *otyp;
- return (char *) 0;
- }
- -boolean
- +int
- exist_artifact(otyp, name)
- int otyp;
- const char *name;
- {
- register const struct artifact *a;
- - boolean *arex;
- + schar *arex;
- if (otyp && *name)
- for (a = artilist + 1, arex = artiexist + 1; a->otyp; a++, arex++)
- if ((int) a->otyp == otyp && !strcmp(a->name, name))
- - return *arex;
- - return FALSE;
- + return (int) *arex;
- + return ARTIFROM_NONE;
- }
- void
- artifact_exists(otmp, name, mod)
- struct obj *otmp;
- const char *name;
- -boolean mod;
- +int mod;
- {
- register const struct artifact *a;
- @@ -266,7 +266,7 @@ boolean mod;
- for (a = artilist + 1; a->otyp; a++)
- if (a->otyp == otmp->otyp && !strcmp(a->name, name)) {
- register int m = (int) (a - artilist);
- - otmp->oartifact = (char) (mod ? m : 0);
- + otmp->oartifact = (char) (mod > 0 ? m : 0);
- otmp->age = 0;
- if (otmp->otyp == RIN_INCREASE_DAMAGE)
- otmp->spe = 0;
- @@ -283,7 +283,7 @@ nartifact_exist()
- int n = SIZE(artiexist);
- while (n > 1)
- - if (artiexist[--n])
- + if (artiexist[--n] > 0)
- a++;
- return a;
- diff --git c/src/bones.c w/src/bones.c
- index 0a7b817..6c55600 100644
- --- c/src/bones.c
- +++ w/src/bones.c
- @@ -80,7 +80,7 @@ boolean restore;
- if (has_oname(otmp))
- free_oname(otmp);
- } else {
- - artifact_exists(otmp, safe_oname(otmp), TRUE);
- + artifact_exists(otmp, safe_oname(otmp), ARTIFROM_BONES);
- }
- } else if (has_oname(otmp)) {
- sanitize_name(ONAME(otmp));
- diff --git c/src/do_name.c w/src/do_name.c
- index 6dd8d5a..19e722e 100644
- --- c/src/do_name.c
- +++ w/src/do_name.c
- @@ -1186,8 +1186,6 @@ do_mname()
- (void) christen_monst(mtmp, buf);
- }
- -STATIC_VAR int via_naming = 0;
- -
- /*
- * This routine used to change the address of 'obj' so be unsafe if not
- * used with extreme care. Applying a name to an object no longer
- @@ -1259,15 +1257,14 @@ register struct obj *obj;
- a valid artifact name */
- u.uconduct.literate++;
- }
- - ++via_naming; /* This ought to be an argument rather than a static... */
- - obj = oname(obj, buf);
- - --via_naming; /* ...but oname() is used in a lot of places, so defer. */
- + obj = oname(obj, buf, ARTIFROM_NAMED);
- }
- struct obj *
- -oname(obj, name)
- +oname(obj, name, how)
- struct obj *obj;
- const char *name;
- +int how;
- {
- int lth;
- char buf[PL_PSIZ];
- @@ -1289,8 +1286,8 @@ const char *name;
- if (lth)
- Strcpy(ONAME(obj), name);
- - if (lth)
- - artifact_exists(obj, name, TRUE);
- + if (lth && how > 0)
- + artifact_exists(obj, name, how);
- if (obj->oartifact) {
- /* can't dual-wield with artifact as secondary weapon */
- if (obj == uswapwep)
- @@ -1301,7 +1298,7 @@ const char *name;
- /* if obj is owned by a shop, increase your bill */
- if (obj->unpaid)
- alter_cost(obj, 0L);
- - if (via_naming) {
- + if (how == ARTIFROM_NAMED) {
- /* violate illiteracy conduct since successfully wrote arti-name */
- u.uconduct.literate++;
- }
- diff --git c/src/eat.c w/src/eat.c
- index 4dd3a0a..0819bbf 100644
- --- c/src/eat.c
- +++ w/src/eat.c
- @@ -58,8 +58,6 @@ char msgbuf[BUFSZ];
- ((otyp) == LEMBAS_WAFER || (otyp) == CRAM_RATION)
- STATIC_OVL NEARDATA const char comestibles[] = { FOOD_CLASS, 0 };
- -STATIC_OVL NEARDATA const char offerfodder[] = { FOOD_CLASS, AMULET_CLASS,
- - 0 };
- /* Gold must come first for getobj(). */
- STATIC_OVL NEARDATA const char allobj[] = {
- @@ -3136,6 +3134,7 @@ int corpsecheck; /* 0, no check, 1, corpses, 2, tinnable corpses */
- if (corpsecheck
- ? (otmp->otyp == CORPSE
- && (corpsecheck == 1 || tinnable(otmp)))
- + || (offering && otmp->oartifact)
- : feeding ? (otmp->oclass != COIN_CLASS && is_edible(otmp))
- : otmp->oclass == FOOD_CLASS) {
- char qsfx[QBUFSZ];
- @@ -3168,9 +3167,10 @@ skipfloor:
- /* We cannot use ALL_CLASSES since that causes getobj() to skip its
- * "ugly checks" and we need to check for inedible items.
- */
- - otmp = getobj(feeding ? allobj : offering ? offerfodder : comestibles,
- + otmp = getobj(feeding || offering ? allobj : comestibles,
- verb);
- - if (corpsecheck && otmp && !(offering && otmp->oclass == AMULET_CLASS))
- + if (corpsecheck && otmp && !(offering && (otmp->oclass == AMULET_CLASS
- + || otmp->oartifact)))
- if (otmp->otyp != CORPSE || (corpsecheck == 2 && !tinnable(otmp))) {
- You_cant("%s that!", verb);
- return (struct obj *) 0;
- diff --git c/src/fountain.c w/src/fountain.c
- index 57e9145..036514e 100644
- --- c/src/fountain.c
- +++ w/src/fountain.c
- @@ -388,7 +388,7 @@ register struct obj *obj;
- pline(
- "From the murky depths, a hand reaches up to bless the sword.");
- pline("As the hand retreats, the fountain disappears!");
- - obj = oname(obj, artiname(ART_EXCALIBUR));
- + obj = oname(obj, artiname(ART_EXCALIBUR), ARTIFROM_FOUND);
- discover_artifact(ART_EXCALIBUR);
- bless(obj);
- obj->oeroded = obj->oeroded2 = 0;
- diff --git c/src/invent.c w/src/invent.c
- index ff69de7..ae727f7 100644
- --- c/src/invent.c
- +++ w/src/invent.c
- @@ -728,7 +728,7 @@ struct obj **potmp, **pobj;
- else if (!Is_pudding(otmp))
- otmp->owt += obj->owt;
- if (!has_oname(otmp) && has_oname(obj))
- - otmp = *potmp = oname(otmp, ONAME(obj));
- + otmp = *potmp = oname(otmp, ONAME(obj), ARTIFROM_NONE);
- obj_extract_self(obj);
- /* really should merge the timeouts */
- @@ -1530,7 +1530,7 @@ register const char *let, *word;
- || (!strcmp(word, "eat") && !is_edible(otmp))
- || (!strcmp(word, "sacrifice")
- && (otyp != CORPSE && otyp != AMULET_OF_YENDOR
- - && otyp != FAKE_AMULET_OF_YENDOR))
- + && otyp != FAKE_AMULET_OF_YENDOR && !otmp->oartifact))
- || (!strcmp(word, "write with")
- && (otmp->oclass == TOOL_CLASS
- && otyp != MAGIC_MARKER && otyp != TOWEL))
- diff --git c/src/mail.c w/src/mail.c
- index 63142ad..2cfd394 100644
- --- c/src/mail.c
- +++ w/src/mail.c
- @@ -409,7 +409,7 @@ struct mail_info *info;
- struct obj *obj = mksobj(SCR_MAIL, FALSE, FALSE);
- if (info->object_nam)
- - obj = oname(obj, info->object_nam);
- + obj = oname(obj, info->object_nam, ARTIFROM_NONE);
- if (info->response_cmd)
- new_omailcmd(obj, info->response_cmd);
- diff --git c/src/makemon.c w/src/makemon.c
- index 94ee223..4db7641 100644
- --- c/src/makemon.c
- +++ w/src/makemon.c
- @@ -333,7 +333,8 @@ register struct monst *mtmp;
- /* maybe make it special */
- if (!rn2(20) || is_lord(ptr))
- otmp = oname(otmp,
- - artiname(rn2(2) ? ART_DEMONBANE : ART_SUNSWORD));
- + artiname(rn2(2) ? ART_DEMONBANE : ART_SUNSWORD),
- + ARTIFROM_FOUND);
- bless(otmp);
- otmp->oerodeproof = TRUE;
- spe2 = rn2(4);
- diff --git c/src/mkobj.c w/src/mkobj.c
- index 195de0b..7278fd7 100644
- --- c/src/mkobj.c
- +++ w/src/mkobj.c
- @@ -386,7 +386,7 @@ struct obj *obj2, *obj1;
- if (!obj2->oextra)
- obj2->oextra = newoextra();
- if (has_oname(obj1))
- - oname(obj2, ONAME(obj1));
- + oname(obj2, ONAME(obj1), ARTIFROM_NONE);
- if (has_omonst(obj1)) {
- if (!OMONST(obj2))
- newomonst(obj2);
- @@ -1097,7 +1097,7 @@ boolean artif;
- break;
- case SPE_NOVEL:
- otmp->novelidx = -1; /* "none of the above"; will be changed */
- - otmp = oname(otmp, noveltitle(&otmp->novelidx));
- + otmp = oname(otmp, noveltitle(&otmp->novelidx), ARTIFROM_NONE);
- break;
- }
- @@ -1675,7 +1675,7 @@ const char *nm;
- otmp = mkcorpstat(objtype, (struct monst *) 0, ptr, x, y, corpstatflags);
- if (nm)
- - otmp = oname(otmp, nm);
- + otmp = oname(otmp, nm, ARTIFROM_NONE);
- return otmp;
- }
- diff --git c/src/mon.c w/src/mon.c
- index 7bb0d0f..40a736c 100644
- --- c/src/mon.c
- +++ w/src/mon.c
- @@ -465,7 +465,7 @@ unsigned corpseflags;
- bypass_obj(obj);
- if (has_mname(mtmp))
- - obj = oname(obj, MNAME(mtmp));
- + obj = oname(obj, MNAME(mtmp), ARTIFROM_NONE);
- /* Avoid "It was hidden under a green mold corpse!"
- * during Blind combat. An unseen monster referred to as "it"
- @@ -2210,7 +2210,7 @@ struct monst *mdef;
- item-conferred attributes */
- otmp = mkcorpstat(STATUE, mdef, mdef->data, x, y, CORPSTAT_NONE);
- if (has_mname(mdef))
- - otmp = oname(otmp, MNAME(mdef));
- + otmp = oname(otmp, MNAME(mdef), ARTIFROM_NONE);
- while ((obj = oldminvent) != 0) {
- oldminvent = obj->nobj;
- obj->nobj = 0; /* avoid merged-> obfree-> dealloc_obj-> panic */
- diff --git c/src/objnam.c w/src/objnam.c
- index 06efd9b..c1044d6 100644
- --- c/src/objnam.c
- +++ w/src/objnam.c
- @@ -3972,7 +3972,7 @@ struct obj *no_wish;
- name = novelname;
- }
- - otmp = oname(otmp, name);
- + otmp = oname(otmp, name, ARTIFROM_WISHED);
- /* name==aname => wished for artifact (otmp->oartifact => got it) */
- if (otmp->oartifact || name == aname) {
- otmp->quan = 1L;
- @@ -3984,7 +3984,7 @@ struct obj *no_wish;
- /* and make them pay; charge them for the wish anyway! */
- if ((is_quest_artifact(otmp)
- || (otmp->oartifact && rn2(nartifact_exist()) > 1)) && !wizard) {
- - artifact_exists(otmp, safe_oname(otmp), FALSE);
- + artifact_exists(otmp, safe_oname(otmp), ARTIFROM_NONE);
- obfree(otmp, (struct obj *) 0);
- otmp = (struct obj *) &zeroobj;
- pline("For a moment, you feel %s in your %s, but it disappears!",
- diff --git c/src/pickup.c w/src/pickup.c
- index 8842e14..7f6e164 100644
- --- c/src/pickup.c
- +++ w/src/pickup.c
- @@ -2404,7 +2404,7 @@ boolean makecat, givemsg;
- now rather than from when this special corpse got created */
- deadcat->age = monstermoves;
- set_corpsenm(deadcat, PM_HOUSECAT);
- - deadcat = oname(deadcat, sc);
- + deadcat = oname(deadcat, sc, ARTIFROM_NONE);
- }
- if (givemsg)
- pline_The("%s inside the box is dead!",
- diff --git c/src/pray.c w/src/pray.c
- index bc9a9ba..58e43b3 100644
- --- c/src/pray.c
- +++ w/src/pray.c
- @@ -831,7 +831,7 @@ gcrownu()
- } else if (obj && obj->otyp == LONG_SWORD && !obj->oartifact) {
- if (!Blind)
- Your("sword shines brightly for a moment.");
- - obj = oname(obj, artiname(ART_EXCALIBUR));
- + obj = oname(obj, artiname(ART_EXCALIBUR), ARTIFROM_GIFTED_LAWFUL);
- if (obj && obj->oartifact == ART_EXCALIBUR)
- u.ugifts++;
- }
- @@ -848,7 +848,7 @@ gcrownu()
- obj->dknown = TRUE;
- } else if (!already_exists) {
- obj = mksobj(LONG_SWORD, FALSE, FALSE);
- - obj = oname(obj, artiname(ART_VORPAL_BLADE));
- + obj = oname(obj, artiname(ART_VORPAL_BLADE), ARTIFROM_GIFTED_NEUTRAL);
- obj->spe = 1;
- at_your_feet("A sword");
- dropy(obj);
- @@ -870,7 +870,7 @@ gcrownu()
- obj->dknown = TRUE;
- } else if (!already_exists) {
- obj = mksobj(RUNESWORD, FALSE, FALSE);
- - obj = oname(obj, artiname(ART_STORMBRINGER));
- + obj = oname(obj, artiname(ART_STORMBRINGER), ARTIFROM_GIFTED_CHAOTIC);
- obj->spe = 1;
- at_your_feet(An(swordbuf));
- dropy(obj);
- @@ -1306,6 +1306,8 @@ register struct obj *otmp;
- else
- Your("sacrifice is consumed in a %s!",
- u.ualign.type == A_LAWFUL ? "flash of light" : "burst of flame");
- + if (otmp->oartifact)
- + artifact_exists(otmp, safe_oname(otmp), ARTIFROM_GONE);
- if (carried(otmp))
- useup(otmp);
- else
- @@ -1333,6 +1335,12 @@ dosacrifice()
- otmp = floorfood("sacrifice", 1);
- if (!otmp)
- return 0;
- + if (otmp->owornmask & (W_ARMOR | W_SADDLE))
- + {
- + You_cant("sacrifice %s you're wearing.", something);
- + return 0;
- + }
- +
- /*
- * Was based on nutritional value and aging behavior (< 50 moves).
- * Sacrificing a food ration got you max luck instantly, making the
- @@ -1578,6 +1586,65 @@ dosacrifice()
- }
- } /* fake Amulet */
- + if (otmp->oartifact) {
- + char buf[BUFSZ];
- + /* just in case */
- + if (objects[otmp->otyp].oc_unique && !u.uevent.invoked)
- + {
- + You("decide against that.");
- + return 0;
- + }
- + sprintf(buf, "Are you sure you want to sacrifice your %s?",
- + xname(otmp));
- + if (yn(buf) != 'y')
- + return 0;
- +
- + int multiplier;
- + int background = exist_artifact(otmp->otyp, safe_oname(otmp));
- + switch (background) {
- + case ARTIFROM_BONES:
- + /* used condition */
- + multiplier = 3;
- + break;
- + case ARTIFROM_NAMED:
- + /* barely even an artifact */
- + multiplier = 1;
- + break;
- + case ARTIFROM_GIFTED_CHAOTIC:
- + case ARTIFROM_GIFTED_NEUTRAL:
- + case ARTIFROM_GIFTED_LAWFUL:
- + /* no regifts! */
- + multiplier = 0;
- + break;
- + case ARTIFROM_WISHED:
- + case ARTIFROM_FOUND:
- + default:
- + multiplier = 5;
- + break;
- + }
- + value = arti_cost(otmp) * multiplier / 500;
- +
- + if (ARTIFROM_IS_GIFTED(background))
- + {
- + boolean very_rude = background == ARTIFROM_GIFTED(altaralign);
- + if ((very_rude || !rn2(4)))
- + {
- + You("have not used %s gift wisely...",
- + s_suffix(align_gname(ARTIFROM_GIFTED_BY(background))));
- + (void) adjattrib(A_WIS, -rnd(3), 1);
- + exercise(A_WIS, FALSE);
- + if (very_rude) value = -1;
- + }
- + else
- + You_feel(Hallucination ? "in violation of a no-return policy."
- + : "like a lowly pawnbroker.");
- + }
- +
- + /* artifacts are not 'proper' sacrifices so no converting etc. */
- + if (altaralign != u.ualign.type && value > 0)
- + value = 0;
- + }
- +
- if (value == 0) {
- pline1(nothing_happens);
- return 1;
- diff --git c/src/sp_lev.c w/src/sp_lev.c
- index cd95210..671485e 100644
- --- c/src/sp_lev.c
- +++ w/src/sp_lev.c
- @@ -1905,7 +1905,7 @@ struct mkroom *croom;
- /* set_corpsenm() took care of egg hatch and corpse timers */
- if (named)
- - otmp = oname(otmp, o->name.str);
- + otmp = oname(otmp, o->name.str, ARTIFROM_FOUND);
- if (o->eroded) {
- if (o->eroded < 0) {
- diff --git c/src/topten.c w/src/topten.c
- index 6a226df..1f9715c 100644
- --- c/src/topten.c
- +++ w/src/topten.c
- @@ -1232,7 +1232,7 @@ struct obj *otmp;
- return (struct obj *) 0;
- set_corpsenm(otmp, classmon(tt->plrole, (tt->plgend[0] == 'F')));
- - otmp = oname(otmp, tt->name);
- + otmp = oname(otmp, tt->name, ARTIFROM_NONE);
- return otmp;
- }
Add Comment
Please, Sign In to add comment