openmw-tes3coop/components/openmw-mp/Packets/Actor/PacketActorAI.cpp
David Cernat 00c13ae96c [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.
2018-07-10 07:07:37 +03:00

49 lines
1.5 KiB
C++

#include <components/openmw-mp/NetworkMessages.hpp>
#include <components/openmw-mp/Log.hpp>
#include "PacketActorAI.hpp"
using namespace mwmp;
PacketActorAI::PacketActorAI(RakNet::RakPeerInterface *peer) : ActorPacket(peer)
{
packetID = ID_ACTOR_AI;
}
void PacketActorAI::Actor(BaseActor &actor, bool send)
{
RW(actor.aiAction, send);
if (actor.aiAction != mwmp::BaseActorList::CANCEL)
{
if (actor.aiAction == mwmp::BaseActorList::WANDER)
RW(actor.aiDistance, send);
if (actor.aiAction == mwmp::BaseActorList::ESCORT || actor.aiAction == mwmp::BaseActorList::TRAVEL)
RW(actor.aiCoordinates, send);
if (actor.aiAction == mwmp::BaseActorList::ESCORT || actor.aiAction == mwmp::BaseActorList::WANDER)
RW(actor.aiDuration, send);
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);
if (actor.hasAiTarget)
{
RW(actor.aiTarget.isPlayer, send);
if (actor.aiTarget.isPlayer)
{
RW(actor.aiTarget.guid, send);
}
else
{
RW(actor.aiTarget.refId, send, true);
RW(actor.aiTarget.refNumIndex, send);
RW(actor.aiTarget.mpNum, send);
}
}
}
}
}