Moved pray.c globals to instance_globals.

This commit is contained in:
Bart House
2018-11-23 16:50:23 -08:00
parent 1c1e5b7e36
commit 74caa8d8e4
11 changed files with 88 additions and 105 deletions

View File

@@ -47,11 +47,6 @@ static const char *godvoices[] = {
"booms out", "thunders", "rings out", "booms",
};
/* values calculated when prayer starts, and used when completed */
static aligntyp p_aligntyp;
static int p_trouble;
static int p_type; /* (-1)-3: (-1)=really naughty, 3=really good */
#define PIOUS 20
#define DEVOUT 14
#define FERVENT 9
@@ -907,7 +902,7 @@ aligntyp g_align;
: Hallucination ? "full" : "satisfied");
/* not your deity */
if (on_altar() && p_aligntyp != u.ualign.type) {
if (on_altar() && g.p_aligntyp != u.ualign.type) {
adjalign(-1);
return;
} else if (u.ualign.record < 2 && trouble <= 0)
@@ -929,7 +924,7 @@ aligntyp g_align;
*/
if (!trouble && u.ualign.record >= DEVOUT) {
/* if hero was in trouble, but got better, no special favor */
if (p_trouble == 0)
if (g.p_trouble == 0)
pat_on_head = 1;
} else {
int action, prayer_luck;
@@ -1768,47 +1763,47 @@ boolean praying; /* false means no messages should be given */
{
int alignment;
p_aligntyp = on_altar() ? a_align(u.ux, u.uy) : u.ualign.type;
p_trouble = in_trouble();
g.p_aligntyp = on_altar() ? a_align(u.ux, u.uy) : u.ualign.type;
g.p_trouble = in_trouble();
if (is_demon(youmonst.data) && (p_aligntyp != A_CHAOTIC)) {
if (is_demon(youmonst.data) && (g.p_aligntyp != A_CHAOTIC)) {
if (praying)
pline_The("very idea of praying to a %s god is repugnant to you.",
p_aligntyp ? "lawful" : "neutral");
g.p_aligntyp ? "lawful" : "neutral");
return FALSE;
}
if (praying)
You("begin praying to %s.", align_gname(p_aligntyp));
You("begin praying to %s.", align_gname(g.p_aligntyp));
if (u.ualign.type && u.ualign.type == -p_aligntyp)
if (u.ualign.type && u.ualign.type == -g.p_aligntyp)
alignment = -u.ualign.record; /* Opposite alignment altar */
else if (u.ualign.type != p_aligntyp)
else if (u.ualign.type != g.p_aligntyp)
alignment = u.ualign.record / 2; /* Different alignment altar */
else
alignment = u.ualign.record;
if ((p_trouble > 0) ? (u.ublesscnt > 200) /* big trouble */
: (p_trouble < 0) ? (u.ublesscnt > 100) /* minor difficulties */
if ((g.p_trouble > 0) ? (u.ublesscnt > 200) /* big trouble */
: (g.p_trouble < 0) ? (u.ublesscnt > 100) /* minor difficulties */
: (u.ublesscnt > 0)) /* not in trouble */
p_type = 0; /* too soon... */
g.p_type = 0; /* too soon... */
else if ((int) Luck < 0 || u.ugangr || alignment < 0)
p_type = 1; /* too naughty... */
g.p_type = 1; /* too naughty... */
else /* alignment >= 0 */ {
if (on_altar() && u.ualign.type != p_aligntyp)
p_type = 2;
if (on_altar() && u.ualign.type != g.p_aligntyp)
g.p_type = 2;
else
p_type = 3;
g.p_type = 3;
}
if (is_undead(youmonst.data) && !Inhell
&& (p_aligntyp == A_LAWFUL || (p_aligntyp == A_NEUTRAL && !rn2(10))))
p_type = -1;
&& (g.p_aligntyp == A_LAWFUL || (g.p_aligntyp == A_NEUTRAL && !rn2(10))))
g.p_type = -1;
/* Note: when !praying, the random factor for neutrals makes the
return value a non-deterministic approximation for enlightenment.
This case should be uncommon enough to live with... */
return !praying ? (boolean) (p_type == 3 && !Inhell) : TRUE;
return !praying ? (boolean) (g.p_type == 3 && !Inhell) : TRUE;
}
/* #pray commmand */
@@ -1825,7 +1820,7 @@ dopray()
if (!can_pray(TRUE))
return 0;
if (wizard && p_type >= 0) {
if (wizard && g.p_type >= 0) {
if (yn("Force the gods to be pleased?") == 'y') {
u.ublesscnt = 0;
if (u.uluck < 0)
@@ -1833,8 +1828,8 @@ dopray()
if (u.ualign.record <= 0)
u.ualign.record = 1;
u.ugangr = 0;
if (p_type < 2)
p_type = 3;
if (g.p_type < 2)
g.p_type = 3;
}
}
nomul(-3);
@@ -1842,7 +1837,7 @@ dopray()
nomovemsg = "You finish your prayer.";
afternmv = prayer_done;
if (p_type == 3 && !Inhell) {
if (g.p_type == 3 && !Inhell) {
/* if you've been true to your god you can't die while you pray */
if (!Blind)
You("are surrounded by a shimmering light.");
@@ -1855,10 +1850,10 @@ dopray()
STATIC_PTR int
prayer_done() /* M. Stephenson (1.0.3b) */
{
aligntyp alignment = p_aligntyp;
aligntyp alignment = g.p_aligntyp;
u.uinvulnerable = FALSE;
if (p_type == -1) {
if (g.p_type == -1) {
godvoice(alignment,
(alignment == A_LAWFUL)
? "Vile creature, thou durst call upon me?"
@@ -1880,17 +1875,17 @@ prayer_done() /* M. Stephenson (1.0.3b) */
return 0;
}
if (p_type == 0) {
if (g.p_type == 0) {
if (on_altar() && u.ualign.type != alignment)
(void) water_prayer(FALSE);
u.ublesscnt += rnz(250);
change_luck(-3);
gods_upset(u.ualign.type);
} else if (p_type == 1) {
} else if (g.p_type == 1) {
if (on_altar() && u.ualign.type != alignment)
(void) water_prayer(FALSE);
angrygods(u.ualign.type); /* naughty */
} else if (p_type == 2) {
} else if (g.p_type == 2) {
if (water_prayer(FALSE)) {
/* attempted water prayer on a non-coaligned altar */
u.ublesscnt += rnz(250);