MCPcopy Create free account
hub / github.com/NetHack/NetHack / bestow_artifact

Function bestow_artifact

src/pray.c:1780–1836  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1778}
1779
1780staticfn int
1781bestow_artifact(uchar max_giftvalue)
1782{
1783 int nartifacts = nartifact_exist();
1784 boolean do_bestow = u.ulevel > 2 && u.uluck >= 0;
1785 if (do_bestow) {
1786 /* you were already in pretty good standing */
1787 /* The player can gain an artifact */
1788 /* The chance goes down as the number of artifacts goes up */
1789 if (wizard)
1790 do_bestow = y_n("Gift an artifact?") == 'y';
1791 else
1792 do_bestow = !rn2(6 + (2 * u.ugifts * nartifacts));
1793 }
1794
1795 if (do_bestow) {
1796 struct obj *otmp;
1797 /* mk_artifact() with NULL obj and a_align() arg can return NULL */
1798 otmp = mk_artifact((struct obj *) 0, a_align(u.ux, u.uy),
1799 max_giftvalue, TRUE);
1800 if (otmp) {
1801 char buf[BUFSZ];
1802
1803 artifact_origin(otmp, ONAME_GIFT | ONAME_KNOW_ARTI);
1804 if (otmp->spe < 0)
1805 otmp->spe = 0;
1806 if (otmp->cursed)
1807 uncurse(otmp);
1808 otmp->oerodeproof = TRUE;
1809 Strcpy(buf, (Hallucination ? "a doodad"
1810 : Blind ? "an object"
1811 : ansimpleoname(otmp)));
1812 if (!Blind)
1813 Sprintf(eos(buf), " named %s",
1814 bare_artifactname(otmp));
1815 at_your_feet(upstart(buf));
1816 dropy(otmp);
1817 godvoice(u.ualign.type, "Use my gift wisely!");
1818 u.ugifts++;
1819 u.ublesscnt = rnz(300 + (50 * nartifacts));
1820 exercise(A_WIS, TRUE);
1821 livelog_printf (LL_DIVINEGIFT | LL_ARTIFACT,
1822 "was bestowed with %s by %s",
1823 artiname(otmp->oartifact),
1824 align_gname(u.ualign.type));
1825 /* make sure we can use this weapon */
1826 unrestrict_weapon_skill(weapon_type(otmp));
1827 if (!Hallucination && !Blind) {
1828 observe_object(otmp);
1829 makeknown(otmp->otyp);
1830 discover_artifact(otmp->oartifact);
1831 }
1832 return TRUE;
1833 }
1834 }
1835 return FALSE;
1836}
1837

Callers 1

offer_corpseFunction · 0.85

Calls 15

nartifact_existFunction · 0.85
rn2Function · 0.85
mk_artifactFunction · 0.85
artifact_originFunction · 0.85
uncurseFunction · 0.85
ansimpleonameFunction · 0.85
eosFunction · 0.85
bare_artifactnameFunction · 0.85
at_your_feetFunction · 0.85
upstartFunction · 0.85
dropyFunction · 0.85
godvoiceFunction · 0.85

Tested by

no test coverage detected