moving onto different terrain; might be going into solid rock, inhibiting levitation or flight, or coming back out of such, reinstating levitation/flying */
| 3175 | might be going into solid rock, inhibiting levitation or flight, |
| 3176 | or coming back out of such, reinstating levitation/flying */ |
| 3177 | void |
| 3178 | switch_terrain(void) |
| 3179 | { |
| 3180 | struct rm *lev = &levl[u.ux][u.uy]; |
| 3181 | boolean blocklev = (IS_OBSTRUCTED(lev->typ) || closed_door(u.ux, u.uy) |
| 3182 | || IS_WATERWALL(lev->typ) |
| 3183 | || lev->typ == LAVAWALL), |
| 3184 | was_levitating = !!Levitation, was_flying = !!Flying; |
| 3185 | |
| 3186 | if (blocklev) { |
| 3187 | /* called from spoteffects(), stop levitating but skip float_down() */ |
| 3188 | if (Levitation) |
| 3189 | You_cant("levitate in here."); |
| 3190 | BLevitation |= FROMOUTSIDE; |
| 3191 | } else if (BLevitation) { |
| 3192 | BLevitation &= ~FROMOUTSIDE; |
| 3193 | /* we're probably levitating now; if not, we must be chained |
| 3194 | to a buried iron ball so get float_up() feedback for that */ |
| 3195 | if (Levitation || BLevitation) |
| 3196 | float_up(); |
| 3197 | } |
| 3198 | /* the same terrain that blocks levitation also blocks flight */ |
| 3199 | if (blocklev) { |
| 3200 | if (Flying) |
| 3201 | You_cant("fly in here."); |
| 3202 | BFlying |= FROMOUTSIDE; |
| 3203 | } else if (BFlying) { |
| 3204 | BFlying &= ~FROMOUTSIDE; |
| 3205 | float_vs_flight(); /* maybe toggle (BFlying & I_SPECIAL) */ |
| 3206 | /* [minor bug: we don't know whether this is beginning flight or |
| 3207 | resuming it; that could be tracked so that this message could |
| 3208 | be adjusted to "resume flying", but isn't worth the effort...] */ |
| 3209 | if (Flying) |
| 3210 | You("start flying."); |
| 3211 | } |
| 3212 | if ((!!Levitation ^ was_levitating) || (!!Flying ^ was_flying)) |
| 3213 | disp.botl = TRUE; /* update Lev/Fly status condition */ |
| 3214 | |
| 3215 | if (flags.terrainstatus) |
| 3216 | classify_terrain(); |
| 3217 | } |
| 3218 | |
| 3219 | /* set or clear u.uinwater */ |
| 3220 | void |
no test coverage detected