mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-24 21:09:43 +00:00
Merge remote-tracking branch 'jeffreyhaines/master'
This commit is contained in:
commit
c38812d026
7 changed files with 29 additions and 14 deletions
|
@ -136,7 +136,7 @@ namespace MWClass
|
||||||
|
|
||||||
// TODO: this is not quite correct, in vanilla the merchant's gold pool is not available in his inventory.
|
// TODO: this is not quite correct, in vanilla the merchant's gold pool is not available in his inventory.
|
||||||
// (except for gold you gave him)
|
// (except for gold you gave him)
|
||||||
getContainerStore(ptr).add(MWWorld::ContainerStore::sGoldId, ref->mBase->mData.mGold, ptr);
|
//getContainerStore(ptr).add(MWWorld::ContainerStore::sGoldId, ref->mBase->mData.mGold, ptr);
|
||||||
|
|
||||||
if (ref->mBase->mFlags & ESM::Creature::Weapon)
|
if (ref->mBase->mFlags & ESM::Creature::Weapon)
|
||||||
getInventoryStore(ptr).autoEquip(ptr);
|
getInventoryStore(ptr).autoEquip(ptr);
|
||||||
|
@ -811,6 +811,11 @@ namespace MWClass
|
||||||
customData.mCreatureStats.writeState (state2.mCreatureStats);
|
customData.mCreatureStats.writeState (state2.mCreatureStats);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Creature::getBaseGold(const MWWorld::Ptr& ptr) const
|
||||||
|
{
|
||||||
|
return ptr.get<ESM::Creature>()->mBase->mData.mGold;
|
||||||
|
}
|
||||||
|
|
||||||
const ESM::GameSetting* Creature::fMinWalkSpeedCreature;
|
const ESM::GameSetting* Creature::fMinWalkSpeedCreature;
|
||||||
const ESM::GameSetting* Creature::fMaxWalkSpeedCreature;
|
const ESM::GameSetting* Creature::fMaxWalkSpeedCreature;
|
||||||
const ESM::GameSetting *Creature::fEncumberedMoveEffect;
|
const ESM::GameSetting *Creature::fEncumberedMoveEffect;
|
||||||
|
|
|
@ -141,6 +141,8 @@ namespace MWClass
|
||||||
virtual void writeAdditionalState (const MWWorld::Ptr& ptr, ESM::ObjectState& state)
|
virtual void writeAdditionalState (const MWWorld::Ptr& ptr, ESM::ObjectState& state)
|
||||||
const;
|
const;
|
||||||
///< Write additional state from \a ptr into \a state.
|
///< Write additional state from \a ptr into \a state.
|
||||||
|
|
||||||
|
virtual int getBaseGold(const MWWorld::Ptr& ptr) const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -367,7 +367,7 @@ namespace MWClass
|
||||||
|
|
||||||
// TODO: this is not quite correct, in vanilla the merchant's gold pool is not available in his inventory.
|
// TODO: this is not quite correct, in vanilla the merchant's gold pool is not available in his inventory.
|
||||||
// (except for gold you gave him)
|
// (except for gold you gave him)
|
||||||
getContainerStore(ptr).add(MWWorld::ContainerStore::sGoldId, gold, ptr);
|
//getContainerStore(ptr).add(MWWorld::ContainerStore::sGoldId, gold, ptr);
|
||||||
|
|
||||||
getInventoryStore(ptr).autoEquip(ptr);
|
getInventoryStore(ptr).autoEquip(ptr);
|
||||||
|
|
||||||
|
@ -1294,6 +1294,15 @@ namespace MWClass
|
||||||
static_cast<const MWMechanics::CreatureStats&> (customData.mNpcStats).writeState (state2.mCreatureStats);
|
static_cast<const MWMechanics::CreatureStats&> (customData.mNpcStats).writeState (state2.mCreatureStats);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Npc::getBaseGold(const MWWorld::Ptr& ptr) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::NPC> *ref = ptr.get<ESM::NPC>();
|
||||||
|
if(ref->mBase->mNpdtType != ESM::NPC::NPC_WITH_AUTOCALCULATED_STATS)
|
||||||
|
return ref->mBase->mNpdt52.mGold;
|
||||||
|
else
|
||||||
|
return ref->mBase->mNpdt12.mGold;
|
||||||
|
}
|
||||||
|
|
||||||
const ESM::GameSetting *Npc::fMinWalkSpeed;
|
const ESM::GameSetting *Npc::fMinWalkSpeed;
|
||||||
const ESM::GameSetting *Npc::fMaxWalkSpeed;
|
const ESM::GameSetting *Npc::fMaxWalkSpeed;
|
||||||
const ESM::GameSetting *Npc::fEncumberedMoveEffect;
|
const ESM::GameSetting *Npc::fEncumberedMoveEffect;
|
||||||
|
|
|
@ -166,6 +166,8 @@ namespace MWClass
|
||||||
virtual void writeAdditionalState (const MWWorld::Ptr& ptr, ESM::ObjectState& state)
|
virtual void writeAdditionalState (const MWWorld::Ptr& ptr, ESM::ObjectState& state)
|
||||||
const;
|
const;
|
||||||
///< Write additional state from \a ptr into \a state.
|
///< Write additional state from \a ptr into \a state.
|
||||||
|
|
||||||
|
virtual int getBaseGold(const MWWorld::Ptr& ptr) const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -360,7 +360,8 @@ namespace MWGui
|
||||||
if (mCurrentBalance != 0)
|
if (mCurrentBalance != 0)
|
||||||
{
|
{
|
||||||
addOrRemoveGold(mCurrentBalance, player);
|
addOrRemoveGold(mCurrentBalance, player);
|
||||||
addOrRemoveGold(-mCurrentBalance, mPtr);
|
mPtr.getClass().getCreatureStats(mPtr).setGoldPool(
|
||||||
|
mPtr.getClass().getCreatureStats(mPtr).getGoldPool() - mCurrentBalance );
|
||||||
}
|
}
|
||||||
|
|
||||||
updateTradeTime();
|
updateTradeTime();
|
||||||
|
@ -470,28 +471,20 @@ namespace MWGui
|
||||||
|
|
||||||
int TradeWindow::getMerchantGold()
|
int TradeWindow::getMerchantGold()
|
||||||
{
|
{
|
||||||
int merchantGold = 0;
|
int merchantGold = mPtr.getClass().getCreatureStats(mPtr).getGoldPool();
|
||||||
MWWorld::ContainerStore store = mPtr.getClass().getContainerStore(mPtr);
|
|
||||||
for (MWWorld::ContainerStoreIterator it = store.begin(); it != store.end(); ++it)
|
|
||||||
{
|
|
||||||
if (Misc::StringUtils::ciEqual(it->getCellRef().mRefID, MWWorld::ContainerStore::sGoldId))
|
|
||||||
merchantGold += it->getRefData().getCount();
|
|
||||||
}
|
|
||||||
return merchantGold;
|
return merchantGold;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Relates to NPC gold reset delay
|
// Relates to NPC gold reset delay
|
||||||
void TradeWindow::checkTradeTime()
|
void TradeWindow::checkTradeTime()
|
||||||
{
|
{
|
||||||
MWWorld::ContainerStore store = mPtr.getClass().getContainerStore(mPtr);
|
MWMechanics::CreatureStats &sellerStats = mPtr.getClass().getCreatureStats(mPtr);
|
||||||
const MWMechanics::CreatureStats &sellerStats = mPtr.getClass().getCreatureStats(mPtr);
|
|
||||||
double delay = boost::lexical_cast<double>(MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fBarterGoldResetDelay")->getInt());
|
double delay = boost::lexical_cast<double>(MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fBarterGoldResetDelay")->getInt());
|
||||||
|
|
||||||
// if time stamp longer than gold reset delay, reset gold.
|
// if time stamp longer than gold reset delay, reset gold.
|
||||||
if (MWBase::Environment::get().getWorld()->getTimeStamp() >= sellerStats.getTradeTime() + delay)
|
if (MWBase::Environment::get().getWorld()->getTimeStamp() >= sellerStats.getTradeTime() + delay)
|
||||||
{
|
{
|
||||||
addOrRemoveGold(-store.count(MWWorld::ContainerStore::sGoldId), mPtr);
|
sellerStats.setGoldPool(mPtr.getClass().getBaseGold(mPtr));
|
||||||
addOrRemoveGold(+sellerStats.getGoldPool(), mPtr);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -396,4 +396,6 @@ namespace MWWorld
|
||||||
void Class::readAdditionalState (const MWWorld::Ptr& ptr, const ESM::ObjectState& state) const {}
|
void Class::readAdditionalState (const MWWorld::Ptr& ptr, const ESM::ObjectState& state) const {}
|
||||||
|
|
||||||
void Class::writeAdditionalState (const MWWorld::Ptr& ptr, ESM::ObjectState& state) const {}
|
void Class::writeAdditionalState (const MWWorld::Ptr& ptr, ESM::ObjectState& state) const {}
|
||||||
|
|
||||||
|
int Class::getBaseGold(const MWWorld::Ptr& ptr) const {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -332,6 +332,8 @@ namespace MWWorld
|
||||||
///< If there is no class for this pointer, an exception is thrown.
|
///< If there is no class for this pointer, an exception is thrown.
|
||||||
|
|
||||||
static void registerClass (const std::string& key, boost::shared_ptr<Class> instance);
|
static void registerClass (const std::string& key, boost::shared_ptr<Class> instance);
|
||||||
|
|
||||||
|
virtual int getBaseGold(const MWWorld::Ptr& ptr) const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue