mon summons a monster */
| 56 | |
| 57 | /* mon summons a monster */ |
| 58 | int |
| 59 | msummon(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: |
no test coverage detected