From a28cc37501c729930bb935cc305696e413a75c4e Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Tue, 5 Dec 2017 10:24:58 +0400 Subject: [PATCH 1/4] Do not sell ingredients from organic containers --- apps/openmw/mwworld/worldimp.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 9c7fba9fa..2d38f1518 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -2446,6 +2446,11 @@ namespace MWWorld if (ptr.getRefData().isDeleted()) return true; + // we should not sell ingrediends from owned organic containers + MWWorld::LiveCellRef* ref = ptr.get(); + if (ref && (ref->mBase->mFlags & ESM::Container::Organic)) + return true; + if (Misc::StringUtils::ciEqual(ptr.getCellRef().getOwner(), mOwner.getCellRef().getRefId())) mOut.push_back(ptr); From e0c54b3f396d53c13cd83bf3f9806cc4104fa47e Mon Sep 17 00:00:00 2001 From: Allofich Date: Tue, 5 Dec 2017 23:41:08 +0900 Subject: [PATCH 2/4] Stop guards trying to arrest player when calm (Fixes #3863) --- apps/openmw/mwmechanics/actors.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index 20955f22a..d685967da 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -1009,7 +1009,8 @@ namespace MWMechanics if (player.getClass().getNpcStats(player).isWerewolf()) return; - if (ptr.getClass().isClass(ptr, "Guard") && creatureStats.getAiSequence().getTypeId() != AiPackage::TypeIdPursue && !creatureStats.getAiSequence().isInCombat()) + if (ptr.getClass().isClass(ptr, "Guard") && creatureStats.getAiSequence().getTypeId() != AiPackage::TypeIdPursue && !creatureStats.getAiSequence().isInCombat() + && creatureStats.getMagicEffects().get(ESM::MagicEffect::CalmHumanoid).getMagnitude() == 0) { const MWWorld::ESMStore& esmStore = MWBase::Environment::get().getWorld()->getStore(); static const int cutoff = esmStore.get().find("iCrimeThreshold")->getInt(); From 7e87ce878760022c2c875336b7802aac0b18dc9c Mon Sep 17 00:00:00 2001 From: Allofich Date: Wed, 6 Dec 2017 00:31:48 +0900 Subject: [PATCH 3/4] Prevent combat on/off cycling for calmed actors --- apps/openmw/mwmechanics/mechanicsmanagerimp.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index 2b6236ecb..b51b55421 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -1653,6 +1653,12 @@ namespace MWMechanics bool MechanicsManager::isAggressive(const MWWorld::Ptr &ptr, const MWWorld::Ptr &target) { + // Don't become aggressive if a calm effect is active, since it would cause combat to cycle on/off as + // combat is activated here and then canceled by the calm effect + if ((ptr.getClass().isNpc() && ptr.getClass().getCreatureStats(ptr).getMagicEffects().get(ESM::MagicEffect::CalmHumanoid).getMagnitude() > 0) + || (!ptr.getClass().isNpc() && ptr.getClass().getCreatureStats(ptr).getMagicEffects().get(ESM::MagicEffect::CalmCreature).getMagnitude() > 0)) + return false; + int disposition = 50; if (ptr.getClass().isNpc()) disposition = getDerivedDisposition(ptr, true); From 744859f32715a1244930f049b9d4933e27f2b34f Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Thu, 7 Dec 2017 22:43:32 +0400 Subject: [PATCH 4/4] Take in account armor condition in the armor rating calculation (bug #4246) --- apps/openmw/mwclass/npc.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index e7085bfbc..134bbf943 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -1129,6 +1129,15 @@ namespace MWClass else { ratings[i] = it->getClass().getEffectiveArmorRating(*it, ptr); + + // Take in account armor condition + const bool hasHealth = it->getClass().hasItemHealth(*it); + if (hasHealth) + { + int armorHealth = it->getClass().getItemHealth(*it); + int armorMaxHealth = it->getClass().getItemMaxHealth(*it); + ratings[i] *= (float(armorHealth) / armorMaxHealth); + } } }