* Move obj from (x1,y1) to (x2,y2) * * Return 0 if no object was launched. * 1 if an object was launched and placed somewhere. * 2 if an object was launched, but used up. */
| 3257 | * 2 if an object was launched, but used up. |
| 3258 | */ |
| 3259 | int |
| 3260 | launch_obj( |
| 3261 | short otyp, |
| 3262 | coordxy x1, coordxy y1, |
| 3263 | coordxy x2, coordxy y2, |
| 3264 | int style) |
| 3265 | { |
| 3266 | struct monst *mtmp; |
| 3267 | struct obj *otmp, *otmp2; |
| 3268 | int dx, dy; |
| 3269 | coordxy x, y; |
| 3270 | struct obj *singleobj; |
| 3271 | boolean used_up = FALSE, otherside = FALSE; |
| 3272 | int dist, tmp, delaycnt = 0; |
| 3273 | |
| 3274 | otmp = sobj_at(otyp, x1, y1); |
| 3275 | /* Try the other side too, for rolling boulder traps */ |
| 3276 | if (!otmp && otyp == BOULDER) { |
| 3277 | otherside = TRUE; |
| 3278 | otmp = sobj_at(otyp, x2, y2); |
| 3279 | } |
| 3280 | if (!otmp) |
| 3281 | return 0; |
| 3282 | if (otherside) { /* swap 'em */ |
| 3283 | int tx, ty; |
| 3284 | |
| 3285 | tx = x1; |
| 3286 | ty = y1; |
| 3287 | x1 = x2; |
| 3288 | y1 = y2; |
| 3289 | x2 = tx; |
| 3290 | y2 = ty; |
| 3291 | } |
| 3292 | |
| 3293 | if (otmp->quan == 1L) { |
| 3294 | obj_extract_self(otmp); |
| 3295 | maybe_unhide_at(otmp->ox, otmp->oy); |
| 3296 | singleobj = otmp; |
| 3297 | otmp = (struct obj *) 0; |
| 3298 | } else { |
| 3299 | singleobj = splitobj(otmp, 1L); |
| 3300 | obj_extract_self(singleobj); |
| 3301 | } |
| 3302 | newsym(x1, y1); |
| 3303 | /* in case you're using a pick-axe to chop the boulder that's being |
| 3304 | launched (perhaps a monster triggered it), destroy context so that |
| 3305 | the next dig attempt never thinks that you're resuming |
| 3306 | the previous effort */ |
| 3307 | if ((otyp == BOULDER || otyp == STATUE) |
| 3308 | && singleobj->ox == svc.context.digging.pos.x |
| 3309 | && singleobj->oy == svc.context.digging.pos.y) |
| 3310 | (void) memset((genericptr_t) &svc.context.digging, 0, |
| 3311 | sizeof(struct dig_info)); |
| 3312 | |
| 3313 | dist = distmin(x1, y1, x2, y2); |
| 3314 | x = gb.bhitpos.x = x1; |
| 3315 | y = gb.bhitpos.y = y1; |
| 3316 | dx = sgn(x2 - x1); |
no test coverage detected