|
|
|
@ -15,10 +15,14 @@
|
|
|
|
|
|
|
|
|
|
#include "../mwmechanics/spells.hpp"
|
|
|
|
|
#include "../mwmechanics/creaturestats.hpp"
|
|
|
|
|
#include "../mwmechanics/spellsuccess.hpp"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "tooltips.hpp"
|
|
|
|
|
#include "widgets.hpp"
|
|
|
|
|
#include "class.hpp"
|
|
|
|
|
#include "inventorywindow.hpp"
|
|
|
|
|
#include "tradewindow.hpp"
|
|
|
|
|
|
|
|
|
|
namespace
|
|
|
|
|
{
|
|
|
|
@ -310,14 +314,25 @@ namespace MWGui
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ESM::Spell newSpell;
|
|
|
|
|
ESM::EffectList effectList;
|
|
|
|
|
effectList.mList = mEffects;
|
|
|
|
|
newSpell.mEffects = effectList;
|
|
|
|
|
newSpell.mName = mNameEdit->getCaption();
|
|
|
|
|
newSpell.mData.mType = ESM::Spell::ST_Spell;
|
|
|
|
|
if (mMagickaCost->getCaption() == "0")
|
|
|
|
|
{
|
|
|
|
|
mWindowManager.messageBox ("#{sEnchantmentMenu8}", std::vector<std::string>());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (boost::lexical_cast<int>(mPriceLabel->getCaption()) > mWindowManager.getInventoryWindow()->getPlayerGold())
|
|
|
|
|
{
|
|
|
|
|
mWindowManager.messageBox ("#{sNotifyMessage18}", std::vector<std::string>());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::pair<std::string, const ESM::Spell*> result = MWBase::Environment::get().getWorld()->createRecord(newSpell);
|
|
|
|
|
mSpell.mName = mNameEdit->getCaption();
|
|
|
|
|
|
|
|
|
|
mWindowManager.getTradeWindow()->addOrRemoveGold(-boost::lexical_cast<int>(mPriceLabel->getCaption()));
|
|
|
|
|
|
|
|
|
|
MWBase::Environment::get().getSoundManager()->playSound ("Item Gold Up", 1.0, 1.0);
|
|
|
|
|
|
|
|
|
|
std::pair<std::string, const ESM::Spell*> result = MWBase::Environment::get().getWorld()->createRecord(mSpell);
|
|
|
|
|
|
|
|
|
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
|
|
|
|
MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player);
|
|
|
|
@ -340,6 +355,47 @@ namespace MWGui
|
|
|
|
|
mWindowManager.removeGuiMode (GM_SpellCreation);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SpellCreationDialog::notifyEffectsChanged ()
|
|
|
|
|
{
|
|
|
|
|
float y = 0;
|
|
|
|
|
|
|
|
|
|
for (std::vector<ESM::ENAMstruct>::const_iterator it = mEffects.begin(); it != mEffects.end(); ++it)
|
|
|
|
|
{
|
|
|
|
|
float x = 0.5 * it->mMagnMin + it->mMagnMax;
|
|
|
|
|
|
|
|
|
|
const ESM::MagicEffect* effect = MWBase::Environment::get().getWorld()->getStore().magicEffects.find(it->mEffectID);
|
|
|
|
|
x *= 0.1 * effect->mData.mBaseCost;
|
|
|
|
|
x *= 1 + it->mDuration;
|
|
|
|
|
x += 0.05 * std::max(1, it->mArea) * effect->mData.mBaseCost;
|
|
|
|
|
|
|
|
|
|
float fEffectCostMult = MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fEffectCostMult")->getFloat();
|
|
|
|
|
y += x * fEffectCostMult;
|
|
|
|
|
y = std::max(1.f,y);
|
|
|
|
|
|
|
|
|
|
if (effect->mData.mFlags & ESM::MagicEffect::CastTarget)
|
|
|
|
|
y *= 1.5;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mSpell.mData.mCost = int(y);
|
|
|
|
|
|
|
|
|
|
ESM::EffectList effectList;
|
|
|
|
|
effectList.mList = mEffects;
|
|
|
|
|
mSpell.mEffects = effectList;
|
|
|
|
|
mSpell.mData.mType = ESM::Spell::ST_Spell;
|
|
|
|
|
|
|
|
|
|
mMagickaCost->setCaption(boost::lexical_cast<std::string>(int(y)));
|
|
|
|
|
|
|
|
|
|
float fSpellMakingValueMult = MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fSpellMakingValueMult")->getFloat();
|
|
|
|
|
|
|
|
|
|
/// \todo mercantile
|
|
|
|
|
int price = int(y) * fSpellMakingValueMult;
|
|
|
|
|
|
|
|
|
|
mPriceLabel->setCaption(boost::lexical_cast<std::string>(int(price)));
|
|
|
|
|
|
|
|
|
|
float chance = MWMechanics::getSpellSuccessChance(&mSpell, MWBase::Environment::get().getWorld()->getPlayer().getPlayer());
|
|
|
|
|
mSuccessChance->setCaption(boost::lexical_cast<std::string>(int(chance)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -443,6 +499,11 @@ namespace MWGui
|
|
|
|
|
|
|
|
|
|
void EffectEditorBase::onAvailableEffectClicked (MyGUI::Widget* sender)
|
|
|
|
|
{
|
|
|
|
|
if (mEffects.size() >= 8)
|
|
|
|
|
{
|
|
|
|
|
MWBase::Environment::get().getWindowManager()->messageBox("#{sNotifyMessage28}", std::vector<std::string>());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
short effectId = *sender->getUserData<short>();
|
|
|
|
|
|
|
|
|
@ -534,6 +595,8 @@ namespace MWGui
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mUsedEffectsView->setCanvasSize(size);
|
|
|
|
|
|
|
|
|
|
notifyEffectsChanged();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EffectEditorBase::onEffectAdded (ESM::ENAMstruct effect)
|
|
|
|
|