1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-05 06:40:09 +00:00

Merge branch 'swim_when_follow' into 'master'

Allow actors to find path over water surface (#5943)

See merge request OpenMW/openmw!731
This commit is contained in:
psi29a 2021-04-13 07:19:54 +00:00
commit 0a6ef9c1bd
7 changed files with 45 additions and 1 deletions

View File

@ -108,6 +108,7 @@ bool Launcher::AdvancedPage::loadSettings()
int numPhysicsThreads = mEngineSettings.getInt("async num threads", "Physics");
if (numPhysicsThreads >= 0)
physicsThreadsSpinBox->setValue(numPhysicsThreads);
loadSettingBool(allowNPCToFollowOverWaterSurfaceCheckBox, "allow actors to follow over water surface", "Game");
}
// Visuals

View File

@ -23,4 +23,10 @@ namespace MWMechanics
MWBase::World* world = MWBase::Environment::get().getWorld();
return (actor.getClass().canSwim(actor) && world->isSwimming(actor)) || world->isFlying(actor);
}
bool hasWaterWalking(const MWWorld::Ptr& actor)
{
const MWMechanics::MagicEffects& effects = actor.getClass().getCreatureStats(actor).getMagicEffects();
return effects.get(ESM::MagicEffect::WaterWalking).getMagnitude() > 0;
}
}

View File

@ -31,6 +31,7 @@ namespace MWMechanics
MWWorld::Ptr getPlayer();
bool isPlayerInCombat();
bool canActorMoveByZAxis(const MWWorld::Ptr& actor);
bool hasWaterWalking(const MWWorld::Ptr& actor);
template<class T>
void setBaseAISetting(const std::string& id, MWMechanics::CreatureStats::AiSetting setting, int value)

View File

@ -411,10 +411,16 @@ bool MWMechanics::AiPackage::isReachableRotatingOnTheRun(const MWWorld::Ptr& act
DetourNavigator::Flags MWMechanics::AiPackage::getNavigatorFlags(const MWWorld::Ptr& actor) const
{
static const bool allowToFollowOverWaterSurface = Settings::Manager::getBool("allow actors to follow over water surface", "Game");
const MWWorld::Class& actorClass = actor.getClass();
DetourNavigator::Flags result = DetourNavigator::Flag_none;
if (actorClass.isPureWaterCreature(actor) || (getTypeId() != AiPackageTypeId::Wander && actorClass.canSwim(actor)))
if (actorClass.isPureWaterCreature(actor)
|| (getTypeId() != AiPackageTypeId::Wander
&& ((allowToFollowOverWaterSurface && getTypeId() == AiPackageTypeId::Follow)
|| actorClass.canSwim(actor)
|| hasWaterWalking(actor))))
result |= DetourNavigator::Flag_swim;
if (actorClass.canWalk(actor))

View File

@ -439,3 +439,19 @@ graphic herbalism
Some mods add harvestable container models. When this setting is enabled, activating a container using a harvestable model will visually harvest from it instead of opening the menu.
When this setting is turned off or when activating a regular container, the menu will open as usual.
allow actors to follow over water surface
---------------------
:Type: boolean
:Range: True/False
:Default: True
If enabled actors will always find path over the water surface when following other actors. This makes OpenMW behaviour closer to the vanilla engine.
If disabled actors without the ability to swim will not follow other actors to the water.
.. note::
Has effect only when Navigator is enabled.
This setting can be controlled in Advanced tab of the launcher.

View File

@ -364,6 +364,10 @@ always allow stealing from knocked out actors = false
# Enables visually harvesting plants for models that support it.
graphic herbalism = true
# Give actors an ability to swim over water surface when they follow other actor independently from their ability to swim
# (true, false)
allow actors to follow over water surface = true
[General]
# Anisotropy reduces distortion in textures at low angles (e.g. 0 to 16).

View File

@ -153,6 +153,16 @@
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QCheckBox" name="allowNPCToFollowOverWaterSurfaceCheckBox">
<property name="toolTip">
<string>Give NPC an ability to swim over the water surface when they follow other actor independently from their ability to swim. Has effect only when nav mesh building is enabled.</string>
</property>
<property name="text">
<string>Always allow NPC to follow over water surface</string>
</property>
</widget>
</item>
</layout>
</item>
<item>