From 5e614c6206017b2e8c225fde7e97111a95fbc575 Mon Sep 17 00:00:00 2001 From: Sam V Date: Wed, 11 Oct 2023 17:19:49 +0200 Subject: [PATCH] Save and restore allied grunt repel entities to ensure spawned NPCs have correct properties --- CHANGELOG.md | 1 + dlls/hgrunt_ally.cpp | 15 ++++++++++++++- dlls/hgrunt_medic.cpp | 15 ++++++++++++++- dlls/hgrunt_torch.cpp | 14 +++++++++++++- 4 files changed, 42 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cd23ce91..eb7cdefb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ * Fixed Male Assassin Snipers not tracking their last shot time properly (Thanks malortie) * Fixed torch and medic grunts, male assassins and shock troopers continuing to fire for a few seconds after killing the last enemy in an area [#100](https://github.com/SamVanheer/halflife-op4-updated/issues/100) (Thanks Ronin4862 and malortie) * Fixed Gonome crashing the game if the player dies while being damaged by Gonome's chest mouth (Thanks malortie) +* Save and restore allied grunt repel entities to ensure spawned NPCs have correct properties (Thanks malortie) ## Changes in V1.0.0 Release Candidate 001 diff --git a/dlls/hgrunt_ally.cpp b/dlls/hgrunt_ally.cpp index 6013402f..f3024033 100644 --- a/dlls/hgrunt_ally.cpp +++ b/dlls/hgrunt_ally.cpp @@ -2920,6 +2920,11 @@ void CHGruntAlly::Killed(entvars_t* pevAttacker, int iGib) class CHGruntAllyRepel : public CBaseMonster { public: + static TYPEDESCRIPTION m_SaveData[]; + + bool Save(CSave& save) override; + bool Restore(CRestore& restore) override; + bool KeyValue(KeyValueData* pkvd) override; void Spawn() override; @@ -2927,7 +2932,6 @@ class CHGruntAllyRepel : public CBaseMonster void EXPORT RepelUse(CBaseEntity* pActivator, CBaseEntity* pCaller, USE_TYPE useType, float value); int m_iSpriteTexture; // Don't save, precache - //TODO: needs save/restore (not in op4) int m_iGruntHead; int m_iszUse; int m_iszUnUse; @@ -2935,6 +2939,15 @@ class CHGruntAllyRepel : public CBaseMonster LINK_ENTITY_TO_CLASS(monster_grunt_ally_repel, CHGruntAllyRepel); +TYPEDESCRIPTION CHGruntAllyRepel::m_SaveData[] = + { + DEFINE_FIELD(CHGruntAllyRepel, m_iGruntHead, FIELD_INTEGER), + DEFINE_FIELD(CHGruntAllyRepel, m_iszUse, FIELD_STRING), + DEFINE_FIELD(CHGruntAllyRepel, m_iszUnUse, FIELD_STRING), +}; + +IMPLEMENT_SAVERESTORE(CHGruntAllyRepel, CBaseMonster); + bool CHGruntAllyRepel::KeyValue(KeyValueData* pkvd) { if (FStrEq(pkvd->szKeyName, "head")) diff --git a/dlls/hgrunt_medic.cpp b/dlls/hgrunt_medic.cpp index 2ef8bb47..c5ef2d84 100644 --- a/dlls/hgrunt_medic.cpp +++ b/dlls/hgrunt_medic.cpp @@ -3172,6 +3172,11 @@ void COFMedicAlly::HealerUse(CBaseEntity* pActivator, CBaseEntity* pCaller, USE_ class COFMedicAllyRepel : public CBaseMonster { public: + static TYPEDESCRIPTION m_SaveData[]; + + bool Save(CSave& save) override; + bool Restore(CRestore& restore) override; + bool KeyValue(KeyValueData* pkvd) override; void Spawn() override; @@ -3179,7 +3184,6 @@ class COFMedicAllyRepel : public CBaseMonster void EXPORT RepelUse(CBaseEntity* pActivator, CBaseEntity* pCaller, USE_TYPE useType, float value); int m_iSpriteTexture; // Don't save, precache - //TODO: needs save/restore (not in op4) int m_iBlackOrWhite; int m_iszUse; int m_iszUnUse; @@ -3187,6 +3191,15 @@ class COFMedicAllyRepel : public CBaseMonster LINK_ENTITY_TO_CLASS(monster_medic_ally_repel, COFMedicAllyRepel); +TYPEDESCRIPTION COFMedicAllyRepel::m_SaveData[] = + { + DEFINE_FIELD(COFMedicAllyRepel, m_iBlackOrWhite, FIELD_INTEGER), + DEFINE_FIELD(COFMedicAllyRepel, m_iszUse, FIELD_STRING), + DEFINE_FIELD(COFMedicAllyRepel, m_iszUnUse, FIELD_STRING), +}; + +IMPLEMENT_SAVERESTORE(COFMedicAllyRepel, CBaseMonster); + bool COFMedicAllyRepel::KeyValue(KeyValueData* pkvd) { if (FStrEq(pkvd->szKeyName, "head")) diff --git a/dlls/hgrunt_torch.cpp b/dlls/hgrunt_torch.cpp index 13dd8263..5f52798c 100644 --- a/dlls/hgrunt_torch.cpp +++ b/dlls/hgrunt_torch.cpp @@ -2754,6 +2754,11 @@ void COFTorchAlly::MonsterThink() class COFTorchAllyRepel : public CBaseMonster { public: + static TYPEDESCRIPTION m_SaveData[]; + + bool Save(CSave& save) override; + bool Restore(CRestore& restore) override; + bool KeyValue(KeyValueData* pkvd) override; void Spawn() override; @@ -2761,13 +2766,20 @@ class COFTorchAllyRepel : public CBaseMonster void EXPORT RepelUse(CBaseEntity* pActivator, CBaseEntity* pCaller, USE_TYPE useType, float value); int m_iSpriteTexture; // Don't save, precache - //TODO: needs save/restore (not in op4) int m_iszUse; int m_iszUnUse; }; LINK_ENTITY_TO_CLASS(monster_torch_ally_repel, COFTorchAllyRepel); +TYPEDESCRIPTION COFTorchAllyRepel::m_SaveData[] = + { + DEFINE_FIELD(COFTorchAllyRepel, m_iszUse, FIELD_STRING), + DEFINE_FIELD(COFTorchAllyRepel, m_iszUnUse, FIELD_STRING), +}; + +IMPLEMENT_SAVERESTORE(COFTorchAllyRepel, CBaseMonster); + bool COFTorchAllyRepel::KeyValue(KeyValueData* pkvd) { if (FStrEq(pkvd->szKeyName, "UseSentence"))