From 2d38ca4c35362c75d3dde7227615a720813b32bf Mon Sep 17 00:00:00 2001 From: Alexei Kotov Date: Mon, 30 Oct 2023 15:30:01 +0300 Subject: [PATCH] Improve invisibility breaking consistency (bug #7660) - Break on recharge attempts - Break on repair attempts - Break on potion creation attempts - Don't break on failed ingredient consuming --- CHANGELOG.md | 1 + apps/openmw/mwclass/actor.cpp | 8 ++++++-- apps/openmw/mwmechanics/alchemy.cpp | 2 ++ apps/openmw/mwmechanics/recharge.cpp | 2 ++ apps/openmw/mwmechanics/repair.cpp | 2 ++ 5 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 19e122f0a9..8eeea365f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -85,6 +85,7 @@ Bug #7631: Cannot trade with/talk to Creeper or Mudcrab Merchant when they're fleeing Bug #7639: NPCs don't use hand-to-hand if their other melee skills were damaged during combat Bug #7647: NPC walk cycle bugs after greeting player + Bug #7660: Some inconsistencies regarding Invisibility breaking Feature #3537: Shader-based water ripples Feature #5492: Let rain and snow collide with statics Feature #6149: Dehardcode Lua API_REVISION diff --git a/apps/openmw/mwclass/actor.cpp b/apps/openmw/mwclass/actor.cpp index 7f60ae5c2c..9c197a70d2 100644 --- a/apps/openmw/mwclass/actor.cpp +++ b/apps/openmw/mwclass/actor.cpp @@ -95,12 +95,16 @@ namespace MWClass bool Actor::consume(const MWWorld::Ptr& consumable, const MWWorld::Ptr& actor) const { - MWBase::Environment::get().getWorld()->breakInvisibility(actor); MWMechanics::CastSpell cast(actor, actor); const ESM::RefId& recordId = consumable.getCellRef().getRefId(); MWBase::Environment::get().getWorldModel()->registerPtr(consumable); MWBase::Environment::get().getLuaManager()->itemConsumed(consumable, actor); actor.getClass().getContainerStore(actor).remove(consumable, 1); - return cast.cast(recordId); + if (cast.cast(recordId)) + { + MWBase::Environment::get().getWorld()->breakInvisibility(actor); + return true; + } + return false; } } diff --git a/apps/openmw/mwmechanics/alchemy.cpp b/apps/openmw/mwmechanics/alchemy.cpp index 914de6da2b..995d55759b 100644 --- a/apps/openmw/mwmechanics/alchemy.cpp +++ b/apps/openmw/mwmechanics/alchemy.cpp @@ -510,6 +510,8 @@ MWMechanics::Alchemy::Result MWMechanics::Alchemy::create(const std::string& nam if (readyStatus != Result_Success) return readyStatus; + MWBase::Environment::get().getWorld()->breakInvisibility(mAlchemist); + Result result = Result_RandomFailure; int brewedCount = 0; for (int i = 0; i < count; ++i) diff --git a/apps/openmw/mwmechanics/recharge.cpp b/apps/openmw/mwmechanics/recharge.cpp index fc8a0e8a72..9c42e4088c 100644 --- a/apps/openmw/mwmechanics/recharge.cpp +++ b/apps/openmw/mwmechanics/recharge.cpp @@ -44,6 +44,8 @@ namespace MWMechanics MWWorld::Ptr player = MWMechanics::getPlayer(); MWMechanics::CreatureStats& stats = player.getClass().getCreatureStats(player); + MWBase::Environment::get().getWorld()->breakInvisibility(player); + float luckTerm = 0.1f * stats.getAttribute(ESM::Attribute::Luck).getModified(); if (luckTerm < 1 || luckTerm > 10) luckTerm = 1; diff --git a/apps/openmw/mwmechanics/repair.cpp b/apps/openmw/mwmechanics/repair.cpp index 4894b93e7f..3011004244 100644 --- a/apps/openmw/mwmechanics/repair.cpp +++ b/apps/openmw/mwmechanics/repair.cpp @@ -22,6 +22,8 @@ namespace MWMechanics MWWorld::Ptr player = getPlayer(); MWWorld::LiveCellRef* ref = mTool.get(); + MWBase::Environment::get().getWorld()->breakInvisibility(player); + // unstack tool if required player.getClass().getContainerStore(player).unstack(mTool);