-/* NetHack 3.6 teleport.c $NHDT-Date: 1583881126 2020/03/10 22:58:46 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.116 $ */
+/* NetHack 3.6 teleport.c $NHDT-Date: 1585211492 2020/03/26 08:31:32 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.118 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2011. */
/* NetHack may be freely redistributed. See license for details. */
int nux, nuy;
int teleds_flags;
{
- boolean ball_active, ball_still_in_range;
- boolean allow_drag = ((teleds_flags & TELEDS_ALLOW_DRAG) != 0
- && near_capacity() <= SLT_ENCUMBER);
- boolean is_teleport = (teleds_flags & TELEDS_TELEPORT) != 0;
+ boolean ball_active, ball_still_in_range = FALSE,
+ allow_drag = (teleds_flags & TELEDS_ALLOW_DRAG) != 0,
+ is_teleport = (teleds_flags & TELEDS_TELEPORT) != 0;
struct monst *vault_guard = vault_occupied(u.urooms) ? findgd() : 0;
if (u.utraptype == TT_BURIEDBALL) {
buried_ball_to_punishment();
}
ball_active = (Punished && uball->where != OBJ_FREE);
- ball_still_in_range = FALSE;
+ if (!ball_active
+ || near_capacity() > SLT_ENCUMBER
+ || distmin(u.ux, u.uy, nux, nuy) > 1)
+ allow_drag = FALSE;
/* If they have to move the ball, then drag if allow_drag is true;
* otherwise they are teleporting, so unplacebc().
* rock in the way), in which case it teleports the ball on its own.
*/
if (ball_active) {
- if (!carried(uball) && distmin(nux, nuy, uball->ox, uball->oy) <= 2) {
+ if (!carried(uball) && distmin(nux, nuy, uball->ox, uball->oy) <= 2)
ball_still_in_range = TRUE; /* don't have to move the ball */
- } else {
- /* have to move the ball */
- if (!allow_drag || distmin(u.ux, u.uy, nux, nuy) > 1) {
- /* we should not have dist > 1 and allow_drag at the same
- * time, but just in case, we must then revert to teleport.
- */
- allow_drag = FALSE;
- unplacebc();
- }
- }
+ else if (!allow_drag)
+ unplacebc(); /* have to move the ball */
}
reset_utrap(FALSE);
set_ustuck((struct monst *) 0);
}
if (u.uswallow) {
+ /* subset of unstuck() */
u.uswldtim = u.uswallow = 0;
- if (Punished && !ball_active) {
- /* ensure ball placement, like unstuck */
- ball_active = TRUE;
- allow_drag = FALSE;
+ if (Punished) { /* ball&chain are off map while swallowed */
+ ball_active = TRUE; /* to put chain and non-carried ball on map */
+ ball_still_in_range = allow_drag = FALSE; /* (redundant) */
}
docrt();
}
- if (ball_active) {
- if (ball_still_in_range || allow_drag) {
- int bc_control;
- xchar ballx, bally, chainx, chainy;
- boolean cause_delay;
-
- if (drag_ball(nux, nuy, &bc_control, &ballx, &bally, &chainx,
- &chainy, &cause_delay, allow_drag)) {
- move_bc(0, bc_control, ballx, bally, chainx, chainy);
- } else {
- /* dragging fails if hero is encumbered beyond 'burdened' */
- allow_drag = FALSE; /* teleport b&c to hero's new spot */
- unplacebc(); /* to match placebc() below */
- }
- }
+ if (ball_active && (ball_still_in_range || allow_drag)) {
+ int bc_control;
+ xchar ballx, bally, chainx, chainy;
+ boolean cause_delay;
+
+ if (drag_ball(nux, nuy, &bc_control, &ballx, &bally, &chainx,
+ &chainy, &cause_delay, allow_drag))
+ move_bc(0, bc_control, ballx, bally, chainx, chainy);
+ else /* dragging fails if hero is encumbered beyond 'burdened' */
+ unplacebc(); /* to match placebc() below */
}
if (is_teleport && flags.verbose)
the old position if allow_drag is true... */
u_on_newpos(nux, nuy); /* set u.<x,y>, usteed-><mx,my>; cliparound() */
fill_pit(u.ux0, u.uy0);
- if (ball_active) {
- if (!ball_still_in_range && !allow_drag)
- placebc();
- }
+ if (ball_active && uchain->where == OBJ_FREE)
+ placebc(); /* put back the ball&chain if they were taken off map */
initrack(); /* teleports mess up tracking monsters without this */
update_player_regions();
/*