mirror of
https://github.com/TES3MP/TES3MP.git
synced 2025-09-28 07:32:00 -04:00
[Client] Add doesEffectListContainEffect() method to MechanicsHelper
This commit is contained in:
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)
|
||||
{
|
||||
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);
|
||||
|
||||
for (const auto &effect : enchantment->mEffects.mList)
|
||||
{
|
||||
if (effect.mEffectID == effectId)
|
||||
{
|
||||
if (attributeId == -1 || effect.mAttribute == attributeId)
|
||||
{
|
||||
if (skillId == -1 || effect.mSkill == skillId)
|
||||
{
|
||||
ptrInventory.unequipSlot(slot, ptr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (doesEffectListContainEffect(enchantment->mEffects, effectId, attributeId, skillId))
|
||||
ptrInventory.unequipSlot(slot, ptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ namespace MechanicsHelper
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user