forked from mirror/openmw-tes3mp
Pass the CharacterController to AiPackage::execute
This commit is contained in:
parent
a44be148d8
commit
59db9664ba
20 changed files with 24 additions and 21 deletions
|
@ -1124,7 +1124,7 @@ namespace MWMechanics
|
||||||
{
|
{
|
||||||
CreatureStats &stats = iter->first.getClass().getCreatureStats(iter->first);
|
CreatureStats &stats = iter->first.getClass().getCreatureStats(iter->first);
|
||||||
if (isConscious(iter->first))
|
if (isConscious(iter->first))
|
||||||
stats.getAiSequence().execute(iter->first,iter->second->getAiState(), duration);
|
stats.getAiSequence().execute(iter->first, *iter->second->getCharacterController(), iter->second->getAiState(), duration);
|
||||||
|
|
||||||
if (stats.getAiSequence().isInCombat() && !stats.isDead()) hostilesCount++;
|
if (stats.getAiSequence().isInCombat() && !stats.isDead()) hostilesCount++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ MWMechanics::AiActivate *MWMechanics::AiActivate::clone() const
|
||||||
{
|
{
|
||||||
return new AiActivate(*this);
|
return new AiActivate(*this);
|
||||||
}
|
}
|
||||||
bool MWMechanics::AiActivate::execute (const MWWorld::Ptr& actor, AiState& state, float duration)
|
bool MWMechanics::AiActivate::execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration)
|
||||||
{
|
{
|
||||||
ESM::Position pos = actor.getRefData().getPosition(); //position of the actor
|
ESM::Position pos = actor.getRefData().getPosition(); //position of the actor
|
||||||
const MWWorld::Ptr target = MWBase::Environment::get().getWorld()->searchPtr(mObjectId, false); //The target to follow
|
const MWWorld::Ptr target = MWBase::Environment::get().getWorld()->searchPtr(mObjectId, false); //The target to follow
|
||||||
|
|
|
@ -28,7 +28,7 @@ namespace MWMechanics
|
||||||
AiActivate(const ESM::AiSequence::AiActivate* activate);
|
AiActivate(const ESM::AiSequence::AiActivate* activate);
|
||||||
|
|
||||||
virtual AiActivate *clone() const;
|
virtual AiActivate *clone() const;
|
||||||
virtual bool execute (const MWWorld::Ptr& actor, AiState& state, float duration);
|
virtual bool execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration);
|
||||||
virtual int getTypeId() const;
|
virtual int getTypeId() const;
|
||||||
|
|
||||||
virtual void writeState(ESM::AiSequence::AiSequence& sequence) const;
|
virtual void writeState(ESM::AiSequence::AiSequence& sequence) const;
|
||||||
|
|
|
@ -17,7 +17,7 @@ MWMechanics::AiAvoidDoor::AiAvoidDoor(const MWWorld::Ptr& doorPtr)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MWMechanics::AiAvoidDoor::execute (const MWWorld::Ptr& actor, AiState& state, float duration)
|
bool MWMechanics::AiAvoidDoor::execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration)
|
||||||
{
|
{
|
||||||
|
|
||||||
ESM::Position pos = actor.getRefData().getPosition();
|
ESM::Position pos = actor.getRefData().getPosition();
|
||||||
|
|
|
@ -20,7 +20,7 @@ namespace MWMechanics
|
||||||
|
|
||||||
virtual AiAvoidDoor *clone() const;
|
virtual AiAvoidDoor *clone() const;
|
||||||
|
|
||||||
virtual bool execute (const MWWorld::Ptr& actor, AiState& state, float duration);
|
virtual bool execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration);
|
||||||
|
|
||||||
virtual int getTypeId() const;
|
virtual int getTypeId() const;
|
||||||
|
|
||||||
|
|
|
@ -181,7 +181,7 @@ namespace MWMechanics
|
||||||
* Use the Observer Pattern to co-ordinate attacks, provide intelligence on
|
* Use the Observer Pattern to co-ordinate attacks, provide intelligence on
|
||||||
* whether the target was hit, etc.
|
* whether the target was hit, etc.
|
||||||
*/
|
*/
|
||||||
bool AiCombat::execute (const MWWorld::Ptr& actor, AiState& state, float duration)
|
bool AiCombat::execute (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>();
|
||||||
|
|
|
@ -40,7 +40,7 @@ namespace MWMechanics
|
||||||
|
|
||||||
virtual AiCombat *clone() const;
|
virtual AiCombat *clone() const;
|
||||||
|
|
||||||
virtual bool execute (const MWWorld::Ptr& actor, AiState& state, float duration);
|
virtual bool execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration);
|
||||||
|
|
||||||
virtual int getTypeId() const;
|
virtual int getTypeId() const;
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ namespace MWMechanics
|
||||||
return new AiEscort(*this);
|
return new AiEscort(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AiEscort::execute (const MWWorld::Ptr& actor, AiState& state, float duration)
|
bool AiEscort::execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration)
|
||||||
{
|
{
|
||||||
// If AiEscort has ran for as long or longer then the duration specified
|
// If AiEscort has ran for as long or longer then the duration specified
|
||||||
// and the duration is not infinite, the package is complete.
|
// and the duration is not infinite, the package is complete.
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace MWMechanics
|
||||||
|
|
||||||
virtual AiEscort *clone() const;
|
virtual AiEscort *clone() const;
|
||||||
|
|
||||||
virtual bool execute (const MWWorld::Ptr& actor, AiState& state, float duration);
|
virtual bool execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration);
|
||||||
|
|
||||||
virtual int getTypeId() const;
|
virtual int getTypeId() const;
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ AiFollow::AiFollow(const ESM::AiSequence::AiFollow *follow)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AiFollow::execute (const MWWorld::Ptr& actor, AiState& state, float duration)
|
bool AiFollow::execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration)
|
||||||
{
|
{
|
||||||
MWWorld::Ptr target = getTarget();
|
MWWorld::Ptr target = getTarget();
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ namespace MWMechanics
|
||||||
|
|
||||||
virtual AiFollow *clone() const;
|
virtual AiFollow *clone() const;
|
||||||
|
|
||||||
virtual bool execute (const MWWorld::Ptr& actor, AiState& state, float duration);
|
virtual bool execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration);
|
||||||
|
|
||||||
virtual int getTypeId() const;
|
virtual int getTypeId() const;
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,8 @@ namespace ESM
|
||||||
namespace MWMechanics
|
namespace MWMechanics
|
||||||
{
|
{
|
||||||
|
|
||||||
|
class CharacterController;
|
||||||
|
|
||||||
/// \brief Base class for AI packages
|
/// \brief Base class for AI packages
|
||||||
class AiPackage
|
class AiPackage
|
||||||
{
|
{
|
||||||
|
@ -53,7 +55,7 @@ namespace MWMechanics
|
||||||
|
|
||||||
/// Updates and runs the package (Should run every frame)
|
/// Updates and runs the package (Should run every frame)
|
||||||
/// \return Package completed?
|
/// \return Package completed?
|
||||||
virtual bool execute (const MWWorld::Ptr& actor, AiState& state, float duration) = 0;
|
virtual bool execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration) = 0;
|
||||||
|
|
||||||
/// Returns the TypeID of the AiPackage
|
/// Returns the TypeID of the AiPackage
|
||||||
/// \see enum TypeId
|
/// \see enum TypeId
|
||||||
|
|
|
@ -30,7 +30,7 @@ AiPursue *MWMechanics::AiPursue::clone() const
|
||||||
{
|
{
|
||||||
return new AiPursue(*this);
|
return new AiPursue(*this);
|
||||||
}
|
}
|
||||||
bool AiPursue::execute (const MWWorld::Ptr& actor, AiState& state, float duration)
|
bool AiPursue::execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration)
|
||||||
{
|
{
|
||||||
if(actor.getClass().getCreatureStats(actor).isDead())
|
if(actor.getClass().getCreatureStats(actor).isDead())
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace MWMechanics
|
||||||
AiPursue(const ESM::AiSequence::AiPursue* pursue);
|
AiPursue(const ESM::AiSequence::AiPursue* pursue);
|
||||||
|
|
||||||
virtual AiPursue *clone() const;
|
virtual AiPursue *clone() const;
|
||||||
virtual bool execute (const MWWorld::Ptr& actor, AiState& state, float duration);
|
virtual bool execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration);
|
||||||
virtual int getTypeId() const;
|
virtual int getTypeId() const;
|
||||||
|
|
||||||
MWWorld::Ptr getTarget() const;
|
MWWorld::Ptr getTarget() const;
|
||||||
|
|
|
@ -150,7 +150,7 @@ bool AiSequence::isPackageDone() const
|
||||||
return mDone;
|
return mDone;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AiSequence::execute (const MWWorld::Ptr& actor, AiState& state,float duration)
|
void AiSequence::execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration)
|
||||||
{
|
{
|
||||||
if(actor != MWBase::Environment::get().getWorld()->getPlayerPtr())
|
if(actor != MWBase::Environment::get().getWorld()->getPlayerPtr())
|
||||||
{
|
{
|
||||||
|
@ -211,7 +211,7 @@ void AiSequence::execute (const MWWorld::Ptr& actor, AiState& state,float durati
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (package->execute (actor,state,duration))
|
if (package->execute (actor,characterController,state,duration))
|
||||||
{
|
{
|
||||||
// To account for the rare case where AiPackage::execute() queued another AI package
|
// To account for the rare case where AiPackage::execute() queued another AI package
|
||||||
// (e.g. AiPursue executing a dialogue script that uses startCombat)
|
// (e.g. AiPursue executing a dialogue script that uses startCombat)
|
||||||
|
|
|
@ -24,6 +24,7 @@ namespace ESM
|
||||||
namespace MWMechanics
|
namespace MWMechanics
|
||||||
{
|
{
|
||||||
class AiPackage;
|
class AiPackage;
|
||||||
|
class CharacterController;
|
||||||
|
|
||||||
template< class Base > class DerivedClassStorage;
|
template< class Base > class DerivedClassStorage;
|
||||||
struct AiTemporaryBase;
|
struct AiTemporaryBase;
|
||||||
|
@ -95,7 +96,7 @@ namespace MWMechanics
|
||||||
void stopPursuit();
|
void stopPursuit();
|
||||||
|
|
||||||
/// Execute current package, switching if needed.
|
/// Execute current package, switching if needed.
|
||||||
void execute (const MWWorld::Ptr& actor, MWMechanics::AiState& state, float duration);
|
void execute (const MWWorld::Ptr& actor, CharacterController& characterController, MWMechanics::AiState& state, float duration);
|
||||||
|
|
||||||
/// Simulate the passing of time using the currently active AI package
|
/// Simulate the passing of time using the currently active AI package
|
||||||
void fastForward(const MWWorld::Ptr &actor, AiState &state);
|
void fastForward(const MWWorld::Ptr &actor, AiState &state);
|
||||||
|
|
|
@ -47,7 +47,7 @@ namespace MWMechanics
|
||||||
return new AiTravel(*this);
|
return new AiTravel(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AiTravel::execute (const MWWorld::Ptr& actor, AiState& state, float duration)
|
bool AiTravel::execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration)
|
||||||
{
|
{
|
||||||
ESM::Position pos = actor.getRefData().getPosition();
|
ESM::Position pos = actor.getRefData().getPosition();
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ namespace MWMechanics
|
||||||
|
|
||||||
virtual AiTravel *clone() const;
|
virtual AiTravel *clone() const;
|
||||||
|
|
||||||
virtual bool execute (const MWWorld::Ptr& actor, AiState& state, float duration);
|
virtual bool execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration);
|
||||||
|
|
||||||
virtual int getTypeId() const;
|
virtual int getTypeId() const;
|
||||||
|
|
||||||
|
|
|
@ -168,7 +168,7 @@ namespace MWMechanics
|
||||||
* actors will enter combat (i.e. no longer wandering) and different pathfinding
|
* actors will enter combat (i.e. no longer wandering) and different pathfinding
|
||||||
* will kick in.
|
* will kick in.
|
||||||
*/
|
*/
|
||||||
bool AiWander::execute (const MWWorld::Ptr& actor, AiState& state, float duration)
|
bool AiWander::execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration)
|
||||||
{
|
{
|
||||||
// get or create temporary storage
|
// get or create temporary storage
|
||||||
AiWanderStorage& storage = state.get<AiWanderStorage>();
|
AiWanderStorage& storage = state.get<AiWanderStorage>();
|
||||||
|
|
|
@ -46,7 +46,7 @@ namespace MWMechanics
|
||||||
|
|
||||||
virtual AiPackage *clone() const;
|
virtual AiPackage *clone() const;
|
||||||
|
|
||||||
virtual bool execute (const MWWorld::Ptr& actor, AiState& state, float duration);
|
virtual bool execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration);
|
||||||
|
|
||||||
virtual int getTypeId() const;
|
virtual int getTypeId() const;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue