mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-22 22:53:53 +00:00
Move previous items to player
This commit is contained in:
parent
f977c6876f
commit
9fd2d57b86
4 changed files with 33 additions and 9 deletions
|
@ -262,7 +262,10 @@ namespace MWMechanics
|
||||||
MWBase::Environment::get().getWorld()->getPlayer().setDrawState(MWMechanics::DrawState_Weapon);
|
MWBase::Environment::get().getWorld()->getPlayer().setDrawState(MWMechanics::DrawState_Weapon);
|
||||||
|
|
||||||
if (prevItem != store.end())
|
if (prevItem != store.end())
|
||||||
mPreviousItems[itemId] = (*prevItem).getCellRef().getRefId();
|
{
|
||||||
|
MWWorld::Player* player = &MWBase::Environment::get().getWorld()->getPlayer();
|
||||||
|
player->setPreviousItem(itemId, prevItem->getCellRef().getRefId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Actors::removeBoundItem (const std::string& itemId, const MWWorld::Ptr& actor)
|
void Actors::removeBoundItem (const std::string& itemId, const MWWorld::Ptr& actor)
|
||||||
|
@ -272,16 +275,16 @@ namespace MWMechanics
|
||||||
|
|
||||||
MWWorld::ContainerStoreIterator currentItem = store.getSlot(slot);
|
MWWorld::ContainerStoreIterator currentItem = store.getSlot(slot);
|
||||||
|
|
||||||
bool wasEquipped = currentItem != store.end() && Misc::StringUtils::ciEqual((*currentItem).getCellRef().getRefId(), itemId);
|
bool wasEquipped = currentItem != store.end() && Misc::StringUtils::ciEqual(currentItem->getCellRef().getRefId(), itemId);
|
||||||
|
|
||||||
store.remove(itemId, 1, actor, true);
|
store.remove(itemId, 1, actor, true);
|
||||||
|
|
||||||
if (actor != MWMechanics::getPlayer())
|
if (actor != MWMechanics::getPlayer())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
std::string prevItemId = mPreviousItems[itemId];
|
MWWorld::Player* player = &MWBase::Environment::get().getWorld()->getPlayer();
|
||||||
|
std::string prevItemId = player->getPreviousItem(itemId);
|
||||||
mPreviousItems.erase(itemId);
|
player->erasePreviousItem(itemId);
|
||||||
|
|
||||||
if (prevItemId.empty())
|
if (prevItemId.empty())
|
||||||
return;
|
return;
|
||||||
|
@ -1956,7 +1959,6 @@ namespace MWMechanics
|
||||||
}
|
}
|
||||||
mActors.clear();
|
mActors.clear();
|
||||||
mDeathCount.clear();
|
mDeathCount.clear();
|
||||||
mPreviousItems.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Actors::updateMagicEffects(const MWWorld::Ptr &ptr)
|
void Actors::updateMagicEffects(const MWWorld::Ptr &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"
|
||||||
|
@ -25,8 +24,6 @@ namespace MWMechanics
|
||||||
class Actors
|
class Actors
|
||||||
{
|
{
|
||||||
std::map<std::string, int> mDeathCount;
|
std::map<std::string, int> mDeathCount;
|
||||||
typedef std::map<std::string, std::string> PreviousItems;
|
|
||||||
PreviousItems mPreviousItems;
|
|
||||||
|
|
||||||
void addBoundItem (const std::string& itemId, const MWWorld::Ptr& actor);
|
void addBoundItem (const std::string& itemId, const MWWorld::Ptr& actor);
|
||||||
void removeBoundItem (const std::string& itemId, const MWWorld::Ptr& actor);
|
void removeBoundItem (const std::string& itemId, const MWWorld::Ptr& actor);
|
||||||
|
|
|
@ -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)
|
||||||
|
@ -461,4 +462,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
|
||||||
|
|
Loading…
Reference in a new issue