mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-30 21:15:36 +00:00
Deselect magic item before selecting a spell
This commit is contained in:
parent
b9cb028809
commit
d9c16328dd
1 changed files with 12 additions and 0 deletions
|
@ -744,8 +744,19 @@ namespace MWLua
|
||||||
const MWWorld::Ptr& ptr = obj.ptr();
|
const MWWorld::Ptr& ptr = obj.ptr();
|
||||||
auto& stats = ptr.getClass().getCreatureStats(ptr);
|
auto& stats = ptr.getClass().getCreatureStats(ptr);
|
||||||
|
|
||||||
|
// We need to deselect any enchant items before we can select a spell otherwise the item will be
|
||||||
|
// reselected
|
||||||
|
const auto resetEnchantItem = [&]() {
|
||||||
|
if (ptr.getClass().hasInventoryStore(ptr))
|
||||||
|
{
|
||||||
|
MWWorld::InventoryStore& inventory = ptr.getClass().getInventoryStore(ptr);
|
||||||
|
inventory.setSelectedEnchantItem(inventory.end());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
if (spellId.empty())
|
if (spellId.empty())
|
||||||
{
|
{
|
||||||
|
resetEnchantItem();
|
||||||
if (ptr == MWBase::Environment::get().getWorld()->getPlayerPtr())
|
if (ptr == MWBase::Environment::get().getWorld()->getPlayerPtr())
|
||||||
MWBase::Environment::get().getWindowManager()->unsetSelectedSpell();
|
MWBase::Environment::get().getWindowManager()->unsetSelectedSpell();
|
||||||
else
|
else
|
||||||
|
@ -755,6 +766,7 @@ namespace MWLua
|
||||||
if (!stats.getSpells().hasSpell(spellId))
|
if (!stats.getSpells().hasSpell(spellId))
|
||||||
throw std::runtime_error("Actor doesn't know spell " + spellId.toDebugString());
|
throw std::runtime_error("Actor doesn't know spell " + spellId.toDebugString());
|
||||||
|
|
||||||
|
resetEnchantItem();
|
||||||
if (ptr == MWBase::Environment::get().getWorld()->getPlayerPtr())
|
if (ptr == MWBase::Environment::get().getWorld()->getPlayerPtr())
|
||||||
{
|
{
|
||||||
int chance = MWMechanics::getSpellSuccessChance(spellId, ptr);
|
int chance = MWMechanics::getSpellSuccessChance(spellId, ptr);
|
||||||
|
|
Loading…
Reference in a new issue