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

Function msummon

src/minion.c:58–195  ·  view source on GitHub ↗

mon summons a monster */

Source from the content-addressed store, hash-verified

56
57/* mon summons a monster */
58int
59msummon(struct monst *mon)
60{
61 struct permonst *ptr;
62 int dtype = NON_PM, cnt = 0, result = 0, census;
63 boolean xlight;
64 aligntyp atyp;
65 struct monst *mtmp;
66
67 if (mon) {
68 ptr = mon->data;
69
70 if (u_wield_art(ART_DEMONBANE) && is_demon(ptr)) {
71 if (canseemon(mon))
72 pline("%s looks puzzled for a moment.", Monnam(mon));
73 return 0;
74 }
75
76 atyp = mon->ispriest ? EPRI(mon)->shralign
77 : mon->isminion ? EMIN(mon)->min_align
78 : (ptr->maligntyp == A_NONE) ? A_NONE
79 : sgn(ptr->maligntyp);
80 } else {
81 ptr = &mons[PM_WIZARD_OF_YENDOR];
82 atyp = (ptr->maligntyp == A_NONE) ? A_NONE : sgn(ptr->maligntyp);
83 }
84
85 if (is_dprince(ptr) || (ptr == &mons[PM_WIZARD_OF_YENDOR])) {
86 dtype = (!rn2(20)) ? dprince(atyp) : (!rn2(4)) ? dlord(atyp)
87 : ndemon(atyp);
88 cnt = ((dtype != NON_PM)
89 && !rn2(4) && is_ndemon(&mons[dtype])) ? 2 : 1;
90 } else if (is_dlord(ptr)) {
91 dtype = (!rn2(50)) ? dprince(atyp) : (!rn2(20)) ? dlord(atyp)
92 : ndemon(atyp);
93 cnt = ((dtype != NON_PM)
94 && !rn2(4) && is_ndemon(&mons[dtype])) ? 2 : 1;
95 } else if (ptr == &mons[PM_BONE_DEVIL]) {
96 dtype = PM_SKELETON;
97 cnt = 1;
98 } else if (is_ndemon(ptr)) {
99 dtype = (!rn2(20)) ? dlord(atyp) : (!rn2(6)) ? ndemon(atyp)
100 : monsndx(ptr);
101 cnt = 1;
102 } else if (is_lminion(mon)) {
103 dtype = (is_lord(ptr) && !rn2(20))
104 ? llord()
105 : (is_lord(ptr) || !rn2(6)) ? lminion() : monsndx(ptr);
106 cnt = ((dtype != NON_PM)
107 && !rn2(4) && !is_lord(&mons[dtype])) ? 2 : 1;
108 } else if (ptr == &mons[PM_ANGEL]) {
109 /* non-lawful angels can also summon */
110 if (!rn2(6)) {
111 switch (atyp) { /* see summon_minion */
112 case A_NEUTRAL:
113 dtype = ROLL_FROM(elementals);
114 break;
115 case A_CHAOTIC:

Callers 3

special_throne_effectFunction · 0.85
nastyFunction · 0.85
summonmuFunction · 0.85

Calls 15

canseemonFunction · 0.85
MonnamFunction · 0.85
sgnFunction · 0.85
rn2Function · 0.85
dprinceFunction · 0.85
dlordFunction · 0.85
ndemonFunction · 0.85
llordFunction · 0.85
lminionFunction · 0.85
monster_censusFunction · 0.85
makemonFunction · 0.85
show_transient_lightFunction · 0.85

Tested by

no test coverage detected