MCPcopy Index your code
hub / github.com/NetHack/NetHack / pleased

Function pleased

src/pray.c:1070–1381  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1068}
1069
1070staticfn void
1071pleased(aligntyp g_align)
1072{
1073 /* don't use p_trouble, worst trouble may get fixed while praying */
1074 int trouble = in_trouble(); /* what's your worst difficulty? */
1075 int pat_on_head = 0, kick_on_butt;
1076
1077 You_feel("that %s is %s.", align_gname(g_align),
1078 (u.ualign.record >= DEVOUT)
1079 ? Hallucination ? "pleased as punch" : "well-pleased"
1080 : (u.ualign.record >= STRIDENT)
1081 ? Hallucination ? "ticklish" : "pleased"
1082 : Hallucination ? "full" : "satisfied");
1083
1084 /* not your deity */
1085 if (on_altar() && gp.p_aligntyp != u.ualign.type) {
1086 adjalign(-1);
1087 return;
1088 } else if (u.ualign.record < 2 && trouble <= 0)
1089 adjalign(1);
1090
1091 /*
1092 * Depending on your luck & align level, the god you prayed to will:
1093 * - fix your worst problem if it's major;
1094 * - fix all your major problems;
1095 * - fix your worst problem if it's minor;
1096 * - fix all of your problems;
1097 * - do you a gratuitous favor.
1098 *
1099 * If you make it to the last category, you roll randomly again
1100 * to see what they do for you.
1101 *
1102 * If your luck is at least 0, then you are guaranteed rescued from
1103 * your worst major problem.
1104 */
1105 if (!trouble && u.ualign.record >= DEVOUT) {
1106 /* if hero was in trouble, but got better, no special favor */
1107 if (gp.p_trouble == 0)
1108 pat_on_head = 1;
1109 } else {
1110 int action, prayer_luck;
1111 int tryct = 0;
1112
1113 /* Negative luck is normally impossible here (can_pray() forces
1114 prayer failure in that situation), but it's possible for
1115 Luck to drop during the period of prayer occupation and
1116 become negative by the time we get here. [Reported case
1117 was lawful character whose stinking cloud caused a delayed
1118 killing of a peaceful human, triggering the "murderer"
1119 penalty while successful prayer was in progress. It could
1120 also happen due to inconvenient timing on Friday 13th, but
1121 the magnitude there (-1) isn't big enough to cause trouble.]
1122 We don't bother remembering start-of-prayer luck, just make
1123 sure it's at least -1 so that Luck+2 is big enough to avoid
1124 a divide by zero crash when generating a random number. */
1125 prayer_luck = max(Luck, -1); /* => (prayer_luck + 2 > 0) */
1126 action = rn1(prayer_luck + (on_altar() ? 3 + on_shrine() : 2), 1);
1127 if (!on_altar())

Callers 1

prayer_doneFunction · 0.85

Calls 15

in_troubleFunction · 0.85
You_feelFunction · 0.85
align_gnameFunction · 0.85
adjalignFunction · 0.85
rnlFunction · 0.85
fix_worst_troubleFunction · 0.85
rn2Function · 0.85
weldedFunction · 0.85
otenseFunction · 0.85
Yobjnam2Function · 0.85
hcolorFunction · 0.85
u_gnameFunction · 0.85

Tested by

no test coverage detected