OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
MWMechanics::Alchemy Class Reference

Potion creation via alchemy skill. More...

#include <alchemy.hpp>

Collaboration diagram for MWMechanics::Alchemy:

Public Types

enum  Result {
  Result_Success, Result_NoMortarAndPestle, Result_LessThanTwoIngredients, Result_NoName,
  Result_NoEffects, Result_RandomFailure
}
 
typedef std::vector< MWWorld::PtrTToolsContainer
 
typedef
TToolsContainer::const_iterator 
TToolsIterator
 
typedef std::vector< MWWorld::PtrTIngredientsContainer
 
typedef
TIngredientsContainer::const_iterator 
TIngredientsIterator
 
typedef std::vector
< ESM::ENAMstruct
TEffectsContainer
 
typedef
TEffectsContainer::const_iterator 
TEffectsIterator
 

Public Member Functions

 Alchemy ()
 
void setAlchemist (const MWWorld::Ptr &npc)
 
TToolsIterator beginTools () const
 
TToolsIterator endTools () const
 
TIngredientsIterator beginIngredients () const
 
TIngredientsIterator endIngredients () const
 
void clear ()
 Remove alchemist, tools and ingredients. More...
 
std::set< EffectKeylistEffects () const
 List all effects shared by at least two ingredients. More...
 
int addIngredient (const MWWorld::Ptr &ingredient)
 
void removeIngredient (int index)
 Remove ingredient from slot (calling this function on an empty slot is a no-op). More...
 
std::string suggestPotionName ()
 Suggest a name for the potion, based on the current effects. More...
 
Result create (const std::string &name)
 

Static Public Member Functions

static bool knownEffect (unsigned int potionEffectIndex, const MWWorld::Ptr &npc)
 Does npc have sufficient alchemy skill to know about this potion effect? More...
 

Private Member Functions

void applyTools (int flags, float &value) const
 
void updateEffects ()
 
const ESM::PotiongetRecord (const ESM::Potion &toFind) const
 
void removeIngredients ()
 
void addPotion (const std::string &name)
 Add a potion to the alchemist's inventory. More...
 
void increaseSkill ()
 Increase alchemist's skill. More...
 
float getAlchemyFactor () const
 
int countIngredients () const
 
TEffectsIterator beginEffects () const
 
TEffectsIterator endEffects () const
 

Private Attributes

MWWorld::Ptr mAlchemist
 
TToolsContainer mTools
 
TIngredientsContainer mIngredients
 
TEffectsContainer mEffects
 
int mValue
 

Detailed Description

Potion creation via alchemy skill.

Member Typedef Documentation

typedef TEffectsContainer::const_iterator MWMechanics::Alchemy::TEffectsIterator
typedef TIngredientsContainer::const_iterator MWMechanics::Alchemy::TIngredientsIterator
typedef TToolsContainer::const_iterator MWMechanics::Alchemy::TToolsIterator

Member Enumeration Documentation

Enumerator
Result_Success 
Result_NoMortarAndPestle 
Result_LessThanTwoIngredients 
Result_NoName 
Result_NoEffects 
Result_RandomFailure 

Constructor & Destructor Documentation

MWMechanics::Alchemy::Alchemy ( )

Member Function Documentation

int MWMechanics::Alchemy::addIngredient ( const MWWorld::Ptr ingredient)

Add ingredient into the next free slot.

Returns
Slot index or -1, if adding failed because of no free slot or the ingredient type being listed already.

Here is the call graph for this function:

void MWMechanics::Alchemy::addPotion ( const std::string &  name)
private

Add a potion to the alchemist's inventory.

Here is the call graph for this function:

void MWMechanics::Alchemy::applyTools ( int  flags,
float &  value 
) const
private
MWMechanics::Alchemy::TEffectsIterator MWMechanics::Alchemy::beginEffects ( ) const
private
MWMechanics::Alchemy::TIngredientsIterator MWMechanics::Alchemy::beginIngredients ( ) const
Attention
Iterates over ingredient slots, not over ingredients. Some of the slots may be empty.
MWMechanics::Alchemy::TToolsIterator MWMechanics::Alchemy::beginTools ( ) const
Attention
Iterates over tool slots, not over tools. Some of the slots may be empty.
void MWMechanics::Alchemy::clear ( )

Remove alchemist, tools and ingredients.

int MWMechanics::Alchemy::countIngredients ( ) const
private
MWMechanics::Alchemy::Result MWMechanics::Alchemy::create ( const std::string &  name)

Try to create a potion from the ingredients, place it in the inventory of the alchemist and adjust the skills of the alchemist accordingly.

Parameters
namemust not be an empty string, or Result_NoName is returned

Here is the call graph for this function:

MWMechanics::Alchemy::TEffectsIterator MWMechanics::Alchemy::endEffects ( ) const
private
MWMechanics::Alchemy::TIngredientsIterator MWMechanics::Alchemy::endIngredients ( ) const
MWMechanics::Alchemy::TToolsIterator MWMechanics::Alchemy::endTools ( ) const
float MWMechanics::Alchemy::getAlchemyFactor ( ) const
private

Here is the call graph for this function:

const ESM::Potion * MWMechanics::Alchemy::getRecord ( const ESM::Potion toFind) const
private

Try to find a potion record similar to toFind in the record store, or return 0 if not found

Note
Does not account for record ID, model or icon

Here is the call graph for this function:

void MWMechanics::Alchemy::increaseSkill ( )
private

Increase alchemist's skill.

bool MWMechanics::Alchemy::knownEffect ( unsigned int  potionEffectIndex,
const MWWorld::Ptr npc 
)
static

Does npc have sufficient alchemy skill to know about this potion effect?

Here is the call graph for this function:

Here is the caller graph for this function:

std::set< MWMechanics::EffectKey > MWMechanics::Alchemy::listEffects ( ) const

List all effects shared by at least two ingredients.

void MWMechanics::Alchemy::removeIngredient ( int  index)

Remove ingredient from slot (calling this function on an empty slot is a no-op).

void MWMechanics::Alchemy::removeIngredients ( )
private

Remove selected ingredients from alchemist's inventory, cleanup selected ingredients and update effect list accordingly.

void MWMechanics::Alchemy::setAlchemist ( const MWWorld::Ptr npc)

Set alchemist and configure alchemy setup accordingly. npc may be empty to indicate that there is no alchemist (alchemy session has ended).

Here is the call graph for this function:

std::string MWMechanics::Alchemy::suggestPotionName ( )

Suggest a name for the potion, based on the current effects.

Here is the call graph for this function:

void MWMechanics::Alchemy::updateEffects ( )
private

Here is the call graph for this function:

Member Data Documentation

MWWorld::Ptr MWMechanics::Alchemy::mAlchemist
private
TEffectsContainer MWMechanics::Alchemy::mEffects
private
TIngredientsContainer MWMechanics::Alchemy::mIngredients
private
TToolsContainer MWMechanics::Alchemy::mTools
private
int MWMechanics::Alchemy::mValue
private

The documentation for this class was generated from the following files: