Merge pull request #2513 from Capostrophic/crime

Make sure failed pick/trap attempts are a crime (bug #5149)
pull/541/head
Andrei Kortunov 5 years ago committed by GitHub
commit 58be8dc976
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -136,6 +136,7 @@
Bug #5126: Swimming creatures without RunForward animations are motionless during combat Bug #5126: Swimming creatures without RunForward animations are motionless during combat
Bug #5134: Doors rotation by "Lock" console command is inconsistent Bug #5134: Doors rotation by "Lock" console command is inconsistent
Bug #5137: Textures with Clamp Mode set to Clamp instead of Wrap are too dark outside the boundaries Bug #5137: Textures with Clamp Mode set to Clamp instead of Wrap are too dark outside the boundaries
Bug #5149: Failing lock pick attempts isn't always a crime
Feature #1774: Handle AvoidNode Feature #1774: Handle AvoidNode
Feature #2229: Improve pathfinding AI Feature #2229: Improve pathfinding AI
Feature #3025: Analogue gamepad movement controls Feature #3025: Analogue gamepad movement controls

@ -143,8 +143,8 @@ namespace MWBase
/// @param container The container the item is in; may be empty for an item in the world /// @param container The container the item is in; may be empty for an item in the world
virtual void itemTaken (const MWWorld::Ptr& ptr, const MWWorld::Ptr& item, const MWWorld::Ptr& container, virtual void itemTaken (const MWWorld::Ptr& ptr, const MWWorld::Ptr& item, const MWWorld::Ptr& container,
int count, bool alarm = true) = 0; int count, bool alarm = true) = 0;
/// Utility to check if opening (i.e. unlocking) this object is illegal and calling commitCrime if so /// Utility to check if unlocking this object is illegal and calling commitCrime if so
virtual void objectOpened (const MWWorld::Ptr& ptr, const MWWorld::Ptr& item) = 0; virtual void unlockAttempted (const MWWorld::Ptr& ptr, const MWWorld::Ptr& item) = 0;
/// Attempt sleeping in a bed. If this is illegal, call commitCrime. /// Attempt sleeping in a bed. If this is illegal, call commitCrime.
/// @return was it illegal, and someone saw you doing it? /// @return was it illegal, and someone saw you doing it?
virtual bool sleepInBed (const MWWorld::Ptr& ptr, const MWWorld::Ptr& bed) = 0; virtual bool sleepInBed (const MWWorld::Ptr& ptr, const MWWorld::Ptr& bed) = 0;

@ -1034,7 +1034,7 @@ namespace MWMechanics
return false; return false;
} }
void MechanicsManager::objectOpened(const MWWorld::Ptr &ptr, const MWWorld::Ptr &item) void MechanicsManager::unlockAttempted(const MWWorld::Ptr &ptr, const MWWorld::Ptr &item)
{ {
MWWorld::Ptr victim; MWWorld::Ptr victim;
if (isAllowedToUse(ptr, item, victim)) if (isAllowedToUse(ptr, item, victim))

@ -142,8 +142,8 @@ namespace MWMechanics
/// @param container The container the item is in; may be empty for an item in the world /// @param container The container the item is in; may be empty for an item in the world
virtual void itemTaken (const MWWorld::Ptr& ptr, const MWWorld::Ptr& item, const MWWorld::Ptr& container, virtual void itemTaken (const MWWorld::Ptr& ptr, const MWWorld::Ptr& item, const MWWorld::Ptr& container,
int count, bool alarm = true) override; int count, bool alarm = true) override;
/// Utility to check if opening (i.e. unlocking) this object is illegal and calling commitCrime if so /// Utility to check if unlocking this object is illegal and calling commitCrime if so
virtual void objectOpened (const MWWorld::Ptr& ptr, const MWWorld::Ptr& item) override; virtual void unlockAttempted (const MWWorld::Ptr& ptr, const MWWorld::Ptr& item) override;
/// Attempt sleeping in a bed. If this is illegal, call commitCrime. /// Attempt sleeping in a bed. If this is illegal, call commitCrime.
/// @return was it illegal, and someone saw you doing it? Also returns fail when enemies are nearby /// @return was it illegal, and someone saw you doing it? Also returns fail when enemies are nearby
virtual bool sleepInBed (const MWWorld::Ptr& ptr, const MWWorld::Ptr& bed) override; virtual bool sleepInBed (const MWWorld::Ptr& ptr, const MWWorld::Ptr& bed) override;

@ -48,7 +48,6 @@ namespace MWMechanics
resultMessage = "#{sLockImpossible}"; resultMessage = "#{sLockImpossible}";
else else
{ {
MWBase::Environment::get().getMechanicsManager()->objectOpened(mActor, lock);
if (Misc::Rng::roll0to99() <= x) if (Misc::Rng::roll0to99() <= x)
{ {
lock.getClass().unlock(lock); lock.getClass().unlock(lock);
@ -60,6 +59,7 @@ namespace MWMechanics
resultMessage = "#{sLockFail}"; resultMessage = "#{sLockFail}";
} }
MWBase::Environment::get().getMechanicsManager()->unlockAttempted(mActor, lock);
int uses = lockpick.getClass().getItemHealth(lockpick); int uses = lockpick.getClass().getItemHealth(lockpick);
--uses; --uses;
lockpick.getCellRef().setCharge(uses); lockpick.getCellRef().setCharge(uses);
@ -89,7 +89,6 @@ namespace MWMechanics
resultMessage = "#{sTrapImpossible}"; resultMessage = "#{sTrapImpossible}";
else else
{ {
MWBase::Environment::get().getMechanicsManager()->objectOpened(mActor, trap);
if (Misc::Rng::roll0to99() <= x) if (Misc::Rng::roll0to99() <= x)
{ {
trap.getCellRef().setTrap(""); trap.getCellRef().setTrap("");
@ -102,6 +101,7 @@ namespace MWMechanics
resultMessage = "#{sTrapFail}"; resultMessage = "#{sTrapFail}";
} }
MWBase::Environment::get().getMechanicsManager()->unlockAttempted(mActor, trap);
int uses = probe.getClass().getItemHealth(probe); int uses = probe.getClass().getItemHealth(probe);
--uses; --uses;
probe.getCellRef().setCharge(uses); probe.getCellRef().setCharge(uses);

@ -712,9 +712,6 @@ namespace MWMechanics
if (target.getCellRef().getLockLevel() > 0) if (target.getCellRef().getLockLevel() > 0)
{ {
MWBase::Environment::get().getSoundManager()->playSound3D(target, "Open Lock", 1.f, 1.f); MWBase::Environment::get().getSoundManager()->playSound3D(target, "Open Lock", 1.f, 1.f);
if (!caster.isEmpty())
MWBase::Environment::get().getMechanicsManager()->objectOpened(getPlayer(), target);
// Use the player instead of the caster for vanilla crime compatibility
if (caster == getPlayer()) if (caster == getPlayer())
MWBase::Environment::get().getWindowManager()->messageBox("#{sMagicOpenSuccess}"); MWBase::Environment::get().getWindowManager()->messageBox("#{sMagicOpenSuccess}");
@ -723,6 +720,10 @@ namespace MWMechanics
} }
else else
MWBase::Environment::get().getSoundManager()->playSound3D(target, "Open Lock Fail", 1.f, 1.f); MWBase::Environment::get().getSoundManager()->playSound3D(target, "Open Lock Fail", 1.f, 1.f);
if (!caster.isEmpty())
MWBase::Environment::get().getMechanicsManager()->unlockAttempted(getPlayer(), target);
// Use the player instead of the caster for vanilla crime compatibility
return true; return true;
} }
} }

Loading…
Cancel
Save