[Client] Add createSpellGfx() method to MechanicsHelper

Use it to create spell GFX when adding active spells to dedicated players and actors.
pull/593/head
David Cernat 3 years ago
parent eb005a5c33
commit 3e582199fb

@ -368,6 +368,8 @@ void DedicatedActor::addSpellsActive()
MWWorld::TimeStamp timestamp = MWWorld::TimeStamp(activeSpell.timestampHour, activeSpell.timestampDay);
int casterActorId = MechanicsHelper::getActorId(activeSpell.caster);
MechanicsHelper::createSpellGfx(getPtr(), activeSpell.params.mEffects);
// Don't do a check for a spell's existence, because active effects from potions need to be applied here too
activeSpells.addSpell(activeSpell.id, activeSpell.isStackingSpell, activeSpell.params.mEffects, activeSpell.params.mDisplayName, casterActorId, timestamp, false);
}

@ -507,6 +507,8 @@ void DedicatedPlayer::addSpellsActive()
MWWorld::TimeStamp timestamp = MWWorld::TimeStamp(activeSpell.timestampHour, activeSpell.timestampDay);
int casterActorId = MechanicsHelper::getActorId(activeSpell.caster);
MechanicsHelper::createSpellGfx(getPtr(), activeSpell.params.mEffects);
// Don't do a check for a spell's existence, because active effects from potions need to be applied here too
activeSpells.addSpell(activeSpell.id, activeSpell.isStackingSpell, activeSpell.params.mEffects, activeSpell.params.mDisplayName, casterActorId, timestamp, false);
}

@ -13,6 +13,8 @@
#include "../mwmechanics/spellcasting.hpp"
#include "../mwmechanics/spellutil.hpp"
#include "../mwrender/animation.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/inventorystore.hpp"
@ -562,6 +564,28 @@ void MechanicsHelper::processCast(Cast cast, const MWWorld::Ptr& caster)
}
}
void MechanicsHelper::createSpellGfx(const MWWorld::Ptr& targetPtr, const std::vector<ESM::ActiveEffect>& mEffects)
{
for (auto&& effect : mEffects)
{
const ESM::MagicEffect* magicEffect = MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find(effect.mEffectId);
const ESM::Static* castStatic;
if (!magicEffect->mHit.empty())
castStatic = MWBase::Environment::get().getWorld()->getStore().get<ESM::Static>().find(magicEffect->mHit);
else
castStatic = MWBase::Environment::get().getWorld()->getStore().get<ESM::Static>().find("VFX_DefaultHit");
bool loop = (magicEffect->mData.mFlags & ESM::MagicEffect::ContinuousVfx) != 0;
// Note: in case of non actor, a free effect should be fine as well
MWRender::Animation* anim = MWBase::Environment::get().getWorld()->getAnimation(targetPtr);
if (anim && !castStatic->mModel.empty())
{
anim->addEffect("meshes\\" + castStatic->mModel, magicEffect->mIndex, loop, "", magicEffect->mParticle);
}
}
}
bool MechanicsHelper::isStackingSpell(const std::string& id)
{
return !MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().search(id);

@ -46,6 +46,8 @@ namespace MechanicsHelper
void processAttack(mwmp::Attack attack, const MWWorld::Ptr& attacker);
void processCast(mwmp::Cast cast, const MWWorld::Ptr& caster);
void createSpellGfx(const MWWorld::Ptr& targetPtr, const std::vector<ESM::ActiveEffect>& mEffects);
bool isStackingSpell(const std::string& id);
bool doesEffectListContainEffect(const ESM::EffectList& effectList, short effectId, short attributeId = -1, short skillId = -1);
void unequipItemsByEffect(const MWWorld::Ptr& ptr, short enchantmentType, short effectId, short attributeId = -1, short skillId = -1);

Loading…
Cancel
Save