[General] Implement ActorAI packet, part 4

The server can now make actors activate players and objects, at least in theory. In practice, OpenMW''s AiActivate package needs to be worked so it allows specific objects as targets instead of just refIds.
0.6.3
David Cernat 7 years ago
parent 0e13207afe
commit 00c13ae96c

@ -318,7 +318,7 @@ void ActorFunctions::SetActorAITargetToPlayer(unsigned short pid) noexcept
tempActor.aiTarget.guid = player->guid;
}
void ActorFunctions::SetActorAITargetToActor(int refNumIndex, int mpNum) noexcept
void ActorFunctions::SetActorAITargetToObject(int refNumIndex, int mpNum) noexcept
{
tempActor.hasAiTarget = true;
tempActor.aiTarget.isPlayer = false;

@ -69,7 +69,7 @@
\
{"SetActorAIAction", ActorFunctions::SetActorAIAction},\
{"SetActorAITargetToPlayer", ActorFunctions::SetActorAITargetToPlayer},\
{"SetActorAITargetToActor", ActorFunctions::SetActorAITargetToActor},\
{"SetActorAITargetToObject", ActorFunctions::SetActorAITargetToObject},\
{"SetActorAICoordinates", ActorFunctions::SetActorAICoordinates},\
{"SetActorAIDistance", ActorFunctions::SetActorAIDistance},\
{"SetActorAIDuration", ActorFunctions::SetActorAIDuration},\
@ -561,13 +561,13 @@ public:
static void SetActorAITargetToPlayer(unsigned short pid) noexcept;
/**
* \brief Set another actor as the AI target of the temporary actor stored on the server.
* \brief Set another object as the AI target of the temporary actor stored on the server.
*
* \param refNumIndex The refNumIndex of the target actor.
* \param mpNum The mpNum of the target actor.
* \param refNumIndex The refNumIndex of the target object.
* \param mpNum The mpNum of the target object.
* \return void
*/
static void SetActorAITargetToActor(int refNumIndex, int mpNum) noexcept;
static void SetActorAITargetToObject(int refNumIndex, int mpNum) noexcept;
/**
* \brief Set the coordinates for the AI package associated with the current AI action.

@ -6,6 +6,7 @@
#include "../mwdialogue/dialoguemanagerimp.hpp"
#include "../mwmechanics/aiactivate.hpp"
#include "../mwmechanics/aicombat.hpp"
#include "../mwmechanics/aiescort.hpp"
#include "../mwmechanics/aifollow.hpp"
@ -271,6 +272,14 @@ void DedicatedActor::setAI()
if (targetPtr)
{
if (aiAction == mwmp::BaseActorList::ACTIVATE)
{
LOG_APPEND(Log::LOG_VERBOSE, "--- Activating target");
MWMechanics::AiActivate package(targetPtr.getCellRef().getRefId());
ptr.getClass().getCreatureStats(ptr).getAiSequence().stack(package, ptr, true);
}
if (aiAction == mwmp::BaseActorList::COMBAT)
{
LOG_APPEND(Log::LOG_VERBOSE, "--- Starting combat with target");

@ -74,11 +74,12 @@ namespace mwmp
enum AI_ACTION
{
CANCEL = 0,
COMBAT = 1,
ESCORT = 2,
FOLLOW = 3,
TRAVEL = 4,
WANDER = 5
ACTIVATE = 1,
COMBAT = 2,
ESCORT = 3,
FOLLOW = 4,
TRAVEL = 5,
WANDER = 6
};
RakNet::RakNetGUID guid;

@ -24,8 +24,8 @@ void PacketActorAI::Actor(BaseActor &actor, bool send)
if (actor.aiAction == mwmp::BaseActorList::ESCORT || actor.aiAction == mwmp::BaseActorList::WANDER)
RW(actor.aiDuration, send);
if (actor.aiAction == mwmp::BaseActorList::COMBAT || actor.aiAction == mwmp::BaseActorList::ESCORT ||
actor.aiAction == mwmp::BaseActorList::FOLLOW)
if (actor.aiAction == mwmp::BaseActorList::ACTIVATE || actor.aiAction == mwmp::BaseActorList::COMBAT ||
actor.aiAction == mwmp::BaseActorList::ESCORT || actor.aiAction == mwmp::BaseActorList::FOLLOW)
{
RW(actor.hasAiTarget, send);

Loading…
Cancel
Save