Stop allied monsters from attacking the player.
Part B of making MonsterMod aware of normal HL entities.
This commit is contained in:
@@ -1154,11 +1154,8 @@ void RadiusDamage( Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacke
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!UTIL_IsPlayer(pEntity))
|
else
|
||||||
{
|
{
|
||||||
// I'm doing really bad copypastes instead of making the code clean!
|
|
||||||
// Remind me to refactor this, this is not how this is supposed to be written!
|
|
||||||
// -Giegue
|
|
||||||
edict_t *pMonster = pEntity;
|
edict_t *pMonster = pEntity;
|
||||||
|
|
||||||
if ( iClassIgnore != CLASS_NONE && pMonster->v.iuser4 == iClassIgnore )
|
if ( iClassIgnore != CLASS_NONE && pMonster->v.iuser4 == iClassIgnore )
|
||||||
@@ -1260,7 +1257,7 @@ edict_t* CMBaseMonster :: CheckTraceHullAttack( float flDist, int iDamage, int i
|
|||||||
CMBaseMonster *pMonster = GetClassPtr((CMBaseMonster *)VARS(pEntity));
|
CMBaseMonster *pMonster = GetClassPtr((CMBaseMonster *)VARS(pEntity));
|
||||||
pMonster->TakeDamage( pev, pev, iDamage, iDmgType );
|
pMonster->TakeDamage( pev, pev, iDamage, iDmgType );
|
||||||
}
|
}
|
||||||
else if (!UTIL_IsPlayer(pEntity))
|
else
|
||||||
UTIL_TakeDamageExternal( pEntity, pev, pev, iDamage, iDmgType );
|
UTIL_TakeDamageExternal( pEntity, pev, pev, iDamage, iDmgType );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1571,7 +1568,7 @@ void CMBaseEntity::FireBullets(ULONG cShots, Vector vecSrc, Vector vecDirShootin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!UTIL_IsPlayer(tr.pHit)) // normal game monster
|
else // normal game entity
|
||||||
{
|
{
|
||||||
edict_t *pMonster = tr.pHit;
|
edict_t *pMonster = tr.pHit;
|
||||||
|
|
||||||
|
|||||||
@@ -326,11 +326,10 @@ void CMHornet :: TrackTouch ( edict_t *pOther )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// is this NOT a player and IS a monster?
|
// is this NOT a player and IS a monster?
|
||||||
if (!UTIL_IsPlayer(pOther) && (pOther->v.euser4 != NULL))
|
if (!UTIL_IsPlayer(pOther) && (pOther->v.flags & FL_MONSTER))
|
||||||
{
|
{
|
||||||
CMBaseMonster *pMonster = GetClassPtr((CMBaseMonster *)VARS(pOther));
|
CMBaseMonster *pMonster = GetClassPtr((CMBaseMonster *)VARS(pOther));
|
||||||
|
if ( pMonster != NULL && IRelationship( pMonster ) <= R_NO || IRelationshipByClass( pOther->v.iuser4 ) <= R_NO )
|
||||||
if ( IRelationship( pMonster ) <= R_NO )
|
|
||||||
{
|
{
|
||||||
// hit something we don't want to hurt, so turn around.
|
// hit something we don't want to hurt, so turn around.
|
||||||
|
|
||||||
|
|||||||
@@ -56,8 +56,8 @@ static META_FUNCTIONS gMetaFunctionTable =
|
|||||||
plugin_info_t Plugin_info = {
|
plugin_info_t Plugin_info = {
|
||||||
META_INTERFACE_VERSION, // interface version
|
META_INTERFACE_VERSION, // interface version
|
||||||
"MonsterMod", // name
|
"MonsterMod", // name
|
||||||
"2.0", // version
|
"3.0-dev", // version
|
||||||
"03/06/2020", // date in DD/MM/YYYY format
|
"15/02/2023", // date in DD/MM/YYYY format
|
||||||
"botman, Rick90, Giegue", // original authors + recreation by...
|
"botman, Rick90, Giegue", // original authors + recreation by...
|
||||||
"https://github.com/JulianR0/monstermod-redo", // url
|
"https://github.com/JulianR0/monstermod-redo", // url
|
||||||
"MONSTER", // logtag
|
"MONSTER", // logtag
|
||||||
|
|||||||
@@ -274,6 +274,10 @@ SOURCE=.\strooper.cpp
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\stukabat.cpp
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=.\subs.cpp
|
SOURCE=.\subs.cpp
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|||||||
@@ -207,7 +207,7 @@ void CMBaseMonster :: Look ( int iDistance )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!UTIL_IsPlayer(pSightEnt))
|
else
|
||||||
{
|
{
|
||||||
/* MonsterMod monster looking at a NON-MonsterMod monster */
|
/* MonsterMod monster looking at a NON-MonsterMod monster */
|
||||||
|
|
||||||
@@ -2085,13 +2085,26 @@ edict_t *CMBaseMonster :: BestVisibleEnemy ( void )
|
|||||||
if ( UTIL_IsPlayer(pEnt) )
|
if ( UTIL_IsPlayer(pEnt) )
|
||||||
{
|
{
|
||||||
// it's a player...
|
// it's a player...
|
||||||
iDist = ( pEnt->v.origin - pev->origin ).Length();
|
if ( UTIL_IsAlive(pEnt) )
|
||||||
|
|
||||||
if ( iDist <= iNearest )
|
|
||||||
{
|
{
|
||||||
iNearest = iDist;
|
// repeat2
|
||||||
iBestRelationship = R_NM; // player is always nemesis
|
if ( IRelationshipByClass( CLASS_PLAYER ) > iBestRelationship )
|
||||||
pReturn = pEnt;
|
{
|
||||||
|
iBestRelationship = IRelationshipByClass( CLASS_PLAYER );
|
||||||
|
iNearest = ( pEnt->v.origin - pev->origin ).Length();
|
||||||
|
pReturn = pEnt;
|
||||||
|
}
|
||||||
|
else if ( IRelationshipByClass( CLASS_PLAYER ) == iBestRelationship )
|
||||||
|
{
|
||||||
|
iDist = ( pEnt->v.origin - pev->origin ).Length();
|
||||||
|
|
||||||
|
if ( iDist <= iNearest )
|
||||||
|
{
|
||||||
|
iNearest = iDist;
|
||||||
|
iBestRelationship = IRelationshipByClass( CLASS_PLAYER );
|
||||||
|
pReturn = pEnt;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (pEnt->v.euser4 != NULL)
|
else if (pEnt->v.euser4 != NULL)
|
||||||
@@ -2125,12 +2138,12 @@ edict_t *CMBaseMonster :: BestVisibleEnemy ( void )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!UTIL_IsPlayer(pEnt))
|
else
|
||||||
{
|
{
|
||||||
// it's a game default monster...
|
// it's a normal game entity...
|
||||||
if ( UTIL_IsAlive(pEnt) )
|
if ( UTIL_IsAlive(pEnt) )
|
||||||
{
|
{
|
||||||
//repeat2
|
//repeat3
|
||||||
if ( IRelationship( pEnt->v.iuser4 ) > iBestRelationship )
|
if ( IRelationship( pEnt->v.iuser4 ) > iBestRelationship )
|
||||||
{
|
{
|
||||||
iBestRelationship = IRelationship( pEnt->v.iuser4 );
|
iBestRelationship = IRelationship( pEnt->v.iuser4 );
|
||||||
@@ -2959,8 +2972,13 @@ BOOL CMBaseMonster :: GetEnemy ( void )
|
|||||||
if (HasConditions(bits_COND_SEE_CLIENT) && (m_hEnemy == NULL))
|
if (HasConditions(bits_COND_SEE_CLIENT) && (m_hEnemy == NULL))
|
||||||
{
|
{
|
||||||
m_hEnemy = BestVisibleEnemy();
|
m_hEnemy = BestVisibleEnemy();
|
||||||
m_hTargetEnt = m_hEnemy;
|
|
||||||
m_vecEnemyLKP = m_hEnemy->v.origin;
|
// the player we've just seen might not always be our enemy
|
||||||
|
if ( m_hEnemy != NULL )
|
||||||
|
{
|
||||||
|
m_hTargetEnt = m_hEnemy;
|
||||||
|
m_vecEnemyLKP = m_hEnemy->v.origin;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// remember old enemies
|
// remember old enemies
|
||||||
|
|||||||
@@ -1540,10 +1540,10 @@ bool UTIL_IsPlayer(edict_t *pEdict)
|
|||||||
|
|
||||||
Vector UTIL_BodyTarget(edict_t *pEdict, Vector posSrc)
|
Vector UTIL_BodyTarget(edict_t *pEdict, Vector posSrc)
|
||||||
{
|
{
|
||||||
if (pEdict->v.flags & FL_CLIENT)
|
if (pEdict->v.flags & FL_CLIENT)
|
||||||
return pEdict->v.origin + (pEdict->v.view_ofs * RANDOM_FLOAT(0.5, 1.1));
|
return pEdict->v.origin + (pEdict->v.view_ofs * RANDOM_FLOAT(0.5, 1.1));
|
||||||
else
|
else
|
||||||
return (pEdict->v.origin + ((pEdict->v.mins + pEdict->v.maxs) * 0.5));
|
return (pEdict->v.origin + ((pEdict->v.mins + pEdict->v.maxs) * 0.5));
|
||||||
}
|
}
|
||||||
|
|
||||||
//=========================================================
|
//=========================================================
|
||||||
@@ -1875,7 +1875,11 @@ void UTIL_TraceBleed( edict_t *pEdict, float flDamage, Vector vecDir, TraceResul
|
|||||||
|
|
||||||
if ( Bloodtr.flFraction != 1.0 )
|
if ( Bloodtr.flFraction != 1.0 )
|
||||||
{
|
{
|
||||||
UTIL_BloodDecalTrace( &Bloodtr, BLOOD_COLOR_RED );
|
int bloodColor = pEdict->v.iuser3;
|
||||||
|
if ( !bloodColor )
|
||||||
|
bloodColor = BLOOD_COLOR_RED;
|
||||||
|
|
||||||
|
UTIL_BloodDecalTrace( &Bloodtr, bloodColor );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1886,9 +1890,13 @@ void UTIL_TraceAttack( edict_t *pEdict, entvars_t *pevAttacker, float flDamage,
|
|||||||
|
|
||||||
if ( pEdict->v.takedamage )
|
if ( pEdict->v.takedamage )
|
||||||
{
|
{
|
||||||
|
int bloodColor = pEdict->v.iuser3;
|
||||||
|
if ( !bloodColor )
|
||||||
|
bloodColor = BLOOD_COLOR_RED;
|
||||||
|
|
||||||
AddMultiDamage( pevAttacker, pEdict, flDamage, bitsDamageType );
|
AddMultiDamage( pevAttacker, pEdict, flDamage, bitsDamageType );
|
||||||
|
|
||||||
SpawnBlood(ptr->vecEndPos, BLOOD_COLOR_RED, flDamage);// a little surface blood.
|
SpawnBlood(ptr->vecEndPos, bloodColor, flDamage);// a little surface blood.
|
||||||
|
|
||||||
UTIL_TraceBleed( pEdict, flDamage, vecDir, ptr, bitsDamageType );
|
UTIL_TraceBleed( pEdict, flDamage, vecDir, ptr, bitsDamageType );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ void ApplyMultiDamage(entvars_t *pevInflictor, entvars_t *pevAttacker )
|
|||||||
CMBaseMonster *pMonster = GetClassPtr((CMBaseMonster *)VARS(gMultiDamage.pEntity));
|
CMBaseMonster *pMonster = GetClassPtr((CMBaseMonster *)VARS(gMultiDamage.pEntity));
|
||||||
pMonster->TakeDamage(pevInflictor, pevAttacker, gMultiDamage.amount, gMultiDamage.type );
|
pMonster->TakeDamage(pevInflictor, pevAttacker, gMultiDamage.amount, gMultiDamage.type );
|
||||||
}
|
}
|
||||||
else if (!UTIL_IsPlayer(gMultiDamage.pEntity))
|
else
|
||||||
UTIL_TakeDamageExternal(gMultiDamage.pEntity, pevInflictor, pevAttacker, gMultiDamage.amount, gMultiDamage.type );
|
UTIL_TakeDamageExternal(gMultiDamage.pEntity, pevInflictor, pevAttacker, gMultiDamage.amount, gMultiDamage.type );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user