From 32080bc7fd22d62daa44f7ccfa51156d25669c3a Mon Sep 17 00:00:00 2001 From: SHIRAKATA Kentaro Date: Sat, 28 Jan 2023 14:17:45 +0900 Subject: [PATCH] split offering to different alignment alter into a separate function --- src/pray.c | 140 ++++++++++++++++++++++++++++------------------------- 1 file changed, 73 insertions(+), 67 deletions(-) diff --git a/src/pray.c b/src/pray.c index f9839d728..af732faf2 100644 --- a/src/pray.c +++ b/src/pray.c @@ -23,6 +23,7 @@ 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); /* NORETURN */ +static void offer_different_alignment_altar(struct obj *, aligntyp); static boolean pray_revive(void); static boolean water_prayer(boolean); static boolean blocked_boulder(int, int); @@ -1534,6 +1535,76 @@ offer_real_amulet(struct obj *otmp, aligntyp altaralign) /*NOTREACHED*/ } +static void +offer_different_alignment_altar(struct obj *otmp, aligntyp altaralign) +{ + /* Is this a conversion ? */ + /* An unaligned altar in Gehennom will always elicit rejection. */ + if (ugod_is_angry() || (altaralign == A_NONE && Inhell)) { + if (u.ualignbase[A_CURRENT] == u.ualignbase[A_ORIGINAL] + && altaralign != A_NONE) { + You("have a strong feeling that %s is angry...", + u_gname()); + consume_offering(otmp); + pline("%s accepts your allegiance.", a_gname()); + + uchangealign(altaralign, 0); + /* Beware, Conversion is costly */ + change_luck(-3); + u.ublesscnt += 300; + } else { + u.ugangr += 3; + adjalign(-5); + pline("%s rejects your sacrifice!", a_gname()); + godvoice(altaralign, "Suffer, infidel!"); + change_luck(-5); + (void) adjattrib(A_WIS, -2, TRUE); + if (!Inhell) + angrygods(u.ualign.type); + } + } else { + consume_offering(otmp); + You("sense a conflict between %s and %s.", u_gname(), + a_gname()); + if (rn2(8 + u.ulevel) > 5) { + struct monst *pri; + boolean shrine; + + You_feel("the power of %s increase.", u_gname()); + exercise(A_WIS, TRUE); + change_luck(1); + shrine = on_shrine(); + levl[u.ux][u.uy].altarmask = Align2amask(u.ualign.type); + if (shrine) + levl[u.ux][u.uy].altarmask |= AM_SHRINE; + newsym(u.ux, u.uy); /* in case Invisible to self */ + if (!Blind) + pline_The("altar glows %s.", + hcolor((u.ualign.type == A_LAWFUL) + ? NH_WHITE + : u.ualign.type + ? NH_BLACK + : (const char *) "gray")); + + if (rnl(u.ulevel) > 6 && u.ualign.record > 0 + && rnd(u.ualign.record) > (3 * ALIGNLIM) / 4) + summon_minion(altaralign, TRUE); + /* anger priest; test handles bones files */ + if ((pri = findpriest(temple_occupied(u.urooms))) + && !p_coaligned(pri)) + angry_priest(); + } else { + pline("Unluckily, you feel the power of %s decrease.", + u_gname()); + change_luck(-1); + exercise(A_WIS, FALSE); + if (rnl(u.ulevel) > 6 && u.ualign.record > 0 + && rnd(u.ualign.record) > (7 * ALIGNLIM) / 8) + summon_minion(altaralign, TRUE); + } + } +} + /* the #offer command - sacrifice something to the gods */ int dosacrifice(void) @@ -1771,73 +1842,8 @@ dosacrifice(void) /* Sacrificing at an altar of a different alignment */ if (u.ualign.type != altaralign) { - /* Is this a conversion ? */ - /* An unaligned altar in Gehennom will always elicit rejection. */ - if (ugod_is_angry() || (altaralign == A_NONE && Inhell)) { - if (u.ualignbase[A_CURRENT] == u.ualignbase[A_ORIGINAL] - && altaralign != A_NONE) { - You("have a strong feeling that %s is angry...", - u_gname()); - consume_offering(otmp); - pline("%s accepts your allegiance.", a_gname()); - - uchangealign(altaralign, 0); - /* Beware, Conversion is costly */ - change_luck(-3); - u.ublesscnt += 300; - } else { - u.ugangr += 3; - adjalign(-5); - pline("%s rejects your sacrifice!", a_gname()); - godvoice(altaralign, "Suffer, infidel!"); - change_luck(-5); - (void) adjattrib(A_WIS, -2, TRUE); - if (!Inhell) - angrygods(u.ualign.type); - } - return ECMD_TIME; - } else { - consume_offering(otmp); - You("sense a conflict between %s and %s.", u_gname(), - a_gname()); - if (rn2(8 + u.ulevel) > 5) { - struct monst *pri; - boolean shrine; - - You_feel("the power of %s increase.", u_gname()); - exercise(A_WIS, TRUE); - change_luck(1); - shrine = on_shrine(); - levl[u.ux][u.uy].altarmask = Align2amask(u.ualign.type); - if (shrine) - levl[u.ux][u.uy].altarmask |= AM_SHRINE; - newsym(u.ux, u.uy); /* in case Invisible to self */ - if (!Blind) - pline_The("altar glows %s.", - hcolor((u.ualign.type == A_LAWFUL) - ? NH_WHITE - : u.ualign.type - ? NH_BLACK - : (const char *) "gray")); - - if (rnl(u.ulevel) > 6 && u.ualign.record > 0 - && rnd(u.ualign.record) > (3 * ALIGNLIM) / 4) - summon_minion(altaralign, TRUE); - /* anger priest; test handles bones files */ - if ((pri = findpriest(temple_occupied(u.urooms))) - && !p_coaligned(pri)) - angry_priest(); - } else { - pline("Unluckily, you feel the power of %s decrease.", - u_gname()); - change_luck(-1); - exercise(A_WIS, FALSE); - if (rnl(u.ulevel) > 6 && u.ualign.record > 0 - && rnd(u.ualign.record) > (7 * ALIGNLIM) / 8) - summon_minion(altaralign, TRUE); - } - return ECMD_TIME; - } + offer_different_alignment_altar(otmp, altaralign); + return ECMD_TIME; } consume_offering(otmp); -- 2.50.1