mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 18:35:20 +00:00
Allow using keys to open trapped objects of lock level 0
This commit is contained in:
parent
cabe038a97
commit
599e6708ec
@ -137,7 +137,8 @@ namespace MWClass
|
|||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayerPtr();
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayerPtr();
|
||||||
MWWorld::InventoryStore& invStore = player.getClass().getInventoryStore(player);
|
MWWorld::InventoryStore& invStore = player.getClass().getInventoryStore(player);
|
||||||
|
|
||||||
bool needKey = ptr.getCellRef().getLockLevel() > 0;
|
bool isLocked = ptr.getCellRef().getLockLevel() > 0;
|
||||||
|
bool isTrapped = !ptr.getCellRef().getTrap().empty();
|
||||||
bool hasKey = false;
|
bool hasKey = false;
|
||||||
std::string keyName;
|
std::string keyName;
|
||||||
|
|
||||||
@ -155,24 +156,26 @@ namespace MWClass
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (needKey && hasKey)
|
if ((isLocked || isTrapped) && hasKey)
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getWindowManager ()->messageBox (keyName + " #{sKeyUsed}");
|
MWBase::Environment::get().getWindowManager ()->messageBox (keyName + " #{sKeyUsed}");
|
||||||
unlock(ptr);
|
if(isLocked)
|
||||||
|
unlock(ptr);
|
||||||
// using a key disarms the trap
|
// using a key disarms the trap
|
||||||
if(!ptr.getCellRef().getTrap().empty())
|
if(isTrapped)
|
||||||
{
|
{
|
||||||
ptr.getCellRef().setTrap("");
|
ptr.getCellRef().setTrap("");
|
||||||
MWBase::Environment::get().getSoundManager()->playSound3D(ptr,
|
MWBase::Environment::get().getSoundManager()->playSound3D(ptr,
|
||||||
"Disarm Trap", 1.0f, 1.0f, MWBase::SoundManager::Play_TypeSfx,
|
"Disarm Trap", 1.0f, 1.0f, MWBase::SoundManager::Play_TypeSfx,
|
||||||
MWBase::SoundManager::Play_Normal);
|
MWBase::SoundManager::Play_Normal);
|
||||||
|
isTrapped = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!needKey || hasKey)
|
if (!isLocked || hasKey)
|
||||||
{
|
{
|
||||||
if(ptr.getCellRef().getTrap().empty())
|
if(!isTrapped)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<MWWorld::Action> action (new MWWorld::ActionOpen(ptr));
|
boost::shared_ptr<MWWorld::Action> action (new MWWorld::ActionOpen(ptr));
|
||||||
return action;
|
return action;
|
||||||
|
@ -107,7 +107,8 @@ namespace MWClass
|
|||||||
|
|
||||||
MWWorld::ContainerStore &invStore = actor.getClass().getContainerStore(actor);
|
MWWorld::ContainerStore &invStore = actor.getClass().getContainerStore(actor);
|
||||||
|
|
||||||
bool needKey = ptr.getCellRef().getLockLevel() > 0;
|
bool isLocked = ptr.getCellRef().getLockLevel() > 0;
|
||||||
|
bool isTrapped = !ptr.getCellRef().getTrap().empty();
|
||||||
bool hasKey = false;
|
bool hasKey = false;
|
||||||
std::string keyName;
|
std::string keyName;
|
||||||
|
|
||||||
@ -125,24 +126,26 @@ namespace MWClass
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (needKey && hasKey)
|
if ((isLocked || isTrapped) && hasKey)
|
||||||
{
|
{
|
||||||
if(actor == MWMechanics::getPlayer())
|
if(actor == MWMechanics::getPlayer())
|
||||||
MWBase::Environment::get().getWindowManager()->messageBox(keyName + " #{sKeyUsed}");
|
MWBase::Environment::get().getWindowManager()->messageBox(keyName + " #{sKeyUsed}");
|
||||||
unlock(ptr); //Call the function here. because that makes sense.
|
if(isLocked)
|
||||||
|
unlock(ptr); //Call the function here. because that makes sense.
|
||||||
// using a key disarms the trap
|
// using a key disarms the trap
|
||||||
if(!ptr.getCellRef().getTrap().empty())
|
if(isTrapped)
|
||||||
{
|
{
|
||||||
ptr.getCellRef().setTrap("");
|
ptr.getCellRef().setTrap("");
|
||||||
MWBase::Environment::get().getSoundManager()->playSound3D(ptr,
|
MWBase::Environment::get().getSoundManager()->playSound3D(ptr,
|
||||||
"Disarm Trap", 1.0f, 1.0f, MWBase::SoundManager::Play_TypeSfx,
|
"Disarm Trap", 1.0f, 1.0f, MWBase::SoundManager::Play_TypeSfx,
|
||||||
MWBase::SoundManager::Play_Normal);
|
MWBase::SoundManager::Play_Normal);
|
||||||
|
isTrapped = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!needKey || hasKey)
|
if (!isLocked || hasKey)
|
||||||
{
|
{
|
||||||
if(!ptr.getCellRef().getTrap().empty())
|
if(isTrapped)
|
||||||
{
|
{
|
||||||
// Trap activation
|
// Trap activation
|
||||||
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTrap(ptr.getCellRef().getTrap(), ptr));
|
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTrap(ptr.getCellRef().getTrap(), ptr));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user