fix: Doors with KeyRequired=1 cannot be unlocked

This commit is contained in:
Vsevolod Kremianskii 2021-01-19 17:33:45 +07:00
parent 351f342a8f
commit 62b3f73941
4 changed files with 15 additions and 5 deletions

View file

@ -309,13 +309,16 @@ void ActionExecutor::executeOpenLock(const shared_ptr<Object> &actor, ObjectActi
creatureActor->face(*door);
creatureActor->playAnimation(AnimationType::LoopingUnlockDoor);
door->setLocked(false);
door->open(actor);
if (!door->isKeyRequired()) {
door->setLocked(false);
door->open(actor);
string onOpen(door->getOnOpen());
if (!onOpen.empty()) {
_game->scriptRunner().run(onOpen, door->id(), actor->id());
string onOpen(door->getOnOpen());
if (!onOpen.empty()) {
_game->scriptRunner().run(onOpen, door->id(), actor->id());
}
}
action.complete();
}
} else {

View file

@ -56,6 +56,7 @@ void DoorBlueprint::load(Door &door) {
door._locked = _utd->getBool("Locked");
door._genericType = _utd->getInt("GenericType");
door._static = _utd->getBool("Static");
door._keyRequired = _utd->getBool("KeyRequired");
door._minOneHP = _utd->getBool("Min1HP");
door._hitPoints = _utd->getInt("HP");
door._currentHitPoints = _utd->getInt("CurrentHP");

View file

@ -113,6 +113,10 @@ bool Door::isStatic() const {
return _static;
}
bool Door::isKeyRequired() const {
return _keyRequired;
}
const string &Door::getOnOpen() const {
return _onOpen;
}

View file

@ -44,6 +44,7 @@ public:
bool isLockable() const;
bool isLocked() const;
bool isStatic() const;
bool isKeyRequired() const;
const std::string &getOnOpen() const;
const std::string &getOnFailToOpen() const;
@ -60,6 +61,7 @@ private:
bool _locked { false };
int _genericType { 0 };
bool _static { false };
bool _keyRequired { false };
std::string _linkedToModule;
std::string _linkedTo;
std::string _transitionDestin;