[General] Include AI alarm & flee for creatures/NPCs in RecordDynamic

pull/541/head
David Cernat 5 years ago
parent ef432d1419
commit 14af0be657

@ -1206,6 +1206,40 @@ void RecordsDynamicFunctions::SetRecordAIFight(int aiFight) noexcept
tempOverrides.hasAiFight = true;
}
void RecordsDynamicFunctions::SetRecordAIFlee(int aiFlee) noexcept
{
unsigned short writeRecordsType = WorldstateFunctions::writeWorldstate.recordsType;
if (writeRecordsType == mwmp::RECORD_TYPE::CREATURE)
tempCreature.data.mAiData.mFlee = aiFlee;
else if (writeRecordsType == mwmp::RECORD_TYPE::NPC)
tempNpc.data.mAiData.mFlee = aiFlee;
else
{
LOG_MESSAGE_SIMPLE(Log::LOG_ERROR, "Tried to set AI fight for record type %i which lacks that property", writeRecordsType);
return;
}
tempOverrides.hasAiFlee = true;
}
void RecordsDynamicFunctions::SetRecordAIAlarm(int aiAlarm) noexcept
{
unsigned short writeRecordsType = WorldstateFunctions::writeWorldstate.recordsType;
if (writeRecordsType == mwmp::RECORD_TYPE::CREATURE)
tempCreature.data.mAiData.mAlarm = aiAlarm;
else if (writeRecordsType == mwmp::RECORD_TYPE::NPC)
tempNpc.data.mAiData.mAlarm = aiAlarm;
else
{
LOG_MESSAGE_SIMPLE(Log::LOG_ERROR, "Tried to set AI fight for record type %i which lacks that property", writeRecordsType);
return;
}
tempOverrides.hasAiAlarm = true;
}
void RecordsDynamicFunctions::SetRecordAIServices(int aiServices) noexcept
{
unsigned short writeRecordsType = WorldstateFunctions::writeWorldstate.recordsType;

@ -86,6 +86,8 @@
{"SetRecordFatigue", RecordsDynamicFunctions::SetRecordFatigue},\
\
{"SetRecordAIFight", RecordsDynamicFunctions::SetRecordAIFight},\
{"SetRecordAIFlee", RecordsDynamicFunctions::SetRecordAIFlee},\
{"SetRecordAIAlarm", RecordsDynamicFunctions::SetRecordAIAlarm},\
{"SetRecordAIServices", RecordsDynamicFunctions::SetRecordAIServices},\
\
{"SetRecordOpenSound", RecordsDynamicFunctions::SetRecordOpenSound},\
@ -737,6 +739,24 @@ public:
*/
static void SetRecordAIFight(int aiFight) noexcept;
/**
* \brief Set the AI flee value of the temporary record stored on the server for the
* currently specified record type.
*
* \param aiFlee The AI flee value of the record.
* \return void
*/
static void SetRecordAIFlee(int aiFlee) noexcept;
/**
* \brief Set the AI alarm value of the temporary record stored on the server for the
* currently specified record type.
*
* \param aiAlarm The AI alarm value of the record.
* \return void
*/
static void SetRecordAIAlarm(int aiAlarm) noexcept;
/**
* \brief Set the AI services value of the temporary record stored on the server for the
* currently specified record type.

@ -214,6 +214,12 @@ void RecordHelper::overrideCreatureRecord(const mwmp::CreatureRecord& record)
if (record.baseOverrides.hasAiFight)
finalData.mAiData.mFight = recordData.mAiData.mFight;
if (record.baseOverrides.hasAiFlee)
finalData.mAiData.mFlee = recordData.mAiData.mFlee;
if (record.baseOverrides.hasAiAlarm)
finalData.mAiData.mAlarm = recordData.mAiData.mAlarm;
if (record.baseOverrides.hasAiServices)
finalData.mAiData.mServices = recordData.mAiData.mServices;
@ -323,6 +329,12 @@ void RecordHelper::overrideNpcRecord(const mwmp::NpcRecord& record)
if (record.baseOverrides.hasAiFight)
finalData.mAiData.mFight = recordData.mAiData.mFight;
if (record.baseOverrides.hasAiFlee)
finalData.mAiData.mFlee = recordData.mAiData.mFlee;
if (record.baseOverrides.hasAiAlarm)
finalData.mAiData.mAlarm = recordData.mAiData.mAlarm;
if (record.baseOverrides.hasAiServices)
finalData.mAiData.mServices = recordData.mAiData.mServices;

@ -112,6 +112,8 @@ namespace mwmp
bool hasFatigue = false;
bool hasAiFight = false;
bool hasAiFlee = false;
bool hasAiAlarm = false;
bool hasAiServices = false;
bool hasOpenSound = false;

@ -216,6 +216,8 @@ 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.mFlee, send);
RW(recordData.mAiData.mAlarm, send);
RW(recordData.mAiData.mServices, send);
RW(recordData.mFlags, send);
RW(recordData.mScript, send, true);
@ -232,6 +234,8 @@ void PacketRecordDynamic::Packet(RakNet::BitStream *bs, bool send)
RW(overrides.hasMagicka, send);
RW(overrides.hasFatigue, send);
RW(overrides.hasAiFight, send);
RW(overrides.hasAiFlee, send);
RW(overrides.hasAiAlarm, send);
RW(overrides.hasAiServices, send);
RW(overrides.hasFlags, send);
RW(overrides.hasScript, send);
@ -262,6 +266,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.mFlee, send);
RW(recordData.mAiData.mAlarm, send);
RW(recordData.mAiData.mServices, send);
RW(recordData.mNpdtType, send);
@ -283,6 +289,8 @@ void PacketRecordDynamic::Packet(RakNet::BitStream *bs, bool send)
RW(overrides.hasMagicka, send);
RW(overrides.hasFatigue, send);
RW(overrides.hasAiFight, send);
RW(overrides.hasAiFlee, send);
RW(overrides.hasAiAlarm, send);
RW(overrides.hasAiServices, send);
RW(overrides.hasAutoCalc, send);
RW(overrides.hasInventory, send);

Loading…
Cancel
Save