pull request #965 - split offering the Amulet

into a separate routine

Pull request from argrath:  move the code used when offering the
Amulet of Yendor on a high altar out of dosacrifice() into a new
routine.

Closes #965
This commit is contained in:
PatR
2023-01-26 08:28:27 -08:00

View File

@@ -22,6 +22,7 @@ static void gods_upset(aligntyp);
static void consume_offering(struct obj *);
static void offer_too_soon(aligntyp);
static void desecrate_high_altar(aligntyp);
static void offer_real_amulet(struct obj *, aligntyp);
static boolean pray_revive(void);
static boolean water_prayer(boolean);
static boolean blocked_boulder(int, int);
@@ -1468,12 +1469,68 @@ desecrate_high_altar(aligntyp altaralign)
god_zaps_you(altaralign);
}
static void
offer_real_amulet(struct obj *otmp, aligntyp altaralign)
{
static NEARDATA const char
cloud_of_smoke[] = "A cloud of %s smoke surrounds you...";
/* The final Test. Did you win? */
if (uamul == otmp)
Amulet_off();
if (carried(otmp))
useup(otmp); /* well, it's gone now */
else
useupf(otmp, 1L);
You("offer the Amulet of Yendor to %s...", a_gname());
if (altaralign == A_NONE) {
/* Moloch's high altar */
if (u.ualign.record > -99)
u.ualign.record = -99;
pline(
"An invisible choir chants, and you are bathed in darkness...");
/*[apparently shrug/snarl can be sensed without being seen]*/
pline("%s shrugs and retains dominion over %s,", Moloch,
u_gname());
pline("then mercilessly snuffs out your life.");
Sprintf(gk.killer.name, "%s indifference", s_suffix(Moloch));
gk.killer.format = KILLED_BY;
done(DIED);
/* life-saved (or declined to die in wizard/explore mode) */
pline("%s snarls and tries again...", Moloch);
fry_by_god(A_NONE, TRUE); /* wrath of Moloch */
/* declined to die in wizard or explore mode */
pline(cloud_of_smoke, hcolor(NH_BLACK));
done(ESCAPED);
} else if (u.ualign.type != altaralign) {
/* And the opposing team picks you up and
carries you off on their shoulders */
adjalign(-99);
pline("%s accepts your gift, and gains dominion over %s...",
a_gname(), u_gname());
pline("%s is enraged...", u_gname());
pline("Fortunately, %s permits you to live...", a_gname());
pline(cloud_of_smoke, hcolor(NH_ORANGE));
done(ESCAPED);
} else { /* super big win */
u.uevent.ascended = 1;
adjalign(10);
pline(
"An invisible choir sings, and you are bathed in radiance...");
godvoice(altaralign, "Mortal, thou hast done well!");
display_nhwindow(WIN_MESSAGE, FALSE);
verbalize(
"In return for thy service, I grant thee the gift of Immortality!");
You("ascend to the status of Demigod%s...",
flags.female ? "dess" : "");
done(ASCENDED);
}
}
/* the #offer command - sacrifice something to the gods */
int
dosacrifice(void)
{
static NEARDATA const char
cloud_of_smoke[] = "A cloud of %s smoke surrounds you...";
register struct obj *otmp;
int value = 0, pm;
boolean highaltar;
@@ -1662,56 +1719,7 @@ dosacrifice(void)
offer_too_soon(altaralign);
return ECMD_TIME;
} else {
/* The final Test. Did you win? */
if (uamul == otmp)
Amulet_off();
if (carried(otmp))
useup(otmp); /* well, it's gone now */
else
useupf(otmp, 1L);
You("offer the Amulet of Yendor to %s...", a_gname());
if (altaralign == A_NONE) {
/* Moloch's high altar */
if (u.ualign.record > -99)
u.ualign.record = -99;
pline(
"An invisible choir chants, and you are bathed in darkness...");
/*[apparently shrug/snarl can be sensed without being seen]*/
pline("%s shrugs and retains dominion over %s,", Moloch,
u_gname());
pline("then mercilessly snuffs out your life.");
Sprintf(gk.killer.name, "%s indifference", s_suffix(Moloch));
gk.killer.format = KILLED_BY;
done(DIED);
/* life-saved (or declined to die in wizard/explore mode) */
pline("%s snarls and tries again...", Moloch);
fry_by_god(A_NONE, TRUE); /* wrath of Moloch */
/* declined to die in wizard or explore mode */
pline(cloud_of_smoke, hcolor(NH_BLACK));
done(ESCAPED);
} else if (u.ualign.type != altaralign) {
/* And the opposing team picks you up and
carries you off on their shoulders */
adjalign(-99);
pline("%s accepts your gift, and gains dominion over %s...",
a_gname(), u_gname());
pline("%s is enraged...", u_gname());
pline("Fortunately, %s permits you to live...", a_gname());
pline(cloud_of_smoke, hcolor(NH_ORANGE));
done(ESCAPED);
} else { /* super big win */
u.uevent.ascended = 1;
adjalign(10);
pline(
"An invisible choir sings, and you are bathed in radiance...");
godvoice(altaralign, "Mortal, thou hast done well!");
display_nhwindow(WIN_MESSAGE, FALSE);
verbalize(
"In return for thy service, I grant thee the gift of Immortality!");
You("ascend to the status of Demigod%s...",
flags.female ? "dess" : "");
done(ASCENDED);
}
offer_real_amulet(otmp, altaralign);
/*NOTREACHED*/
}
} /* real Amulet */