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

Function eval_offering

src/pray.c:1898–1956  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1896}
1897
1898staticfn int
1899eval_offering(struct obj *otmp, aligntyp altaralign)
1900{
1901 struct permonst *ptr;
1902 int value;
1903
1904 value = sacrifice_value(otmp);
1905
1906 if (!value)
1907 return 0;
1908
1909 ptr = &mons[otmp->corpsenm];
1910
1911 if (is_undead(ptr)) { /* Not demons--no demon corpses */
1912 /* most undead that leave a corpse yield 'human' (or other race)
1913 corpse so won't get here; the exception is wraith; give the
1914 bonus for wraith to chaotics too because they are sacrificing
1915 something valuable (unless hero refuses to eat such things) */
1916 if (u.ualign.type != A_CHAOTIC
1917 /* reaching this side of the 'or' means hero is chaotic */
1918 || (ptr == &mons[PM_WRAITH] && u.uconduct.unvegetarian))
1919 value += 1;
1920 } else if (is_unicorn(ptr)) {
1921 int unicalign = sgn(ptr->maligntyp);
1922
1923 if (unicalign == altaralign) {
1924 /* When same as altar, always a very bad action.
1925 */
1926 pline("Such an action is an insult to %s!",
1927 (unicalign == A_CHAOTIC) ? "chaos"
1928 : unicalign ? "law" : "balance");
1929 (void) adjattrib(A_WIS, -1, TRUE);
1930 return -1;
1931 } else if (u.ualign.type == altaralign) {
1932 /* When different from altar, and altar is same as yours,
1933 * it's a very good action.
1934 */
1935 if (u.ualign.record < ALIGNLIM)
1936 You_feel("appropriately %s.", align_str(u.ualign.type));
1937 else
1938 You_feel("you are thoroughly on the right path.");
1939 adjalign(5);
1940 value += 3;
1941 } else if (unicalign == u.ualign.type) {
1942 /* When sacrificing unicorn of your alignment to altar not of
1943 * your alignment, your god gets angry and it's a conversion.
1944 */
1945 u.ualign.record = -1;
1946 value = 1;
1947 } else {
1948 /* Otherwise, unicorn's alignment is different from yours
1949 * and different from the altar's. It's an ordinary (well,
1950 * with a bonus) sacrifice on a cross-aligned altar.
1951 */
1952 value += 3;
1953 }
1954 }
1955 return value;

Callers 1

offer_corpseFunction · 0.85

Calls 7

sacrifice_valueFunction · 0.85
sgnFunction · 0.85
adjattribFunction · 0.85
You_feelFunction · 0.85
align_strFunction · 0.85
adjalignFunction · 0.85
plineFunction · 0.70

Tested by

no test coverage detected