mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-20 23:39:40 +00:00
[Client] Add doesEffectListContainEffect() method to MechanicsHelper
This commit is contained in:
parent
aa392ebf20
commit
c6a85ee8f9
2 changed files with 22 additions and 14 deletions
|
@ -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…
Reference in a new issue