iAutoSpellConjurationMax - максимальное количество заклинаний школы Изменения которые может получить NPC при расчете его в Auto-Calc
Значение по умолчанию: 2
Часть кода из OpenMW:
iAutoSpell{school}Max - лимит по максимальному кол-ву заклинаний для каждой из школ.
iAutoSpellTimesCanCast - на какое минимальное колличество кастов заклинания должно хватить маны у игрока или NPC для того чтобы получить его как стартовое или при расчете Auto-Calc
baseActor.spells = vector()
baseMagicka = fNPCbaseMagickaMult * baseActor.intelligence
spellSchools = { Alteration, Conjuration, Destruction, Illusion, Mysticism, Restoration }
schoolCaps = {} # could be an array indexed by school enum
for each school in spellSchools:
schoolCaps[school] = { count : 0,
limit : iAutoSpell{school}Max,
reachedLimit : iAutoSpell{school}Max <= 0,
minCost : INT_MAX,
weakestSpell : none }
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.isAutoCalculate: continue
if baseMagicka < iAutoSpellTimesCanCast * spell.cost: continue
if spell is in baseActor.race.racialSpells: 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
school, _ = calcWeakestSchool(spell, actor)
cap = schoolCaps[school]
if cap.reachedLimit and spell.cost <= cap.minCost: continue
if calcBaseCastChance(baseActor, spell, school) < fAutoSpellChance: continue
baseActor.spells.add(spell)
if cap.reachedLimit:
baseActor.spells.remove(cap.weakestSpell)
cap.weakestSpell = baseActor.spells.findMinCostSpell() # note: not school specific
cap.minCost = cap.weakestSpell.cost
else:
cap.count += 1
if cap.count == cap.limit:
cap.reachedLimit = true
if spell.cost < cap.minCost:
cap.weakestSpell = spell
cap.minCost = spell.cost
baseMagicka - запас маны для NPC