TRUE if monster does something to avoid turning into green slime */
| 3028 | |
| 3029 | /* TRUE if monster does something to avoid turning into green slime */ |
| 3030 | boolean |
| 3031 | munslime(struct monst *mon, boolean by_you) |
| 3032 | { |
| 3033 | struct obj *obj, odummy; |
| 3034 | struct permonst *mptr = mon->data; |
| 3035 | |
| 3036 | /* |
| 3037 | * muse_unslime() gives "mon starts turning green", "mon zaps |
| 3038 | * itself with a wand of fire", and "mon's slime burns away" |
| 3039 | * messages. Monsters who don't get any chance at that just have |
| 3040 | * (via our caller) newcham()'s "mon turns into slime" feedback. |
| 3041 | */ |
| 3042 | |
| 3043 | if (slimeproof(mptr)) |
| 3044 | return FALSE; |
| 3045 | if (mon->meating || helpless(mon)) |
| 3046 | return FALSE; |
| 3047 | mon->mstrategy &= ~STRAT_WAITFORU; |
| 3048 | |
| 3049 | /* if monster can breathe fire, do so upon self; a monster who deals |
| 3050 | fire damage by biting, clawing, gazing, and especially exploding |
| 3051 | isn't able to cure itself of green slime with its own attack |
| 3052 | [possible extension: monst capable of casting high level clerical |
| 3053 | spells could toss pillar of fire at self--probably too suicidal] */ |
| 3054 | if (!mon->mcan && !mon->mspec_used |
| 3055 | && attacktype_fordmg(mptr, AT_BREA, AD_FIRE)) { |
| 3056 | odummy = cg.zeroobj; /* otyp == STRANGE_OBJECT */ |
| 3057 | return muse_unslime(mon, &odummy, (struct trap *) 0, by_you); |
| 3058 | } |
| 3059 | |
| 3060 | /* same MUSE criteria as use_defensive() */ |
| 3061 | if (!is_animal(mptr) && !mindless(mptr)) { |
| 3062 | struct trap *t; |
| 3063 | |
| 3064 | for (obj = mon->minvent; obj; obj = obj->nobj) |
| 3065 | if (cures_sliming(mon, obj)) |
| 3066 | return muse_unslime(mon, obj, (struct trap *) 0, by_you); |
| 3067 | |
| 3068 | if (((t = t_at(mon->mx, mon->my)) == 0 || t->ttyp != FIRE_TRAP) |
| 3069 | && mptr->mmove && !mon->mtrapped) { |
| 3070 | coordxy xy[2][8], x, y, idx, ridx, nxy = 0; |
| 3071 | |
| 3072 | for (x = mon->mx - 1; x <= mon->mx + 1; ++x) |
| 3073 | for (y = mon->my - 1; y <= mon->my + 1; ++y) |
| 3074 | if (isok(x, y) && accessible(x, y) |
| 3075 | && !m_at(x, y) && (x != u.ux || y != u.uy)) { |
| 3076 | xy[0][nxy] = x, xy[1][nxy] = y; |
| 3077 | ++nxy; |
| 3078 | } |
| 3079 | for (idx = 0; idx < nxy; ++idx) { |
| 3080 | ridx = rn1(nxy - idx, idx); |
| 3081 | if (ridx != idx) { |
| 3082 | x = xy[0][idx]; |
| 3083 | xy[0][idx] = xy[0][ridx]; |
| 3084 | xy[0][ridx] = x; |
| 3085 | y = xy[1][idx]; |
| 3086 | xy[1][idx] = xy[1][ridx]; |
| 3087 | xy[1][ridx] = y; |
no test coverage detected