* cancel a monster (possibly the hero). inventory is cancelled only * if the monster is zapping itself directly, since otherwise the * effect is too strong. currently non-hero monsters do not zap * themselves with cancellation. */
| 3147 | * themselves with cancellation. |
| 3148 | */ |
| 3149 | boolean |
| 3150 | cancel_monst(struct monst *mdef, struct obj *obj, boolean youattack, |
| 3151 | boolean allow_cancel_kill, boolean self_cancel) |
| 3152 | { |
| 3153 | static const char |
| 3154 | writing_vanishes[] = "Some writing vanishes from %s head!", |
| 3155 | your[] = "your"; /* should be extern */ |
| 3156 | boolean youdefend = (mdef == &gy.youmonst); |
| 3157 | |
| 3158 | if (youdefend ? (!youattack && Antimagic) |
| 3159 | : resist(mdef, obj->oclass, 0, NOTELL)) |
| 3160 | return FALSE; /* resisted cancellation */ |
| 3161 | |
| 3162 | if (self_cancel) { /* 1st cancel inventory */ |
| 3163 | struct obj *otmp; |
| 3164 | |
| 3165 | for (otmp = (youdefend ? gi.invent : mdef->minvent); otmp; |
| 3166 | otmp = otmp->nobj) |
| 3167 | cancel_item(otmp); |
| 3168 | |
| 3169 | if (youdefend) { |
| 3170 | disp.botl = TRUE; /* potential AC change */ |
| 3171 | find_ac(); |
| 3172 | /* update_inventory(); -- handled by caller */ |
| 3173 | } |
| 3174 | } |
| 3175 | |
| 3176 | /* now handle special cases */ |
| 3177 | if (youdefend) { |
| 3178 | if (Upolyd) { /* includes lycanthrope in creature form */ |
| 3179 | /* |
| 3180 | * Return to normal form unless Unchanging. |
| 3181 | * Hero in clay golem form dies if Unchanging. |
| 3182 | * Does not cure lycanthropy or stop timed random polymorph. |
| 3183 | */ |
| 3184 | if (u.umonnum == PM_CLAY_GOLEM) { |
| 3185 | if (!Blind) |
| 3186 | pline(writing_vanishes, your); |
| 3187 | else /* note: "dark" rather than "heavy" is intentional... */ |
| 3188 | You_feel("%s headed.", Hallucination ? "dark" : "light"); |
| 3189 | u.mh = 0; /* fatal; death handled by rehumanize() */ |
| 3190 | } |
| 3191 | if (Unchanging && u.mh > 0) |
| 3192 | Your("amulet grows hot for a moment, then cools."); |
| 3193 | else |
| 3194 | rehumanize(); |
| 3195 | } |
| 3196 | } else { |
| 3197 | mdef->mcan = 1; |
| 3198 | /* force shapeshifter into its base form or mimic to unhide */ |
| 3199 | normal_shape(mdef); |
| 3200 | |
| 3201 | if (mdef->data == &mons[PM_CLAY_GOLEM]) { |
| 3202 | if (canseemon(mdef)) |
| 3203 | pline(writing_vanishes, s_suffix(mon_nam(mdef))); |
| 3204 | /* !allow_cancel_kill is for Magicbane, where clay golem |
| 3205 | will be killed somewhere back up the call/return chain... */ |
| 3206 | if (allow_cancel_kill) { |
no test coverage detected