1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-11-08 20:16:43 +00:00

Merge branch 'KwarmaQueenCombat' into 'master'

Prevent immobile creatures' combat actions, but allow combat

Closes #7871

See merge request OpenMW/openmw!4632
This commit is contained in:
Alexei Kotov 2025-07-12 15:29:32 +03:00
commit 403b5d19e0
3 changed files with 15 additions and 16 deletions

View file

@ -360,16 +360,12 @@ namespace MWClass
{ {
stats.setAttacked(true); stats.setAttacked(true);
// No retaliation for totally static creatures (they have no movement or attacks anyway) bool complain = sourceType == MWMechanics::DamageSourceType::Melee;
if (isMobile(ptr)) bool supportFriendlyFire = sourceType != MWMechanics::DamageSourceType::Ranged;
{ if (supportFriendlyFire && MWMechanics::friendlyHit(attacker, ptr, complain))
bool complain = sourceType == MWMechanics::DamageSourceType::Melee; setOnPcHitMe = false;
bool supportFriendlyFire = sourceType != MWMechanics::DamageSourceType::Ranged; else
if (supportFriendlyFire && MWMechanics::friendlyHit(attacker, ptr, complain)) setOnPcHitMe = MWBase::Environment::get().getMechanicsManager()->actorAttacked(ptr, attacker);
setOnPcHitMe = false;
else
setOnPcHitMe = MWBase::Environment::get().getMechanicsManager()->actorAttacked(ptr, attacker);
}
} }
// Attacker and target store each other as hitattemptactor if they have no one stored yet // Attacker and target store each other as hitattemptactor if they have no one stored yet

View file

@ -605,10 +605,6 @@ namespace MWMechanics
void Actors::engageCombat( void Actors::engageCombat(
const MWWorld::Ptr& actor1, const MWWorld::Ptr& actor2, SidingCache& cachedAllies, bool againstPlayer) const const MWWorld::Ptr& actor1, const MWWorld::Ptr& actor2, SidingCache& cachedAllies, bool againstPlayer) const
{ {
// No combat for totally static creatures
if (!actor1.getClass().isMobile(actor1))
return;
CreatureStats& creatureStats1 = actor1.getClass().getCreatureStats(actor1); CreatureStats& creatureStats1 = actor1.getClass().getCreatureStats(actor1);
if (creatureStats1.isDead() || creatureStats1.getAiSequence().isInCombat(actor2)) if (creatureStats1.isDead() || creatureStats1.getAiSequence().isInCombat(actor2))
return; return;

View file

@ -104,10 +104,10 @@ namespace MWMechanics
bool AiCombat::execute( bool AiCombat::execute(
const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration) const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration)
{ {
// get or create temporary storage // Get or create temporary storage
AiCombatStorage& storage = state.get<AiCombatStorage>(); AiCombatStorage& storage = state.get<AiCombatStorage>();
// General description // No combat for dead creatures
if (actor.getClass().getCreatureStats(actor).isDead()) if (actor.getClass().getCreatureStats(actor).isDead())
return true; return true;
@ -124,6 +124,13 @@ namespace MWMechanics
if (actor == target) // This should never happen. if (actor == target) // This should never happen.
return true; return true;
// No actions for totally static creatures
if (!actor.getClass().isMobile(actor))
{
storage.mFleeState = AiCombatStorage::FleeState_Idle;
return false;
}
if (!storage.isFleeing()) if (!storage.isFleeing())
{ {
if (storage.mCurrentAction.get()) // need to wait to init action with its attack range if (storage.mCurrentAction.get()) // need to wait to init action with its attack range