mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 22:23:51 +00:00
Stop combat between AI when canFight is false
This commit is contained in:
parent
e8c7ad2f4b
commit
e10c4d8814
2 changed files with 14 additions and 7 deletions
|
@ -19,6 +19,7 @@
|
||||||
#include "aicombataction.hpp"
|
#include "aicombataction.hpp"
|
||||||
#include "combat.hpp"
|
#include "combat.hpp"
|
||||||
#include "coordinateconverter.hpp"
|
#include "coordinateconverter.hpp"
|
||||||
|
#include "actorutil.hpp"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
@ -210,13 +211,14 @@ namespace MWMechanics
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
timerReact = 0;
|
timerReact = 0;
|
||||||
attack(actor, target, storage, characterController);
|
if (attack(actor, target, storage, characterController))
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AiCombat::attack(const MWWorld::Ptr& actor, const MWWorld::Ptr& target, AiCombatStorage& storage, CharacterController& characterController)
|
bool AiCombat::attack(const MWWorld::Ptr& actor, const MWWorld::Ptr& target, AiCombatStorage& storage, CharacterController& characterController)
|
||||||
{
|
{
|
||||||
const MWWorld::CellStore*& currentCell = storage.mCell;
|
const MWWorld::CellStore*& currentCell = storage.mCell;
|
||||||
bool cellChange = currentCell && (actor.getCell() != currentCell);
|
bool cellChange = currentCell && (actor.getCell() != currentCell);
|
||||||
|
@ -231,7 +233,10 @@ namespace MWMechanics
|
||||||
storage.stopAttack();
|
storage.stopAttack();
|
||||||
characterController.setAttackingOrSpell(false);
|
characterController.setAttackingOrSpell(false);
|
||||||
storage.mActionCooldown = 0.f;
|
storage.mActionCooldown = 0.f;
|
||||||
|
if (target == MWMechanics::getPlayer())
|
||||||
forceFlee = true;
|
forceFlee = true;
|
||||||
|
else
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const MWWorld::Class& actorClass = actor.getClass();
|
const MWWorld::Class& actorClass = actor.getClass();
|
||||||
|
@ -243,7 +248,7 @@ namespace MWMechanics
|
||||||
if (!forceFlee)
|
if (!forceFlee)
|
||||||
{
|
{
|
||||||
if (actionCooldown > 0)
|
if (actionCooldown > 0)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
if (characterController.readyToPrepareAttack())
|
if (characterController.readyToPrepareAttack())
|
||||||
{
|
{
|
||||||
|
@ -258,7 +263,7 @@ namespace MWMechanics
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!currentAction)
|
if (!currentAction)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
if (storage.isFleeing() != currentAction->isFleeing())
|
if (storage.isFleeing() != currentAction->isFleeing())
|
||||||
{
|
{
|
||||||
|
@ -266,7 +271,7 @@ namespace MWMechanics
|
||||||
{
|
{
|
||||||
storage.startFleeing();
|
storage.startFleeing();
|
||||||
MWBase::Environment::get().getDialogueManager()->say(actor, "flee");
|
MWBase::Environment::get().getDialogueManager()->say(actor, "flee");
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
storage.stopFleeing();
|
storage.stopFleeing();
|
||||||
|
@ -311,6 +316,7 @@ namespace MWMechanics
|
||||||
storage.mMovement.mRotation[2] = getZAngleToDir((vTargetPos-vActorPos)); // using vAimDir results in spastic movements since the head is animated
|
storage.mMovement.mRotation[2] = getZAngleToDir((vTargetPos-vActorPos)); // using vAimDir results in spastic movements since the head is animated
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MWMechanics::AiCombat::updateLOS(const MWWorld::Ptr& actor, const MWWorld::Ptr& target, float duration, MWMechanics::AiCombatStorage& storage)
|
void MWMechanics::AiCombat::updateLOS(const MWWorld::Ptr& actor, const MWWorld::Ptr& target, float duration, MWMechanics::AiCombatStorage& storage)
|
||||||
|
|
|
@ -59,7 +59,8 @@ namespace MWMechanics
|
||||||
|
|
||||||
int mTargetActorId;
|
int mTargetActorId;
|
||||||
|
|
||||||
void attack(const MWWorld::Ptr& actor, const MWWorld::Ptr& target, AiCombatStorage& storage, CharacterController& characterController);
|
/// Returns true if combat should end
|
||||||
|
bool attack(const MWWorld::Ptr& actor, const MWWorld::Ptr& target, AiCombatStorage& storage, CharacterController& characterController);
|
||||||
|
|
||||||
void updateLOS(const MWWorld::Ptr& actor, const MWWorld::Ptr& target, float duration, AiCombatStorage& storage);
|
void updateLOS(const MWWorld::Ptr& actor, const MWWorld::Ptr& target, float duration, AiCombatStorage& storage);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue