mirror of
https://github.com/TES3MP/TES3MP.git
synced 2025-09-29 08:00:56 -04:00
Fix being able to use enchantments of items that failed to equip (Fixes #2215)
This commit is contained in:
parent
4e0d16da8c
commit
4d5adfb5dd
@ -99,15 +99,9 @@ void InventoryItemModel::update()
|
|||||||
if (mActor.getClass().hasInventoryStore(mActor))
|
if (mActor.getClass().hasInventoryStore(mActor))
|
||||||
{
|
{
|
||||||
MWWorld::InventoryStore& store = mActor.getClass().getInventoryStore(mActor);
|
MWWorld::InventoryStore& store = mActor.getClass().getInventoryStore(mActor);
|
||||||
for (int slot=0; slot<MWWorld::InventoryStore::Slots; ++slot)
|
if (store.isEquipped(newItem.mBase))
|
||||||
{
|
|
||||||
MWWorld::ContainerStoreIterator equipped = store.getSlot(slot);
|
|
||||||
if (equipped == store.end())
|
|
||||||
continue;
|
|
||||||
if (*equipped == newItem.mBase)
|
|
||||||
newItem.mType = ItemStack::Type_Equipped;
|
newItem.mType = ItemStack::Type_Equipped;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
mItems.push_back(newItem);
|
mItems.push_back(newItem);
|
||||||
}
|
}
|
||||||
|
@ -326,6 +326,10 @@ namespace MWGui
|
|||||||
if (!item.getClass().getEquipmentSlots(item).first.empty())
|
if (!item.getClass().getEquipmentSlots(item).first.empty())
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getWindowManager()->getInventoryWindow()->useItem(item);
|
MWBase::Environment::get().getWindowManager()->getInventoryWindow()->useItem(item);
|
||||||
|
|
||||||
|
// make sure that item was successfully equipped
|
||||||
|
if (!store.isEquipped(item))
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
store.setSelectedEnchantItem(it);
|
store.setSelectedEnchantItem(it);
|
||||||
|
@ -108,16 +108,7 @@ namespace MWGui
|
|||||||
std::string charge = boost::lexical_cast<std::string>(currentCharge);
|
std::string charge = boost::lexical_cast<std::string>(currentCharge);
|
||||||
newSpell.mCostColumn = cost + "/" + charge;
|
newSpell.mCostColumn = cost + "/" + charge;
|
||||||
|
|
||||||
bool equipped = false;
|
newSpell.mActive = invStore.isEquipped(item);
|
||||||
for (int i=0; i < MWWorld::InventoryStore::Slots; ++i)
|
|
||||||
{
|
|
||||||
if (invStore.getSlot(i) != invStore.end() && *invStore.getSlot(i) == item)
|
|
||||||
{
|
|
||||||
equipped = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
newSpell.mActive = equipped;
|
|
||||||
}
|
}
|
||||||
mSpells.push_back(newSpell);
|
mSpells.push_back(newSpell);
|
||||||
}
|
}
|
||||||
|
@ -86,6 +86,9 @@ namespace MWGui
|
|||||||
&& !item.getClass().getEquipmentSlots(item).first.empty())
|
&& !item.getClass().getEquipmentSlots(item).first.empty())
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getWindowManager()->getInventoryWindow()->useItem(item);
|
MWBase::Environment::get().getWindowManager()->getInventoryWindow()->useItem(item);
|
||||||
|
// make sure that item was successfully equipped
|
||||||
|
if (!store.isEquipped(item))
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MWBase::Environment::get().getWindowManager()->unsetSelectedSpell();
|
MWBase::Environment::get().getWindowManager()->unsetSelectedSpell();
|
||||||
|
@ -175,17 +175,8 @@ namespace MWGui
|
|||||||
// don't show equipped items
|
// don't show equipped items
|
||||||
if(mMerchant.getClass().hasInventoryStore(mMerchant))
|
if(mMerchant.getClass().hasInventoryStore(mMerchant))
|
||||||
{
|
{
|
||||||
bool isEquipped = false;
|
|
||||||
MWWorld::InventoryStore& store = mMerchant.getClass().getInventoryStore(mMerchant);
|
MWWorld::InventoryStore& store = mMerchant.getClass().getInventoryStore(mMerchant);
|
||||||
for (int slot=0; slot<MWWorld::InventoryStore::Slots; ++slot)
|
if (store.isEquipped(base))
|
||||||
{
|
|
||||||
MWWorld::ContainerStoreIterator equipped = store.getSlot(slot);
|
|
||||||
if (equipped == store.end())
|
|
||||||
continue;
|
|
||||||
if (*equipped == base)
|
|
||||||
isEquipped = true;
|
|
||||||
}
|
|
||||||
if (isEquipped)
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -201,13 +201,17 @@ namespace MWMechanics
|
|||||||
return 0.f;
|
return 0.f;
|
||||||
|
|
||||||
const ESM::Enchantment* enchantment = MWBase::Environment::get().getWorld()->getStore().get<ESM::Enchantment>().find(ptr.getClass().getEnchantment(ptr));
|
const ESM::Enchantment* enchantment = MWBase::Environment::get().getWorld()->getStore().get<ESM::Enchantment>().find(ptr.getClass().getEnchantment(ptr));
|
||||||
|
|
||||||
if (enchantment->mData.mType == ESM::Enchantment::CastOnce)
|
if (enchantment->mData.mType == ESM::Enchantment::CastOnce)
|
||||||
{
|
{
|
||||||
return rateEffects(enchantment->mEffects, actor, target);
|
return rateEffects(enchantment->mEffects, actor, target);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
//if (!ptr.getClass().canBeEquipped(ptr, actor))
|
||||||
return 0.f;
|
return 0.f;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
float rateEffect(const ESM::ENAMstruct &effect, const MWWorld::Ptr &actor, const MWWorld::Ptr &target)
|
float rateEffect(const ESM::ENAMstruct &effect, const MWWorld::Ptr &actor, const MWWorld::Ptr &target)
|
||||||
{
|
{
|
||||||
|
@ -643,3 +643,13 @@ void MWWorld::InventoryStore::clear()
|
|||||||
initSlots (mSlots);
|
initSlots (mSlots);
|
||||||
ContainerStore::clear();
|
ContainerStore::clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MWWorld::InventoryStore::isEquipped(const MWWorld::Ptr &item)
|
||||||
|
{
|
||||||
|
for (int i=0; i < MWWorld::InventoryStore::Slots; ++i)
|
||||||
|
{
|
||||||
|
if (getSlot(i) != end() && *getSlot(i) == item)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
@ -145,6 +145,9 @@ namespace MWWorld
|
|||||||
void equip (int slot, const ContainerStoreIterator& iterator, const Ptr& actor);
|
void equip (int slot, const ContainerStoreIterator& iterator, const Ptr& actor);
|
||||||
///< \warning \a iterator can not be an end()-iterator, use unequip function instead
|
///< \warning \a iterator can not be an end()-iterator, use unequip function instead
|
||||||
|
|
||||||
|
bool isEquipped(const MWWorld::Ptr& item);
|
||||||
|
///< Utility function, returns true if the given item is equipped in any slot
|
||||||
|
|
||||||
void setSelectedEnchantItem(const ContainerStoreIterator& iterator);
|
void setSelectedEnchantItem(const ContainerStoreIterator& iterator);
|
||||||
///< set the selected magic item (for using enchantments of type "Cast once" or "Cast when used")
|
///< set the selected magic item (for using enchantments of type "Cast once" or "Cast when used")
|
||||||
/// \note to unset the selected item, call this method with end() iterator
|
/// \note to unset the selected item, call this method with end() iterator
|
||||||
|
Loading…
x
Reference in New Issue
Block a user