From ba9414ea6ee3b0beebcfdf7af6e8e3bb0d3b09fc Mon Sep 17 00:00:00 2001 From: Giegue Date: Thu, 27 Apr 2023 13:02:23 -0300 Subject: [PATCH] Add missing keyvalue in monstermaker. Fix duplicate entity spawn in Half-Life. --- src/dlls/monster_config.cpp | 14 ++++++++++---- src/dlls/monstermaker.cpp | 6 ++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/dlls/monster_config.cpp b/src/dlls/monster_config.cpp index b2dc6c1..30a5b0d 100644 --- a/src/dlls/monster_config.cpp +++ b/src/dlls/monster_config.cpp @@ -450,11 +450,11 @@ void scan_monster_bsp(void) { // the entity we are trying to spawn could already exist within the game // use the engine's CREATE_NAMED_ENTITY to see if it's valid or not - // - // if it is valid, this entity already exists and we should ignore it edict_t *existsGAME = CREATE_NAMED_ENTITY( MAKE_STRING( kv_pair->value ) ); if ( !FNullEnt( existsGAME ) ) { + // this entity already exists and we should ignore it + // use REMOVE_ENTITY instead of UTIL_Remove! // UTIL_Remove sets FL_KILLME to remove the entity on the next frame, that won't do. // REMOVE_ENTITY instead removes it instantly, which is needed to prevent server crashes @@ -468,8 +468,14 @@ void scan_monster_bsp(void) { if (atoi(kv_pair->value) == 1) { - // EXPLICITY requested to use monstermod for this entity - use_monstermod_explicit = true; + // The extra plugin must be available to handle the old entity! + if (CVAR_GET_FLOAT("_hl_explicit")) + { + // EXPLICITY requested to use monstermod for this entity + use_monstermod_explicit = true; + } + else + LOG_MESSAGE(PLID, "WARNING: can't explicity add entity #%i - add-on plugin unavailable", ent); } } diff --git a/src/dlls/monstermaker.cpp b/src/dlls/monstermaker.cpp index 408ff0b..c2b2d3f 100644 --- a/src/dlls/monstermaker.cpp +++ b/src/dlls/monstermaker.cpp @@ -70,6 +70,12 @@ void CMMonsterMaker :: KeyValue( KeyValueData *pkvd ) m_iMonsterBlood = atoi(pkvd->szValue); pkvd->fHandled = TRUE; } + else if ( FStrEq(pkvd->szKeyName, "respawn_as_playerally") ) + { + if (atoi(pkvd->szValue)) + m_iClassifyOverride = CLASS_PLAYER_ALLY; + pkvd->fHandled = TRUE; + } // These are to keep consistency with Sven Co-op's squadmaker entity. // CMBaseMonster::KeyValue will process TriggerCondition/TriggerTarget // keyvalues in the same way.