Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide plastic babies in slices of king cake #58

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions include/obj.h
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,11 @@ struct obj {
#define thiefstone_ledger_valid(stone) \
((stone)->keyed_ledger > 0 && (stone)->keyed_ledger <= maxledgerno())

/* special holiday fruits are differentiated from user-defined fruits by
* negative spe */
#define is_holiday_fruit(obj) ((obj)->otyp == SLIME_MOLD && (obj)->spe < 0)
#define fruit_id(obj) (abs((obj)->spe))

/*
* Notes for adding new oextra structures:
*
Expand Down
4 changes: 2 additions & 2 deletions src/bones.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ resetobjs(struct obj *ochain, boolean restore)
}

if (otmp->otyp == SLIME_MOLD) {
goodfruit(otmp->spe);
goodfruit(fruit_id(otmp));
#ifdef MAIL_STRUCTURES
} else if (otmp->otyp == SCR_MAIL) {
/* 0: delivered in-game via external event;
Expand Down Expand Up @@ -321,7 +321,7 @@ drop_upon_death(struct monst *mtmp, /* monster if hero turned into one (other th
otmp->owt = weight(otmp);

if (otmp->otyp == SLIME_MOLD)
goodfruit(otmp->spe);
goodfruit(fruit_id(otmp));

if (rn2(5))
curse(otmp);
Expand Down
28 changes: 28 additions & 0 deletions src/eat.c
Original file line number Diff line number Diff line change
Expand Up @@ -2385,6 +2385,34 @@ fpostfx(struct obj *otmp)
if (!u.uconduct.literate++)
livelog_printf(LL_CONDUCT, "became literate by reading the fortune inside a cookie");
break;
case SLIME_MOLD:
if (is_holiday_fruit(otmp)) {
struct fruit *f = fruit_from_indx(fruit_id(otmp));
if (!rn2(8) && f && !strcmp("slice of king cake", f->fname)) {
static const int babies[] = {
PM_BABY_CROCODILE,
PM_BABY_LONG_WORM,
PM_BABY_PURPLE_WORM,
PM_BABY_GRAY_DRAGON,
PM_BABY_GOLD_DRAGON,
PM_BABY_SILVER_DRAGON,
PM_BABY_RED_DRAGON,
PM_BABY_WHITE_DRAGON,
PM_BABY_ORANGE_DRAGON,
PM_BABY_BLACK_DRAGON,
PM_BABY_BLUE_DRAGON,
PM_BABY_GREEN_DRAGON,
PM_BABY_YELLOW_DRAGON,
};
struct obj *feve = mksobj(FIGURINE, TRUE, FALSE);
set_corpsenm(feve, babies[rn2(SIZE(babies))]);
set_material(feve, PLASTIC);
There("is a plastic baby inside the slice of king cake!");
hold_another_object(feve, "It falls to the floor.",
(const char *) 0, (const char *) 0);
}
}
break;
case LUMP_OF_ROYAL_JELLY:
/* This stuff seems to be VERY healthy! */
gainstr(otmp, 1, TRUE); /* will -1 if cursed */
Expand Down
3 changes: 2 additions & 1 deletion src/mkobj.c
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,8 @@ mksobj(int otyp, boolean init, boolean artif)
/* fruitadd requires a modifiable string */
char foodbuf[BUFSZ];
Strcpy(foodbuf, foods[rn2(idx)]);
otmp->spe = fruitadd(foodbuf, NULL);
/* holiday fruits have negative spe */
otmp->spe = -fruitadd(foodbuf, NULL);
}
}
flags.made_fruit = TRUE;
Expand Down
2 changes: 1 addition & 1 deletion src/objnam.c
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ xname_flags(
case FOOD_CLASS:
/* we could include partly-eaten-hack on fruit but don't need to */
if (typ == SLIME_MOLD) {
struct fruit *f = fruit_from_indx(obj->spe);
struct fruit *f = fruit_from_indx(fruit_id(obj));

if (!f) {
impossible("Bad fruit #%d?", obj->spe);
Expand Down
2 changes: 1 addition & 1 deletion src/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -7172,7 +7172,7 @@ fruitadd(char *str, struct fruit *replace_fruit)
char buf[PL_FSIZ], altname[PL_FSIZ];
boolean user_specified = (str == g.pl_fruit);
/* if not user-specified, then it's a fruit name for a fruit on
* a bones level or from orctown raider's loot...
* a bones level, a holiday food, or from orctown raider's loot...
*/

/* Note: every fruit has an id (kept in obj->spe) of at least 1;
Expand Down
11 changes: 8 additions & 3 deletions src/restore.c
Original file line number Diff line number Diff line change
Expand Up @@ -507,13 +507,18 @@ ghostfruit(register struct obj* otmp)
register struct fruit *oldf;

for (oldf = g.oldfruit; oldf; oldf = oldf->nextf)
if (oldf->fid == otmp->spe)
if (oldf->fid == fruit_id(otmp))
break;

if (!oldf)
if (!oldf) {
impossible("no old fruit?");
else
} else {
boolean holiday_food = is_holiday_fruit(otmp);
otmp->spe = fruitadd(oldf->fname, (struct fruit *) 0);
if (holiday_food) {
otmp->spe = -(otmp->spe);
}
}
}

#ifdef SYSCF
Expand Down