mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 18:19:55 +00:00
Move cleanupSummonedCreature to the mechanics manager (Bug #3439)
This commit is contained in:
parent
910ad76e29
commit
4acfe1a7e4
8 changed files with 43 additions and 39 deletions
|
@ -229,6 +229,8 @@ namespace MWBase
|
|||
/// Sets the NPC's Acrobatics skill to match the fWerewolfAcrobatics GMST.
|
||||
/// It only applies to the current form the NPC is in.
|
||||
virtual void applyWerewolfAcrobatics(const MWWorld::Ptr& actor) = 0;
|
||||
|
||||
virtual void cleanupSummonedCreature(const MWWorld::Ptr& caster, int creatureActorId) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -688,9 +688,7 @@ namespace MWMechanics
|
|||
creatureStats.getActiveSpells().visitEffectSources(updateSummonedCreatures);
|
||||
if (ptr.getClass().hasInventoryStore(ptr))
|
||||
ptr.getClass().getInventoryStore(ptr).visitEffectSources(updateSummonedCreatures);
|
||||
std::set<int> deleted = updateSummonedCreatures.process();
|
||||
for (std::set<int>::const_iterator it = deleted.begin(); it != deleted.end(); ++it)
|
||||
purgeSpellEffects(*it);
|
||||
updateSummonedCreatures.process();
|
||||
}
|
||||
|
||||
void Actors::calculateNpcStatModifiers (const MWWorld::Ptr& ptr, float duration)
|
||||
|
@ -1259,6 +1257,30 @@ namespace MWMechanics
|
|||
}
|
||||
}
|
||||
|
||||
void Actors::cleanupSummonedCreature (MWMechanics::CreatureStats& casterStats, int creatureActorId)
|
||||
{
|
||||
MWWorld::Ptr ptr = MWBase::Environment::get().getWorld()->searchPtrViaActorId(creatureActorId);
|
||||
if (!ptr.isEmpty())
|
||||
{
|
||||
MWBase::Environment::get().getWorld()->deleteObject(ptr);
|
||||
|
||||
const ESM::Static* fx = MWBase::Environment::get().getWorld()->getStore().get<ESM::Static>()
|
||||
.search("VFX_Summon_End");
|
||||
if (fx)
|
||||
MWBase::Environment::get().getWorld()->spawnEffect("meshes\\" + fx->mModel,
|
||||
"", ptr.getRefData().getPosition().asVec3());
|
||||
}
|
||||
else if (creatureActorId != -1)
|
||||
{
|
||||
// We didn't find the creature. It's probably in an inactive cell.
|
||||
// Add to graveyard so we can delete it when the cell becomes active.
|
||||
std::vector<int>& graveyard = casterStats.getSummonedCreatureGraveyard();
|
||||
graveyard.push_back(creatureActorId);
|
||||
}
|
||||
|
||||
purgeSpellEffects(creatureActorId);
|
||||
}
|
||||
|
||||
void Actors::purgeSpellEffects(int casterActorId)
|
||||
{
|
||||
for (PtrActorMap::iterator iter(mActors.begin());iter != mActors.end();++iter)
|
||||
|
|
|
@ -19,6 +19,7 @@ namespace MWWorld
|
|||
namespace MWMechanics
|
||||
{
|
||||
class Actor;
|
||||
class CreatureStats;
|
||||
|
||||
class Actors
|
||||
{
|
||||
|
@ -113,6 +114,8 @@ namespace MWMechanics
|
|||
|
||||
void getObjectsInRange(const osg::Vec3f& position, float radius, std::vector<MWWorld::Ptr>& out);
|
||||
|
||||
void cleanupSummonedCreature (CreatureStats& casterStats, int creatureActorId);
|
||||
|
||||
///Returns the list of actors which are siding with the given actor in fights
|
||||
/**ie AiFollow or AiEscort is active and the target is the actor **/
|
||||
std::list<MWWorld::Ptr> getActorsSidingWith(const MWWorld::Ptr& actor);
|
||||
|
|
|
@ -1700,4 +1700,9 @@ namespace MWMechanics
|
|||
stats.getSkill(ESM::Skill::Acrobatics).setBase(gmst.find("fWerewolfAcrobatics")->getInt());
|
||||
}
|
||||
|
||||
void MechanicsManager::cleanupSummonedCreature(const MWWorld::Ptr &caster, int creatureActorId)
|
||||
{
|
||||
mActors.cleanupSummonedCreature(caster.getClass().getCreatureStats(caster), creatureActorId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -189,6 +189,8 @@ namespace MWMechanics
|
|||
virtual void setWerewolf(const MWWorld::Ptr& actor, bool werewolf);
|
||||
virtual void applyWerewolfAcrobatics(const MWWorld::Ptr& actor);
|
||||
|
||||
virtual void cleanupSummonedCreature(const MWWorld::Ptr& caster, int creatureActorId);
|
||||
|
||||
private:
|
||||
void reportCrime (const MWWorld::Ptr& ptr, const MWWorld::Ptr& victim,
|
||||
OffenseType type, int arg=0);
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
|
||||
#include "magiceffects.hpp"
|
||||
#include "npcstats.hpp"
|
||||
#include "summoning.hpp"
|
||||
#include "actorutil.hpp"
|
||||
|
||||
namespace
|
||||
|
@ -510,7 +509,7 @@ namespace MWMechanics
|
|||
std::map<CreatureStats::SummonKey, int>::iterator found = targetStats.getSummonedCreatureMap().find(std::make_pair(effectIt->mEffectID, mId));
|
||||
if (found != targetStats.getSummonedCreatureMap().end())
|
||||
{
|
||||
cleanupSummonedCreature(targetStats, found->second);
|
||||
MWBase::Environment::get().getMechanicsManager()->cleanupSummonedCreature(target, found->second);
|
||||
targetStats.getSummonedCreatureMap().erase(found);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
#include "../mwbase/mechanicsmanager.hpp"
|
||||
|
||||
#include "../mwmechanics/spellcasting.hpp"
|
||||
|
||||
|
@ -21,28 +22,6 @@
|
|||
namespace MWMechanics
|
||||
{
|
||||
|
||||
void cleanupSummonedCreature (MWMechanics::CreatureStats& casterStats, int creatureActorId)
|
||||
{
|
||||
MWWorld::Ptr ptr = MWBase::Environment::get().getWorld()->searchPtrViaActorId(creatureActorId);
|
||||
if (!ptr.isEmpty())
|
||||
{
|
||||
MWBase::Environment::get().getWorld()->deleteObject(ptr);
|
||||
|
||||
const ESM::Static* fx = MWBase::Environment::get().getWorld()->getStore().get<ESM::Static>()
|
||||
.search("VFX_Summon_End");
|
||||
if (fx)
|
||||
MWBase::Environment::get().getWorld()->spawnEffect("meshes\\" + fx->mModel,
|
||||
"", ptr.getRefData().getPosition().asVec3());
|
||||
}
|
||||
else if (creatureActorId != -1)
|
||||
{
|
||||
// We didn't find the creature. It's probably in an inactive cell.
|
||||
// Add to graveyard so we can delete it when the cell becomes active.
|
||||
std::vector<int>& graveyard = casterStats.getSummonedCreatureGraveyard();
|
||||
graveyard.push_back(creatureActorId);
|
||||
}
|
||||
}
|
||||
|
||||
UpdateSummonedCreatures::UpdateSummonedCreatures(const MWWorld::Ptr &actor)
|
||||
: mActor(actor)
|
||||
{
|
||||
|
@ -61,10 +40,8 @@ namespace MWMechanics
|
|||
}
|
||||
}
|
||||
|
||||
std::set<int> UpdateSummonedCreatures::process()
|
||||
void UpdateSummonedCreatures::process()
|
||||
{
|
||||
std::set<int> deletedCreatures;
|
||||
|
||||
static std::map<int, std::string> summonMap;
|
||||
if (summonMap.empty())
|
||||
{
|
||||
|
@ -102,8 +79,7 @@ namespace MWMechanics
|
|||
if (!found)
|
||||
{
|
||||
// Effect has ended
|
||||
cleanupSummonedCreature(creatureStats, it->second);
|
||||
deletedCreatures.insert(it->second);
|
||||
MWBase::Environment::get().getMechanicsManager()->cleanupSummonedCreature(mActor, it->second);
|
||||
creatureMap.erase(it++);
|
||||
continue;
|
||||
}
|
||||
|
@ -165,7 +141,7 @@ namespace MWMechanics
|
|||
if (mActor.getClass().hasInventoryStore(ptr))
|
||||
mActor.getClass().getInventoryStore(mActor).purgeEffect(it->first.first, it->first.second);
|
||||
|
||||
cleanupSummonedCreature(creatureStats, it->second);
|
||||
MWBase::Environment::get().getMechanicsManager()->cleanupSummonedCreature(mActor, it->second);
|
||||
creatureMap.erase(it++);
|
||||
}
|
||||
else
|
||||
|
@ -191,8 +167,6 @@ namespace MWMechanics
|
|||
else
|
||||
++it;
|
||||
}
|
||||
|
||||
return deletedCreatures;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,8 +21,7 @@ namespace MWMechanics
|
|||
float magnitude, float remainingTime = -1, float totalTime = -1);
|
||||
|
||||
/// To call after all effect sources have been visited
|
||||
/// Returns list of actorIds for creatures that have been deleted due to the magic effect having expired
|
||||
std::set<int> process();
|
||||
void process();
|
||||
|
||||
private:
|
||||
MWWorld::Ptr mActor;
|
||||
|
@ -30,8 +29,6 @@ namespace MWMechanics
|
|||
std::set<std::pair<int, std::string> > mActiveEffects;
|
||||
};
|
||||
|
||||
void cleanupSummonedCreature (MWMechanics::CreatureStats& casterStats, int creatureActorId);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue