engine/calculators/source/SpellbookCalculator.cpp
// Get the number of castings available to the creature.
//
// This is calculated as:
//
// min(SpellConstants::MIN_CASTINGS,
//      spellbook status factor * 
//         (Random value between SpellConstants::MIN_CASTINGS, SpellConstants::MAX_CASTINGS
//       + (Creature's intelligence / 2)
//       + Creature's willpower
//       + (Creature's magic general skill / 4)
//       + (Creature's magic category skill / 2)
//       - (Difficulty / 3))
Get the number of castings available to the creature.
This is calculated as.


Get the number of castings available to the creature . This is calculated as .
int SpellbookCalculator::get_num_castings(CreaturePtr creature, const SkillType magic_category, const ItemStatus spellbook_status, const int difficulty)
{
  Skills& skills = creature->get_skills();
  int int_score = creature->get_intelligence().get_current();
  int will_score = creature->get_willpower().get_current();
  int magic_general_score = skills.get_skill(SkillType::SKILL_GENERAL_MAGIC)->get_value();
  int magic_category_score = skills.get_skill(magic_category)->get_value();
  int random_factor = RNG::range(SpellConstants::BASE_MIN_CASTINGS, SpellConstants::BASE_MAX_CASTINGS);
  int calculated_castings = random_factor
                          + (int_score / 2)
                          + will_score
                          + (magic_general_score / 4)
                          + (magic_category_score / 2)
                          - (difficulty / 3);
  calculated_castings = static_cast<int>(calculated_castings * status_casting_multipliers[spellbook_status]);
  int castings = std::max<int>(SpellConstants::MIN_CASTINGS, calculated_castings);
  return castings;
}
int SpellbookCalculator :: get_num_castings ( CreaturePtr creature , const SkillType magic_category , const ItemStatus spellbook_status , const int difficulty ) { Skills & skills = creature -> get_skills ( ) ; int int_score = creature -> get_intelligence ( ) . get_current ( ) ; int will_score = creature -> get_willpower ( ) . get_current ( ) ; int magic_general_score = skills . get_skill ( SkillType :: SKILL_GENERAL_MAGIC ) -> get_value ( ) ; int magic_category_score = skills . get_skill ( magic_category ) -> get_value ( ) ; int random_factor = RNG :: range ( SpellConstants :: BASE_MIN_CASTINGS , SpellConstants :: BASE_MAX_CASTINGS ) ; int calculated_castings = random_factor + ( int_score / 2 ) + will_score + ( magic_general_score / 4 ) + ( magic_category_score / 2 ) - ( difficulty / 3 ) ; calculated_castings = static_cast < int > ( calculated_castings * status_casting_multipliers [ spellbook_status ] ) ; int castings = std :: max < int > ( SpellConstants :: MIN_CASTINGS , calculated_castings ) ; return castings ; }
Get the number of castings available to the creature.
Get the number of castings available to the creature .