mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 05:49:56 +00:00
0e13207afe
The server can now cancel actor AI, make actors travel to a location, make actors wander, and make actors get escorted by a player or another actor.
49 lines
1.5 KiB
C++
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::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);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|