mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-16 15:59:54 +00:00
Remove spell effects when a summoned creature expires (Bug #3439)
This commit is contained in:
parent
b7e45b046d
commit
910ad76e29
4 changed files with 23 additions and 8 deletions
|
@ -688,7 +688,9 @@ namespace MWMechanics
|
|||
creatureStats.getActiveSpells().visitEffectSources(updateSummonedCreatures);
|
||||
if (ptr.getClass().hasInventoryStore(ptr))
|
||||
ptr.getClass().getInventoryStore(ptr).visitEffectSources(updateSummonedCreatures);
|
||||
updateSummonedCreatures.finish();
|
||||
std::set<int> deleted = updateSummonedCreatures.process();
|
||||
for (std::set<int>::const_iterator it = deleted.begin(); it != deleted.end(); ++it)
|
||||
purgeSpellEffects(*it);
|
||||
}
|
||||
|
||||
void Actors::calculateNpcStatModifiers (const MWWorld::Ptr& ptr, float duration)
|
||||
|
@ -1242,11 +1244,7 @@ namespace MWMechanics
|
|||
++mDeathCount[Misc::StringUtils::lowerCase(iter->first.getCellRef().getRefId())];
|
||||
|
||||
// Make sure spell effects are removed
|
||||
for (PtrActorMap::iterator iter2(mActors.begin());iter2 != mActors.end();++iter2)
|
||||
{
|
||||
MWMechanics::ActiveSpells& spells = iter2->first.getClass().getCreatureStats(iter2->first).getActiveSpells();
|
||||
spells.purge(stats.getActorId());
|
||||
}
|
||||
purgeSpellEffects(stats.getActorId());
|
||||
|
||||
if( iter->first == getPlayer())
|
||||
{
|
||||
|
@ -1261,6 +1259,15 @@ namespace MWMechanics
|
|||
}
|
||||
}
|
||||
|
||||
void Actors::purgeSpellEffects(int casterActorId)
|
||||
{
|
||||
for (PtrActorMap::iterator iter(mActors.begin());iter != mActors.end();++iter)
|
||||
{
|
||||
MWMechanics::ActiveSpells& spells = iter->first.getClass().getCreatureStats(iter->first).getActiveSpells();
|
||||
spells.purge(casterActorId);
|
||||
}
|
||||
}
|
||||
|
||||
void Actors::restoreDynamicStats(bool sleep)
|
||||
{
|
||||
for(PtrActorMap::iterator iter(mActors.begin());iter != mActors.end();++iter)
|
||||
|
|
|
@ -43,6 +43,8 @@ namespace MWMechanics
|
|||
|
||||
void killDeadActors ();
|
||||
|
||||
void purgeSpellEffects (int casterActorId);
|
||||
|
||||
public:
|
||||
|
||||
Actors();
|
||||
|
|
|
@ -61,8 +61,10 @@ namespace MWMechanics
|
|||
}
|
||||
}
|
||||
|
||||
void UpdateSummonedCreatures::finish()
|
||||
std::set<int> UpdateSummonedCreatures::process()
|
||||
{
|
||||
std::set<int> deletedCreatures;
|
||||
|
||||
static std::map<int, std::string> summonMap;
|
||||
if (summonMap.empty())
|
||||
{
|
||||
|
@ -101,6 +103,7 @@ namespace MWMechanics
|
|||
{
|
||||
// Effect has ended
|
||||
cleanupSummonedCreature(creatureStats, it->second);
|
||||
deletedCreatures.insert(it->second);
|
||||
creatureMap.erase(it++);
|
||||
continue;
|
||||
}
|
||||
|
@ -188,6 +191,8 @@ namespace MWMechanics
|
|||
else
|
||||
++it;
|
||||
}
|
||||
|
||||
return deletedCreatures;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,7 +21,8 @@ namespace MWMechanics
|
|||
float magnitude, float remainingTime = -1, float totalTime = -1);
|
||||
|
||||
/// To call after all effect sources have been visited
|
||||
void finish();
|
||||
/// Returns list of actorIds for creatures that have been deleted due to the magic effect having expired
|
||||
std::set<int> process();
|
||||
|
||||
private:
|
||||
MWWorld::Ptr mActor;
|
||||
|
|
Loading…
Reference in a new issue