diff --git a/apps/openmw-mp/Script/Functions/Actors.cpp b/apps/openmw-mp/Script/Functions/Actors.cpp index a509b29f1..3b37770ad 100644 --- a/apps/openmw-mp/Script/Functions/Actors.cpp +++ b/apps/openmw-mp/Script/Functions/Actors.cpp @@ -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; diff --git a/apps/openmw-mp/Script/Functions/Actors.hpp b/apps/openmw-mp/Script/Functions/Actors.hpp index 0cec3e09f..03527feb2 100644 --- a/apps/openmw-mp/Script/Functions/Actors.hpp +++ b/apps/openmw-mp/Script/Functions/Actors.hpp @@ -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. diff --git a/apps/openmw/mwmp/Cell.cpp b/apps/openmw/mwmp/Cell.cpp index d020e9107..0c18aa616 100644 --- a/apps/openmw/mwmp/Cell.cpp +++ b/apps/openmw/mwmp/Cell.cpp @@ -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; diff --git a/apps/openmw/mwmp/DedicatedActor.cpp b/apps/openmw/mwmp/DedicatedActor.cpp index f8c304a36..4fef9db87 100644 --- a/apps/openmw/mwmp/DedicatedActor.cpp +++ b/apps/openmw/mwmp/DedicatedActor.cpp @@ -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 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) diff --git a/components/openmw-mp/Base/BaseActor.hpp b/components/openmw-mp/Base/BaseActor.hpp index 87162dc3d..560c14f33 100644 --- a/components/openmw-mp/Base/BaseActor.hpp +++ b/components/openmw-mp/Base/BaseActor.hpp @@ -46,6 +46,7 @@ namespace mwmp unsigned int aiAction; unsigned int aiDistance; unsigned int aiDuration; + bool aiShouldRepeat; ESM::Position aiCoordinates; bool hasPositionData; diff --git a/components/openmw-mp/Packets/Actor/PacketActorAI.cpp b/components/openmw-mp/Packets/Actor/PacketActorAI.cpp index 45596aa1f..4f5022dfe 100644 --- a/components/openmw-mp/Packets/Actor/PacketActorAI.cpp +++ b/components/openmw-mp/Packets/Actor/PacketActorAI.cpp @@ -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) {