mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-21 10:53:51 +00:00
Fixed various issues caused by late-night coding. Also added "unlock" message to unlocked doors
This commit is contained in:
parent
61341d4206
commit
f6deca7c80
9 changed files with 21 additions and 43 deletions
|
@ -211,6 +211,8 @@ namespace MWClass
|
||||||
std::string text;
|
std::string text;
|
||||||
if (ref->mRef.mLockLevel > 0)
|
if (ref->mRef.mLockLevel > 0)
|
||||||
text += "\n#{sLockLevel}: " + MWGui::ToolTips::toString(ref->mRef.mLockLevel);
|
text += "\n#{sLockLevel}: " + MWGui::ToolTips::toString(ref->mRef.mLockLevel);
|
||||||
|
else if (ref->mRef.mLockLevel < 0)
|
||||||
|
text += "\n#{sUnlocked}";
|
||||||
if (ref->mRef.mTrap != "")
|
if (ref->mRef.mTrap != "")
|
||||||
text += "\n#{sTrapped}";
|
text += "\n#{sTrapped}";
|
||||||
|
|
||||||
|
@ -240,9 +242,10 @@ namespace MWClass
|
||||||
|
|
||||||
void Container::lock (const MWWorld::Ptr& ptr, int lockLevel) const
|
void Container::lock (const MWWorld::Ptr& ptr, int lockLevel) const
|
||||||
{
|
{
|
||||||
ptr.getCellRef().mLockLevel = abs(ptr.getCellRef().mLockLevel); //Makes lockLevel positive
|
if(lockLevel!=0)
|
||||||
if(lockLevel>=0) //Lock level setting left as most of the code relies on this
|
ptr.getCellRef().mLockLevel = abs(lockLevel); //Changes lock to locklevel, in positive
|
||||||
ptr.getCellRef().mLockLevel = lockLevel;
|
else
|
||||||
|
ptr.getCellRef().mLockLevel = abs(ptr.getCellRef().mLockLevel); //No locklevel given, just flip the oriional one
|
||||||
}
|
}
|
||||||
|
|
||||||
void Container::unlock (const MWWorld::Ptr& ptr) const
|
void Container::unlock (const MWWorld::Ptr& ptr) const
|
||||||
|
@ -250,13 +253,6 @@ namespace MWClass
|
||||||
ptr.getCellRef().mLockLevel = -abs(ptr.getCellRef().mLockLevel); //Makes lockLevel negative
|
ptr.getCellRef().mLockLevel = -abs(ptr.getCellRef().mLockLevel); //Makes lockLevel negative
|
||||||
}
|
}
|
||||||
|
|
||||||
void Container::changeLockLevel(const MWWorld::Ptr& ptr, int lockLevel, bool doLock) {
|
|
||||||
if (lockLevel<0)
|
|
||||||
lockLevel = 0;
|
|
||||||
|
|
||||||
ptr.getCellRef().mLockLevel = lockLevel;
|
|
||||||
if(doLock) lock(ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
MWWorld::Ptr
|
MWWorld::Ptr
|
||||||
Container::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
|
Container::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
|
||||||
|
|
|
@ -48,15 +48,12 @@ namespace MWClass
|
||||||
///< Returns total weight of objects inside this object (including modifications from magic
|
///< Returns total weight of objects inside this object (including modifications from magic
|
||||||
/// effects). Throws an exception, if the object can't hold other objects.
|
/// effects). Throws an exception, if the object can't hold other objects.
|
||||||
|
|
||||||
virtual void lock (const MWWorld::Ptr& ptr, int lockLevel = -999) const;
|
virtual void lock (const MWWorld::Ptr& ptr, int lockLevel = 0) const;
|
||||||
///< Lock object
|
///< Lock object
|
||||||
|
|
||||||
virtual void unlock (const MWWorld::Ptr& ptr) const;
|
virtual void unlock (const MWWorld::Ptr& ptr) const;
|
||||||
///< Unlock object
|
///< Unlock object
|
||||||
|
|
||||||
///Changes the lock level of the object
|
|
||||||
virtual void changeLockLevel(const MWWorld::Ptr& ptr, int lockLevel, bool lock=true);
|
|
||||||
|
|
||||||
virtual void readAdditionalState (const MWWorld::Ptr& ptr, const ESM::ObjectState& state)
|
virtual void readAdditionalState (const MWWorld::Ptr& ptr, const ESM::ObjectState& state)
|
||||||
const;
|
const;
|
||||||
///< Read additional state from \a state into \a ptr.
|
///< Read additional state from \a state into \a ptr.
|
||||||
|
|
|
@ -158,22 +158,15 @@ namespace MWClass
|
||||||
|
|
||||||
void Door::lock (const MWWorld::Ptr& ptr, int lockLevel) const
|
void Door::lock (const MWWorld::Ptr& ptr, int lockLevel) const
|
||||||
{
|
{
|
||||||
ptr.getCellRef().mLockLevel = abs(ptr.getCellRef().mLockLevel); //Makes lockLevel positive;
|
if(lockLevel!=0)
|
||||||
if(lockLevel>=0) //Lock level setting left as most of the code relies on this
|
ptr.getCellRef().mLockLevel = abs(lockLevel); //Changes lock to locklevel, in positive
|
||||||
ptr.getCellRef().mLockLevel = abs(lockLevel);
|
else
|
||||||
}
|
ptr.getCellRef().mLockLevel = abs(ptr.getCellRef().mLockLevel); //No locklevel given, just flip the origional one
|
||||||
|
|
||||||
void Door::changeLockLevel(const MWWorld::Ptr& ptr, int lockLevel, bool doLock) const{
|
|
||||||
if (lockLevel<0)
|
|
||||||
lockLevel = 0;
|
|
||||||
|
|
||||||
ptr.getCellRef().mLockLevel = lockLevel;
|
|
||||||
if(doLock) lock(ptr); //A change in lock level almost always nesesitates a lock
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Door::unlock (const MWWorld::Ptr& ptr) const
|
void Door::unlock (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ptr.getCellRef().mLockLevel = -abs(ptr.getCellRef().mLockLevel); //Makes lockLevel positive
|
ptr.getCellRef().mLockLevel = -abs(ptr.getCellRef().mLockLevel); //Makes lockLevel negative
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Door::getScript (const MWWorld::Ptr& ptr) const
|
std::string Door::getScript (const MWWorld::Ptr& ptr) const
|
||||||
|
@ -217,6 +210,8 @@ namespace MWClass
|
||||||
|
|
||||||
if (ref->mRef.mLockLevel > 0)
|
if (ref->mRef.mLockLevel > 0)
|
||||||
text += "\n#{sLockLevel}: " + MWGui::ToolTips::toString(ref->mRef.mLockLevel);
|
text += "\n#{sLockLevel}: " + MWGui::ToolTips::toString(ref->mRef.mLockLevel);
|
||||||
|
else if (ref->mRef.mLockLevel < 0)
|
||||||
|
text += "\n#{sUnlocked}";
|
||||||
if (ref->mRef.mTrap != "")
|
if (ref->mRef.mTrap != "")
|
||||||
text += "\n#{sTrapped}";
|
text += "\n#{sTrapped}";
|
||||||
|
|
||||||
|
|
|
@ -36,15 +36,12 @@ namespace MWClass
|
||||||
static std::string getDestination (const MWWorld::LiveCellRef<ESM::Door>& door);
|
static std::string getDestination (const MWWorld::LiveCellRef<ESM::Door>& door);
|
||||||
///< @return destination cell name or token
|
///< @return destination cell name or token
|
||||||
|
|
||||||
virtual void lock (const MWWorld::Ptr& ptr, int lockLevel = -999) const;
|
virtual void lock (const MWWorld::Ptr& ptr, int lockLevel = 0) const;
|
||||||
///< Lock object
|
///< Lock object
|
||||||
|
|
||||||
virtual void unlock (const MWWorld::Ptr& ptr) const;
|
virtual void unlock (const MWWorld::Ptr& ptr) const;
|
||||||
///< Unlock object
|
///< Unlock object
|
||||||
|
|
||||||
///Change the lock level
|
|
||||||
virtual void changeLockLevel(const MWWorld::Ptr& ptr, int lockLevel, bool lock=true) const;
|
|
||||||
|
|
||||||
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
|
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
|
||||||
///< Return name of the script attached to ptr
|
///< Return name of the script attached to ptr
|
||||||
|
|
||||||
|
|
|
@ -420,20 +420,20 @@ namespace MWMechanics
|
||||||
{
|
{
|
||||||
if (effectId == ESM::MagicEffect::Lock)
|
if (effectId == ESM::MagicEffect::Lock)
|
||||||
{
|
{
|
||||||
target.getCellRef().mLockLevel = abs(target.getCellRef().mLockLevel); //Makes lockLevel positive
|
if (target.getCellRef().mLockLevel < magnitude) //If the door is not already locked to a higher value, lock it to spell magnitude
|
||||||
if (target.getCellRef().mLockLevel < magnitude)
|
|
||||||
target.getCellRef().mLockLevel = magnitude;
|
target.getCellRef().mLockLevel = magnitude;
|
||||||
}
|
}
|
||||||
else if (effectId == ESM::MagicEffect::Open)
|
else if (effectId == ESM::MagicEffect::Open)
|
||||||
{
|
{
|
||||||
if (target.getCellRef().mLockLevel <= magnitude)
|
if (target.getCellRef().mLockLevel <= magnitude)
|
||||||
{
|
{
|
||||||
|
//Door not already unlocked
|
||||||
if (target.getCellRef().mLockLevel > 0)
|
if (target.getCellRef().mLockLevel > 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);
|
||||||
MWBase::Environment::get().getMechanicsManager()->objectOpened(caster, target);
|
MWBase::Environment::get().getMechanicsManager()->objectOpened(caster, target);
|
||||||
}
|
}
|
||||||
target.getCellRef().mLockLevel = -abs(target.getCellRef().mLockLevel);
|
target.getCellRef().mLockLevel = -abs(target.getCellRef().mLockLevel); //unlocks the door
|
||||||
}
|
}
|
||||||
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);
|
||||||
|
|
|
@ -132,7 +132,7 @@ namespace MWScript
|
||||||
MWWorld::Ptr ptr = R()(runtime);
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
|
|
||||||
Interpreter::Type_Integer lockLevel = ptr.getCellRef().mLockLevel;
|
Interpreter::Type_Integer lockLevel = ptr.getCellRef().mLockLevel;
|
||||||
if(lockLevel==-999) { //no lock level was ever set, set to 100 as default
|
if(lockLevel==0) { //no lock level was ever set, set to 100 as default
|
||||||
lockLevel = 100;
|
lockLevel = 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -137,11 +137,6 @@ namespace MWWorld
|
||||||
throw std::runtime_error ("class does not support locking");
|
throw std::runtime_error ("class does not support locking");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Class::setLockLevel (const Ptr& ptr, int lockLevel) const
|
|
||||||
{
|
|
||||||
throw std::runtime_error ("class does not support setting lock level");
|
|
||||||
}
|
|
||||||
|
|
||||||
void Class::unlock (const Ptr& ptr) const
|
void Class::unlock (const Ptr& ptr) const
|
||||||
{
|
{
|
||||||
throw std::runtime_error ("class does not support unlocking");
|
throw std::runtime_error ("class does not support unlocking");
|
||||||
|
|
|
@ -165,8 +165,6 @@ namespace MWWorld
|
||||||
virtual void lock (const Ptr& ptr, int lockLevel) const;
|
virtual void lock (const Ptr& ptr, int lockLevel) const;
|
||||||
///< Lock object (default implementation: throw an exception)
|
///< Lock object (default implementation: throw an exception)
|
||||||
|
|
||||||
virtual void setLockLevel(const Ptr& ptr, int lockLevel) const;
|
|
||||||
|
|
||||||
virtual void unlock (const Ptr& ptr) const;
|
virtual void unlock (const Ptr& ptr) const;
|
||||||
///< Unlock object (default implementation: throw an exception)
|
///< Unlock object (default implementation: throw an exception)
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ void ESM::CellRef::load (ESMReader& esm, bool wideRefNum)
|
||||||
else
|
else
|
||||||
mTeleport = false;
|
mTeleport = false;
|
||||||
|
|
||||||
mLockLevel = -999; //Set to impossible value to indicate no lock
|
mLockLevel = 0; //Set to 0 to indicate no lock
|
||||||
esm.getHNOT (mLockLevel, "FLTV");
|
esm.getHNOT (mLockLevel, "FLTV");
|
||||||
|
|
||||||
mKey = esm.getHNOString ("KNAM");
|
mKey = esm.getHNOString ("KNAM");
|
||||||
|
@ -114,7 +114,7 @@ void ESM::CellRef::save (ESMWriter &esm, bool wideRefNum, bool inInventory) cons
|
||||||
esm.writeHNOCString("DNAM", mDestCell);
|
esm.writeHNOCString("DNAM", mDestCell);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mLockLevel != -999 && !inInventory) {
|
if (mLockLevel != 0 && !inInventory) {
|
||||||
esm.writeHNT("FLTV", mLockLevel);
|
esm.writeHNT("FLTV", mLockLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue