[General] Implement ActorAI packet, part 5

Allow repetition for AiWander package to be turned on and off.
0.6.3
David Cernat 7 years ago
parent 2e31c212c0
commit bff6e9e235

@ -344,6 +344,11 @@ void ActorFunctions::SetActorAIDuration(unsigned int duration) noexcept
tempActor.aiDuration = duration;
}
void ActorFunctions::SetActorAIRepetition(bool shouldRepeat) noexcept
{
tempActor.aiShouldRepeat = shouldRepeat;
}
void ActorFunctions::EquipActorItem(unsigned short slot, const char *refId, unsigned int count, int charge, double enchantmentCharge) noexcept
{
tempActor.equipmentItems[slot].refId = refId;

@ -73,6 +73,7 @@
{"SetActorAICoordinates", ActorFunctions::SetActorAICoordinates},\
{"SetActorAIDistance", ActorFunctions::SetActorAIDistance},\
{"SetActorAIDuration", ActorFunctions::SetActorAIDuration},\
{"SetActorAIRepetition", ActorFunctions::SetActorAIRepetition},\
\
{"EquipActorItem", ActorFunctions::EquipActorItem},\
{"UnequipActorItem", ActorFunctions::UnequipActorItem},\
@ -595,6 +596,16 @@ public:
*/
static void SetActorAIDuration(unsigned int duration) noexcept;
/**
* \brief Set whether the current AI package should be repeated.
*
* Note: This only has an effect on the WANDER package.
*
* \param shouldRepeat Whether the package should be repeated.
* \return void
*/
static void SetActorAIRepetition(bool shouldRepeat) noexcept;
/**
* \brief Equip an item in a certain slot of the equipment of the temporary actor stored
* on the server.

@ -259,6 +259,7 @@ void Cell::readAI(ActorList& actorList)
actor->aiAction = baseActor.aiAction;
actor->aiDistance = baseActor.aiDistance;
actor->aiDuration = baseActor.aiDuration;
actor->aiShouldRepeat = baseActor.aiShouldRepeat;
actor->aiCoordinates = baseActor.aiCoordinates;
actor->hasAiTarget = baseActor.hasAiTarget;
actor->aiTarget = baseActor.aiTarget;

@ -232,12 +232,12 @@ void DedicatedActor::setAI()
}
else if (aiAction == mwmp::BaseActorList::WANDER)
{
LOG_APPEND(Log::LOG_VERBOSE, "--- Wandering for distance %i and duration %i",
aiDistance, aiDuration);
LOG_APPEND(Log::LOG_VERBOSE, "--- Wandering for distance %i and duration %i, repetition is %s",
aiDistance, aiDuration, aiShouldRepeat ? "true" : "false");
std::vector<unsigned char> idleList;
MWMechanics::AiWander package(aiDistance, aiDuration, -1, idleList, true);
MWMechanics::AiWander package(aiDistance, aiDuration, -1, idleList, aiShouldRepeat);
ptrCreatureStats->getAiSequence().stack(package, ptr, true);
}
else if (hasAiTarget)

@ -46,6 +46,7 @@ namespace mwmp
unsigned int aiAction;
unsigned int aiDistance;
unsigned int aiDuration;
bool aiShouldRepeat;
ESM::Position aiCoordinates;
bool hasPositionData;

@ -16,14 +16,17 @@ void PacketActorAI::Actor(BaseActor &actor, bool 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);
RW(actor.aiShouldRepeat, send);
}
if (actor.aiAction == mwmp::BaseActorList::ESCORT || actor.aiAction == mwmp::BaseActorList::WANDER)
RW(actor.aiDuration, send);
if (actor.aiAction == mwmp::BaseActorList::ESCORT || actor.aiAction == mwmp::BaseActorList::TRAVEL)
RW(actor.aiCoordinates, send);
if (actor.aiAction == mwmp::BaseActorList::ACTIVATE || actor.aiAction == mwmp::BaseActorList::COMBAT ||
actor.aiAction == mwmp::BaseActorList::ESCORT || actor.aiAction == mwmp::BaseActorList::FOLLOW)
{

Loading…
Cancel
Save