From 272482c5e715e5b7848ccfa106b6abc90a4465a3 Mon Sep 17 00:00:00 2001 From: Giegue Date: Tue, 12 Sep 2023 13:51:25 -0300 Subject: [PATCH] A long overdue update... - Fixed Alien Grunt's hornets being silent. - Fixed many, many, many, many ... many GSR crashes. - Fixed voltigore's beams not being cleared upon gibbing/removal. - Prepare for T4 release. --- src/dlls/agrunt.cpp | 9 +++++++++ src/dlls/cmbasemonster.h | 4 ++++ src/dlls/dllapi.cpp | 17 ----------------- src/dlls/ggrenade.cpp | 17 ++++++++++++++--- src/dlls/globalreplace.cpp | 9 ++++----- src/dlls/hornet.cpp | 21 ++++++--------------- src/dlls/monster_api.cpp | 4 ++-- src/dlls/monster_config.cpp | 12 ++++++++---- src/dlls/monster_plugin.h | 4 ++-- src/dlls/monsters.cpp | 2 +- src/dlls/pitdrone.cpp | 8 +++++++- src/dlls/sporegrenade.cpp | 8 ++++++++ src/dlls/voltigore.cpp | 7 +++++++ src/dlls/weapons.h | 2 ++ 14 files changed, 74 insertions(+), 50 deletions(-) diff --git a/src/dlls/agrunt.cpp b/src/dlls/agrunt.cpp index 34de414..73d34f8 100644 --- a/src/dlls/agrunt.cpp +++ b/src/dlls/agrunt.cpp @@ -87,6 +87,13 @@ const char *CMAGrunt::pAttackSounds[] = "agrunt/ag_attack3.wav", }; +const char *CMAGrunt::pFireSounds[] = +{ + "agrunt/ag_fire1.wav", + "agrunt/ag_fire2.wav", + "agrunt/ag_fire3.wav", +}; + const char *CMAGrunt::pDieSounds[] = { "agrunt/ag_die1.wav", @@ -413,6 +420,8 @@ void CMAGrunt :: HandleAnimEvent( MonsterEvent_t *pEvent ) UTIL_MakeVectors ( pHornet->pev->angles ); pHornet->pev->velocity = gpGlobals->v_forward * 300; + EMIT_SOUND_DYN(ENT(pev), CHAN_WEAPON, pFireSounds[RANDOM_LONG(0, ARRAYSIZE(pFireSounds) - 1)], 1.0, ATTN_NORM, 0, 100); + CMBaseMonster *pHornetMonster = pHornet->MyMonsterPointer(); if ( pHornetMonster ) diff --git a/src/dlls/cmbasemonster.h b/src/dlls/cmbasemonster.h index 7951975..b9606c5 100644 --- a/src/dlls/cmbasemonster.h +++ b/src/dlls/cmbasemonster.h @@ -734,6 +734,7 @@ public: static const char *pAttackHitSounds[]; static const char *pAttackMissSounds[]; static const char *pAttackSounds[]; + static const char *pFireSounds[]; static const char *pDieSounds[]; static const char *pPainSounds[]; static const char *pIdleSounds[]; @@ -1381,6 +1382,8 @@ public: void EXPORT SpikeTouch(edict_t *pOther); void EXPORT StartTrail(); static edict_t *Shoot(entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, Vector vecAngles); + + EHANDLE m_hOwner; }; //========================================================= @@ -1557,6 +1560,7 @@ public: Schedule_t *GetScheduleOfType(int Type); virtual int TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType); virtual void Killed(entvars_t *pevAttacker, int iGib); + void UpdateOnRemove(); CUSTOM_SCHEDULES diff --git a/src/dlls/dllapi.cpp b/src/dlls/dllapi.cpp index 4f5e701..edbfa93 100644 --- a/src/dlls/dllapi.cpp +++ b/src/dlls/dllapi.cpp @@ -211,11 +211,6 @@ int GetMonsterIndex(void) void FreeMonsterIndex(int index) { - /* - if (monsters[index].pMonster->m_srSoundList != NULL) - free(monsters[index].pMonster->m_srSoundList); - monsters[index].pMonster->m_srSoundList = NULL; - */ delete monsters[index].pMonster; monsters[index].monster_index = 0; @@ -261,11 +256,6 @@ void monster_unload(void) { monsters[index].monster_pent->v.flags |= FL_KILLME; - /* - if (monsters[index].pMonster->m_srSoundList != NULL) - free(monsters[index].pMonster->m_srSoundList); - monsters[index].pMonster->m_srSoundList = NULL; - */ delete monsters[index].pMonster; monsters[index].monster_index = 0; @@ -1268,14 +1258,7 @@ int mmDispatchSpawn( edict_t *pent ) for (index = 0; index < MAX_MONSTER_ENTS; index++) { if (monsters[index].pMonster != NULL) - { - // free the soundlists first! - /*if (monsters[index].pMonster->m_srSoundList != NULL) - free(monsters[index].pMonster->m_srSoundList); - monsters[index].pMonster->m_srSoundList = NULL; - */ delete monsters[index].pMonster; - } } // free any allocated keyvalue memory diff --git a/src/dlls/ggrenade.cpp b/src/dlls/ggrenade.cpp index aa2f3d2..099d41f 100644 --- a/src/dlls/ggrenade.cpp +++ b/src/dlls/ggrenade.cpp @@ -48,6 +48,10 @@ void CMGrenade::Explode( Vector vecSrc, Vector vecAim ) // UNDONE: temporary scorching for PreAlpha - find a less sleazy permenant solution. void CMGrenade::Explode( TraceResult *pTrace, int bitsDamageType ) { + // CRITICAL - always ensure owner of grenade is valid + if (m_hOwner == NULL) + pev->owner = NULL; + float flRndSound;// sound randomizer pev->model = iStringNull;//invisible @@ -309,6 +313,10 @@ void CMGrenade::SlideTouch( edict_t *pOther ) void CMGrenade :: BounceSound( void ) { + // CRITICAL - always ensure owner of grenade is valid + if (m_hOwner == NULL) + pev->owner = NULL; + switch ( RANDOM_LONG( 0, 2 ) ) { case 0: EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/grenade_hit1.wav", 0.25, ATTN_NORM); break; @@ -369,7 +377,8 @@ CMGrenade *CMGrenade::ShootContact( entvars_t *pevOwner, Vector vecStart, Vector pGrenade->pev->velocity = vecVelocity; pGrenade->pev->angles = UTIL_VecToAngles (pGrenade->pev->velocity); pGrenade->pev->owner = ENT(pevOwner); - + pGrenade->m_hOwner = ENT(pevOwner); + // make monsters afaid of it while in the air pGrenade->SetThink( &CMGrenade::DangerSoundThink ); pGrenade->pev->nextthink = gpGlobals->time; @@ -398,7 +407,8 @@ CMGrenade * CMGrenade:: ShootTimed( entvars_t *pevOwner, Vector vecStart, Vector pGrenade->pev->velocity = vecVelocity; pGrenade->pev->angles = UTIL_VecToAngles(pGrenade->pev->velocity); pGrenade->pev->owner = ENT(pevOwner); - + pGrenade->m_hOwner = ENT(pevOwner); + pGrenade->SetTouch( &CMGrenade::BounceTouch ); // Bounce if touched // Take one second off of the desired detonation time and set the think to PreDetonate. PreDetonate @@ -451,7 +461,8 @@ CMGrenade * CMGrenade :: ShootSatchelCharge( entvars_t *pevOwner, Vector vecStar pGrenade->pev->velocity = vecVelocity; pGrenade->pev->angles = g_vecZero; pGrenade->pev->owner = ENT(pevOwner); - + pGrenade->m_hOwner = ENT(pevOwner); + // Detonate in "time" seconds pGrenade->SetThink( &CMGrenade::SUB_DoNothing ); pGrenade->SetUse( &CMGrenade::DetonateUse ); diff --git a/src/dlls/globalreplace.cpp b/src/dlls/globalreplace.cpp index ceacf3a..71a0bde 100644 --- a/src/dlls/globalreplace.cpp +++ b/src/dlls/globalreplace.cpp @@ -123,19 +123,19 @@ const char* FindSoundReplacement( edict_t *pMonster, const char *from ) if (UTIL_IsValidEntity(pMonster)) { CMBaseMonster *castMonster = NULL; - + // Check if this is really a monster or not if (pMonster->v.flags & FL_MONSTER) castMonster = GetClassPtr((CMBaseMonster *)VARS(pMonster)); else { // This is probably a monster-owned projectile of sorts - if (!FNullEnt(pMonster->v.owner)) + if (UTIL_IsValidEntity(pMonster->v.owner)) castMonster = GetClassPtr((CMBaseMonster *)VARS(pMonster->v.owner)); } - + // If still no valid BaseMonster pointer, full stop, use GSR. - if (castMonster && castMonster->m_isrSounds) + if (castMonster != NULL && castMonster->m_srSoundList != NULL && castMonster->m_isrSounds > 0) { for (int sound = 0; sound < castMonster->m_isrSounds; sound++) { @@ -145,7 +145,6 @@ const char* FindSoundReplacement( edict_t *pMonster, const char *from ) return castMonster->m_srSoundList[sound].destination; } } - // If nothing is found stick to GSR if available } } diff --git a/src/dlls/hornet.cpp b/src/dlls/hornet.cpp index 3649f01..d841745 100644 --- a/src/dlls/hornet.cpp +++ b/src/dlls/hornet.cpp @@ -126,23 +126,14 @@ int CMHornet::IRelationship ( CMBaseEntity *pTarget ) //========================================================= int CMHornet::Classify ( void ) { - /* - if ( pev->owner && pev->owner->v.flags & FL_CLIENT) - { - return CLASS_PLAYER_BIOWEAPON; - } - - return CLASS_ALIEN_BIOWEAPON; - */ - // Ensure classify is consistent with the owner, in the event // it's classification was overriden. - if ( pev->owner == NULL ) - return CLASS_ALIEN_BIOWEAPON; - - // Ain't this going to make the hornets code "slow"? - CMBaseMonster *pOwner = GetClassPtr((CMBaseMonster *)VARS(pev->owner)); - return pOwner->Classify(); + if (UTIL_IsValidEntity(pev->owner)) + { + CMBaseMonster *pOwner = GetClassPtr((CMBaseMonster *)VARS(pev->owner)); + return pOwner->Classify(); + } + return CLASS_ALIEN_BIOWEAPON; } //========================================================= diff --git a/src/dlls/monster_api.cpp b/src/dlls/monster_api.cpp index 7f131a3..028509a 100644 --- a/src/dlls/monster_api.cpp +++ b/src/dlls/monster_api.cpp @@ -56,8 +56,8 @@ static META_FUNCTIONS gMetaFunctionTable = plugin_info_t Plugin_info = { META_INTERFACE_VERSION, // interface version "MonsterMod", // name - "3.0", // version - "24/02/2023", // date in DD/MM/YYYY format + "4.0", // version + "14/07/2023", // date in DD/MM/YYYY format "botman, Rick90, Giegue", // original authors + recreation by... "https://github.com/JulianR0/monstermod-redo", // url "MONSTER", // logtag diff --git a/src/dlls/monster_config.cpp b/src/dlls/monster_config.cpp index 38994ca..5b2950a 100644 --- a/src/dlls/monster_config.cpp +++ b/src/dlls/monster_config.cpp @@ -74,8 +74,12 @@ void scan_monster_sound(FILE *fp, edict_t *pMonster ) while (get_input(fp, input)) { - char *source = strtok(input, " "); - char *destination = strtok(NULL, " "); + // might slip through + if (strlen(input) == 0) + continue; + + char *source = strtok(input, " \t"); + char *destination = strtok(NULL, " \t"); // Remove all quotes char parse[128] = {0}; @@ -894,8 +898,8 @@ void scan_monster_replace(FILE *fp, bool toGSR ) if (strlen(input) == 0) continue; - char *source = strtok(input, " "); - char *destination = strtok(NULL, " "); + char *source = strtok(input, " \t"); + char *destination = strtok(NULL, " \t"); // Remove all quotes char parse[128] = {0}; diff --git a/src/dlls/monster_plugin.h b/src/dlls/monster_plugin.h index 08d4450..eda2632 100644 --- a/src/dlls/monster_plugin.h +++ b/src/dlls/monster_plugin.h @@ -30,7 +30,7 @@ typedef struct CMBaseMonster *pMonster; } monster_t; -#define MAX_MONSTER_ENTS 400 // increased from 200 so it can hold non-monster entities +#define MAX_MONSTER_ENTS 400 extern monster_t monsters[MAX_MONSTER_ENTS]; @@ -43,7 +43,7 @@ typedef struct { bool need_to_respawn; } monster_spawnpoint_t; -#define MAX_MONSTERS 100 +#define MAX_MONSTERS 200 extern monster_spawnpoint_t monster_spawnpoint[MAX_MONSTERS]; // this is here to store if a node we want to spawn is an ordinary one, or a flying one diff --git a/src/dlls/monsters.cpp b/src/dlls/monsters.cpp index a04e598..947a8ce 100644 --- a/src/dlls/monsters.cpp +++ b/src/dlls/monsters.cpp @@ -172,7 +172,7 @@ void CMBaseMonster :: Look ( int iDistance ) { /* MonsterMod monster looking at another MonsterMod monster */ CMBaseMonster *pMonster = GetClassPtr((CMBaseMonster *)VARS(pSightEnt)); - + // the looker will want to consider this entity // don't check anything else about an entity that can't be seen, or an entity that you don't care about. if ( IRelationship( pMonster ) != R_NO && UTIL_FInViewCone( pSightEnt, ENT(pev), m_flFieldOfView ) && !FBitSet( pSightEnt->v.flags, FL_NOTARGET ) && UTIL_FVisible( pSightEnt, ENT(pev) ) ) diff --git a/src/dlls/pitdrone.cpp b/src/dlls/pitdrone.cpp index ced809d..7c20a85 100644 --- a/src/dlls/pitdrone.cpp +++ b/src/dlls/pitdrone.cpp @@ -60,6 +60,9 @@ void CPitdroneSpike::Spawn(void) void CPitdroneSpike::SpikeTouch(edict_t *pOther) { + if (m_hOwner == NULL) + pev->owner = NULL; + int iPitch; // splat sound @@ -89,7 +92,9 @@ void CPitdroneSpike::SpikeTouch(edict_t *pOther) else { entvars_t *pevOwner = VARS(pev->owner); - + if (pevOwner == NULL) + pevOwner = pev; + if ( UTIL_IsPlayer( pOther ) ) UTIL_TakeDamage( pOther, pev, pevOwner, gSkillData.pitdroneDmgSpit, DMG_GENERIC | DMG_NEVERGIB ); else if ( pOther->v.euser4 != NULL ) @@ -141,6 +146,7 @@ edict_t *CPitdroneSpike::Shoot(entvars_t *pevOwner, Vector vecStart, Vector vecV pSpit->pev->velocity = vecVelocity; pSpit->pev->angles = vecAngles; pSpit->pev->owner = ENT( pevOwner ); + pSpit->m_hOwner = ENT( pevOwner ); pSpit->SetThink(&CPitdroneSpike::StartTrail); pSpit->pev->nextthink = gpGlobals->time + 0.1; diff --git a/src/dlls/sporegrenade.cpp b/src/dlls/sporegrenade.cpp index 7d8615b..6dca0fb 100644 --- a/src/dlls/sporegrenade.cpp +++ b/src/dlls/sporegrenade.cpp @@ -40,6 +40,9 @@ void CMSporeGrenade::Precache() void CMSporeGrenade::Explode(TraceResult *pTrace) { + if (m_hOwner == NULL) + pev->owner = NULL; + pev->solid = SOLID_NOT;// intangible pev->takedamage = DAMAGE_NO; @@ -125,6 +128,9 @@ void CMSporeGrenade::Detonate() void CMSporeGrenade::BounceSound() { + if (m_hOwner == NULL) + pev->owner = NULL; + EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/splauncher_bounce.wav", 0.25, ATTN_NORM); } @@ -252,6 +258,7 @@ CMSporeGrenade* CMSporeGrenade::ShootTimed(entvars_t *pevOwner, Vector vecStart, pGrenade->pev->velocity = vecVelocity; pGrenade->pev->angles = UTIL_VecToAngles(pGrenade->pev->velocity); pGrenade->pev->owner = ENT(pevOwner); + pGrenade->m_hOwner = ENT(pevOwner); pGrenade->SetTouch(&CMSporeGrenade::BounceTouch); // Bounce if touched @@ -286,6 +293,7 @@ CMSporeGrenade *CMSporeGrenade::ShootContact(entvars_t *pevOwner, Vector vecStar pGrenade->pev->velocity = vecVelocity; pGrenade->pev->angles = UTIL_VecToAngles(pGrenade->pev->velocity); pGrenade->pev->owner = ENT(pevOwner); + pGrenade->m_hOwner = ENT(pevOwner); // make monsters afraid of it while in the air pGrenade->SetThink(&CMSporeGrenade::DangerSoundThink); diff --git a/src/dlls/voltigore.cpp b/src/dlls/voltigore.cpp index 7366174..6bf81ab 100644 --- a/src/dlls/voltigore.cpp +++ b/src/dlls/voltigore.cpp @@ -449,6 +449,13 @@ void CMVoltigore::GibMonster() pev->nextthink = gpGlobals->time; } +void CMVoltigore::UpdateOnRemove() +{ + CMBaseMonster::UpdateOnRemove(); + DestroyBeams(); + DestroyGlow(); +} + //========================================================= // CheckMeleeAttack1 - voltigore is a big guy, so has a longer // melee range than most monsters. This is the tailwhip attack diff --git a/src/dlls/weapons.h b/src/dlls/weapons.h index 3fc94dd..d5c15c5 100644 --- a/src/dlls/weapons.h +++ b/src/dlls/weapons.h @@ -47,6 +47,7 @@ public: virtual void Killed( entvars_t *pevAttacker, int iGib ); BOOL m_fRegisteredSound;// whether or not this grenade has issued its DANGER sound to the world sound list yet. + EHANDLE m_hOwner; }; // Contact/Timed spore grenade @@ -75,6 +76,7 @@ public: void UpdateOnRemove(); CMSprite* m_pSporeGlow; + EHANDLE m_hOwner; }; // constant items