|
|
@ -80,7 +80,7 @@ namespace
|
|
|
|
void damageAttribute(const MWWorld::Ptr& target, const ESM::ActiveEffect& effect, float magnitude)
|
|
|
|
void damageAttribute(const MWWorld::Ptr& target, const ESM::ActiveEffect& effect, float magnitude)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
auto& creatureStats = target.getClass().getCreatureStats(target);
|
|
|
|
auto& creatureStats = target.getClass().getCreatureStats(target);
|
|
|
|
auto attribute = static_cast<ESM::Attribute::AttributeID>(effect.mArg);
|
|
|
|
auto attribute = effect.getSkillOrAttribute();
|
|
|
|
auto attr = creatureStats.getAttribute(attribute);
|
|
|
|
auto attr = creatureStats.getAttribute(attribute);
|
|
|
|
if (effect.mEffectId == ESM::MagicEffect::DamageAttribute)
|
|
|
|
if (effect.mEffectId == ESM::MagicEffect::DamageAttribute)
|
|
|
|
magnitude = std::min(attr.getModified(), magnitude);
|
|
|
|
magnitude = std::min(attr.getModified(), magnitude);
|
|
|
@ -91,7 +91,7 @@ namespace
|
|
|
|
void restoreAttribute(const MWWorld::Ptr& target, const ESM::ActiveEffect& effect, float magnitude)
|
|
|
|
void restoreAttribute(const MWWorld::Ptr& target, const ESM::ActiveEffect& effect, float magnitude)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
auto& creatureStats = target.getClass().getCreatureStats(target);
|
|
|
|
auto& creatureStats = target.getClass().getCreatureStats(target);
|
|
|
|
auto attribute = static_cast<ESM::Attribute::AttributeID>(effect.mArg);
|
|
|
|
auto attribute = effect.getSkillOrAttribute();
|
|
|
|
auto attr = creatureStats.getAttribute(attribute);
|
|
|
|
auto attr = creatureStats.getAttribute(attribute);
|
|
|
|
attr.restore(magnitude);
|
|
|
|
attr.restore(magnitude);
|
|
|
|
creatureStats.setAttribute(attribute, attr);
|
|
|
|
creatureStats.setAttribute(attribute, attr);
|
|
|
@ -100,7 +100,7 @@ namespace
|
|
|
|
void fortifyAttribute(const MWWorld::Ptr& target, const ESM::ActiveEffect& effect, float magnitude)
|
|
|
|
void fortifyAttribute(const MWWorld::Ptr& target, const ESM::ActiveEffect& effect, float magnitude)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
auto& creatureStats = target.getClass().getCreatureStats(target);
|
|
|
|
auto& creatureStats = target.getClass().getCreatureStats(target);
|
|
|
|
auto attribute = static_cast<ESM::Attribute::AttributeID>(effect.mArg);
|
|
|
|
auto attribute = effect.getSkillOrAttribute();
|
|
|
|
auto attr = creatureStats.getAttribute(attribute);
|
|
|
|
auto attr = creatureStats.getAttribute(attribute);
|
|
|
|
attr.setModifier(attr.getModifier() + magnitude);
|
|
|
|
attr.setModifier(attr.getModifier() + magnitude);
|
|
|
|
creatureStats.setAttribute(attribute, attr);
|
|
|
|
creatureStats.setAttribute(attribute, attr);
|
|
|
@ -109,7 +109,7 @@ namespace
|
|
|
|
void damageSkill(const MWWorld::Ptr& target, const ESM::ActiveEffect& effect, float magnitude)
|
|
|
|
void damageSkill(const MWWorld::Ptr& target, const ESM::ActiveEffect& effect, float magnitude)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
auto& npcStats = target.getClass().getNpcStats(target);
|
|
|
|
auto& npcStats = target.getClass().getNpcStats(target);
|
|
|
|
auto& skill = npcStats.getSkill(ESM::Skill::indexToRefId(effect.mArg));
|
|
|
|
auto& skill = npcStats.getSkill(effect.getSkillOrAttribute());
|
|
|
|
if (effect.mEffectId == ESM::MagicEffect::DamageSkill)
|
|
|
|
if (effect.mEffectId == ESM::MagicEffect::DamageSkill)
|
|
|
|
magnitude = std::min(skill.getModified(), magnitude);
|
|
|
|
magnitude = std::min(skill.getModified(), magnitude);
|
|
|
|
skill.damage(magnitude);
|
|
|
|
skill.damage(magnitude);
|
|
|
@ -118,14 +118,14 @@ namespace
|
|
|
|
void restoreSkill(const MWWorld::Ptr& target, const ESM::ActiveEffect& effect, float magnitude)
|
|
|
|
void restoreSkill(const MWWorld::Ptr& target, const ESM::ActiveEffect& effect, float magnitude)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
auto& npcStats = target.getClass().getNpcStats(target);
|
|
|
|
auto& npcStats = target.getClass().getNpcStats(target);
|
|
|
|
auto& skill = npcStats.getSkill(ESM::Skill::indexToRefId(effect.mArg));
|
|
|
|
auto& skill = npcStats.getSkill(effect.getSkillOrAttribute());
|
|
|
|
skill.restore(magnitude);
|
|
|
|
skill.restore(magnitude);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void fortifySkill(const MWWorld::Ptr& target, const ESM::ActiveEffect& effect, float magnitude)
|
|
|
|
void fortifySkill(const MWWorld::Ptr& target, const ESM::ActiveEffect& effect, float magnitude)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
auto& npcStats = target.getClass().getNpcStats(target);
|
|
|
|
auto& npcStats = target.getClass().getNpcStats(target);
|
|
|
|
auto& skill = npcStats.getSkill(ESM::Skill::indexToRefId(effect.mArg));
|
|
|
|
auto& skill = npcStats.getSkill(effect.getSkillOrAttribute());
|
|
|
|
skill.setModifier(skill.getModifier() + magnitude);
|
|
|
|
skill.setModifier(skill.getModifier() + magnitude);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -670,7 +670,7 @@ namespace MWMechanics
|
|
|
|
if (spellParams.getType() == ESM::ActiveSpells::Type_Ability)
|
|
|
|
if (spellParams.getType() == ESM::ActiveSpells::Type_Ability)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
auto& npcStats = target.getClass().getNpcStats(target);
|
|
|
|
auto& npcStats = target.getClass().getNpcStats(target);
|
|
|
|
SkillValue& skill = npcStats.getSkill(ESM::Skill::indexToRefId(effect.mArg));
|
|
|
|
SkillValue& skill = npcStats.getSkill(effect.getSkillOrAttribute());
|
|
|
|
// Damage Skill abilities reduce base skill :todd:
|
|
|
|
// Damage Skill abilities reduce base skill :todd:
|
|
|
|
skill.setBase(std::max(skill.getBase() - effect.mMagnitude, 0.f));
|
|
|
|
skill.setBase(std::max(skill.getBase() - effect.mMagnitude, 0.f));
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -741,7 +741,7 @@ namespace MWMechanics
|
|
|
|
if (spellParams.getType() == ESM::ActiveSpells::Type_Ability)
|
|
|
|
if (spellParams.getType() == ESM::ActiveSpells::Type_Ability)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
auto& creatureStats = target.getClass().getCreatureStats(target);
|
|
|
|
auto& creatureStats = target.getClass().getCreatureStats(target);
|
|
|
|
auto attribute = static_cast<ESM::Attribute::AttributeID>(effect.mArg);
|
|
|
|
auto attribute = effect.getSkillOrAttribute();
|
|
|
|
AttributeValue attr = creatureStats.getAttribute(attribute);
|
|
|
|
AttributeValue attr = creatureStats.getAttribute(attribute);
|
|
|
|
attr.setBase(attr.getBase() + effect.mMagnitude);
|
|
|
|
attr.setBase(attr.getBase() + effect.mMagnitude);
|
|
|
|
creatureStats.setAttribute(attribute, attr);
|
|
|
|
creatureStats.setAttribute(attribute, attr);
|
|
|
@ -762,7 +762,7 @@ namespace MWMechanics
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Abilities affect base stats, but not for drain
|
|
|
|
// Abilities affect base stats, but not for drain
|
|
|
|
auto& npcStats = target.getClass().getNpcStats(target);
|
|
|
|
auto& npcStats = target.getClass().getNpcStats(target);
|
|
|
|
auto& skill = npcStats.getSkill(ESM::Skill::indexToRefId(effect.mArg));
|
|
|
|
auto& skill = npcStats.getSkill(effect.getSkillOrAttribute());
|
|
|
|
skill.setBase(skill.getBase() + effect.mMagnitude);
|
|
|
|
skill.setBase(skill.getBase() + effect.mMagnitude);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
@ -1033,7 +1033,8 @@ namespace MWMechanics
|
|
|
|
applyMagicEffect(target, caster, spellParams, effect, invalid, receivedMagicDamage, affectedHealth,
|
|
|
|
applyMagicEffect(target, caster, spellParams, effect, invalid, receivedMagicDamage, affectedHealth,
|
|
|
|
recalculateMagicka);
|
|
|
|
recalculateMagicka);
|
|
|
|
effect.mMagnitude = magnitude;
|
|
|
|
effect.mMagnitude = magnitude;
|
|
|
|
magnitudes.add(EffectKey(effect.mEffectId, effect.mArg), EffectParam(effect.mMagnitude - oldMagnitude));
|
|
|
|
magnitudes.add(EffectKey(effect.mEffectId, effect.getSkillOrAttribute()),
|
|
|
|
|
|
|
|
EffectParam(effect.mMagnitude - oldMagnitude));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
effect.mTimeLeft -= dt;
|
|
|
|
effect.mTimeLeft -= dt;
|
|
|
|
if (invalid)
|
|
|
|
if (invalid)
|
|
|
@ -1145,13 +1146,14 @@ namespace MWMechanics
|
|
|
|
case ESM::MagicEffect::SummonCreature04:
|
|
|
|
case ESM::MagicEffect::SummonCreature04:
|
|
|
|
case ESM::MagicEffect::SummonCreature05:
|
|
|
|
case ESM::MagicEffect::SummonCreature05:
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (effect.mArg != -1)
|
|
|
|
int actorId = effect.getActorId();
|
|
|
|
MWBase::Environment::get().getMechanicsManager()->cleanupSummonedCreature(target, effect.mArg);
|
|
|
|
if (actorId != -1)
|
|
|
|
|
|
|
|
MWBase::Environment::get().getMechanicsManager()->cleanupSummonedCreature(target, actorId);
|
|
|
|
auto& summons = target.getClass().getCreatureStats(target).getSummonedCreatureMap();
|
|
|
|
auto& summons = target.getClass().getCreatureStats(target).getSummonedCreatureMap();
|
|
|
|
auto [begin, end] = summons.equal_range(effect.mEffectId);
|
|
|
|
auto [begin, end] = summons.equal_range(effect.mEffectId);
|
|
|
|
for (auto it = begin; it != end; ++it)
|
|
|
|
for (auto it = begin; it != end; ++it)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (it->second == effect.mArg)
|
|
|
|
if (it->second == actorId)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
summons.erase(it);
|
|
|
|
summons.erase(it);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
@ -1205,7 +1207,7 @@ namespace MWMechanics
|
|
|
|
if (spellParams.getType() == ESM::ActiveSpells::Type_Ability)
|
|
|
|
if (spellParams.getType() == ESM::ActiveSpells::Type_Ability)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
auto& creatureStats = target.getClass().getCreatureStats(target);
|
|
|
|
auto& creatureStats = target.getClass().getCreatureStats(target);
|
|
|
|
auto attribute = static_cast<ESM::Attribute::AttributeID>(effect.mArg);
|
|
|
|
auto attribute = effect.getSkillOrAttribute();
|
|
|
|
AttributeValue attr = creatureStats.getAttribute(attribute);
|
|
|
|
AttributeValue attr = creatureStats.getAttribute(attribute);
|
|
|
|
attr.setBase(attr.getBase() - effect.mMagnitude);
|
|
|
|
attr.setBase(attr.getBase() - effect.mMagnitude);
|
|
|
|
creatureStats.setAttribute(attribute, attr);
|
|
|
|
creatureStats.setAttribute(attribute, attr);
|
|
|
@ -1221,7 +1223,7 @@ namespace MWMechanics
|
|
|
|
if (spellParams.getType() == ESM::ActiveSpells::Type_Ability)
|
|
|
|
if (spellParams.getType() == ESM::ActiveSpells::Type_Ability)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
auto& npcStats = target.getClass().getNpcStats(target);
|
|
|
|
auto& npcStats = target.getClass().getNpcStats(target);
|
|
|
|
auto& skill = npcStats.getSkill(ESM::Skill::indexToRefId(effect.mArg));
|
|
|
|
auto& skill = npcStats.getSkill(effect.getSkillOrAttribute());
|
|
|
|
skill.setBase(skill.getBase() - effect.mMagnitude);
|
|
|
|
skill.setBase(skill.getBase() - effect.mMagnitude);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
@ -1277,7 +1279,7 @@ namespace MWMechanics
|
|
|
|
if (!(effect.mFlags & ESM::ActiveEffect::Flag_Applied))
|
|
|
|
if (!(effect.mFlags & ESM::ActiveEffect::Flag_Applied))
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
auto& magnitudes = target.getClass().getCreatureStats(target).getMagicEffects();
|
|
|
|
auto& magnitudes = target.getClass().getCreatureStats(target).getMagicEffects();
|
|
|
|
magnitudes.add(EffectKey(effect.mEffectId, effect.mArg), EffectParam(-effect.mMagnitude));
|
|
|
|
magnitudes.add(EffectKey(effect.mEffectId, effect.getSkillOrAttribute()), EffectParam(-effect.mMagnitude));
|
|
|
|
removeMagicEffect(target, spellParams, effect);
|
|
|
|
removeMagicEffect(target, spellParams, effect);
|
|
|
|
if (magnitudes.getOrDefault(effect.mEffectId).getMagnitude() <= 0.f)
|
|
|
|
if (magnitudes.getOrDefault(effect.mEffectId).getMagnitude() <= 0.f)
|
|
|
|
{
|
|
|
|
{
|
|
|
|