forked from teamnwah/openmw-tes3coop
67abc60264
1) Taking into account target move vector and speed. However aiming is not ideal, since attack strength can't be controlled directly. I did achieve almost 100% accuracy updating it everyframe but then thought it would be unfair, cause AI should mimic human targetting. 2) Also added in this commit func to measure real attack durations for weapon.
77 lines
2.2 KiB
C++
77 lines
2.2 KiB
C++
#ifndef GAME_MWMECHANICS_AICOMBAT_H
|
|
#define GAME_MWMECHANICS_AICOMBAT_H
|
|
|
|
#include "aipackage.hpp"
|
|
|
|
#include "pathfinding.hpp"
|
|
|
|
#include "movement.hpp"
|
|
#include "obstacle.hpp"
|
|
|
|
#include <OgreVector3.h>
|
|
|
|
#include "../mwworld/cellstore.hpp" // for Doors
|
|
|
|
#include "../mwbase/world.hpp"
|
|
|
|
namespace MWMechanics
|
|
{
|
|
/// \brief Causes the actor to fight another actor
|
|
class AiCombat : public AiPackage
|
|
{
|
|
public:
|
|
///Constructor
|
|
/** \param actor Actor to fight **/
|
|
AiCombat(const MWWorld::Ptr& actor);
|
|
|
|
virtual AiCombat *clone() const;
|
|
|
|
virtual bool execute (const MWWorld::Ptr& actor,float duration);
|
|
|
|
virtual int getTypeId() const;
|
|
|
|
virtual unsigned int getPriority() const;
|
|
|
|
///Returns target ID
|
|
MWWorld::Ptr getTarget() const;
|
|
|
|
private:
|
|
PathFinder mPathFinder;
|
|
// controls duration of the actual strike
|
|
float mTimerAttack;
|
|
float mTimerReact;
|
|
// controls duration of the sideway & forward moves
|
|
// when mCombatMove is true
|
|
float mTimerCombatMove;
|
|
|
|
// AiCombat states
|
|
bool mReadyToAttack, mAttack;
|
|
bool mFollowTarget;
|
|
bool mCombatMove;
|
|
bool mBackOffDoor;
|
|
|
|
float mStrength; // this is actually make sense only in ranged combat
|
|
float mMinMaxAttackDuration[3][2]; // slash, thrust, chop has different durations
|
|
|
|
bool mForceNoShortcut;
|
|
ESM::Position mShortcutFailPos;
|
|
|
|
Ogre::Vector3 mLastActorPos;
|
|
MWMechanics::Movement mMovement;
|
|
|
|
int mTargetActorId;
|
|
Ogre::Vector3 mLastTargetPos;
|
|
|
|
const MWWorld::CellStore* mCell;
|
|
ObstacleCheck mObstacleCheck;
|
|
float mDoorCheckDuration;
|
|
// TODO: for some reason mDoors.searchViaHandle() returns
|
|
// null pointers, workaround by keeping an iterator
|
|
MWWorld::CellRefList<ESM::Door>::List::iterator mDoorIter;
|
|
MWWorld::CellRefList<ESM::Door>& mDoors;
|
|
|
|
void buildNewPath(const MWWorld::Ptr& actor, const MWWorld::Ptr& target);
|
|
};
|
|
}
|
|
|
|
#endif
|