MCPcopy Create free account
hub / github.com/NetHack/NetHack / zap_updown

Function zap_updown

src/zap.c:3218–3411  ·  view source on GitHub ↗

you've zapped an immediate type wand up or down */

Source from the content-addressed store, hash-verified

3216
3217/* you've zapped an immediate type wand up or down */
3218staticfn boolean
3219zap_updown(struct obj *obj) /* wand or spell, nonnull */
3220{
3221 boolean striking = FALSE, disclose = FALSE, map_zapped = FALSE;
3222 coordxy x, y, xx, yy;
3223 int ptmp;
3224 struct obj *otmp;
3225 struct engr *e;
3226 struct trap *ttmp;
3227 stairway *stway = gs.stairs;
3228
3229 /* some wands have special effects other than normal bhitpile */
3230 /* drawbridge might change <u.ux,u.uy> */
3231 x = xx = u.ux; /* <x,y> is zap location */
3232 y = yy = u.uy; /* <xx,yy> is drawbridge (portcullis) position */
3233 ttmp = t_at(x, y); /* trap if there is one */
3234
3235 switch (obj->otyp) {
3236 case WAN_PROBING:
3237 ptmp = 0;
3238 if (u.dz < 0) {
3239 You("probe towards the %s.", ceiling(x, y));
3240 } else { /* down */
3241 const char *surf;
3242 schar ltyp, rememberedltyp = update_mapseen_for(x, y);
3243
3244 ptmp += bhitpile(obj, bhito, x, y, u.dz);
3245 /* sequencing: zap_map() calls force_decor() for ice or furniture;
3246 we need to call it before probing for buried objects */
3247 ltyp = SURFACE_AT(x, y);
3248 zap_map(x, y, obj);
3249 /*map_zapped = TRUE; // not needed due to early return*/
3250 if (ltyp == ICE || IS_FURNITURE(ltyp)) {
3251 surf = "it";
3252 if (svl.lastseentyp[x][y] != rememberedltyp)
3253 ptmp += 1;
3254 } else {
3255 surf = the(surface(x, y));
3256 }
3257 You("probe beneath %s.", surf);
3258 ptmp += display_binventory(x, y, TRUE);
3259 }
3260 if (!ptmp)
3261 Your("probe reveals nothing.");
3262 return TRUE; /* we've done our own bhitpile */
3263 case WAN_OPENING:
3264 case SPE_KNOCK:
3265 while (stway) {
3266 if (!stway->isladder && !stway->up
3267 && stway->tolev.dnum == u.uz.dnum)
3268 break;
3269 stway = stway->next;
3270 }
3271 /* up or down, but at closed portcullis only */
3272 if (is_db_wall(x, y) && find_drawbridge(&xx, &yy)) {
3273 open_drawbridge(xx, yy);
3274 disclose = TRUE;
3275 } else if (u.dz > 0 && stway && stway->sx == x && stway->sy == y

Callers 1

weffectsFunction · 0.85

Calls 15

t_atFunction · 0.85
YouFunction · 0.85
ceilingFunction · 0.85
update_mapseen_forFunction · 0.85
bhitpileFunction · 0.85
zap_mapFunction · 0.85
theFunction · 0.85
surfaceFunction · 0.85
display_binventoryFunction · 0.85
YourFunction · 0.85
is_db_wallFunction · 0.85
find_drawbridgeFunction · 0.85

Tested by

no test coverage detected