mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-29 21:06:41 +00:00
Don't buy/sell keys which are set to open a lock
This commit is contained in:
parent
2d2196b0d6
commit
f3c8cd2065
28 changed files with 97 additions and 27 deletions
|
@ -159,4 +159,9 @@ namespace MWClass
|
|||
|
||||
return MWWorld::Ptr(&cell.mAppas.insert(*ref), &cell);
|
||||
}
|
||||
|
||||
bool Apparatus::canSell (const MWWorld::Ptr& item, int npcServices) const
|
||||
{
|
||||
return npcServices & ESM::NPC::Apparatus;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,6 +54,8 @@ namespace MWClass
|
|||
///< Generate action for using via inventory menu
|
||||
|
||||
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
|
||||
|
||||
virtual bool canSell (const MWWorld::Ptr& item, int npcServices) const;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -315,4 +315,9 @@ namespace MWClass
|
|||
|
||||
return ref->mBase->mData.mEnchant;
|
||||
}
|
||||
|
||||
bool Armor::canSell (const MWWorld::Ptr& item, int npcServices) const
|
||||
{
|
||||
return npcServices & ESM::NPC::Armor;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,6 +74,8 @@ namespace MWClass
|
|||
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
|
||||
|
||||
virtual short getEnchantmentPoints (const MWWorld::Ptr& ptr) const;
|
||||
|
||||
virtual bool canSell (const MWWorld::Ptr& item, int npcServices) const;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -183,4 +183,9 @@ namespace MWClass
|
|||
|
||||
return ref->mBase->mData.mEnchant;
|
||||
}
|
||||
|
||||
bool Book::canSell (const MWWorld::Ptr& item, int npcServices) const
|
||||
{
|
||||
return npcServices & ESM::NPC::Books;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,6 +59,8 @@ namespace MWClass
|
|||
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
|
||||
|
||||
virtual short getEnchantmentPoints (const MWWorld::Ptr& ptr) const;
|
||||
|
||||
virtual bool canSell (const MWWorld::Ptr& item, int npcServices) const;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -262,4 +262,9 @@ namespace MWClass
|
|||
|
||||
return ref->mBase->mData.mEnchant;
|
||||
}
|
||||
|
||||
bool Clothing::canSell (const MWWorld::Ptr& item, int npcServices) const
|
||||
{
|
||||
return npcServices & ESM::NPC::Clothing;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,6 +68,8 @@ namespace MWClass
|
|||
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
|
||||
|
||||
virtual short getEnchantmentPoints (const MWWorld::Ptr& ptr) const;
|
||||
|
||||
virtual bool canSell (const MWWorld::Ptr& item, int npcServices) const;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -197,4 +197,9 @@ namespace MWClass
|
|||
|
||||
return MWWorld::Ptr(&cell.mIngreds.insert(*ref), &cell);
|
||||
}
|
||||
|
||||
bool Ingredient::canSell (const MWWorld::Ptr& item, int npcServices) const
|
||||
{
|
||||
return npcServices & ESM::NPC::Ingredients;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,6 +56,8 @@ namespace MWClass
|
|||
///< Return name of inventory icon.
|
||||
|
||||
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
|
||||
|
||||
virtual bool canSell (const MWWorld::Ptr& item, int npcServices) const;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -203,4 +203,9 @@ namespace MWClass
|
|||
|
||||
return MWWorld::Ptr(&cell.mLights.insert(*ref), &cell);
|
||||
}
|
||||
|
||||
bool Light::canSell (const MWWorld::Ptr& item, int npcServices) const
|
||||
{
|
||||
return npcServices & ESM::NPC::Lights;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,6 +57,8 @@ namespace MWClass
|
|||
///< Generate action for using via inventory menu
|
||||
|
||||
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
|
||||
|
||||
virtual bool canSell (const MWWorld::Ptr& item, int npcServices) const;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -176,4 +176,9 @@ namespace MWClass
|
|||
|
||||
return MWWorld::Ptr(&cell.mLockpicks.insert(*ref), &cell);
|
||||
}
|
||||
|
||||
bool Lockpick::canSell (const MWWorld::Ptr& item, int npcServices) const
|
||||
{
|
||||
return npcServices & ESM::NPC::Picks;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,6 +57,8 @@ namespace MWClass
|
|||
///< Generate action for using via inventory menu
|
||||
|
||||
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
|
||||
|
||||
virtual bool canSell (const MWWorld::Ptr& item, int npcServices) const;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -246,4 +246,12 @@ namespace MWClass
|
|||
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionSoulgem(ptr));
|
||||
}
|
||||
|
||||
bool Miscellaneous::canSell (const MWWorld::Ptr& item, int npcServices) const
|
||||
{
|
||||
MWWorld::LiveCellRef<ESM::Miscellaneous> *ref =
|
||||
item.get<ESM::Miscellaneous>();
|
||||
|
||||
return !ref->mBase->mData.mIsKey && (npcServices & ESM::NPC::Misc);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -53,6 +53,8 @@ namespace MWClass
|
|||
virtual boost::shared_ptr<MWWorld::Action> use (const MWWorld::Ptr& ptr)
|
||||
const;
|
||||
///< Generate action for using via inventory menu
|
||||
|
||||
virtual bool canSell (const MWWorld::Ptr& item, int npcServices) const;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -194,4 +194,9 @@ namespace MWClass
|
|||
|
||||
return MWWorld::Ptr(&cell.mPotions.insert(*ref), &cell);
|
||||
}
|
||||
|
||||
bool Potion::canSell (const MWWorld::Ptr& item, int npcServices) const
|
||||
{
|
||||
return npcServices & ESM::NPC::Potions;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,6 +52,8 @@ namespace MWClass
|
|||
///< Return name of inventory icon.
|
||||
|
||||
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
|
||||
|
||||
virtual bool canSell (const MWWorld::Ptr& item, int npcServices) const;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -175,4 +175,9 @@ namespace MWClass
|
|||
|
||||
return MWWorld::Ptr(&cell.mProbes.insert(*ref), &cell);
|
||||
}
|
||||
|
||||
bool Probe::canSell (const MWWorld::Ptr& item, int npcServices) const
|
||||
{
|
||||
return npcServices & ESM::NPC::Probes;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,6 +57,8 @@ namespace MWClass
|
|||
///< Generate action for using via inventory menu
|
||||
|
||||
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
|
||||
|
||||
virtual bool canSell (const MWWorld::Ptr& item, int npcServices) const;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -175,4 +175,9 @@ namespace MWClass
|
|||
{
|
||||
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionRepair(ptr));
|
||||
}
|
||||
|
||||
bool Repair::canSell (const MWWorld::Ptr& item, int npcServices) const
|
||||
{
|
||||
return npcServices & ESM::NPC::RepairItem;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,6 +61,8 @@ namespace MWClass
|
|||
virtual int getItemMaxHealth (const MWWorld::Ptr& ptr) const;
|
||||
///< Return item max health or throw an exception, if class does not have item health
|
||||
/// (default implementation: throw an exceoption)
|
||||
|
||||
virtual bool canSell (const MWWorld::Ptr& item, int npcServices) const;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -409,4 +409,9 @@ namespace MWClass
|
|||
|
||||
return ref->mBase->mData.mEnchant;
|
||||
}
|
||||
|
||||
bool Weapon::canSell (const MWWorld::Ptr& item, int npcServices) const
|
||||
{
|
||||
return npcServices & ESM::NPC::Weapon;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,6 +73,8 @@ namespace MWClass
|
|||
|
||||
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
|
||||
|
||||
virtual bool canSell (const MWWorld::Ptr& item, int npcServices) const;
|
||||
|
||||
virtual short getEnchantmentPoints (const MWWorld::Ptr& ptr) const;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -356,32 +356,7 @@ namespace MWGui
|
|||
services = ref->mBase->mAiData.mServices;
|
||||
}
|
||||
|
||||
/// \todo what about potions, there doesn't seem to be a flag for them??
|
||||
|
||||
if (item.getTypeName() == typeid(ESM::Weapon).name())
|
||||
return services & ESM::NPC::Weapon;
|
||||
else if (item.getTypeName() == typeid(ESM::Armor).name())
|
||||
return services & ESM::NPC::Armor;
|
||||
else if (item.getTypeName() == typeid(ESM::Clothing).name())
|
||||
return services & ESM::NPC::Clothing;
|
||||
else if (item.getTypeName() == typeid(ESM::Book).name())
|
||||
return services & ESM::NPC::Books;
|
||||
else if (item.getTypeName() == typeid(ESM::Ingredient).name())
|
||||
return services & ESM::NPC::Ingredients;
|
||||
else if (item.getTypeName() == typeid(ESM::Lockpick).name())
|
||||
return services & ESM::NPC::Picks;
|
||||
else if (item.getTypeName() == typeid(ESM::Probe).name())
|
||||
return services & ESM::NPC::Probes;
|
||||
else if (item.getTypeName() == typeid(ESM::Light).name())
|
||||
return services & ESM::NPC::Lights;
|
||||
else if (item.getTypeName() == typeid(ESM::Apparatus).name())
|
||||
return services & ESM::NPC::Apparatus;
|
||||
else if (item.getTypeName() == typeid(ESM::Repair).name())
|
||||
return services & ESM::NPC::RepairItem;
|
||||
else if (item.getTypeName() == typeid(ESM::Miscellaneous).name())
|
||||
return services & ESM::NPC::Misc;
|
||||
|
||||
return false;
|
||||
return MWWorld::Class::get(item).canSell(item, services);
|
||||
}
|
||||
|
||||
std::vector<MWWorld::Ptr> TradeWindow::itemsToIgnore()
|
||||
|
|
|
@ -47,6 +47,11 @@ namespace MWWorld
|
|||
throw std::runtime_error ("class does not represent an actor");
|
||||
}
|
||||
|
||||
bool Class::canSell (const MWWorld::Ptr& item, int npcServices) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
MWMechanics::CreatureStats& Class::getCreatureStats (const Ptr& ptr) const
|
||||
{
|
||||
throw std::runtime_error ("class does not have creature stats");
|
||||
|
|
|
@ -238,6 +238,9 @@ namespace MWWorld
|
|||
|
||||
virtual void adjustRotation(const MWWorld::Ptr& ptr,float& x,float& y,float& z) const;
|
||||
|
||||
virtual bool canSell (const MWWorld::Ptr& item, int npcServices) const;
|
||||
///< Determine whether or not \a item can be sold to an npc with the given \a npcServices
|
||||
|
||||
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
|
||||
|
||||
virtual void applyEnchantment(const MWWorld::Ptr &ptr, const std::string& enchId, int enchCharge, const std::string& newName) const;
|
||||
|
|
|
@ -35,11 +35,11 @@ struct NPC
|
|||
Apparatus = 0x00100,
|
||||
RepairItem = 0x00200,
|
||||
Misc = 0x00400,
|
||||
Potions = 0x02000,
|
||||
|
||||
// Other services
|
||||
Spells = 0x00800,
|
||||
MagicItems = 0x01000,
|
||||
Potions = 0x02000,
|
||||
Training = 0x04000, // What skills?
|
||||
Spellmaking = 0x08000,
|
||||
Enchanting = 0x10000,
|
||||
|
|
Loading…
Reference in a new issue