Use monster classname for player deaths.

This commit is contained in:
Julian
2020-06-01 17:10:52 -03:00
parent 5c275e5b62
commit d39bc85ab6
19 changed files with 307 additions and 19 deletions

View File

@@ -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" );
}
//=========================================================

View File

@@ -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
#endif

View File

@@ -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" );
}
//=========================================================

View File

@@ -610,6 +610,8 @@ void CMBigMomma :: Spawn()
m_MonsterState = MONSTERSTATE_NONE;
MonsterInit();
pev->classname = MAKE_STRING( "monster_bigmomma" );
}
//=========================================================

View File

@@ -617,6 +617,8 @@ void CMBullsquid :: Spawn()
m_flNextSpitTime = gpGlobals->time;
MonsterInit();
pev->classname = MAKE_STRING( "monster_bullchicken" );
}
//=========================================================

View File

@@ -310,6 +310,8 @@ void CMController :: Spawn()
m_MonsterState = MONSTERSTATE_NONE;
MonsterInit();
pev->classname = MAKE_STRING( "monster_alien_controller" );
}
//=========================================================

View File

@@ -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()

View File

@@ -684,6 +684,8 @@ void CMGargantua :: Spawn()
EyeOff();
m_seeTime = gpGlobals->time + 5;
m_flameTime = gpGlobals->time + 2;
pev->classname = MAKE_STRING( "monster_gargantua" );
}

View File

@@ -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
#endif

View File

@@ -256,6 +256,8 @@ void CMHeadCrab :: Spawn()
m_MonsterState = MONSTERSTATE_NONE;
MonsterInit();
pev->classname = MAKE_STRING( "monster_headcrab" );
}
//=========================================================

View File

@@ -886,6 +886,8 @@ void CMHGrunt :: Spawn()
CMTalkMonster::g_talkWaitTime = 0;
MonsterInit();
pev->classname = MAKE_STRING( "monster_human_grunt" );
}
//=========================================================

View File

@@ -277,6 +277,8 @@ void CMHoundeye :: Spawn()
m_fDontBlink = FALSE;
MonsterInit();
pev->classname = MAKE_STRING( "monster_houndeye" );
}
//=========================================================

View File

@@ -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" );
}
//=========================================================

View File

@@ -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

View File

@@ -616,6 +616,8 @@ void CMScientist :: Spawn( void )
pev->skin = 1;
MonsterInit();
pev->classname = MAKE_STRING( "monster_scientist" );
}
//=========================================================

View File

@@ -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
#endif

View File

@@ -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)

View File

@@ -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

View File

@@ -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;
}
}