forked from mirror/openmw-tes3mp
Add instant spell effects to the actor's magic effect list
Via http://forum.openmw.org/viewtopic.php?f=2&t=3212&start=20#p36208
This commit is contained in:
parent
d6bcb7906d
commit
689dea4cb3
3 changed files with 46 additions and 40 deletions
|
@ -497,7 +497,12 @@ namespace MWMechanics
|
||||||
if (it->second.getMagnitude() > 0)
|
if (it->second.getMagnitude() > 0)
|
||||||
{
|
{
|
||||||
CastSpell cast(ptr, ptr);
|
CastSpell cast(ptr, ptr);
|
||||||
cast.applyInstantEffect(ptr, ptr, it->first, it->second.getMagnitude());
|
if (cast.applyInstantEffect(ptr, ptr, it->first, it->second.getMagnitude()))
|
||||||
|
{
|
||||||
|
creatureStats.getActiveSpells().purgeEffect(it->first.mId);
|
||||||
|
if (ptr.getClass().hasInventoryStore(ptr))
|
||||||
|
ptr.getClass().getInventoryStore(ptr).purgeEffect(it->first.mId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -452,9 +452,28 @@ namespace MWMechanics
|
||||||
float magnitude = effectIt->mMagnMin + (effectIt->mMagnMax - effectIt->mMagnMin) * random;
|
float magnitude = effectIt->mMagnMin + (effectIt->mMagnMax - effectIt->mMagnMin) * random;
|
||||||
magnitude *= magnitudeMult;
|
magnitude *= magnitudeMult;
|
||||||
|
|
||||||
bool hasDuration = !(magicEffect->mData.mFlags & ESM::MagicEffect::NoDuration);
|
if (!target.getClass().isActor())
|
||||||
if (target.getClass().isActor() && hasDuration && effectIt->mDuration > 0)
|
|
||||||
{
|
{
|
||||||
|
// non-actor objects have no list of active magic effects, so have to apply instantly
|
||||||
|
if (!applyInstantEffect(target, caster, EffectKey(*effectIt), magnitude))
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else // target.getClass().isActor() == true
|
||||||
|
{
|
||||||
|
bool hasDuration = !(magicEffect->mData.mFlags & ESM::MagicEffect::NoDuration);
|
||||||
|
if (hasDuration && effectIt->mDuration == 0)
|
||||||
|
{
|
||||||
|
// duration 0 means apply full magnitude instantly
|
||||||
|
bool wasDead = target.getClass().getCreatureStats(target).isDead();
|
||||||
|
effectTick(target.getClass().getCreatureStats(target), target, EffectKey(*effectIt), magnitude);
|
||||||
|
bool isDead = target.getClass().getCreatureStats(target).isDead();
|
||||||
|
|
||||||
|
if (!wasDead && isDead)
|
||||||
|
MWBase::Environment::get().getMechanicsManager()->actorKilled(target, caster);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// add to list of active effects, to apply in next frame
|
||||||
ActiveSpells::ActiveEffect effect;
|
ActiveSpells::ActiveEffect effect;
|
||||||
effect.mEffectId = effectIt->mEffectID;
|
effect.mEffectId = effectIt->mEffectID;
|
||||||
effect.mArg = MWMechanics::EffectKey(*effectIt).mArg;
|
effect.mArg = MWMechanics::EffectKey(*effectIt).mArg;
|
||||||
|
@ -484,19 +503,6 @@ namespace MWMechanics
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
if (hasDuration && target.getClass().isActor())
|
|
||||||
{
|
|
||||||
bool wasDead = target.getClass().getCreatureStats(target).isDead();
|
|
||||||
effectTick(target.getClass().getCreatureStats(target), target, EffectKey(*effectIt), magnitude);
|
|
||||||
bool isDead = target.getClass().getCreatureStats(target).isDead();
|
|
||||||
|
|
||||||
if (!wasDead && isDead)
|
|
||||||
MWBase::Environment::get().getMechanicsManager()->actorKilled(target, caster);
|
|
||||||
}
|
|
||||||
else if (!applyInstantEffect(target, caster, EffectKey(*effectIt), magnitude))
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Re-casting a summon effect will remove the creature from previous castings of that effect.
|
// Re-casting a summon effect will remove the creature from previous castings of that effect.
|
||||||
|
|
|
@ -410,11 +410,6 @@ void MWWorld::InventoryStore::updateMagicEffects(const Ptr& actor)
|
||||||
// the items should appear as if they'd always been equipped.
|
// the items should appear as if they'd always been equipped.
|
||||||
mListener->permanentEffectAdded(magicEffect, !mFirstAutoEquip,
|
mListener->permanentEffectAdded(magicEffect, !mFirstAutoEquip,
|
||||||
!mFirstAutoEquip && effectIt == enchantment.mEffects.mList.begin());
|
!mFirstAutoEquip && effectIt == enchantment.mEffects.mList.begin());
|
||||||
|
|
||||||
// Apply instant effects
|
|
||||||
MWMechanics::CastSpell cast(actor, actor);
|
|
||||||
if (magnitude)
|
|
||||||
cast.applyInstantEffect(actor, actor, effectIt->mEffectID, magnitude);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (magnitude)
|
if (magnitude)
|
||||||
|
|
Loading…
Reference in a new issue