getBaseGold implemented in MWWorld::Class for NPC and Creature

Implemented a getBaseGold() to get the vendor gold base
NPC gold base now can come from mNpdt12 and mNpdt52
actorid
Jeffrey Haines 11 years ago
parent 895748f18d
commit 401d21b4ee

@ -811,6 +811,11 @@ namespace MWClass
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::fMaxWalkSpeedCreature;
const ESM::GameSetting *Creature::fEncumberedMoveEffect;

@ -141,6 +141,8 @@ namespace MWClass
virtual void writeAdditionalState (const MWWorld::Ptr& ptr, ESM::ObjectState& state)
const;
///< Write additional state from \a ptr into \a state.
virtual int getBaseGold(const MWWorld::Ptr& ptr) const;
};
}

@ -1294,6 +1294,15 @@ namespace MWClass
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::fMaxWalkSpeed;
const ESM::GameSetting *Npc::fEncumberedMoveEffect;

@ -166,6 +166,8 @@ namespace MWClass
virtual void writeAdditionalState (const MWWorld::Ptr& ptr, ESM::ObjectState& state)
const;
///< Write additional state from \a ptr into \a state.
virtual int getBaseGold(const MWWorld::Ptr& ptr) const;
};
}

@ -484,11 +484,7 @@ namespace MWGui
// if time stamp longer than gold reset delay, reset gold.
if (MWBase::Environment::get().getWorld()->getTimeStamp() >= sellerStats.getTradeTime() + delay)
{
// reset gold to the base gold
if ( mPtr.getClass().isNpc() )
sellerStats.setGoldPool(mPtr.get<ESM::NPC>()->mBase->mNpdt52.mGold);
else
sellerStats.setGoldPool(mPtr.get<ESM::Creature>()->mBase->mData.mGold);
sellerStats.setGoldPool(mPtr.getClass().getBaseGold(mPtr));
}
}

@ -396,4 +396,6 @@ namespace MWWorld
void Class::readAdditionalState (const MWWorld::Ptr& ptr, const 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.
static void registerClass (const std::string& key, boost::shared_ptr<Class> instance);
virtual int getBaseGold(const MWWorld::Ptr& ptr) const;
};
}

Loading…
Cancel
Save