From 14c9a4e1d391c7be655ff89ba9e3cec26a6f1d58 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 23 Nov 2013 23:12:54 +0100 Subject: [PATCH] Cap enchantment casting cost to 1 as displayed in enchanting window. Display current enchantment charge in spell window. --- apps/openmw/mwclass/npc.cpp | 2 +- apps/openmw/mwgui/spellwindow.cpp | 12 ++++++++++-- apps/openmw/mwmechanics/spellcasting.cpp | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 6970e8646e..8ff8081bc7 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -463,7 +463,7 @@ namespace MWClass // Check if we have enough charges const float enchantCost = enchantment->mData.mCost; int eSkill = stats.getSkill(ESM::Skill::Enchant).getModified(); - const float castCost = enchantCost - (enchantCost / 100) * (eSkill - 10); + const int castCost = std::max(1.f, enchantCost - (enchantCost / 100) * (eSkill - 10)); if (weapon.getCellRef().mEnchantmentCharge == -1) weapon.getCellRef().mEnchantmentCharge = enchantment->mData.mCharge; diff --git a/apps/openmw/mwgui/spellwindow.cpp b/apps/openmw/mwgui/spellwindow.cpp index 03bb106310..42a0b98657 100644 --- a/apps/openmw/mwgui/spellwindow.cpp +++ b/apps/openmw/mwgui/spellwindow.cpp @@ -282,8 +282,16 @@ namespace MWGui MyGUI::Button* costCharge = mSpellView->createWidget(equipped ? "SpellText" : "SpellTextUnequipped", MyGUI::IntCoord(4, mHeight, mWidth-8, spellHeight), MyGUI::Align::Left | MyGUI::Align::Top); - std::string cost = boost::lexical_cast(enchant->mData.mCost); - std::string charge = boost::lexical_cast(enchant->mData.mCharge); /// \todo track current charge + float enchantCost = enchant->mData.mCost; + MWMechanics::NpcStats &stats = player.getClass().getNpcStats(player); + int eSkill = stats.getSkill(ESM::Skill::Enchant).getModified(); + int castCost = std::max(1.f, enchantCost - (enchantCost / 100) * (eSkill - 10)); + + std::string cost = boost::lexical_cast(castCost); + int currentCharge = int(item.getCellRef().mEnchantmentCharge); + if (currentCharge == -1) + currentCharge = enchant->mData.mCharge; + std::string charge = boost::lexical_cast(currentCharge); if (enchant->mData.mType == ESM::Enchantment::CastOnce) { // this is Morrowind behaviour diff --git a/apps/openmw/mwmechanics/spellcasting.cpp b/apps/openmw/mwmechanics/spellcasting.cpp index 08db189778..65efc0dab9 100644 --- a/apps/openmw/mwmechanics/spellcasting.cpp +++ b/apps/openmw/mwmechanics/spellcasting.cpp @@ -295,7 +295,7 @@ namespace MWMechanics const float enchantCost = enchantment->mData.mCost; MWMechanics::NpcStats &stats = MWWorld::Class::get(mCaster).getNpcStats(mCaster); int eSkill = stats.getSkill(ESM::Skill::Enchant).getModified(); - const float castCost = enchantCost - (enchantCost / 100) * (eSkill - 10); + const int castCost = std::max(1.f, enchantCost - (enchantCost / 100) * (eSkill - 10)); if (item.getCellRef().mEnchantmentCharge == -1) item.getCellRef().mEnchantmentCharge = enchantment->mData.mCharge;