Skip to content

Commit

Permalink
Save and restore allied grunt repel entities to ensure spawned NPCs h…
Browse files Browse the repository at this point in the history
…ave correct properties
  • Loading branch information
SamVanheer committed Oct 11, 2023
1 parent f99d293 commit 5e614c6
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 14 additions & 1 deletion dlls/hgrunt_ally.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2920,21 +2920,34 @@ 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;
void Precache() override;
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;
};

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"))
Expand Down
15 changes: 14 additions & 1 deletion dlls/hgrunt_medic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3172,21 +3172,34 @@ 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;
void Precache() override;
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;
};

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"))
Expand Down
14 changes: 13 additions & 1 deletion dlls/hgrunt_torch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2754,20 +2754,32 @@ 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;
void Precache() override;
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"))
Expand Down

0 comments on commit 5e614c6

Please sign in to comment.