mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-06 00:55:50 +00:00
Merge pull request #1316 from akortunov/doorfix
Doors usage improvements
This commit is contained in:
commit
dd3f612e88
@ -132,15 +132,19 @@ namespace MWClass
|
||||
|
||||
// make key id lowercase
|
||||
std::string keyId = ptr.getCellRef().getKey();
|
||||
Misc::StringUtils::lowerCaseInPlace(keyId);
|
||||
for (MWWorld::ConstContainerStoreIterator it = invStore.cbegin(); it != invStore.cend(); ++it)
|
||||
if (!keyId.empty())
|
||||
{
|
||||
std::string refId = it->getCellRef().getRefId();
|
||||
Misc::StringUtils::lowerCaseInPlace(refId);
|
||||
if (refId == keyId)
|
||||
Misc::StringUtils::lowerCaseInPlace(keyId);
|
||||
for (MWWorld::ConstContainerStoreIterator it = invStore.cbegin(); it != invStore.cend(); ++it)
|
||||
{
|
||||
hasKey = true;
|
||||
keyName = it->getClass().getName(*it);
|
||||
std::string refId = it->getCellRef().getRefId();
|
||||
Misc::StringUtils::lowerCaseInPlace(refId);
|
||||
if (refId == keyId)
|
||||
{
|
||||
hasKey = true;
|
||||
keyName = it->getClass().getName(*it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "../mwworld/action.hpp"
|
||||
#include "../mwworld/class.hpp"
|
||||
#include "../mwworld/cellstore.hpp"
|
||||
#include "../mwworld/inventorystore.hpp"
|
||||
|
||||
#include "creaturestats.hpp"
|
||||
#include "movement.hpp"
|
||||
@ -179,10 +180,36 @@ void MWMechanics::AiPackage::evadeObstacles(const MWWorld::Ptr& actor, float dur
|
||||
if (door != MWWorld::Ptr())
|
||||
{
|
||||
// note: AiWander currently does not open doors
|
||||
if (getTypeId() != TypeIdWander && !door.getCellRef().getTeleport() && door.getCellRef().getTrap().empty()
|
||||
&& door.getCellRef().getLockLevel() <= 0 && door.getClass().getDoorState(door) == 0)
|
||||
if (getTypeId() != TypeIdWander && !door.getCellRef().getTeleport() && door.getClass().getDoorState(door) == 0)
|
||||
{
|
||||
MWBase::Environment::get().getWorld()->activateDoor(door, 1);
|
||||
if ((door.getCellRef().getTrap().empty() && door.getCellRef().getLockLevel() <= 0 ))
|
||||
{
|
||||
MWBase::Environment::get().getWorld()->activate(door, actor);
|
||||
return;
|
||||
}
|
||||
|
||||
std::string keyId = door.getCellRef().getKey();
|
||||
if (keyId.empty())
|
||||
return;
|
||||
|
||||
bool hasKey = false;
|
||||
const MWWorld::ContainerStore &invStore = actor.getClass().getContainerStore(actor);
|
||||
|
||||
// make key id lowercase
|
||||
Misc::StringUtils::lowerCaseInPlace(keyId);
|
||||
for (MWWorld::ConstContainerStoreIterator it = invStore.cbegin(); it != invStore.cend(); ++it)
|
||||
{
|
||||
std::string refId = it->getCellRef().getRefId();
|
||||
Misc::StringUtils::lowerCaseInPlace(refId);
|
||||
if (refId == keyId)
|
||||
{
|
||||
hasKey = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasKey)
|
||||
MWBase::Environment::get().getWorld()->activate(door, actor);
|
||||
}
|
||||
}
|
||||
else // any other obstacle (NPC, crate, etc.)
|
||||
|
Loading…
Reference in New Issue
Block a user