Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git i/include/extern.h w/include/extern.h
- index b6f4825..69d2865 100644
- --- i/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));
- @@ -402,7 +402,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 i/include/hack.h w/include/hack.h
- index af35c2c..311ced8 100644
- --- i/include/hack.h
- +++ w/include/hack.h
- @@ -418,6 +418,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 i/src/artifact.c w/src/artifact.c
- index 2ef7dfa..330f36d 100644
- --- i/src/artifact.c
- +++ w/src/artifact.c
- @@ -43,8 +43,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];
- @@ -194,11 +196,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)
- @@ -238,26 +238,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;
- @@ -265,7 +265,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;
- @@ -282,7 +282,7 @@ nartifact_exist()
- int n = SIZE(artiexist);
- while (n > 1)
- - if (artiexist[--n])
- + if (artiexist[--n] > 0)
- a++;
- return a;
- diff --git i/src/bones.c w/src/bones.c
- index 33f5f2c..dcee878 100644
- --- i/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 i/src/do_name.c w/src/do_name.c
- index e4a8741..54ff4bf 100644
- --- i/src/do_name.c
- +++ w/src/do_name.c
- @@ -1177,8 +1177,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
- @@ -1250,15 +1248,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];
- @@ -1280,8 +1277,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)
- @@ -1292,7 +1289,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 i/src/eat.c w/src/eat.c
- index 79fd56d..e0b25be 100644
- --- i/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[] = {
- @@ -3140,9 +3138,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 i/src/fountain.c w/src/fountain.c
- index 616d42b..2ea5983 100644
- --- i/src/fountain.c
- +++ w/src/fountain.c
- @@ -389,7 +389,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 i/src/invent.c w/src/invent.c
- index 13951f1..50b98c5 100644
- --- i/src/invent.c
- +++ w/src/invent.c
- @@ -398,7 +398,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 */
- @@ -1189,7 +1189,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 i/src/mail.c w/src/mail.c
- index 067dab0..f218411 100644
- --- i/src/mail.c
- +++ w/src/mail.c
- @@ -405,7 +405,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 i/src/makemon.c w/src/makemon.c
- index efca15e..54f8b07 100644
- --- i/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 i/src/mkobj.c w/src/mkobj.c
- index 1724cde..204eab6 100644
- --- i/src/mkobj.c
- +++ w/src/mkobj.c
- @@ -368,7 +368,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);
- @@ -1061,7 +1061,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;
- }
- @@ -1641,7 +1641,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 i/src/mon.c w/src/mon.c
- index b088460..766c859 100644
- --- i/src/mon.c
- +++ w/src/mon.c
- @@ -454,7 +454,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"
- @@ -2118,7 +2118,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;
- (void) add_to_container(otmp, obj);
- diff --git i/src/objnam.c w/src/objnam.c
- index 12bba3c..4dac32e 100644
- --- i/src/objnam.c
- +++ w/src/objnam.c
- @@ -3871,7 +3871,7 @@ typfnd:
- 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;
- @@ -3883,7 +3883,7 @@ typfnd:
- /* 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 = &zeroobj;
- pline("For a moment, you feel %s in your %s, but it disappears!",
- diff --git i/src/pray.c w/src/pray.c
- index d0cb794..4ce265e 100644
- --- i/src/pray.c
- +++ w/src/pray.c
- @@ -813,7 +813,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++;
- }
- @@ -830,7 +830,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);
- @@ -852,7 +852,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);
- @@ -1284,6 +1284,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
- @@ -1311,6 +1313,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
- @@ -1557,6 +1565,64 @@ 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);
- + 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 i/src/sp_lev.c w/src/sp_lev.c
- index a1b1f6d..d94907b 100644
- --- i/src/sp_lev.c
- +++ w/src/sp_lev.c
- @@ -1893,7 +1893,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 i/src/topten.c w/src/topten.c
- index fbe6573..ea399e1 100644
- --- i/src/topten.c
- +++ w/src/topten.c
- @@ -1231,7 +1231,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