Unify stumbling on door mimic

This commit is contained in:
Pasi Kallinen
2015-04-22 09:23:54 +03:00
parent 75e7d837e6
commit bd69677933
3 changed files with 19 additions and 17 deletions

View File

@@ -984,6 +984,7 @@ E int NDECL(doforce);
E boolean FDECL(boxlock, (struct obj *,struct obj *));
E boolean FDECL(doorlock, (struct obj *,int,int));
E int NDECL(doopen);
E boolean FDECL(stumble_on_door_mimic, (int,int));
E int FDECL(doopen_indir, (int,int));
E int NDECL(doclose);

View File

@@ -526,6 +526,22 @@ doopen() /* try to open a door */
return doopen_indir(0, 0);
}
boolean
stumble_on_door_mimic(x,y)
int x,y;
{
struct monst *mtmp;
if ((mtmp = m_at(x,y)) &&
mtmp->m_ap_type == M_AP_FURNITURE &&
(mtmp->mappearance == S_hcdoor ||
mtmp->mappearance == S_vcdoor) &&
!Protection_from_shape_changers) {
stumble_onto_mimic(mtmp);
return TRUE;
}
return FALSE;
}
int
doopen_indir(x, y) /* try to open a door in direction u.dx/u.dy */
int x, y;
@@ -554,15 +570,7 @@ int x, y;
if((cc.x == u.ux) && (cc.y == u.uy)) return(0);
if ((mtmp = m_at(cc.x,cc.y)) &&
mtmp->m_ap_type == M_AP_FURNITURE &&
(mtmp->mappearance == S_hcdoor ||
mtmp->mappearance == S_vcdoor) &&
!Protection_from_shape_changers) {
stumble_onto_mimic(mtmp);
return(1);
}
if (stumble_on_door_mimic(cc.x, cc.y)) return 1;
/* when choosing a direction is impaired, use a turn
regardless of whether a door is successfully targetted */

View File

@@ -4108,14 +4108,7 @@ boolean force;
return(0);
}
if ((mtmp = m_at(x,y)) &&
mtmp->m_ap_type == M_AP_FURNITURE &&
(mtmp->mappearance == S_hcdoor ||
mtmp->mappearance == S_vcdoor) &&
!Protection_from_shape_changers) {
stumble_onto_mimic(mtmp);
return(1);
}
if (stumble_on_door_mimic(x,y)) return 1;
} /* deal_with_floor_trap */
/* doors can be manipulated even while levitating/unskilled riding */