Split sitting code into smaller parts
Split sitting on a throne and laying an egg into their own functions. No changes to behaviour.
This commit is contained in:
@@ -6,6 +6,8 @@
|
|||||||
#include "hack.h"
|
#include "hack.h"
|
||||||
#include "artifact.h"
|
#include "artifact.h"
|
||||||
|
|
||||||
|
static void throne_sit_effect(void);
|
||||||
|
static int lay_an_egg(void);
|
||||||
|
|
||||||
/* take away the hero's money */
|
/* take away the hero's money */
|
||||||
void
|
void
|
||||||
@@ -30,6 +32,205 @@ take_gold(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* maybe do something when hero sits on a throne */
|
||||||
|
static void
|
||||||
|
throne_sit_effect(void)
|
||||||
|
{
|
||||||
|
if (rnd(6) > 4) {
|
||||||
|
switch (rnd(13)) {
|
||||||
|
case 1:
|
||||||
|
(void) adjattrib(rn2(A_MAX), -rn1(4, 3), FALSE);
|
||||||
|
losehp(rnd(10), "cursed throne", KILLED_BY_AN);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
(void) adjattrib(rn2(A_MAX), 1, FALSE);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
pline("A%s electric shock shoots through your body!",
|
||||||
|
(Shock_resistance) ? "n" : " massive");
|
||||||
|
losehp(Shock_resistance ? rnd(6) : rnd(30), "electric chair",
|
||||||
|
KILLED_BY_AN);
|
||||||
|
exercise(A_CON, FALSE);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
You_feel("much, much better!");
|
||||||
|
if (Upolyd) {
|
||||||
|
if (u.mh >= (u.mhmax - 5))
|
||||||
|
u.mhmax += 4;
|
||||||
|
u.mh = u.mhmax;
|
||||||
|
}
|
||||||
|
if (u.uhp >= (u.uhpmax - 5)) {
|
||||||
|
u.uhpmax += 4;
|
||||||
|
if (u.uhpmax > u.uhppeak)
|
||||||
|
u.uhppeak = u.uhpmax;
|
||||||
|
}
|
||||||
|
u.uhp = u.uhpmax;
|
||||||
|
u.ucreamed = 0;
|
||||||
|
make_blinded(0L, TRUE);
|
||||||
|
make_sick(0L, (char *) 0, FALSE, SICK_ALL);
|
||||||
|
heal_legs(0);
|
||||||
|
g.context.botl = 1;
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
take_gold();
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
if (u.uluck + rn2(5) < 0) {
|
||||||
|
You_feel("your luck is changing.");
|
||||||
|
change_luck(1);
|
||||||
|
} else
|
||||||
|
makewish();
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
{
|
||||||
|
int cnt = rnd(10);
|
||||||
|
|
||||||
|
/* Magical voice not affected by deafness */
|
||||||
|
pline("A voice echoes:");
|
||||||
|
verbalize("Thine audience hath been summoned, %s!",
|
||||||
|
flags.female ? "Dame" : "Sire");
|
||||||
|
while (cnt--)
|
||||||
|
(void) makemon(courtmon(), u.ux, u.uy, NO_MM_FLAGS);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 8:
|
||||||
|
/* Magical voice not affected by deafness */
|
||||||
|
pline("A voice echoes:");
|
||||||
|
verbalize("By thine Imperious order, %s...",
|
||||||
|
flags.female ? "Dame" : "Sire");
|
||||||
|
do_genocide(5); /* REALLY|ONTHRONE, see do_genocide() */
|
||||||
|
break;
|
||||||
|
case 9:
|
||||||
|
/* Magical voice not affected by deafness */
|
||||||
|
pline("A voice echoes:");
|
||||||
|
verbalize(
|
||||||
|
"A curse upon thee for sitting upon this most holy throne!");
|
||||||
|
if (Luck > 0) {
|
||||||
|
make_blinded(Blinded + rn1(100, 250), TRUE);
|
||||||
|
change_luck((Luck > 1) ? -rnd(2) : -1);
|
||||||
|
} else
|
||||||
|
rndcurse();
|
||||||
|
break;
|
||||||
|
case 10:
|
||||||
|
if (Luck < 0 || (HSee_invisible & INTRINSIC)) {
|
||||||
|
if (g.level.flags.nommap) {
|
||||||
|
pline("A terrible drone fills your head!");
|
||||||
|
make_confused((HConfusion & TIMEOUT) + (long) rnd(30),
|
||||||
|
FALSE);
|
||||||
|
} else {
|
||||||
|
pline("An image forms in your mind.");
|
||||||
|
do_mapping();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* avoid "vision clears" if hero can't see */
|
||||||
|
if (!Blind) {
|
||||||
|
Your("vision becomes clear.");
|
||||||
|
} else {
|
||||||
|
int num_of_eyes = eyecount(g.youmonst.data);
|
||||||
|
const char *eye = body_part(EYE);
|
||||||
|
|
||||||
|
/* note: 1 eye case won't actually happen--can't
|
||||||
|
sit on throne when poly'd into always-levitating
|
||||||
|
floating eye and can't polymorph into Cyclops */
|
||||||
|
switch (num_of_eyes) { /* 2, 1, or 0 */
|
||||||
|
default:
|
||||||
|
case 2: /* more than 1 eye */
|
||||||
|
eye = makeplural(eye);
|
||||||
|
/*FALLTHRU*/
|
||||||
|
case 1: /* one eye (Cyclops, floating eye) */
|
||||||
|
Your("%s %s...", eye, vtense(eye, "tingle"));
|
||||||
|
break;
|
||||||
|
case 0: /* no eyes */
|
||||||
|
You("have a very strange feeling in your %s.",
|
||||||
|
body_part(HEAD));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
HSee_invisible |= FROMOUTSIDE;
|
||||||
|
newsym(u.ux, u.uy);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 11:
|
||||||
|
if (Luck < 0) {
|
||||||
|
You_feel("threatened.");
|
||||||
|
aggravate();
|
||||||
|
} else {
|
||||||
|
You_feel("a wrenching sensation.");
|
||||||
|
tele(); /* teleport him */
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 12:
|
||||||
|
You("are granted an insight!");
|
||||||
|
if (g.invent) {
|
||||||
|
/* rn2(5) agrees w/seffects() */
|
||||||
|
identify_pack(rn2(5), FALSE);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 13:
|
||||||
|
Your("mind turns into a pretzel!");
|
||||||
|
make_confused((HConfusion & TIMEOUT) + (long) rn1(7, 16),
|
||||||
|
FALSE);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
impossible("throne effect");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (is_prince(g.youmonst.data) || u.uevent.uhand_of_elbereth)
|
||||||
|
You_feel("very comfortable here.");
|
||||||
|
else
|
||||||
|
You_feel("somehow out of place...");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!rn2(3) && IS_THRONE(levl[u.ux][u.uy].typ)) {
|
||||||
|
/* may have teleported */
|
||||||
|
levl[u.ux][u.uy].typ = ROOM, levl[u.ux][u.uy].flags = 0;
|
||||||
|
pline_The("throne vanishes in a puff of logic.");
|
||||||
|
newsym(u.ux, u.uy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* hero lays an egg */
|
||||||
|
static int
|
||||||
|
lay_an_egg(void)
|
||||||
|
{
|
||||||
|
struct obj *uegg;
|
||||||
|
|
||||||
|
if (!flags.female) {
|
||||||
|
pline("%s can't lay eggs!",
|
||||||
|
Hallucination
|
||||||
|
? "You may think you are a platypus, but a male still"
|
||||||
|
: "Males");
|
||||||
|
return ECMD_OK;
|
||||||
|
} else if (u.uhunger < (int) objects[EGG].oc_nutrition) {
|
||||||
|
You("don't have enough energy to lay an egg.");
|
||||||
|
return ECMD_OK;
|
||||||
|
} else if (eggs_in_water(g.youmonst.data)) {
|
||||||
|
if (!(Underwater || Is_waterlevel(&u.uz))) {
|
||||||
|
pline("A splash tetra you are not.");
|
||||||
|
return ECMD_OK;
|
||||||
|
}
|
||||||
|
if (Upolyd
|
||||||
|
&& (g.youmonst.data == &mons[PM_GIANT_EEL]
|
||||||
|
|| g.youmonst.data == &mons[PM_ELECTRIC_EEL])) {
|
||||||
|
You("yearn for the Sargasso Sea.");
|
||||||
|
return ECMD_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
uegg = mksobj(EGG, FALSE, FALSE);
|
||||||
|
uegg->spe = 1;
|
||||||
|
uegg->quan = 1L;
|
||||||
|
uegg->owt = weight(uegg);
|
||||||
|
/* this sets hatch timers if appropriate */
|
||||||
|
set_corpsenm(uegg, egg_type_from_parent(u.umonnum, FALSE));
|
||||||
|
uegg->known = uegg->dknown = 1;
|
||||||
|
You("%s an egg.", eggs_in_water(g.youmonst.data) ? "spawn" : "lay");
|
||||||
|
dropy(uegg);
|
||||||
|
stackobj(uegg);
|
||||||
|
morehungry((int) objects[EGG].oc_nutrition);
|
||||||
|
return ECMD_TIME;
|
||||||
|
}
|
||||||
|
|
||||||
/* #sit command */
|
/* #sit command */
|
||||||
int
|
int
|
||||||
dosit(void)
|
dosit(void)
|
||||||
@@ -163,193 +364,9 @@ dosit(void)
|
|||||||
You(sit_message, "drawbridge");
|
You(sit_message, "drawbridge");
|
||||||
} else if (IS_THRONE(typ)) {
|
} else if (IS_THRONE(typ)) {
|
||||||
You(sit_message, defsyms[S_throne].explanation);
|
You(sit_message, defsyms[S_throne].explanation);
|
||||||
if (rnd(6) > 4) {
|
throne_sit_effect();
|
||||||
switch (rnd(13)) {
|
|
||||||
case 1:
|
|
||||||
(void) adjattrib(rn2(A_MAX), -rn1(4, 3), FALSE);
|
|
||||||
losehp(rnd(10), "cursed throne", KILLED_BY_AN);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
(void) adjattrib(rn2(A_MAX), 1, FALSE);
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
pline("A%s electric shock shoots through your body!",
|
|
||||||
(Shock_resistance) ? "n" : " massive");
|
|
||||||
losehp(Shock_resistance ? rnd(6) : rnd(30), "electric chair",
|
|
||||||
KILLED_BY_AN);
|
|
||||||
exercise(A_CON, FALSE);
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
You_feel("much, much better!");
|
|
||||||
if (Upolyd) {
|
|
||||||
if (u.mh >= (u.mhmax - 5))
|
|
||||||
u.mhmax += 4;
|
|
||||||
u.mh = u.mhmax;
|
|
||||||
}
|
|
||||||
if (u.uhp >= (u.uhpmax - 5)) {
|
|
||||||
u.uhpmax += 4;
|
|
||||||
if (u.uhpmax > u.uhppeak)
|
|
||||||
u.uhppeak = u.uhpmax;
|
|
||||||
}
|
|
||||||
u.uhp = u.uhpmax;
|
|
||||||
u.ucreamed = 0;
|
|
||||||
make_blinded(0L, TRUE);
|
|
||||||
make_sick(0L, (char *) 0, FALSE, SICK_ALL);
|
|
||||||
heal_legs(0);
|
|
||||||
g.context.botl = 1;
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
take_gold();
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
if (u.uluck + rn2(5) < 0) {
|
|
||||||
You_feel("your luck is changing.");
|
|
||||||
change_luck(1);
|
|
||||||
} else
|
|
||||||
makewish();
|
|
||||||
break;
|
|
||||||
case 7:
|
|
||||||
{
|
|
||||||
int cnt = rnd(10);
|
|
||||||
|
|
||||||
/* Magical voice not affected by deafness */
|
|
||||||
pline("A voice echoes:");
|
|
||||||
verbalize("Thine audience hath been summoned, %s!",
|
|
||||||
flags.female ? "Dame" : "Sire");
|
|
||||||
while (cnt--)
|
|
||||||
(void) makemon(courtmon(), u.ux, u.uy, NO_MM_FLAGS);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 8:
|
|
||||||
/* Magical voice not affected by deafness */
|
|
||||||
pline("A voice echoes:");
|
|
||||||
verbalize("By thine Imperious order, %s...",
|
|
||||||
flags.female ? "Dame" : "Sire");
|
|
||||||
do_genocide(5); /* REALLY|ONTHRONE, see do_genocide() */
|
|
||||||
break;
|
|
||||||
case 9:
|
|
||||||
/* Magical voice not affected by deafness */
|
|
||||||
pline("A voice echoes:");
|
|
||||||
verbalize(
|
|
||||||
"A curse upon thee for sitting upon this most holy throne!");
|
|
||||||
if (Luck > 0) {
|
|
||||||
make_blinded(Blinded + rn1(100, 250), TRUE);
|
|
||||||
change_luck((Luck > 1) ? -rnd(2) : -1);
|
|
||||||
} else
|
|
||||||
rndcurse();
|
|
||||||
break;
|
|
||||||
case 10:
|
|
||||||
if (Luck < 0 || (HSee_invisible & INTRINSIC)) {
|
|
||||||
if (g.level.flags.nommap) {
|
|
||||||
pline("A terrible drone fills your head!");
|
|
||||||
make_confused((HConfusion & TIMEOUT) + (long) rnd(30),
|
|
||||||
FALSE);
|
|
||||||
} else {
|
|
||||||
pline("An image forms in your mind.");
|
|
||||||
do_mapping();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
/* avoid "vision clears" if hero can't see */
|
|
||||||
if (!Blind) {
|
|
||||||
Your("vision becomes clear.");
|
|
||||||
} else {
|
|
||||||
int num_of_eyes = eyecount(g.youmonst.data);
|
|
||||||
const char *eye = body_part(EYE);
|
|
||||||
|
|
||||||
/* note: 1 eye case won't actually happen--can't
|
|
||||||
sit on throne when poly'd into always-levitating
|
|
||||||
floating eye and can't polymorph into Cyclops */
|
|
||||||
switch (num_of_eyes) { /* 2, 1, or 0 */
|
|
||||||
default:
|
|
||||||
case 2: /* more than 1 eye */
|
|
||||||
eye = makeplural(eye);
|
|
||||||
/*FALLTHRU*/
|
|
||||||
case 1: /* one eye (Cyclops, floating eye) */
|
|
||||||
Your("%s %s...", eye, vtense(eye, "tingle"));
|
|
||||||
break;
|
|
||||||
case 0: /* no eyes */
|
|
||||||
You("have a very strange feeling in your %s.",
|
|
||||||
body_part(HEAD));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
HSee_invisible |= FROMOUTSIDE;
|
|
||||||
newsym(u.ux, u.uy);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 11:
|
|
||||||
if (Luck < 0) {
|
|
||||||
You_feel("threatened.");
|
|
||||||
aggravate();
|
|
||||||
} else {
|
|
||||||
You_feel("a wrenching sensation.");
|
|
||||||
tele(); /* teleport him */
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 12:
|
|
||||||
You("are granted an insight!");
|
|
||||||
if (g.invent) {
|
|
||||||
/* rn2(5) agrees w/seffects() */
|
|
||||||
identify_pack(rn2(5), FALSE);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 13:
|
|
||||||
Your("mind turns into a pretzel!");
|
|
||||||
make_confused((HConfusion & TIMEOUT) + (long) rn1(7, 16),
|
|
||||||
FALSE);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
impossible("throne effect");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (is_prince(g.youmonst.data) || u.uevent.uhand_of_elbereth)
|
|
||||||
You_feel("very comfortable here.");
|
|
||||||
else
|
|
||||||
You_feel("somehow out of place...");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!rn2(3) && IS_THRONE(levl[u.ux][u.uy].typ)) {
|
|
||||||
/* may have teleported */
|
|
||||||
levl[u.ux][u.uy].typ = ROOM, levl[u.ux][u.uy].flags = 0;
|
|
||||||
pline_The("throne vanishes in a puff of logic.");
|
|
||||||
newsym(u.ux, u.uy);
|
|
||||||
}
|
|
||||||
} else if (lays_eggs(g.youmonst.data)) {
|
} else if (lays_eggs(g.youmonst.data)) {
|
||||||
struct obj *uegg;
|
return lay_an_egg();
|
||||||
|
|
||||||
if (!flags.female) {
|
|
||||||
pline("%s can't lay eggs!",
|
|
||||||
Hallucination
|
|
||||||
? "You may think you are a platypus, but a male still"
|
|
||||||
: "Males");
|
|
||||||
return ECMD_OK;
|
|
||||||
} else if (u.uhunger < (int) objects[EGG].oc_nutrition) {
|
|
||||||
You("don't have enough energy to lay an egg.");
|
|
||||||
return ECMD_OK;
|
|
||||||
} else if (eggs_in_water(g.youmonst.data)) {
|
|
||||||
if (!(Underwater || Is_waterlevel(&u.uz))) {
|
|
||||||
pline("A splash tetra you are not.");
|
|
||||||
return ECMD_OK;
|
|
||||||
}
|
|
||||||
if (Upolyd
|
|
||||||
&& (g.youmonst.data == &mons[PM_GIANT_EEL]
|
|
||||||
|| g.youmonst.data == &mons[PM_ELECTRIC_EEL])) {
|
|
||||||
You("yearn for the Sargasso Sea.");
|
|
||||||
return ECMD_OK;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
uegg = mksobj(EGG, FALSE, FALSE);
|
|
||||||
uegg->spe = 1;
|
|
||||||
uegg->quan = 1L;
|
|
||||||
uegg->owt = weight(uegg);
|
|
||||||
/* this sets hatch timers if appropriate */
|
|
||||||
set_corpsenm(uegg, egg_type_from_parent(u.umonnum, FALSE));
|
|
||||||
uegg->known = uegg->dknown = 1;
|
|
||||||
You("%s an egg.", eggs_in_water(g.youmonst.data) ? "spawn" : "lay");
|
|
||||||
dropy(uegg);
|
|
||||||
stackobj(uegg);
|
|
||||||
morehungry((int) objects[EGG].oc_nutrition);
|
|
||||||
} else {
|
} else {
|
||||||
pline("Having fun sitting on the %s?", surface(u.ux, u.uy));
|
pline("Having fun sitting on the %s?", surface(u.ux, u.uy));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user