mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 20:19:57 +00:00
Slightly reduce code duplication
This commit is contained in:
parent
af2ea477d5
commit
1251b32f0f
3 changed files with 16 additions and 9 deletions
|
@ -1111,10 +1111,7 @@ namespace MWScript
|
|||
|
||||
if (ptr == MWMechanics::getPlayer())
|
||||
{
|
||||
MWWorld::InventoryStore& store = ptr.getClass().getInventoryStore(ptr);
|
||||
store.setSelectedEnchantItem(store.end());
|
||||
MWBase::Environment::get().getWindowManager()->setSelectedSpell(spellId, int(MWMechanics::getSpellSuccessChance(spellId, ptr)));
|
||||
MWBase::Environment::get().getWindowManager()->updateSpellWindow();
|
||||
MWBase::Environment::get().getWorld()->getPlayer().setSelectedSpell(spellId);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1122,7 +1119,6 @@ namespace MWScript
|
|||
{
|
||||
MWMechanics::AiCast castPackage(targetId, spellId, true);
|
||||
ptr.getClass().getCreatureStats (ptr).getAiSequence().stack(castPackage, ptr);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1158,10 +1154,7 @@ namespace MWScript
|
|||
|
||||
if (ptr == MWMechanics::getPlayer())
|
||||
{
|
||||
MWWorld::InventoryStore& store = ptr.getClass().getInventoryStore(ptr);
|
||||
store.setSelectedEnchantItem(store.end());
|
||||
MWBase::Environment::get().getWindowManager()->setSelectedSpell(spellId, int(MWMechanics::getSpellSuccessChance(spellId, ptr)));
|
||||
MWBase::Environment::get().getWindowManager()->updateSpellWindow();
|
||||
MWBase::Environment::get().getWorld()->getPlayer().setSelectedSpell(spellId);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <components/esm/loadbsgn.hpp>
|
||||
|
||||
#include "../mwworld/esmstore.hpp"
|
||||
#include "../mwworld/inventorystore.hpp"
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
|
@ -19,6 +20,7 @@
|
|||
|
||||
#include "../mwmechanics/movement.hpp"
|
||||
#include "../mwmechanics/npcstats.hpp"
|
||||
#include "../mwmechanics/spellcasting.hpp"
|
||||
|
||||
#include "class.hpp"
|
||||
#include "ptr.hpp"
|
||||
|
@ -492,4 +494,14 @@ namespace MWWorld
|
|||
{
|
||||
mPreviousItems.erase(boundItemId);
|
||||
}
|
||||
|
||||
void Player::setSelectedSpell(const std::string& spellId)
|
||||
{
|
||||
Ptr player = getPlayer();
|
||||
InventoryStore& store = player.getClass().getInventoryStore(player);
|
||||
store.setSelectedEnchantItem(store.end());
|
||||
int castChance = int(MWMechanics::getSpellSuccessChance(spellId, player));
|
||||
MWBase::Environment::get().getWindowManager()->setSelectedSpell(spellId, castChance);
|
||||
MWBase::Environment::get().getWindowManager()->updateSpellWindow();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -135,6 +135,8 @@ namespace MWWorld
|
|||
void setPreviousItem(const std::string& boundItemId, const std::string& previousItemId);
|
||||
std::string getPreviousItem(const std::string& boundItemId);
|
||||
void erasePreviousItem(const std::string& boundItemId);
|
||||
|
||||
void setSelectedSpell(const std::string& spellId);
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue