From d39bc85ab68d852b6940b7e3c313376368661777 Mon Sep 17 00:00:00 2001 From: Julian Date: Mon, 1 Jun 2020 17:10:52 -0300 Subject: [PATCH] Use monster classname for player deaths. --- src/dlls/agrunt.cpp | 2 + src/dlls/apache.cpp | 4 +- src/dlls/barney.cpp | 2 + src/dlls/bigmomma.cpp | 2 + src/dlls/bullsquid.cpp | 2 + src/dlls/controller.cpp | 2 + src/dlls/dllapi.cpp | 265 ++++++++++++++++++++++++++++++++++++- src/dlls/gargantua.cpp | 2 + src/dlls/hassassin.cpp | 4 +- src/dlls/headcrab.cpp | 2 + src/dlls/hgrunt.cpp | 2 + src/dlls/houndeye.cpp | 2 + src/dlls/islave.cpp | 5 +- src/dlls/monster_api.cpp | 4 +- src/dlls/scientist.cpp | 2 + src/dlls/squeakgrenade.cpp | 4 +- src/dlls/turret.cpp | 14 +- src/dlls/util.cpp | 2 +- src/dlls/zombie.cpp | 4 +- 19 files changed, 307 insertions(+), 19 deletions(-) diff --git a/src/dlls/agrunt.cpp b/src/dlls/agrunt.cpp index e5debdf..4806075 100644 --- a/src/dlls/agrunt.cpp +++ b/src/dlls/agrunt.cpp @@ -541,6 +541,8 @@ void CMAGrunt :: Spawn() m_flNextSpeakTime = m_flNextWordTime = gpGlobals->time + 10 + RANDOM_LONG(0, 10); MonsterInit(); + + pev->classname = MAKE_STRING( "monster_alien_grunt" ); } //========================================================= diff --git a/src/dlls/apache.cpp b/src/dlls/apache.cpp index d3fcbbb..37a612e 100644 --- a/src/dlls/apache.cpp +++ b/src/dlls/apache.cpp @@ -84,6 +84,8 @@ void CMApache :: Spawn( void ) m_flPrevSeen = 0.0f; m_iSoundState = 0; + + pev->classname = MAKE_STRING( "monster_apache" ); } @@ -974,4 +976,4 @@ void CMApacheHVR :: AccelerateThink( void ) } -#endif \ No newline at end of file +#endif diff --git a/src/dlls/barney.cpp b/src/dlls/barney.cpp index c7a4650..d1d4c78 100644 --- a/src/dlls/barney.cpp +++ b/src/dlls/barney.cpp @@ -357,6 +357,8 @@ void CMBarney :: Spawn() m_afCapability = bits_CAP_HEAR | bits_CAP_TURN_HEAD | bits_CAP_DOORS_GROUP; MonsterInit(); + + pev->classname = MAKE_STRING( "monster_barney" ); } //========================================================= diff --git a/src/dlls/bigmomma.cpp b/src/dlls/bigmomma.cpp index 4712cda..e5839a0 100644 --- a/src/dlls/bigmomma.cpp +++ b/src/dlls/bigmomma.cpp @@ -610,6 +610,8 @@ void CMBigMomma :: Spawn() m_MonsterState = MONSTERSTATE_NONE; MonsterInit(); + + pev->classname = MAKE_STRING( "monster_bigmomma" ); } //========================================================= diff --git a/src/dlls/bullsquid.cpp b/src/dlls/bullsquid.cpp index 67980d8..d1a4729 100644 --- a/src/dlls/bullsquid.cpp +++ b/src/dlls/bullsquid.cpp @@ -617,6 +617,8 @@ void CMBullsquid :: Spawn() m_flNextSpitTime = gpGlobals->time; MonsterInit(); + + pev->classname = MAKE_STRING( "monster_bullchicken" ); } //========================================================= diff --git a/src/dlls/controller.cpp b/src/dlls/controller.cpp index 9bd0ed4..1a9b1e5 100644 --- a/src/dlls/controller.cpp +++ b/src/dlls/controller.cpp @@ -310,6 +310,8 @@ void CMController :: Spawn() m_MonsterState = MONSTERSTATE_NONE; MonsterInit(); + + pev->classname = MAKE_STRING( "monster_alien_controller" ); } //========================================================= diff --git a/src/dlls/dllapi.cpp b/src/dlls/dllapi.cpp index 7b1b0b6..718b7d3 100644 --- a/src/dlls/dllapi.cpp +++ b/src/dlls/dllapi.cpp @@ -69,6 +69,10 @@ int g_DamageBits[33]; bool g_PlayerKilled[33]; float g_flWaitTillMessage[33]; +// DeathMsg +int g_DeathMsg; +bool g_DeathActive; + cvar_t *g_psv_gravity = NULL; DLL_DECALLIST gDecals[] = { @@ -132,7 +136,7 @@ monster_type_t monster_types[]= "monster_bigmomma", FALSE, "monster_bullsquid", FALSE, "monster_alien_controller", FALSE, - "monster_hassassin", FALSE, + "monster_human_assassin", FALSE, "monster_headcrab", FALSE, "monster_human_grunt", FALSE, "monster_houndeye", FALSE, @@ -1484,7 +1488,7 @@ C_DLLEXPORT int GetEntityAPI2_Post( DLL_FUNCTIONS *pFunctionTable, int *interfac } -// Messages in Counter-Strike are offset by 1. +// Some messages seems to be offset by 1. Linux specific? CStrike specific? int IsCSServer( void ) { char mod[16]; @@ -1502,6 +1506,8 @@ int mmRegUserMsg_Post( const char *pName, int iSize ) if ( strcmp( pName, "Damage" ) == 0 ) g_DamageMsg = META_RESULT_ORIG_RET( int ) - cs_server; + else if ( strcmp( pName, "DeathMsg" ) == 0 ) + g_DeathMsg = META_RESULT_ORIG_RET( int );// - cs_server; RETURN_META_VALUE( MRES_IGNORED, 0 ); } @@ -1510,10 +1516,6 @@ void mmMessageBegin_Post( int msg_dest, int msg_type, const float *pOrigin, edic { if ( msg_type == g_DamageMsg ) { - // Death messages are disabled - if (!monster_show_deaths->value) - RETURN_META( MRES_IGNORED ); - // Whatever hurting us must be a valid entity if (ed->v.dmg_inflictor != NULL ) { @@ -1522,6 +1524,11 @@ void mmMessageBegin_Post( int msg_dest, int msg_type, const float *pOrigin, edic g_DamageAttacker[ g_DamageVictim ] = ed->v.dmg_inflictor; } } + else if ( msg_type == g_DeathMsg ) + { + // Prepare to update deathmsg + g_DeathActive = true; + } RETURN_META( MRES_IGNORED ); } @@ -1534,6 +1541,28 @@ void mmWriteLong_Post( int iValue ) RETURN_META( MRES_IGNORED ); } +// This cannot be done on post! +void mmWriteString( const char *szValue ) +{ + if ( g_DeathActive ) + { + // Prevent recursion + g_DeathActive = false; + + // Ensure whatever killed the player is a valid entity + if (g_DamageAttacker[ g_DamageVictim ] != NULL) + { + // Send a new WriteString with the killer's classname + WRITE_STRING( STRING( g_DamageAttacker[ g_DamageVictim ]->v.classname ) ); + + // Supercede the old message + RETURN_META( MRES_SUPERCEDE ); + } + } + + RETURN_META( MRES_IGNORED ); +} + void mmMessageEnd_Post( void ) { g_DamageActive = false; @@ -1541,6 +1570,230 @@ void mmMessageEnd_Post( void ) RETURN_META( MRES_IGNORED ); } +enginefuncs_t meta_engfuncs = +{ + NULL, // pfnPrecacheModel() + NULL, // pfnPrecacheSound() + NULL, // pfnSetModel() + NULL, // pfnModelIndex() + NULL, // pfnModelFrames() + + NULL, // pfnSetSize() + NULL, // pfnChangeLevel() + NULL, // pfnGetSpawnParms() + NULL, // pfnSaveSpawnParms() + + NULL, // pfnVecToYaw() + NULL, // pfnVecToAngles() + NULL, // pfnMoveToOrigin() + NULL, // pfnChangeYaw() + NULL, // pfnChangePitch() + + NULL, // pfnFindEntityByString() + NULL, // pfnGetEntityIllum() + NULL, // pfnFindEntityInSphere() + NULL, // pfnFindClientInPVS() + NULL, // pfnEntitiesInPVS() + + NULL, // pfnMakeVectors() + NULL, // pfnAngleVectors() + + NULL, // pfnCreateEntity() + NULL, // pfnRemoveEntity() + NULL, // pfnCreateNamedEntity() + + NULL, // pfnMakeStatic() + NULL, // pfnEntIsOnFloor() + NULL, // pfnDropToFloor() + + NULL, // pfnWalkMove() + NULL, // pfnSetOrigin() + + NULL, // pfnEmitSound() + NULL, // pfnEmitAmbientSound() + + NULL, // pfnTraceLine() + NULL, // pfnTraceToss() + NULL, // pfnTraceMonsterHull() + NULL, // pfnTraceHull() + NULL, // pfnTraceModel() + NULL, // pfnTraceTexture() + NULL, // pfnTraceSphere() + NULL, // pfnGetAimVector() + + NULL, // pfnServerCommand() + NULL, // pfnServerExecute() + NULL, // pfnClientCommand() + + NULL, // pfnParticleEffect() + NULL, // pfnLightStyle() + NULL, // pfnDecalIndex() + NULL, // pfnPointContents() + + NULL, // pfnMessageBegin() + NULL, // pfnMessageEnd() + + NULL, // pfnWriteByte() + NULL, // pfnWriteChar() + NULL, // pfnWriteShort() + NULL, // pfnWriteLong() + NULL, // pfnWriteAngle() + NULL, // pfnWriteCoord() + mmWriteString, //! pfnWriteString() + NULL, // pfnWriteEntity() + + NULL, // pfnCVarRegister() + NULL, // pfnCVarGetFloat() + NULL, // pfnCVarGetString() + NULL, // pfnCVarSetFloat() + NULL, // pfnCVarSetString() + + NULL, // pfnAlertMessage() + NULL, // pfnEngineFprintf() + + NULL, // pfnPvAllocEntPrivateData() + NULL, // pfnPvEntPrivateData() + NULL, // pfnFreeEntPrivateData() + + NULL, // pfnSzFromIndex() + NULL, // pfnAllocString() + + NULL, // pfnGetVarsOfEnt() + NULL, // pfnPEntityOfEntOffset() + NULL, // pfnEntOffsetOfPEntity() + NULL, // pfnIndexOfEdict() + NULL, // pfnPEntityOfEntIndex() + NULL, // pfnFindEntityByVars() + NULL, // pfnGetModelPtr() + + NULL, // pfnRegUserMsg() + + NULL, // pfnAnimationAutomove() + NULL, // pfnGetBonePosition() + + NULL, // pfnFunctionFromName() + NULL, // pfnNameForFunction() + + NULL, // pfnClientPrintf() + NULL, // pfnServerPrint() + + NULL, // pfnCmd_Args() + NULL, // pfnCmd_Argv() + NULL, // pfnCmd_Argc() + + NULL, // pfnGetAttachment() + + NULL, // pfnCRC32_Init() + NULL, // pfnCRC32_ProcessBuffer() + NULL, // pfnCRC32_ProcessByte() + NULL, // pfnCRC32_Final() + + NULL, // pfnRandomLong() + NULL, // pfnRandomFloat() + + NULL, // pfnSetView() + NULL, // pfnTime() + NULL, // pfnCrosshairAngle() + + NULL, // pfnLoadFileForMe() + NULL, // pfnFreeFile() + + NULL, // pfnEndSection() + NULL, // pfnCompareFileTime() + NULL, // pfnGetGameDir() + NULL, // pfnCvar_RegisterVariable() + NULL, // pfnFadeClientVolume() + NULL, // pfnSetClientMaxspeed() + NULL, // pfnCreateFakeClient() + NULL, // pfnRunPlayerMove() + NULL, // pfnNumberOfEntities() + + NULL, // pfnGetInfoKeyBuffer() + NULL, // pfnInfoKeyValue() + NULL, // pfnSetKeyValue() + NULL, // pfnSetClientKeyValue() + + NULL, // pfnIsMapValid() + NULL, // pfnStaticDecal() + NULL, // pfnPrecacheGeneric() + NULL, // pfnGetPlayerUserId() + NULL, // pfnBuildSoundMsg() + NULL, // pfnIsDedicatedServer() + NULL, // pfnCVarGetPointer() + NULL, // pfnGetPlayerWONId() + + NULL, // pfnInfo_RemoveKey() + NULL, // pfnGetPhysicsKeyValue() + NULL, // pfnSetPhysicsKeyValue() + NULL, // pfnGetPhysicsInfoString() + NULL, // pfnPrecacheEvent() + NULL, // pfnPlaybackEvent() + + NULL, // pfnSetFatPVS() + NULL, // pfnSetFatPAS() + + NULL, // pfnCheckVisibility() + + NULL, // pfnDeltaSetField() + NULL, // pfnDeltaUnsetField() + NULL, // pfnDeltaAddEncoder() + NULL, // pfnGetCurrentPlayer() + NULL, // pfnCanSkipPlayer() + NULL, // pfnDeltaFindField() + NULL, // pfnDeltaSetFieldByIndex() + NULL, // pfnDeltaUnsetFieldByIndex() + + NULL, // pfnSetGroupMask() + + NULL, // pfnCreateInstancedBaseline() + NULL, // pfnCvar_DirectSet() + + NULL, // pfnForceUnmodified() + + NULL, // pfnGetPlayerStats() + + NULL, // pfnAddServerCommand() + + NULL, // pfnVoice_GetClientListening() + NULL, // pfnVoice_SetClientListening() + + NULL, // pfnGetPlayerAuthId() + + NULL, // pfnSequenceGet() + NULL, // pfnSequencePickSentence() + NULL, // pfnGetFileSize() + NULL, // pfnGetApproxWavePlayLen() + NULL, // pfnIsCareerMatch() + NULL, // pfnGetLocalizedStringLength() + NULL, // pfnRegisterTutorMessageShown() + NULL, // pfnGetTimesTutorMessageShown() + NULL, // pfnProcessTutorMessageDecayBuffer() + NULL, // pfnConstructTutorMessageDecayBuffer() + NULL, // pfnResetTutorMessageDecayData() + NULL, // pfnQueryClientCvarValue() + NULL, // pfnQueryClientCvarValue2() + NULL, // pfnEngCheckParm() +}; + +C_DLLEXPORT int GetEngineFunctions(enginefuncs_t *pengfuncsFromEngine, int *interfaceVersion) +{ + if(!pengfuncsFromEngine) + { + LOG_ERROR(PLID, "GetEngineFunctions called with null pengfuncsFromEngine"); + return(FALSE); + } + else if(*interfaceVersion != ENGINE_INTERFACE_VERSION) + { + LOG_ERROR(PLID, "GetEngineFunctions version mismatch; requested=%d ours=%d", *interfaceVersion, ENGINE_INTERFACE_VERSION); + // Tell metamod what version we had, so it can figure out who is + // out of date. + *interfaceVersion = ENGINE_INTERFACE_VERSION; + return(FALSE); + } + memcpy(pengfuncsFromEngine, &meta_engfuncs, sizeof(enginefuncs_t)); + return TRUE; +} + enginefuncs_t meta_engfuncs_post = { NULL, // pfnPrecacheModel() diff --git a/src/dlls/gargantua.cpp b/src/dlls/gargantua.cpp index f14a59f..41415a4 100755 --- a/src/dlls/gargantua.cpp +++ b/src/dlls/gargantua.cpp @@ -684,6 +684,8 @@ void CMGargantua :: Spawn() EyeOff(); m_seeTime = gpGlobals->time + 5; m_flameTime = gpGlobals->time + 2; + + pev->classname = MAKE_STRING( "monster_gargantua" ); } diff --git a/src/dlls/hassassin.cpp b/src/dlls/hassassin.cpp index 630d59d..7b84d10 100644 --- a/src/dlls/hassassin.cpp +++ b/src/dlls/hassassin.cpp @@ -230,6 +230,8 @@ void CMHAssassin :: Spawn() pev->rendermode = kRenderTransTexture; MonsterInit(); + + pev->classname = MAKE_STRING( "monster_human_assassin" ); } //========================================================= @@ -906,4 +908,4 @@ Schedule_t* CMHAssassin :: GetScheduleOfType ( int Type ) return CMBaseMonster :: GetScheduleOfType( Type ); } -#endif \ No newline at end of file +#endif diff --git a/src/dlls/headcrab.cpp b/src/dlls/headcrab.cpp index 8df3507..a912331 100644 --- a/src/dlls/headcrab.cpp +++ b/src/dlls/headcrab.cpp @@ -256,6 +256,8 @@ void CMHeadCrab :: Spawn() m_MonsterState = MONSTERSTATE_NONE; MonsterInit(); + + pev->classname = MAKE_STRING( "monster_headcrab" ); } //========================================================= diff --git a/src/dlls/hgrunt.cpp b/src/dlls/hgrunt.cpp index c860d90..317a0e1 100644 --- a/src/dlls/hgrunt.cpp +++ b/src/dlls/hgrunt.cpp @@ -886,6 +886,8 @@ void CMHGrunt :: Spawn() CMTalkMonster::g_talkWaitTime = 0; MonsterInit(); + + pev->classname = MAKE_STRING( "monster_human_grunt" ); } //========================================================= diff --git a/src/dlls/houndeye.cpp b/src/dlls/houndeye.cpp index ca27db1..b4dbeb0 100644 --- a/src/dlls/houndeye.cpp +++ b/src/dlls/houndeye.cpp @@ -277,6 +277,8 @@ void CMHoundeye :: Spawn() m_fDontBlink = FALSE; MonsterInit(); + + pev->classname = MAKE_STRING( "monster_houndeye" ); } //========================================================= diff --git a/src/dlls/islave.cpp b/src/dlls/islave.cpp index 1970110..2b1ff93 100644 --- a/src/dlls/islave.cpp +++ b/src/dlls/islave.cpp @@ -429,10 +429,11 @@ void CMISlave :: Spawn() for (int i = 0; i < ISLAVE_MAX_BEAMS; i++) m_pBeam[i] = NULL; - m_iBravery = 0; - m_flNextAttack = 0.0f; + m_iBravery = 0; + m_flNextAttack = 0.0f; MonsterInit(); + pev->classname = MAKE_STRING( "monster_alien_slave" ); } //========================================================= diff --git a/src/dlls/monster_api.cpp b/src/dlls/monster_api.cpp index e37ccff..746501b 100644 --- a/src/dlls/monster_api.cpp +++ b/src/dlls/monster_api.cpp @@ -48,7 +48,7 @@ static META_FUNCTIONS gMetaFunctionTable = GetEntityAPI2_Post, // pfnGetEntityAPI2_Post META; called after game DLL NULL, // pfnGetNewDLLFunctions HL SDK2; called before game DLL NULL, // pfnGetNewDLLFunctions_Post META; called after game DLL - NULL, // pfnGetEngineFunctions META; called before HL engine + GetEngineFunctions, // pfnGetEngineFunctions META; called before HL engine GetEngineFunctions_Post, // pfnGetEngineFunctions_Post META; called after HL engine }; @@ -57,7 +57,7 @@ plugin_info_t Plugin_info = { META_INTERFACE_VERSION, // interface version "MonsterMod", // name "2-prerelease", // version - "18/03/2020", // date in DD/MM/YYYY format + "01/06/2020", // 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/scientist.cpp b/src/dlls/scientist.cpp index c761169..39a9a4a 100644 --- a/src/dlls/scientist.cpp +++ b/src/dlls/scientist.cpp @@ -616,6 +616,8 @@ void CMScientist :: Spawn( void ) pev->skin = 1; MonsterInit(); + + pev->classname = MAKE_STRING( "monster_scientist" ); } //========================================================= diff --git a/src/dlls/squeakgrenade.cpp b/src/dlls/squeakgrenade.cpp index 81675b9..60581a6 100644 --- a/src/dlls/squeakgrenade.cpp +++ b/src/dlls/squeakgrenade.cpp @@ -84,6 +84,8 @@ void CMSqueakGrenade :: Spawn( void ) ResetSequenceInfo( ); m_hEnemy = NULL; + + pev->classname = MAKE_STRING( "monster_snark" ); } void CMSqueakGrenade::Precache( void ) @@ -334,4 +336,4 @@ void CMSqueakGrenade::SuperBounceTouch( edict_t *pOther ) #endif -#endif \ No newline at end of file +#endif diff --git a/src/dlls/turret.cpp b/src/dlls/turret.cpp index 730a32a..4c9fe0f 100755 --- a/src/dlls/turret.cpp +++ b/src/dlls/turret.cpp @@ -142,6 +142,8 @@ void CMTurret::Spawn() m_eyeBrightness = 0; pev->nextthink = gpGlobals->time + 0.3; + + pev->classname = MAKE_STRING( "monster_turret" ); } void CMTurret::Precache() @@ -166,8 +168,10 @@ void CMMiniTurret::Spawn() m_iMinPitch = -15; UTIL_SetSize(pev, Vector(-16, -16, -m_iRetractHeight), Vector(16, 16, m_iRetractHeight)); - SetThink(&CMMiniTurret::Initialize); - pev->nextthink = gpGlobals->time + 0.3; + SetThink(&CMMiniTurret::Initialize); + pev->nextthink = gpGlobals->time + 0.3; + + pev->classname = MAKE_STRING( "monster_miniturret" ); } @@ -1006,8 +1010,10 @@ void CMSentry::Spawn() UTIL_SetSize(pev, Vector(-16, -16, -m_iRetractHeight), Vector(16, 16, m_iRetractHeight)); SetTouch(&CMSentry::SentryTouch); - SetThink(&CMSentry::Initialize); - pev->nextthink = gpGlobals->time + 0.3; + SetThink(&CMSentry::Initialize); + pev->nextthink = gpGlobals->time + 0.3; + + pev->classname = MAKE_STRING( "monster_sentry" ); } void CMSentry::Shoot(Vector &vecSrc, Vector &vecDirToEnemy) diff --git a/src/dlls/util.cpp b/src/dlls/util.cpp index 493de7a..360a34a 100644 --- a/src/dlls/util.cpp +++ b/src/dlls/util.cpp @@ -1761,7 +1761,7 @@ int UTIL_TakeDamage( edict_t *pEdict, entvars_t *pevInflictor, entvars_t *pevAtt if ( pEdict->v.health <= 0 ) { pEdict->v.health = 1; // can't suicide if already dead! - gpGamedllFuncs->dllapi_table->pfnClientKill(pEdict); + gpGamedllFuncs->dllapi_table->pfnClientKill(pEdict); } // tell director about it diff --git a/src/dlls/zombie.cpp b/src/dlls/zombie.cpp index 721171f..9755be9 100644 --- a/src/dlls/zombie.cpp +++ b/src/dlls/zombie.cpp @@ -254,6 +254,8 @@ void CMZombie :: Spawn() m_afCapability = bits_CAP_DOORS_GROUP; MonsterInit(); + + pev->classname = MAKE_STRING( "monster_zombie" ); } //========================================================= @@ -313,4 +315,4 @@ int CMZombie::IgnoreConditions ( void ) return iIgnore; -} \ No newline at end of file +}