mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-27 21:35:24 +00:00
Merged pull request #1592
This commit is contained in:
commit
48711bbdde
@ -1,6 +1,7 @@
|
|||||||
0.45.0
|
0.45.0
|
||||||
------
|
------
|
||||||
|
|
||||||
|
Bug #2326: After a bound item expires the last equipped item of that type is not automatically re-equipped
|
||||||
Bug #2835: Player able to slowly move when overencumbered
|
Bug #2835: Player able to slowly move when overencumbered
|
||||||
Bug #3374: Touch spells not hitting kwama foragers
|
Bug #3374: Touch spells not hitting kwama foragers
|
||||||
Bug #3591: Angled hit distance too low
|
Bug #3591: Angled hit distance too low
|
||||||
|
@ -50,27 +50,36 @@ bool isConscious(const MWWorld::Ptr& ptr)
|
|||||||
return !stats.isDead() && !stats.getKnockedDown();
|
return !stats.isDead() && !stats.getKnockedDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
void adjustBoundItem (const std::string& item, bool bound, const MWWorld::Ptr& actor)
|
int getBoundItemSlot (const std::string& itemId)
|
||||||
{
|
{
|
||||||
if (bound)
|
static std::map<std::string, int> boundItemsMap;
|
||||||
|
if (boundItemsMap.empty())
|
||||||
{
|
{
|
||||||
if (actor.getClass().getContainerStore(actor).count(item) == 0)
|
std::string boundId = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("sMagicBoundBootsID")->getString();
|
||||||
{
|
boundItemsMap[boundId] = MWWorld::InventoryStore::Slot_Boots;
|
||||||
MWWorld::InventoryStore& store = actor.getClass().getInventoryStore(actor);
|
|
||||||
MWWorld::Ptr newPtr = *store.MWWorld::ContainerStore::add(item, 1, actor);
|
boundId = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("sMagicBoundCuirassID")->getString();
|
||||||
MWWorld::ActionEquip action(newPtr);
|
boundItemsMap[boundId] = MWWorld::InventoryStore::Slot_Cuirass;
|
||||||
action.execute(actor);
|
|
||||||
MWWorld::ConstContainerStoreIterator rightHand = store.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
boundId = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("sMagicBoundLeftGauntletID")->getString();
|
||||||
// change draw state only if the item is in player's right hand
|
boundItemsMap[boundId] = MWWorld::InventoryStore::Slot_LeftGauntlet;
|
||||||
if (actor == MWMechanics::getPlayer()
|
|
||||||
&& rightHand != store.end() && newPtr == *rightHand)
|
boundId = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("sMagicBoundRightGauntletID")->getString();
|
||||||
{
|
boundItemsMap[boundId] = MWWorld::InventoryStore::Slot_RightGauntlet;
|
||||||
MWBase::Environment::get().getWorld()->getPlayer().setDrawState(MWMechanics::DrawState_Weapon);
|
|
||||||
}
|
boundId = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("sMagicBoundHelmID")->getString();
|
||||||
}
|
boundItemsMap[boundId] = MWWorld::InventoryStore::Slot_Helmet;
|
||||||
|
|
||||||
|
boundId = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("sMagicBoundShieldID")->getString();
|
||||||
|
boundItemsMap[boundId] = MWWorld::InventoryStore::Slot_CarriedLeft;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
actor.getClass().getInventoryStore(actor).remove(item, 1, actor, true);
|
int slot = MWWorld::InventoryStore::Slot_CarriedRight;
|
||||||
|
std::map<std::string, int>::iterator it = boundItemsMap.find(itemId);
|
||||||
|
if (it != boundItemsMap.end())
|
||||||
|
slot = it->second;
|
||||||
|
|
||||||
|
return slot;
|
||||||
}
|
}
|
||||||
|
|
||||||
class CheckActorCommanded : public MWMechanics::EffectSourceVisitor
|
class CheckActorCommanded : public MWMechanics::EffectSourceVisitor
|
||||||
@ -139,7 +148,6 @@ void getRestorationPerHourOfSleep (const MWWorld::Ptr& ptr, float& health, float
|
|||||||
|
|
||||||
namespace MWMechanics
|
namespace MWMechanics
|
||||||
{
|
{
|
||||||
|
|
||||||
const float aiProcessingDistance = 7168;
|
const float aiProcessingDistance = 7168;
|
||||||
const float sqrAiProcessingDistance = aiProcessingDistance*aiProcessingDistance;
|
const float sqrAiProcessingDistance = aiProcessingDistance*aiProcessingDistance;
|
||||||
|
|
||||||
@ -227,6 +235,83 @@ namespace MWMechanics
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void Actors::addBoundItem (const std::string& itemId, const MWWorld::Ptr& actor)
|
||||||
|
{
|
||||||
|
MWWorld::InventoryStore& store = actor.getClass().getInventoryStore(actor);
|
||||||
|
int slot = getBoundItemSlot(itemId);
|
||||||
|
|
||||||
|
if (actor.getClass().getContainerStore(actor).count(itemId) != 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
MWWorld::ContainerStoreIterator prevItem = store.getSlot(slot);
|
||||||
|
|
||||||
|
MWWorld::Ptr boundPtr = *store.MWWorld::ContainerStore::add(itemId, 1, actor);
|
||||||
|
MWWorld::ActionEquip action(boundPtr);
|
||||||
|
action.execute(actor);
|
||||||
|
|
||||||
|
if (actor != MWMechanics::getPlayer())
|
||||||
|
return;
|
||||||
|
|
||||||
|
MWWorld::Ptr newItem = *store.getSlot(slot);
|
||||||
|
|
||||||
|
if (newItem.isEmpty() || boundPtr != newItem)
|
||||||
|
return;
|
||||||
|
|
||||||
|
MWWorld::Player& player = MWBase::Environment::get().getWorld()->getPlayer();
|
||||||
|
|
||||||
|
// change draw state only if the item is in player's right hand
|
||||||
|
if (slot == MWWorld::InventoryStore::Slot_CarriedRight)
|
||||||
|
player.setDrawState(MWMechanics::DrawState_Weapon);
|
||||||
|
|
||||||
|
if (prevItem != store.end())
|
||||||
|
player.setPreviousItem(itemId, prevItem->getCellRef().getRefId());
|
||||||
|
}
|
||||||
|
|
||||||
|
void Actors::removeBoundItem (const std::string& itemId, const MWWorld::Ptr& actor)
|
||||||
|
{
|
||||||
|
MWWorld::InventoryStore& store = actor.getClass().getInventoryStore(actor);
|
||||||
|
int slot = getBoundItemSlot(itemId);
|
||||||
|
|
||||||
|
MWWorld::ContainerStoreIterator currentItem = store.getSlot(slot);
|
||||||
|
|
||||||
|
bool wasEquipped = currentItem != store.end() && Misc::StringUtils::ciEqual(currentItem->getCellRef().getRefId(), itemId);
|
||||||
|
|
||||||
|
store.remove(itemId, 1, actor, true);
|
||||||
|
|
||||||
|
if (actor != MWMechanics::getPlayer())
|
||||||
|
return;
|
||||||
|
|
||||||
|
MWWorld::Player& player = MWBase::Environment::get().getWorld()->getPlayer();
|
||||||
|
std::string prevItemId = player.getPreviousItem(itemId);
|
||||||
|
player.erasePreviousItem(itemId);
|
||||||
|
|
||||||
|
if (prevItemId.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Find the item by id
|
||||||
|
MWWorld::Ptr item;
|
||||||
|
for (MWWorld::ContainerStoreIterator iter = store.begin(); iter != store.end(); ++iter)
|
||||||
|
{
|
||||||
|
if (Misc::StringUtils::ciEqual(iter->getCellRef().getRefId(), prevItemId))
|
||||||
|
{
|
||||||
|
if (item.isEmpty() ||
|
||||||
|
// Prefer the stack with the lowest remaining uses
|
||||||
|
!item.getClass().hasItemHealth(*iter) ||
|
||||||
|
iter->getClass().getItemHealth(*iter) < item.getClass().getItemHealth(item))
|
||||||
|
{
|
||||||
|
item = *iter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// we should equip previous item only if expired bound item was equipped.
|
||||||
|
if (item.isEmpty() || !wasEquipped)
|
||||||
|
return;
|
||||||
|
|
||||||
|
MWWorld::ActionEquip action(item);
|
||||||
|
action.execute(actor);
|
||||||
|
}
|
||||||
|
|
||||||
void Actors::updateActor (const MWWorld::Ptr& ptr, float duration)
|
void Actors::updateActor (const MWWorld::Ptr& ptr, float duration)
|
||||||
{
|
{
|
||||||
// magic effects
|
// magic effects
|
||||||
@ -756,25 +841,23 @@ namespace MWMechanics
|
|||||||
float magnitude = effects.get(it->first).getMagnitude();
|
float magnitude = effects.get(it->first).getMagnitude();
|
||||||
if (found != (magnitude > 0))
|
if (found != (magnitude > 0))
|
||||||
{
|
{
|
||||||
std::string itemGmst = it->second;
|
|
||||||
std::string item = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find(
|
|
||||||
itemGmst)->getString();
|
|
||||||
if (it->first == ESM::MagicEffect::BoundGloves)
|
|
||||||
{
|
|
||||||
item = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find(
|
|
||||||
"sMagicBoundLeftGauntletID")->getString();
|
|
||||||
adjustBoundItem(item, magnitude > 0, ptr);
|
|
||||||
item = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find(
|
|
||||||
"sMagicBoundRightGauntletID")->getString();
|
|
||||||
adjustBoundItem(item, magnitude > 0, ptr);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
adjustBoundItem(item, magnitude > 0, ptr);
|
|
||||||
|
|
||||||
if (magnitude > 0)
|
if (magnitude > 0)
|
||||||
creatureStats.mBoundItems.insert(it->first);
|
creatureStats.mBoundItems.insert(it->first);
|
||||||
else
|
else
|
||||||
creatureStats.mBoundItems.erase(it->first);
|
creatureStats.mBoundItems.erase(it->first);
|
||||||
|
|
||||||
|
std::string itemGmst = it->second;
|
||||||
|
std::string item = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find(
|
||||||
|
itemGmst)->getString();
|
||||||
|
|
||||||
|
magnitude > 0 ? addBoundItem(item, ptr) : removeBoundItem(item, ptr);
|
||||||
|
|
||||||
|
if (it->first == ESM::MagicEffect::BoundGloves)
|
||||||
|
{
|
||||||
|
item = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find(
|
||||||
|
"sMagicBoundRightGauntletID")->getString();
|
||||||
|
magnitude > 0 ? addBoundItem(item, ptr) : removeBoundItem(item, ptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <map>
|
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
#include "../mwbase/world.hpp"
|
#include "../mwbase/world.hpp"
|
||||||
@ -26,6 +25,9 @@ namespace MWMechanics
|
|||||||
{
|
{
|
||||||
std::map<std::string, int> mDeathCount;
|
std::map<std::string, int> mDeathCount;
|
||||||
|
|
||||||
|
void addBoundItem (const std::string& itemId, const MWWorld::Ptr& actor);
|
||||||
|
void removeBoundItem (const std::string& itemId, const MWWorld::Ptr& actor);
|
||||||
|
|
||||||
void updateNpc(const MWWorld::Ptr &ptr, float duration);
|
void updateNpc(const MWWorld::Ptr &ptr, float duration);
|
||||||
|
|
||||||
void adjustMagicEffects (const MWWorld::Ptr& creature);
|
void adjustMagicEffects (const MWWorld::Ptr& creature);
|
||||||
|
@ -287,6 +287,7 @@ namespace MWWorld
|
|||||||
mAttackingOrSpell = false;
|
mAttackingOrSpell = false;
|
||||||
mCurrentCrimeId = -1;
|
mCurrentCrimeId = -1;
|
||||||
mPaidCrimeId = -1;
|
mPaidCrimeId = -1;
|
||||||
|
mPreviousItems.clear();
|
||||||
mLastKnownExteriorPosition = osg::Vec3f(0,0,0);
|
mLastKnownExteriorPosition = osg::Vec3f(0,0,0);
|
||||||
|
|
||||||
for (int i=0; i<ESM::Skill::Length; ++i)
|
for (int i=0; i<ESM::Skill::Length; ++i)
|
||||||
@ -341,6 +342,8 @@ namespace MWWorld
|
|||||||
for (int i=0; i<ESM::Skill::Length; ++i)
|
for (int i=0; i<ESM::Skill::Length; ++i)
|
||||||
mSaveSkills[i].writeState(player.mSaveSkills[i]);
|
mSaveSkills[i].writeState(player.mSaveSkills[i]);
|
||||||
|
|
||||||
|
player.mPreviousItems = mPreviousItems;
|
||||||
|
|
||||||
writer.startRecord (ESM::REC_PLAY);
|
writer.startRecord (ESM::REC_PLAY);
|
||||||
player.save (writer);
|
player.save (writer);
|
||||||
writer.endRecord (ESM::REC_PLAY);
|
writer.endRecord (ESM::REC_PLAY);
|
||||||
@ -441,6 +444,8 @@ namespace MWWorld
|
|||||||
mForwardBackward = 0;
|
mForwardBackward = 0;
|
||||||
mTeleported = false;
|
mTeleported = false;
|
||||||
|
|
||||||
|
mPreviousItems = player.mPreviousItems;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -461,4 +466,19 @@ namespace MWWorld
|
|||||||
{
|
{
|
||||||
return mPaidCrimeId;
|
return mPaidCrimeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Player::setPreviousItem(const std::string& boundItemId, const std::string& previousItemId)
|
||||||
|
{
|
||||||
|
mPreviousItems[boundItemId] = previousItemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string Player::getPreviousItem(const std::string& boundItemId)
|
||||||
|
{
|
||||||
|
return mPreviousItems[boundItemId];
|
||||||
|
}
|
||||||
|
|
||||||
|
void Player::erasePreviousItem(const std::string& boundItemId)
|
||||||
|
{
|
||||||
|
mPreviousItems.erase(boundItemId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#ifndef GAME_MWWORLD_PLAYER_H
|
#ifndef GAME_MWWORLD_PLAYER_H
|
||||||
#define GAME_MWWORLD_PLAYER_H
|
#define GAME_MWWORLD_PLAYER_H
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
|
||||||
#include "../mwworld/refdata.hpp"
|
#include "../mwworld/refdata.hpp"
|
||||||
#include "../mwworld/livecellref.hpp"
|
#include "../mwworld/livecellref.hpp"
|
||||||
|
|
||||||
@ -46,6 +48,9 @@ namespace MWWorld
|
|||||||
int mCurrentCrimeId; // the id assigned witnesses
|
int mCurrentCrimeId; // the id assigned witnesses
|
||||||
int mPaidCrimeId; // the last id paid off (0 bounty)
|
int mPaidCrimeId; // the last id paid off (0 bounty)
|
||||||
|
|
||||||
|
typedef std::map<std::string, std::string> PreviousItems; // previous equipped items, needed for bound spells
|
||||||
|
PreviousItems mPreviousItems;
|
||||||
|
|
||||||
// Saved stats prior to becoming a werewolf
|
// Saved stats prior to becoming a werewolf
|
||||||
MWMechanics::SkillValue mSaveSkills[ESM::Skill::Length];
|
MWMechanics::SkillValue mSaveSkills[ESM::Skill::Length];
|
||||||
MWMechanics::AttributeValue mSaveAttributes[ESM::Attribute::Length];
|
MWMechanics::AttributeValue mSaveAttributes[ESM::Attribute::Length];
|
||||||
@ -120,6 +125,10 @@ namespace MWWorld
|
|||||||
int getNewCrimeId(); // get new id for witnesses
|
int getNewCrimeId(); // get new id for witnesses
|
||||||
void recordCrimeId(); // record the paid crime id when bounty is 0
|
void recordCrimeId(); // record the paid crime id when bounty is 0
|
||||||
int getCrimeId() const; // get the last paid crime id
|
int getCrimeId() const; // get the last paid crime id
|
||||||
|
|
||||||
|
void setPreviousItem(const std::string& boundItemId, const std::string& previousItemId);
|
||||||
|
std::string getPreviousItem(const std::string& boundItemId);
|
||||||
|
void erasePreviousItem(const std::string& boundItemId);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -31,6 +31,18 @@ void ESM::Player::load (ESMReader &esm)
|
|||||||
mPaidCrimeId = -1;
|
mPaidCrimeId = -1;
|
||||||
esm.getHNOT (mPaidCrimeId, "PAYD");
|
esm.getHNOT (mPaidCrimeId, "PAYD");
|
||||||
|
|
||||||
|
bool checkPrevItems = true;
|
||||||
|
while (checkPrevItems)
|
||||||
|
{
|
||||||
|
std::string boundItemId = esm.getHNOString("BOUN");
|
||||||
|
std::string prevItemId = esm.getHNOString("PREV");
|
||||||
|
|
||||||
|
if (!boundItemId.empty())
|
||||||
|
mPreviousItems[boundItemId] = prevItemId;
|
||||||
|
else
|
||||||
|
checkPrevItems = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (esm.hasMoreSubs())
|
if (esm.hasMoreSubs())
|
||||||
{
|
{
|
||||||
for (int i=0; i<ESM::Attribute::Length; ++i)
|
for (int i=0; i<ESM::Attribute::Length; ++i)
|
||||||
@ -62,6 +74,12 @@ void ESM::Player::save (ESMWriter &esm) const
|
|||||||
esm.writeHNT ("CURD", mCurrentCrimeId);
|
esm.writeHNT ("CURD", mCurrentCrimeId);
|
||||||
esm.writeHNT ("PAYD", mPaidCrimeId);
|
esm.writeHNT ("PAYD", mPaidCrimeId);
|
||||||
|
|
||||||
|
for (PreviousItems::const_iterator it=mPreviousItems.begin(); it != mPreviousItems.end(); ++it)
|
||||||
|
{
|
||||||
|
esm.writeHNString ("BOUN", it->first);
|
||||||
|
esm.writeHNString ("PREV", it->second);
|
||||||
|
}
|
||||||
|
|
||||||
for (int i=0; i<ESM::Attribute::Length; ++i)
|
for (int i=0; i<ESM::Attribute::Length; ++i)
|
||||||
mSaveAttributes[i].save(esm);
|
mSaveAttributes[i].save(esm);
|
||||||
for (int i=0; i<ESM::Skill::Length; ++i)
|
for (int i=0; i<ESM::Skill::Length; ++i)
|
||||||
|
@ -34,6 +34,9 @@ namespace ESM
|
|||||||
StatState<int> mSaveAttributes[ESM::Attribute::Length];
|
StatState<int> mSaveAttributes[ESM::Attribute::Length];
|
||||||
StatState<int> mSaveSkills[ESM::Skill::Length];
|
StatState<int> mSaveSkills[ESM::Skill::Length];
|
||||||
|
|
||||||
|
typedef std::map<std::string, std::string> PreviousItems; // previous equipped items, needed for bound spells
|
||||||
|
PreviousItems mPreviousItems;
|
||||||
|
|
||||||
void load (ESMReader &esm);
|
void load (ESMReader &esm);
|
||||||
void save (ESMWriter &esm) const;
|
void save (ESMWriter &esm) const;
|
||||||
};
|
};
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include "defs.hpp"
|
#include "defs.hpp"
|
||||||
|
|
||||||
unsigned int ESM::SavedGame::sRecordId = ESM::REC_SAVE;
|
unsigned int ESM::SavedGame::sRecordId = ESM::REC_SAVE;
|
||||||
int ESM::SavedGame::sCurrentFormat = 4;
|
int ESM::SavedGame::sCurrentFormat = 5;
|
||||||
|
|
||||||
void ESM::SavedGame::load (ESMReader &esm)
|
void ESM::SavedGame::load (ESMReader &esm)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user