forked from mirror/openmw-tes3mp
[Client] Simplify sending of ActorAI packets for uninitialized actors
This commit is contained in:
parent
5f4ec1331f
commit
743933134d
4 changed files with 33 additions and 44 deletions
|
@ -2,6 +2,9 @@
|
||||||
#include "Main.hpp"
|
#include "Main.hpp"
|
||||||
#include "Networking.hpp"
|
#include "Networking.hpp"
|
||||||
#include "LocalPlayer.hpp"
|
#include "LocalPlayer.hpp"
|
||||||
|
#include "MechanicsHelper.hpp"
|
||||||
|
|
||||||
|
#include "../mwworld/class.hpp"
|
||||||
|
|
||||||
#include <components/openmw-mp/Log.hpp>
|
#include <components/openmw-mp/Log.hpp>
|
||||||
|
|
||||||
|
@ -84,6 +87,31 @@ void ActorList::addAiActor(BaseActor baseActor)
|
||||||
aiActors.push_back(baseActor);
|
aiActors.push_back(baseActor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ActorList::addAiActor(const MWWorld::Ptr& actorPtr, const MWWorld::Ptr& targetPtr, unsigned int aiAction)
|
||||||
|
{
|
||||||
|
mwmp::BaseActor baseActor;
|
||||||
|
baseActor.refNum = actorPtr.getCellRef().getRefNum().mIndex;
|
||||||
|
baseActor.mpNum = actorPtr.getCellRef().getMpNum();
|
||||||
|
baseActor.aiAction = aiAction;
|
||||||
|
baseActor.aiTarget = MechanicsHelper::getTarget(targetPtr);
|
||||||
|
|
||||||
|
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Preparing to send ID_ACTOR_AI about %s %i-%i\n- action: %i",
|
||||||
|
actorPtr.getCellRef().getRefId().c_str(), baseActor.refNum, baseActor.mpNum, aiAction);
|
||||||
|
|
||||||
|
if (baseActor.aiTarget.isPlayer)
|
||||||
|
{
|
||||||
|
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "- Has player target %s",
|
||||||
|
targetPtr.getClass().getName(targetPtr).c_str());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "- Has actor target %s %i-%i",
|
||||||
|
targetPtr.getCellRef().getRefId().c_str(), baseActor.aiTarget.refNum, baseActor.aiTarget.mpNum);
|
||||||
|
}
|
||||||
|
|
||||||
|
addAiActor(baseActor);
|
||||||
|
}
|
||||||
|
|
||||||
void ActorList::addAttackActor(BaseActor baseActor)
|
void ActorList::addAttackActor(BaseActor baseActor)
|
||||||
{
|
{
|
||||||
attackActors.push_back(baseActor);
|
attackActors.push_back(baseActor);
|
||||||
|
|
|
@ -28,6 +28,7 @@ namespace mwmp
|
||||||
void addDeathActor(BaseActor baseActor);
|
void addDeathActor(BaseActor baseActor);
|
||||||
void addEquipmentActor(BaseActor baseActor);
|
void addEquipmentActor(BaseActor baseActor);
|
||||||
void addAiActor(BaseActor baseActor);
|
void addAiActor(BaseActor baseActor);
|
||||||
|
void addAiActor(const MWWorld::Ptr& actorPtr, const MWWorld::Ptr& targetPtr, unsigned int aiAction);
|
||||||
void addAttackActor(BaseActor baseActor);
|
void addAttackActor(BaseActor baseActor);
|
||||||
void addCellChangeActor(BaseActor baseActor);
|
void addCellChangeActor(BaseActor baseActor);
|
||||||
|
|
||||||
|
|
|
@ -265,12 +265,12 @@ void DedicatedActor::setAi()
|
||||||
|
|
||||||
if (targetPtr)
|
if (targetPtr)
|
||||||
{
|
{
|
||||||
LOG_APPEND(Log::LOG_VERBOSE, "-- Has AI target %s %i-%i",
|
LOG_APPEND(Log::LOG_VERBOSE, "-- Has actor target %s %i-%i",
|
||||||
targetPtr.getCellRef().getRefId().c_str(), aiTarget.refNum, aiTarget.mpNum);
|
targetPtr.getCellRef().getRefId().c_str(), aiTarget.refNum, aiTarget.mpNum);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LOG_APPEND(Log::LOG_VERBOSE, "-- Has invalid target AI target %i-%i",
|
LOG_APPEND(Log::LOG_VERBOSE, "-- Has invalid actor target %i-%i",
|
||||||
aiTarget.refNum, aiTarget.mpNum);
|
aiTarget.refNum, aiTarget.mpNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -344,30 +344,10 @@ namespace MWScript
|
||||||
|
|
||||||
if (targetPtr)
|
if (targetPtr)
|
||||||
{
|
{
|
||||||
mwmp::BaseActor baseActor;
|
|
||||||
baseActor.refNum = ptr.getCellRef().getRefNum().mIndex;
|
|
||||||
baseActor.mpNum = ptr.getCellRef().getMpNum();
|
|
||||||
baseActor.aiAction = mwmp::BaseActorList::FOLLOW;
|
|
||||||
baseActor.aiTarget = MechanicsHelper::getTarget(targetPtr);
|
|
||||||
|
|
||||||
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Sending ID_ACTOR_AI about %s %i-%i to server",
|
|
||||||
ptr.getCellRef().getRefId().c_str(), baseActor.refNum, baseActor.mpNum);
|
|
||||||
|
|
||||||
if (baseActor.aiTarget.isPlayer)
|
|
||||||
{
|
|
||||||
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "- Following player %s",
|
|
||||||
targetPtr.getClass().getName(targetPtr).c_str());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "- Following actor %s %i-%i",
|
|
||||||
targetPtr.getCellRef().getRefId().c_str(), baseActor.aiTarget.refNum, baseActor.aiTarget.mpNum);
|
|
||||||
}
|
|
||||||
|
|
||||||
mwmp::ActorList *actorList = mwmp::Main::get().getNetworking()->getActorList();
|
mwmp::ActorList *actorList = mwmp::Main::get().getNetworking()->getActorList();
|
||||||
actorList->reset();
|
actorList->reset();
|
||||||
actorList->cell = *ptr.getCell()->getCell();
|
actorList->cell = *ptr.getCell()->getCell();
|
||||||
actorList->addAiActor(baseActor);
|
actorList->addAiActor(ptr, targetPtr, mwmp::BaseActorList::FOLLOW);
|
||||||
actorList->sendAiActors();
|
actorList->sendAiActors();
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
@ -517,30 +497,10 @@ namespace MWScript
|
||||||
*/
|
*/
|
||||||
if (target)
|
if (target)
|
||||||
{
|
{
|
||||||
mwmp::BaseActor baseActor;
|
|
||||||
baseActor.refNum = actor.getCellRef().getRefNum().mIndex;
|
|
||||||
baseActor.mpNum = actor.getCellRef().getMpNum();
|
|
||||||
baseActor.aiAction = mwmp::BaseActorList::COMBAT;
|
|
||||||
baseActor.aiTarget = MechanicsHelper::getTarget(target);
|
|
||||||
|
|
||||||
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Sending ID_ACTOR_AI about %s %i-%i to server",
|
|
||||||
actor.getCellRef().getRefId().c_str(), baseActor.refNum, baseActor.mpNum);
|
|
||||||
|
|
||||||
if (baseActor.aiTarget.isPlayer)
|
|
||||||
{
|
|
||||||
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "- Starting combat with player %s",
|
|
||||||
target.getClass().getName(target).c_str());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "- Starting combat with actor %s %i-%i",
|
|
||||||
target.getCellRef().getRefId().c_str(), baseActor.aiTarget.refNum, baseActor.aiTarget.mpNum);
|
|
||||||
}
|
|
||||||
|
|
||||||
mwmp::ActorList *actorList = mwmp::Main::get().getNetworking()->getActorList();
|
mwmp::ActorList *actorList = mwmp::Main::get().getNetworking()->getActorList();
|
||||||
actorList->reset();
|
actorList->reset();
|
||||||
actorList->cell = *actor.getCell()->getCell();
|
actorList->cell = *actor.getCell()->getCell();
|
||||||
actorList->addAiActor(baseActor);
|
actorList->addAiActor(actor, target, mwmp::BaseActorList::COMBAT);
|
||||||
actorList->sendAiActors();
|
actorList->sendAiActors();
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue