[Client] Add doesEffectListContainEffect() method to MechanicsHelper

0.6.2
David Cernat 7 years ago
parent aa392ebf20
commit c6a85ee8f9

@ -214,6 +214,25 @@ void MechanicsHelper::processAttack(Attack attack, const MWWorld::Ptr& attacker)
} }
} }
bool MechanicsHelper::doesEffectListContainEffect(const ESM::EffectList& effectList, short effectId, short attributeId, short skillId)
{
for (const auto &effect : effectList.mList)
{
if (effect.mEffectID == effectId)
{
if (attributeId == -1 || effect.mAttribute == attributeId)
{
if (skillId == -1 || effect.mSkill == skillId)
{
return true;
}
}
}
}
return false;
}
void MechanicsHelper::unequipItemsByEffect(const MWWorld::Ptr& ptr, short effectId, short attributeId, short skillId) void MechanicsHelper::unequipItemsByEffect(const MWWorld::Ptr& ptr, short effectId, short attributeId, short skillId)
{ {
MWBase::World *world = MWBase::Environment::get().getWorld(); MWBase::World *world = MWBase::Environment::get().getWorld();
@ -230,20 +249,8 @@ void MechanicsHelper::unequipItemsByEffect(const MWWorld::Ptr& ptr, short effect
{ {
const ESM::Enchantment* enchantment = world->getStore().get<ESM::Enchantment>().find(enchantmentName); const ESM::Enchantment* enchantment = world->getStore().get<ESM::Enchantment>().find(enchantmentName);
for (const auto &effect : enchantment->mEffects.mList) if (doesEffectListContainEffect(enchantment->mEffects, effectId, attributeId, skillId))
{ ptrInventory.unequipSlot(slot, ptr);
if (effect.mEffectID == effectId)
{
if (attributeId == -1 || effect.mAttribute == attributeId)
{
if (skillId == -1 || effect.mSkill == skillId)
{
ptrInventory.unequipSlot(slot, ptr);
break;
}
}
}
}
} }
} }
} }

@ -24,6 +24,7 @@ namespace MechanicsHelper
void processAttack(mwmp::Attack attack, const MWWorld::Ptr& attacker); void processAttack(mwmp::Attack attack, const MWWorld::Ptr& attacker);
bool doesEffectListContainEffect(const ESM::EffectList& effectList, short effectId, short attributeId = -1, short skillId = -1);
void unequipItemsByEffect(const MWWorld::Ptr& ptr, short effectId, short attributeId = -1, short skillId = -1); void unequipItemsByEffect(const MWWorld::Ptr& ptr, short effectId, short attributeId = -1, short skillId = -1);
} }

Loading…
Cancel
Save