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

This commit is contained in:
David Cernat 2019-08-07 11:21:22 +03:00
parent ef432d1419
commit 14af0be657
5 changed files with 76 additions and 0 deletions

View File

@ -1206,6 +1206,40 @@ void RecordsDynamicFunctions::SetRecordAIFight(int aiFight) noexcept
tempOverrides.hasAiFight = true; 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 void RecordsDynamicFunctions::SetRecordAIServices(int aiServices) noexcept
{ {
unsigned short writeRecordsType = WorldstateFunctions::writeWorldstate.recordsType; unsigned short writeRecordsType = WorldstateFunctions::writeWorldstate.recordsType;

View File

@ -86,6 +86,8 @@
{"SetRecordFatigue", RecordsDynamicFunctions::SetRecordFatigue},\ {"SetRecordFatigue", RecordsDynamicFunctions::SetRecordFatigue},\
\ \
{"SetRecordAIFight", RecordsDynamicFunctions::SetRecordAIFight},\ {"SetRecordAIFight", RecordsDynamicFunctions::SetRecordAIFight},\
{"SetRecordAIFlee", RecordsDynamicFunctions::SetRecordAIFlee},\
{"SetRecordAIAlarm", RecordsDynamicFunctions::SetRecordAIAlarm},\
{"SetRecordAIServices", RecordsDynamicFunctions::SetRecordAIServices},\ {"SetRecordAIServices", RecordsDynamicFunctions::SetRecordAIServices},\
\ \
{"SetRecordOpenSound", RecordsDynamicFunctions::SetRecordOpenSound},\ {"SetRecordOpenSound", RecordsDynamicFunctions::SetRecordOpenSound},\
@ -737,6 +739,24 @@ public:
*/ */
static void SetRecordAIFight(int aiFight) noexcept; 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 * \brief Set the AI services value of the temporary record stored on the server for the
* currently specified record type. * currently specified record type.

View File

@ -214,6 +214,12 @@ void RecordHelper::overrideCreatureRecord(const mwmp::CreatureRecord& record)
if (record.baseOverrides.hasAiFight) if (record.baseOverrides.hasAiFight)
finalData.mAiData.mFight = recordData.mAiData.mFight; 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) if (record.baseOverrides.hasAiServices)
finalData.mAiData.mServices = recordData.mAiData.mServices; finalData.mAiData.mServices = recordData.mAiData.mServices;
@ -323,6 +329,12 @@ void RecordHelper::overrideNpcRecord(const mwmp::NpcRecord& record)
if (record.baseOverrides.hasAiFight) if (record.baseOverrides.hasAiFight)
finalData.mAiData.mFight = recordData.mAiData.mFight; 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) if (record.baseOverrides.hasAiServices)
finalData.mAiData.mServices = recordData.mAiData.mServices; finalData.mAiData.mServices = recordData.mAiData.mServices;

View File

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

View File

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