Any preliminary checks which may result in the monster being unable to use * the item. Returns 0 if nothing happened, 2 if the monster can't do * anything (i.e. it teleported) and 1 if it's dead. */
| 56 | * anything (i.e. it teleported) and 1 if it's dead. |
| 57 | */ |
| 58 | staticfn int |
| 59 | precheck(struct monst *mon, struct obj *obj) |
| 60 | { |
| 61 | boolean vis; |
| 62 | |
| 63 | if (!obj) |
| 64 | return 0; |
| 65 | vis = cansee(mon->mx, mon->my); |
| 66 | |
| 67 | if (obj->oclass == POTION_CLASS) { |
| 68 | coord cc; |
| 69 | static const char *const empty = "The potion turns out to be empty."; |
| 70 | struct monst *mtmp; |
| 71 | |
| 72 | if (objdescr_is(obj, "milky")) { |
| 73 | if (!(svm.mvitals[PM_GHOST].mvflags & G_GONE) |
| 74 | && !rn2(POTION_OCCUPANT_CHANCE(svm.mvitals[PM_GHOST].born))) { |
| 75 | if (!enexto(&cc, mon->mx, mon->my, &mons[PM_GHOST])) |
| 76 | return 0; |
| 77 | mquaffmsg(mon, obj); |
| 78 | m_useup(mon, obj); |
| 79 | mtmp = makemon(&mons[PM_GHOST], cc.x, cc.y, MM_NOMSG); |
| 80 | if (!mtmp) { |
| 81 | if (vis) |
| 82 | pline1(empty); |
| 83 | } else { |
| 84 | if (vis) { |
| 85 | pline( |
| 86 | "As %s opens the bottle, an enormous %s emerges!", |
| 87 | mon_nam(mon), |
| 88 | Hallucination ? rndmonnam(NULL) |
| 89 | : (const char *) "ghost"); |
| 90 | pline("%s is frightened to death," |
| 91 | " and unable to move.", |
| 92 | Monnam(mon)); |
| 93 | } |
| 94 | paralyze_monst(mon, 3); |
| 95 | } |
| 96 | return 2; |
| 97 | } |
| 98 | } |
| 99 | if (objdescr_is(obj, "smoky") |
| 100 | && !(svm.mvitals[PM_DJINNI].mvflags & G_GONE) |
| 101 | && !rn2(POTION_OCCUPANT_CHANCE(svm.mvitals[PM_DJINNI].born))) { |
| 102 | if (!enexto(&cc, mon->mx, mon->my, &mons[PM_DJINNI])) |
| 103 | return 0; |
| 104 | mquaffmsg(mon, obj); |
| 105 | m_useup(mon, obj); |
| 106 | mtmp = makemon(&mons[PM_DJINNI], cc.x, cc.y, MM_NOMSG); |
| 107 | if (!mtmp) { |
| 108 | if (vis) |
| 109 | pline1(empty); |
| 110 | } else { |
| 111 | if (vis) |
| 112 | pline_mon(mtmp, "In a cloud of smoke, %s emerges!", a_monnam(mtmp)); |
| 113 | pline("%s speaks.", vis ? Monnam(mtmp) : Something); |
| 114 | /* I suspect few players will be upset that monsters */ |
| 115 | /* can't wish for wands of death here.... */ |
no test coverage detected