From b39fe85a5119499a5ec186f538f9fd9d9c9a035b Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 18 Sep 2014 14:56:43 +0200 Subject: [PATCH 1/7] Implement fPCbaseMagickaMult and fNPCbaseMagickaMult --- apps/openmw/mwmechanics/actors.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index 88e89a774..1ee498d84 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -397,8 +397,14 @@ namespace MWMechanics int agility = creatureStats.getAttribute(ESM::Attribute::Agility).getModified(); int endurance = creatureStats.getAttribute(ESM::Attribute::Endurance).getModified(); - double magickaFactor = - creatureStats.getMagicEffects().get (EffectKey (ESM::MagicEffect::FortifyMaximumMagicka)).getMagnitude() * 0.1 + 1; + float base = 1.f; + if (ptr.getCellRef().getRefId() == "player") + base = MWBase::Environment::get().getWorld()->getStore().get().find("fPCbaseMagickaMult")->getFloat(); + else + base = MWBase::Environment::get().getWorld()->getStore().get().find("fNPCbaseMagickaMult")->getFloat(); + + double magickaFactor = base + + creatureStats.getMagicEffects().get (EffectKey (ESM::MagicEffect::FortifyMaximumMagicka)).getMagnitude() * 0.1; DynamicStat magicka = creatureStats.getMagicka(); float diff = (static_cast(magickaFactor*intelligence)) - magicka.getBase(); From b6c6bfe94386d51e6262e3f294f8c90a97d08ccb Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 19 Sep 2014 05:02:54 +0200 Subject: [PATCH 2/7] Merge cell names when merging cells (Fixes #1929) --- apps/openmw/mwworld/store.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/openmw/mwworld/store.cpp b/apps/openmw/mwworld/store.cpp index 7ef06e841..caf4083fe 100644 --- a/apps/openmw/mwworld/store.cpp +++ b/apps/openmw/mwworld/store.cpp @@ -58,6 +58,7 @@ void Store::load(ESM::ESMReader &esm, const std::string &id) // merge new cell into old cell // push the new references on the list of references to manage (saveContext = true) oldcell->mData = cell.mData; + oldcell->mName = cell.mName; // merge name just to be sure (ID will be the same, but case could have been changed) oldcell->loadCell(esm, true); } else { @@ -74,6 +75,7 @@ void Store::load(ESM::ESMReader &esm, const std::string &id) if (oldcell) { // merge new cell into old cell oldcell->mData = cell.mData; + oldcell->mName = cell.mName; oldcell->loadCell(esm, false); // handle moved ref (MVRF) subrecords From 8a3a3baed4d1978911c3864a678d8b38abebdab9 Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 19 Sep 2014 05:46:59 +0200 Subject: [PATCH 3/7] Tweak AiEscort maximum distances --- apps/openmw/mwmechanics/aiescort.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwmechanics/aiescort.cpp b/apps/openmw/mwmechanics/aiescort.cpp index a0f8bffbd..02ad2d0a2 100644 --- a/apps/openmw/mwmechanics/aiescort.cpp +++ b/apps/openmw/mwmechanics/aiescort.cpp @@ -27,7 +27,7 @@ namespace MWMechanics , mCellX(std::numeric_limits::max()) , mCellY(std::numeric_limits::max()) { - mMaxDist = 470; + mMaxDist = 450; // The CS Help File states that if a duration is given, the AI package will run for that long // BUT if a location is givin, it "trumps" the duration so it will simply escort to that location. @@ -40,7 +40,7 @@ namespace MWMechanics , mCellX(std::numeric_limits::max()) , mCellY(std::numeric_limits::max()) { - mMaxDist = 470; + mMaxDist = 450; // The CS Help File states that if a duration is given, the AI package will run for that long // BUT if a location is given, it "trumps" the duration so it will simply escort to that location. @@ -93,14 +93,14 @@ namespace MWMechanics { if(pathTo(actor,ESM::Pathgrid::Point(mX,mY,mZ),duration)) //Returns true on path complete return true; - mMaxDist = 470; + mMaxDist = 450; } else { // Stop moving if the player is to far away MWBase::Environment::get().getMechanicsManager()->playAnimationGroup(actor, "idle3", 0, 1); actor.getClass().getMovementSettings(actor).mPosition[1] = 0; - mMaxDist = 330; + mMaxDist = 250; } return false; From ab9d9c7001f7ad1625028c87c099f34b9487d8d7 Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 19 Sep 2014 08:09:10 +0200 Subject: [PATCH 4/7] Add magic effect flags from ESM files to esmtool --- apps/esmtool/labels.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/esmtool/labels.cpp b/apps/esmtool/labels.cpp index ef45989ef..74b2c5fd2 100644 --- a/apps/esmtool/labels.cpp +++ b/apps/esmtool/labels.cpp @@ -787,6 +787,10 @@ std::string magicEffectFlags(int flags) if (flags & ESM::MagicEffect::NonRecastable) properties += "NonRecastable "; if (flags & ESM::MagicEffect::Unreflectable) properties += "Unreflectable "; if (flags & ESM::MagicEffect::CasterLinked) properties += "CasterLinked "; + if (flags & ESM::MagicEffect::AllowSpellmaking) properties += "AllowSpellmaking "; + if (flags & ESM::MagicEffect::AllowEnchanting) properties += "AllowEnchanting "; + if (flags & ESM::MagicEffect::NegativeLight) properties += "NegativeLight "; + if (flags & 0xFFFC0000) properties += "Invalid "; properties += str(boost::format("(0x%08X)") % flags); return properties; From b145d183aef7e980c025c192593332e36db6c6f3 Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 19 Sep 2014 09:10:46 +0200 Subject: [PATCH 5/7] Fix incorrect alchemy failure handling when an effect has a zero magnitude/duration (Fixes #1922) --- apps/openmw/mwgui/alchemywindow.cpp | 24 +++++++++++++++++------- apps/openmw/mwmechanics/alchemy.cpp | 5 ++++- apps/openmw/mwmechanics/alchemy.hpp | 16 ++++++++-------- 3 files changed, 29 insertions(+), 16 deletions(-) diff --git a/apps/openmw/mwgui/alchemywindow.cpp b/apps/openmw/mwgui/alchemywindow.cpp index 0b3e3c168..427e5bdd7 100644 --- a/apps/openmw/mwgui/alchemywindow.cpp +++ b/apps/openmw/mwgui/alchemywindow.cpp @@ -8,6 +8,8 @@ #include "../mwbase/soundmanager.hpp" #include "../mwbase/windowmanager.hpp" +#include "../mwmechanics/magiceffects.hpp" + #include "../mwworld/class.hpp" #include "inventoryitemmodel.hpp" @@ -211,12 +213,21 @@ namespace MWGui mItemView->update(); - std::vector effects; - ESM::EffectList list; - list.mList = effects; - for (MWMechanics::Alchemy::TEffectsIterator it = mAlchemy.beginEffects (); it != mAlchemy.endEffects (); ++it) + std::set effectIds = mAlchemy.listEffects(); + Widgets::SpellEffectList list; + for (std::set::iterator it = effectIds.begin(); it != effectIds.end(); ++it) { - list.mList.push_back(*it); + Widgets::SpellEffectParams params; + params.mEffectID = it->mId; + const ESM::MagicEffect* magicEffect = MWBase::Environment::get().getWorld()->getStore().get().find(it->mId); + if (magicEffect->mData.mFlags & ESM::MagicEffect::TargetSkill) + params.mSkill = it->mArg; + else if (magicEffect->mData.mFlags & ESM::MagicEffect::TargetAttribute) + params.mAttribute = it->mArg; + params.mIsConstant = true; + params.mNoTarget = true; + + list.push_back(params); } while (mEffectsBox->getChildCount()) @@ -226,8 +237,7 @@ namespace MWGui Widgets::MWEffectListPtr effectsWidget = mEffectsBox->createWidget ("MW_StatName", coord, MyGUI::Align::Left | MyGUI::Align::Top); - Widgets::SpellEffectList _list = Widgets::MWEffectList::effectListFromESM(&list); - effectsWidget->setEffectList(_list); + effectsWidget->setEffectList(list); std::vector effectItems; effectsWidget->createEffectWidgets(effectItems, mEffectsBox, coord, false, 0); diff --git a/apps/openmw/mwmechanics/alchemy.cpp b/apps/openmw/mwmechanics/alchemy.cpp index a097446a0..5b81dff61 100644 --- a/apps/openmw/mwmechanics/alchemy.cpp +++ b/apps/openmw/mwmechanics/alchemy.cpp @@ -306,6 +306,9 @@ float MWMechanics::Alchemy::getChance() const const CreatureStats& creatureStats = mAlchemist.getClass().getCreatureStats (mAlchemist); const NpcStats& npcStats = mAlchemist.getClass().getNpcStats (mAlchemist); + if (beginEffects() == endEffects()) + return 0.f; + return (npcStats.getSkill (ESM::Skill::Alchemy).getModified() + 0.1 * creatureStats.getAttribute (1).getModified() @@ -450,7 +453,7 @@ MWMechanics::Alchemy::Result MWMechanics::Alchemy::create (const std::string& na if (name.empty() && getPotionName().empty()) return Result_NoName; - if (beginEffects()==endEffects()) + if (listEffects().empty()) return Result_NoEffects; if (getChance() (RAND_MAX)*100) diff --git a/apps/openmw/mwmechanics/alchemy.hpp b/apps/openmw/mwmechanics/alchemy.hpp index 31cafa4dc..91e024574 100644 --- a/apps/openmw/mwmechanics/alchemy.hpp +++ b/apps/openmw/mwmechanics/alchemy.hpp @@ -50,15 +50,12 @@ namespace MWMechanics TEffectsContainer mEffects; int mValue; - std::set listEffects() const; - ///< List all effects shared by at least two ingredients. - void applyTools (int flags, float& value) const; void updateEffects(); const ESM::Potion *getRecord() const; - ///< Return existing recrod for created potion (may return 0) + ///< Return existing record for created potion (may return 0) void removeIngredients(); ///< Remove selected ingredients from alchemist's inventory, cleanup selected ingredients and @@ -75,6 +72,10 @@ namespace MWMechanics int countIngredients() const; + TEffectsIterator beginEffects() const; + + TEffectsIterator endEffects() const; + public: void setAlchemist (const MWWorld::Ptr& npc); @@ -94,6 +95,9 @@ namespace MWMechanics void clear(); ///< Remove alchemist, tools and ingredients. + std::set listEffects() const; + ///< List all effects shared by at least two ingredients. + int addIngredient (const MWWorld::Ptr& ingredient); ///< Add ingredient into the next free slot. /// @@ -103,10 +107,6 @@ namespace MWMechanics void removeIngredient (int index); ///< Remove ingredient from slot (calling this function on an empty slot is a no-op). - TEffectsIterator beginEffects() const; - - TEffectsIterator endEffects() const; - std::string getPotionName() const; ///< Return the name of the potion that would be created when calling create (if a record for such /// a potion already exists) or return an empty string. From cbc242d85772fdea35ad5163eb155f9c09a2d28c Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 19 Sep 2014 09:29:00 +0200 Subject: [PATCH 6/7] Move item count text to ItemWidget --- apps/openmw/mwgui/alchemywindow.cpp | 7 +------ apps/openmw/mwgui/container.cpp | 11 +---------- apps/openmw/mwgui/itemview.cpp | 21 +-------------------- apps/openmw/mwgui/itemview.hpp | 2 -- apps/openmw/mwgui/itemwidget.cpp | 28 ++++++++++++++++++++++++++++ apps/openmw/mwgui/itemwidget.hpp | 4 ++++ files/mygui/openmw_resources.xml | 8 ++++++++ 7 files changed, 43 insertions(+), 38 deletions(-) diff --git a/apps/openmw/mwgui/alchemywindow.cpp b/apps/openmw/mwgui/alchemywindow.cpp index 427e5bdd7..0fa9121b7 100644 --- a/apps/openmw/mwgui/alchemywindow.cpp +++ b/apps/openmw/mwgui/alchemywindow.cpp @@ -203,12 +203,7 @@ namespace MWGui ingredient->setUserString("ToolTipType", "ItemPtr"); ingredient->setUserData(item); - MyGUI::TextBox* text = ingredient->createWidget("SandBrightText", MyGUI::IntCoord(0, 14, 32, 18), MyGUI::Align::Default, std::string("Label")); - text->setTextAlign(MyGUI::Align::Right); - text->setNeedMouseFocus(false); - text->setTextShadow(true); - text->setTextShadowColour(MyGUI::Colour(0,0,0)); - text->setCaption(ItemView::getCountString(ingredient->getUserData()->getRefData().getCount())); + ingredient->setCount(ingredient->getUserData()->getRefData().getCount()); } mItemView->update(); diff --git a/apps/openmw/mwgui/container.cpp b/apps/openmw/mwgui/container.cpp index 18488b9b3..7aac65bd3 100644 --- a/apps/openmw/mwgui/container.cpp +++ b/apps/openmw/mwgui/container.cpp @@ -92,16 +92,7 @@ namespace MWGui mDraggedWidget = baseWidget; baseWidget->setItem(mItem.mBase); baseWidget->setNeedMouseFocus(false); - - // text widget that shows item count - // TODO: move to ItemWidget - MyGUI::TextBox* text = baseWidget->createWidget("SandBrightText", - MyGUI::IntCoord(0, 14, 32, 18), MyGUI::Align::Default, std::string("Label")); - text->setTextAlign(MyGUI::Align::Right); - text->setNeedMouseFocus(false); - text->setTextShadow(true); - text->setTextShadowColour(MyGUI::Colour(0,0,0)); - text->setCaption(ItemView::getCountString(count)); + baseWidget->setCount(count); sourceView->update(); diff --git a/apps/openmw/mwgui/itemview.cpp b/apps/openmw/mwgui/itemview.cpp index bb838e340..a51ada275 100644 --- a/apps/openmw/mwgui/itemview.cpp +++ b/apps/openmw/mwgui/itemview.cpp @@ -17,16 +17,6 @@ namespace MWGui { -std::string ItemView::getCountString(int count) -{ - if (count == 1) - return ""; - if (count > 9999) - return boost::lexical_cast(int(count/1000.f)) + "k"; - else - return boost::lexical_cast(count); -} - ItemView::ItemView() : mModel(NULL) , mScrollView(NULL) @@ -123,19 +113,10 @@ void ItemView::update() if (item.mType == ItemStack::Type_Equipped) state = ItemWidget::Equip; itemWidget->setItem(item.mBase, state); + itemWidget->setCount(item.mCount); itemWidget->eventMouseButtonClick += MyGUI::newDelegate(this, &ItemView::onSelectedItem); itemWidget->eventMouseWheel += MyGUI::newDelegate(this, &ItemView::onMouseWheel); - - // text widget that shows item count - // TODO: move to ItemWidget - MyGUI::TextBox* text = itemWidget->createWidget("SandBrightText", - MyGUI::IntCoord(5, 19, 32, 18), MyGUI::Align::Default, std::string("Label")); - text->setTextAlign(MyGUI::Align::Right); - text->setNeedMouseFocus(false); - text->setTextShadow(true); - text->setTextShadowColour(MyGUI::Colour(0,0,0)); - text->setCaption(getCountString(item.mCount)); } layoutWidgets(); diff --git a/apps/openmw/mwgui/itemview.hpp b/apps/openmw/mwgui/itemview.hpp index 68704d219..1a5bd79a3 100644 --- a/apps/openmw/mwgui/itemview.hpp +++ b/apps/openmw/mwgui/itemview.hpp @@ -30,8 +30,6 @@ namespace MWGui void update(); - static std::string getCountString(int count); - private: virtual void initialiseOverride(); diff --git a/apps/openmw/mwgui/itemwidget.cpp b/apps/openmw/mwgui/itemwidget.cpp index ade8f5731..430b57ef3 100644 --- a/apps/openmw/mwgui/itemwidget.cpp +++ b/apps/openmw/mwgui/itemwidget.cpp @@ -2,16 +2,34 @@ #include #include +#include + +#include #include #include "../mwworld/class.hpp" +namespace +{ + std::string getCountString(int count) + { + if (count == 1) + return ""; + if (count > 9999) + return boost::lexical_cast(int(count/1000.f)) + "k"; + else + return boost::lexical_cast(count); + } +} + namespace MWGui { ItemWidget::ItemWidget() : mItem(NULL) + , mFrame(NULL) + , mText(NULL) { } @@ -29,10 +47,20 @@ namespace MWGui assignWidget(mFrame, "Frame"); if (mFrame) mFrame->setNeedMouseFocus(false); + assignWidget(mText, "Text"); + if (mText) + mText->setNeedMouseFocus(false); Base::initialiseOverride(); } + void ItemWidget::setCount(int count) + { + if (!mText) + return; + mText->setCaption(getCountString(count)); + } + void ItemWidget::setIcon(const std::string &icon) { if (mItem) diff --git a/apps/openmw/mwgui/itemwidget.hpp b/apps/openmw/mwgui/itemwidget.hpp index 3de98489d..e7a902239 100644 --- a/apps/openmw/mwgui/itemwidget.hpp +++ b/apps/openmw/mwgui/itemwidget.hpp @@ -29,6 +29,9 @@ namespace MWGui Magic }; + /// Set count to be displayed in a textbox over the item + void setCount(int count); + /// \a ptr may be empty void setItem (const MWWorld::Ptr& ptr, ItemState state = None); @@ -42,6 +45,7 @@ namespace MWGui MyGUI::ImageBox* mItem; MyGUI::ImageBox* mFrame; + MyGUI::TextBox* mText; }; } diff --git a/files/mygui/openmw_resources.xml b/files/mygui/openmw_resources.xml index a37d3335c..1c8251a39 100644 --- a/files/mygui/openmw_resources.xml +++ b/files/mygui/openmw_resources.xml @@ -322,6 +322,10 @@ + + + + @@ -338,6 +342,10 @@ + + + + From e94268b4e69bbe1a5d622df2ad6ea56ca9f57360 Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 19 Sep 2014 10:54:43 +0200 Subject: [PATCH 7/7] Remove some garbage --- files/mygui/openmw_dialogue_window_skin.xml | 2 -- files/mygui/openmw_journal_skin.xml | 1 - files/mygui/openmw_list.skin.xml | 26 --------------------- 3 files changed, 29 deletions(-) diff --git a/files/mygui/openmw_dialogue_window_skin.xml b/files/mygui/openmw_dialogue_window_skin.xml index 5e16fd1f6..057fd14a5 100644 --- a/files/mygui/openmw_dialogue_window_skin.xml +++ b/files/mygui/openmw_dialogue_window_skin.xml @@ -3,14 +3,12 @@ - - diff --git a/files/mygui/openmw_journal_skin.xml b/files/mygui/openmw_journal_skin.xml index 71a2a7865..29829059c 100644 --- a/files/mygui/openmw_journal_skin.xml +++ b/files/mygui/openmw_journal_skin.xml @@ -5,7 +5,6 @@ - diff --git a/files/mygui/openmw_list.skin.xml b/files/mygui/openmw_list.skin.xml index 491ceb033..160930d71 100644 --- a/files/mygui/openmw_list.skin.xml +++ b/files/mygui/openmw_list.skin.xml @@ -166,32 +166,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - -