diff --git a/apps/openmw-mp/Script/Functions/RecordsDynamic.cpp b/apps/openmw-mp/Script/Functions/RecordsDynamic.cpp index 437019eb6..1e586466a 100644 --- a/apps/openmw-mp/Script/Functions/RecordsDynamic.cpp +++ b/apps/openmw-mp/Script/Functions/RecordsDynamic.cpp @@ -1206,6 +1206,23 @@ void RecordsDynamicFunctions::SetRecordAIFight(int aiFight) noexcept tempOverrides.hasAiFight = true; } +void RecordsDynamicFunctions::SetRecordAIServices(int aiServices) noexcept +{ + unsigned short writeRecordsType = WorldstateFunctions::writeWorldstate.recordsType; + + if (writeRecordsType == mwmp::RECORD_TYPE::CREATURE) + tempCreature.data.mAiData.mServices = aiServices; + else if (writeRecordsType == mwmp::RECORD_TYPE::NPC) + tempNpc.data.mAiData.mServices = aiServices; + else + { + LOG_MESSAGE_SIMPLE(Log::LOG_ERROR, "Tried to set AI services for record type %i which lacks that property", writeRecordsType); + return; + } + + tempOverrides.hasAiServices = true; +} + void RecordsDynamicFunctions::SetRecordOpenSound(const char* sound) noexcept { unsigned short writeRecordsType = WorldstateFunctions::writeWorldstate.recordsType; diff --git a/apps/openmw-mp/Script/Functions/RecordsDynamic.hpp b/apps/openmw-mp/Script/Functions/RecordsDynamic.hpp index 1b56a28a4..e2150dc3b 100644 --- a/apps/openmw-mp/Script/Functions/RecordsDynamic.hpp +++ b/apps/openmw-mp/Script/Functions/RecordsDynamic.hpp @@ -84,7 +84,9 @@ {"SetRecordLevel", RecordsDynamicFunctions::SetRecordLevel},\ {"SetRecordMagicka", RecordsDynamicFunctions::SetRecordMagicka},\ {"SetRecordFatigue", RecordsDynamicFunctions::SetRecordFatigue},\ + \ {"SetRecordAIFight", RecordsDynamicFunctions::SetRecordAIFight},\ + {"SetRecordAIServices", RecordsDynamicFunctions::SetRecordAIServices},\ \ {"SetRecordOpenSound", RecordsDynamicFunctions::SetRecordOpenSound},\ {"SetRecordCloseSound", RecordsDynamicFunctions::SetRecordCloseSound},\ @@ -735,6 +737,15 @@ public: */ static void SetRecordAIFight(int aiFight) noexcept; + /** + * \brief Set the AI services value of the temporary record stored on the server for the + * currently specified record type. + * + * \param aiServices The AI services value of the record. + * \return void + */ + static void SetRecordAIServices(int aiServices) noexcept; + /** * \brief Set the opening sound of the temporary record stored on the server for the * currently specified record type. diff --git a/apps/openmw/mwmp/RecordHelper.cpp b/apps/openmw/mwmp/RecordHelper.cpp index 9dbcb8884..534434046 100644 --- a/apps/openmw/mwmp/RecordHelper.cpp +++ b/apps/openmw/mwmp/RecordHelper.cpp @@ -214,6 +214,9 @@ void RecordHelper::overrideCreatureRecord(const mwmp::CreatureRecord& record) if (record.baseOverrides.hasAiFight) finalData.mAiData.mFight = recordData.mAiData.mFight; + if (record.baseOverrides.hasAiServices) + finalData.mAiData.mServices = recordData.mAiData.mServices; + if (record.baseOverrides.hasFlags) finalData.mFlags = recordData.mFlags; @@ -320,6 +323,9 @@ void RecordHelper::overrideNpcRecord(const mwmp::NpcRecord& record) if (record.baseOverrides.hasAiFight) finalData.mAiData.mFight = recordData.mAiData.mFight; + if (record.baseOverrides.hasAiServices) + finalData.mAiData.mServices = recordData.mAiData.mServices; + if (record.baseOverrides.hasFlags) finalData.mFlags = recordData.mFlags; diff --git a/components/openmw-mp/Base/BaseWorldstate.hpp b/components/openmw-mp/Base/BaseWorldstate.hpp index 357112337..b57ed8a00 100644 --- a/components/openmw-mp/Base/BaseWorldstate.hpp +++ b/components/openmw-mp/Base/BaseWorldstate.hpp @@ -110,7 +110,9 @@ namespace mwmp bool hasLevel = false; bool hasMagicka = false; bool hasFatigue = false; + bool hasAiFight = false; + bool hasAiServices = false; bool hasOpenSound = false; bool hasCloseSound = false; diff --git a/components/openmw-mp/Packets/Worldstate/PacketRecordDynamic.cpp b/components/openmw-mp/Packets/Worldstate/PacketRecordDynamic.cpp index 0306291e6..4d9bb7515 100644 --- a/components/openmw-mp/Packets/Worldstate/PacketRecordDynamic.cpp +++ b/components/openmw-mp/Packets/Worldstate/PacketRecordDynamic.cpp @@ -216,6 +216,7 @@ void PacketRecordDynamic::Packet(RakNet::BitStream *bs, bool send) RW(recordData.mData.mMana, send); RW(recordData.mData.mFatigue, send); RW(recordData.mAiData.mFight, send); + RW(recordData.mAiData.mServices, send); RW(recordData.mFlags, send); RW(recordData.mScript, send, true); ProcessInventoryList(record.inventory, recordData.mInventory, send); @@ -231,6 +232,7 @@ void PacketRecordDynamic::Packet(RakNet::BitStream *bs, bool send) RW(overrides.hasMagicka, send); RW(overrides.hasFatigue, send); RW(overrides.hasAiFight, send); + RW(overrides.hasAiServices, send); RW(overrides.hasFlags, send); RW(overrides.hasScript, send); RW(overrides.hasInventory, send); @@ -260,6 +262,8 @@ void PacketRecordDynamic::Packet(RakNet::BitStream *bs, bool send) RW(recordData.mNpdt.mMana, send); RW(recordData.mNpdt.mFatigue, send); RW(recordData.mAiData.mFight, send); + RW(recordData.mAiData.mServices, send); + RW(recordData.mNpdtType, send); ProcessInventoryList(record.inventory, recordData.mInventory, send); @@ -279,6 +283,7 @@ void PacketRecordDynamic::Packet(RakNet::BitStream *bs, bool send) RW(overrides.hasMagicka, send); RW(overrides.hasFatigue, send); RW(overrides.hasAiFight, send); + RW(overrides.hasAiServices, send); RW(overrides.hasAutoCalc, send); RW(overrides.hasInventory, send); }