iAutoPCSpellMax - максимальное количество заклинаний которые игрок может получить как стартовые.
Значение по умолчанию: 100
Часть кода из OpenMW:
baseMagicka = fPCbaseMagickaMult * baseActor.intelligence
reachedLimit = false
weakestSpell = none
minCost = INT_MAX
baseActor.spells = vector()
for each spell in the game: # note: iteration order is important, see comments
if spell.isMarkedDeleted: continue
if spell.castingType != spell: continue
if not spell.isPCStartSpell: continue
if reachedLimit and spell.cost <= minCost: continue
if spell is in baseActor.spells: continue
if spell is in baseActor.race.racialSpells: continue
if baseMagicka < spell.cost: continue
if calcAutoCastChance(spell, baseActor, none) < fAutoPCSpellChance: continue
failedAttrSkillCheck = false
for each effect in spell:
if (effect.baseEffect.flags & TARGET_SKILL) and baseActor.skills[effect.targetSkill] < iAutoSpellAttSkillMin:
failedAttrSkillCheck = true
break
if (effect.baseEffect.flags & TARGET_ATTR) and baseActor.attribute[effect.targetAttr] < iAutoSpellAttSkillMin:
failedAttrSkillCheck = true
break
if failedAttrSkillCheck: continue
baseActor.spells.add(spell)
if reachedLimit:
baseActor.spells.remove(weakestSpell)
weakestSpell = baseActor.spells.findMinCostSpell()
minCost = weakestSpell.cost
else:
if spell.cost < minCost:
weakestSpell = spell
minCost = spell.cost
if baseActor.spells.size() == iAutoPCSpellMax:
reachedLimit = true
baseMagicka - запас маны для PC