forked from teamnwah/openmw-tes3coop
Implement Absorb effects (AbsorbHealth, etc)
This commit is contained in:
parent
a420698237
commit
6902569d03
2 changed files with 21 additions and 4 deletions
|
@ -155,7 +155,8 @@ namespace MWMechanics
|
||||||
{
|
{
|
||||||
Stat<int> stat = creatureStats.getAttribute(i);
|
Stat<int> stat = creatureStats.getAttribute(i);
|
||||||
stat.setModifier(effects.get(EffectKey(ESM::MagicEffect::FortifyAttribute, i)).mMagnitude -
|
stat.setModifier(effects.get(EffectKey(ESM::MagicEffect::FortifyAttribute, i)).mMagnitude -
|
||||||
effects.get(EffectKey(ESM::MagicEffect::DrainAttribute, i)).mMagnitude);
|
effects.get(EffectKey(ESM::MagicEffect::DrainAttribute, i)).mMagnitude -
|
||||||
|
effects.get(EffectKey(ESM::MagicEffect::AbsorbAttribute, i)).mMagnitude);
|
||||||
|
|
||||||
creatureStats.setAttribute(i, stat);
|
creatureStats.setAttribute(i, stat);
|
||||||
}
|
}
|
||||||
|
@ -168,7 +169,8 @@ namespace MWMechanics
|
||||||
effects.get(EffectKey(ESM::MagicEffect::DrainHealth+i)).mMagnitude);
|
effects.get(EffectKey(ESM::MagicEffect::DrainHealth+i)).mMagnitude);
|
||||||
|
|
||||||
float currentDiff = creatureStats.getMagicEffects().get(EffectKey(ESM::MagicEffect::RestoreHealth+i)).mMagnitude
|
float currentDiff = creatureStats.getMagicEffects().get(EffectKey(ESM::MagicEffect::RestoreHealth+i)).mMagnitude
|
||||||
- creatureStats.getMagicEffects().get(EffectKey(ESM::MagicEffect::DamageHealth+i)).mMagnitude;
|
- creatureStats.getMagicEffects().get(EffectKey(ESM::MagicEffect::DamageHealth+i)).mMagnitude
|
||||||
|
- creatureStats.getMagicEffects().get(EffectKey(ESM::MagicEffect::AbsorbHealth)).mMagnitude;
|
||||||
stat.setCurrent(stat.getCurrent() + currentDiff * duration);
|
stat.setCurrent(stat.getCurrent() + currentDiff * duration);
|
||||||
|
|
||||||
creatureStats.setDynamic(i, stat);
|
creatureStats.setDynamic(i, stat);
|
||||||
|
@ -198,7 +200,8 @@ namespace MWMechanics
|
||||||
{
|
{
|
||||||
Stat<float>& skill = npcStats.getSkill(i);
|
Stat<float>& skill = npcStats.getSkill(i);
|
||||||
skill.setModifier(effects.get(EffectKey(ESM::MagicEffect::FortifySkill, i)).mMagnitude -
|
skill.setModifier(effects.get(EffectKey(ESM::MagicEffect::FortifySkill, i)).mMagnitude -
|
||||||
effects.get(EffectKey(ESM::MagicEffect::DrainSkill, i)).mMagnitude);
|
effects.get(EffectKey(ESM::MagicEffect::DrainSkill, i)).mMagnitude -
|
||||||
|
effects.get(EffectKey(ESM::MagicEffect::AbsorbSkill, i)).mMagnitude);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -116,7 +116,7 @@ namespace MWMechanics
|
||||||
{
|
{
|
||||||
float random = std::rand() / static_cast<float>(RAND_MAX);
|
float random = std::rand() / static_cast<float>(RAND_MAX);
|
||||||
float magnitude = effectIt->mMagnMin + (effectIt->mMagnMax - effectIt->mMagnMin) * random;
|
float magnitude = effectIt->mMagnMin + (effectIt->mMagnMax - effectIt->mMagnMin) * random;
|
||||||
magnitude *= magnitudeMult;
|
magnitude *= magnitudeMult;
|
||||||
|
|
||||||
if (target.getClass().isActor() && !(magicEffect->mData.mFlags & ESM::MagicEffect::NoDuration))
|
if (target.getClass().isActor() && !(magicEffect->mData.mFlags & ESM::MagicEffect::NoDuration))
|
||||||
{
|
{
|
||||||
|
@ -126,6 +126,20 @@ namespace MWMechanics
|
||||||
effect.mMagnitude = magnitude;
|
effect.mMagnitude = magnitude;
|
||||||
|
|
||||||
appliedLastingEffects.push_back(effect);
|
appliedLastingEffects.push_back(effect);
|
||||||
|
|
||||||
|
// For absorb effects, also apply the effect to the caster - but with a negative
|
||||||
|
// magnitude, since we're transfering stats from the target to the caster
|
||||||
|
for (int i=0; i<5; ++i)
|
||||||
|
{
|
||||||
|
if (effectIt->mEffectID == ESM::MagicEffect::AbsorbAttribute+i)
|
||||||
|
{
|
||||||
|
std::vector<ActiveSpells::Effect> effects;
|
||||||
|
ActiveSpells::Effect effect_ = effect;
|
||||||
|
effect_.mMagnitude *= -1;
|
||||||
|
effects.push_back(effect_);
|
||||||
|
caster.getClass().getCreatureStats(caster).getActiveSpells().addSpell("", true, effects, mSourceName);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
applyInstantEffect(mTarget, effectIt->mEffectID, magnitude);
|
applyInstantEffect(mTarget, effectIt->mEffectID, magnitude);
|
||||||
|
|
Loading…
Reference in a new issue