Looting will fall through to force

If you have autounlock on, and don't have unlocking tool, but
are wielding a weapon usable for forcing the lock.
This commit is contained in:
Pasi Kallinen
2022-02-16 08:49:12 +02:00
parent a7009e2a54
commit d958d032a0
4 changed files with 27 additions and 9 deletions

View File

@@ -602,6 +602,20 @@ pick_lock(struct obj *pick,
return PICKLOCK_DID_SOMETHING;
}
/* is hero wielding a weapon that can #force? */
boolean
u_have_forceable_weapon(void)
{
if (!uwep /* proper type test */
|| ((uwep->oclass == WEAPON_CLASS || is_weptool(uwep))
? (objects[uwep->otyp].oc_skill < P_DAGGER
|| objects[uwep->otyp].oc_skill == P_FLAIL
|| objects[uwep->otyp].oc_skill > P_LANCE)
: uwep->oclass != ROCK_CLASS))
return FALSE;
return TRUE;
}
RESTORE_WARNING_FORMAT_NONLITERAL
/* the #force command - try to force a chest with your weapon */
@@ -616,12 +630,7 @@ doforce(void)
You_cant("force anything from inside here.");
return ECMD_OK;
}
if (!uwep /* proper type test */
|| ((uwep->oclass == WEAPON_CLASS || is_weptool(uwep))
? (objects[uwep->otyp].oc_skill < P_DAGGER
|| objects[uwep->otyp].oc_skill == P_FLAIL
|| objects[uwep->otyp].oc_skill > P_LANCE)
: uwep->oclass != ROCK_CLASS)) {
if (!u_have_forceable_weapon()) {
You_cant("force anything %s weapon.",
!uwep ? "when not wielding a"
: (uwep->oclass != WEAPON_CLASS && !is_weptool(uwep))