Skip to content

Commit

Permalink
Updated team enum names for better readability.
Browse files Browse the repository at this point in the history
Streamlined the CS relationship function.
  • Loading branch information
jonnyboy0719 committed Dec 8, 2023
1 parent fdedc31 commit 93ded61
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 211 deletions.
42 changes: 1 addition & 41 deletions dlls/apache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1021,47 +1021,7 @@ void CApache::TraceAttack(entvars_t* pevAttacker, float flDamage, Vector vecDir,

int CApache::IRelationship(CBaseEntity* pTarget)
{
CSDSTeams target_team = CZero::GetEnemyTeam(pTarget);
switch ( pev->team )
{
case TEAM_CIV:
{
if ( target_team == TEAM_TERROR1 || target_team == TEAM_TERROR2 )
return R_FR;
else if ( target_team == TEAM_CIV || target_team == TEAM_CT )
return R_AL;
}
break;
case TEAM_CT:
{
if ( target_team == TEAM_TERROR1 || target_team == TEAM_TERROR2 )
return R_NM;
else if ( target_team == TEAM_CIV || target_team == TEAM_CT )
return R_AL;
}
break;
case TEAM_TERROR1:
{
if ( target_team == TEAM_TERROR2 || target_team == TEAM_CT )
return R_NM;
else if ( target_team == TEAM_TERROR1 )
return R_AL;
else if ( target_team == TEAM_CIV )
return R_NO;
}
break;
case TEAM_TERROR2:
{
if ( target_team == TEAM_TERROR1 || target_team == TEAM_CT )
return R_NM;
else if ( target_team == TEAM_TERROR2 )
return R_AL;
else if ( target_team == TEAM_CIV )
return R_NO;
}
break;
}
return R_DL;
return CZero::GetTeamRelationShip(this, pTarget);
}

bool CApache::KeyValue(KeyValueData* pkvd)
Expand Down
129 changes: 47 additions & 82 deletions dlls/czeror/czero_human_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,47 +27,7 @@ IMPLEMENT_SAVERESTORE(CZeroHumanBase, CHGrunt);

int CZeroHumanBase_Pistol::IRelationship(CBaseEntity* pTarget)
{
CSDSTeams target_team = CZero::GetEnemyTeam(pTarget);
switch ( pev->team )
{
case TEAM_CIV:
{
if ( target_team == TEAM_TERROR1 || target_team == TEAM_TERROR2 )
return R_FR;
else if ( target_team == TEAM_CIV || target_team == TEAM_CT )
return R_AL;
}
break;
case TEAM_CT:
{
if ( target_team == TEAM_TERROR1 || target_team == TEAM_TERROR2 )
return R_NM;
else if ( target_team == TEAM_CIV || target_team == TEAM_CT )
return R_AL;
}
break;
case TEAM_TERROR1:
{
if ( target_team == TEAM_TERROR2 || target_team == TEAM_CT )
return R_NM;
else if ( target_team == TEAM_TERROR1 )
return R_AL;
else if ( target_team == TEAM_CIV )
return R_NO;
}
break;
case TEAM_TERROR2:
{
if ( target_team == TEAM_TERROR1 || target_team == TEAM_CT )
return R_NM;
else if ( target_team == TEAM_TERROR2 )
return R_AL;
else if ( target_team == TEAM_CIV )
return R_NO;
}
break;
}
return R_NO;
return CZero::GetTeamRelationShip(this, pTarget);
}

void CZeroHumanBase_Pistol::TalkInit()
Expand Down Expand Up @@ -130,47 +90,7 @@ void CZeroHumanBase_Pistol::OnSentenceSay( BarneySay say )

int CZeroHumanBase::IRelationship(CBaseEntity* pTarget)
{
CSDSTeams target_team = CZero::GetEnemyTeam(pTarget);
switch ( pev->team )
{
case TEAM_CIV:
{
if ( target_team == TEAM_TERROR1 || target_team == TEAM_TERROR2 )
return R_FR;
else if ( target_team == TEAM_CIV || target_team == TEAM_CT )
return R_AL;
}
break;
case TEAM_CT:
{
if ( target_team == TEAM_TERROR1 || target_team == TEAM_TERROR2 )
return R_NM;
else if ( target_team == TEAM_CIV || target_team == TEAM_CT )
return R_AL;
}
break;
case TEAM_TERROR1:
{
if ( target_team == TEAM_TERROR2 || target_team == TEAM_CT )
return R_NM;
else if ( target_team == TEAM_TERROR1 )
return R_AL;
else if ( target_team == TEAM_CIV )
return R_NO;
}
break;
case TEAM_TERROR2:
{
if ( target_team == TEAM_TERROR1 || target_team == TEAM_CT )
return R_NM;
else if ( target_team == TEAM_TERROR2 )
return R_AL;
else if ( target_team == TEAM_CIV )
return R_NO;
}
break;
}
return R_DL;
return CZero::GetTeamRelationShip(this, pTarget);
}

void CZeroHumanBase::DeathSound()
Expand Down Expand Up @@ -309,3 +229,48 @@ CSDSTeams CZero::GetEnemyTeam(CBaseEntity* pEnemy)
return TEAM_CT;
return (CSDSTeams)pEnemy->pev->team;
}

int CZero::GetTeamRelationShip(CBaseEntity* me, CBaseEntity* target)
{
CSDSTeams target_team = CZero::GetEnemyTeam(target);
switch ( me->pev->team )
{
case TEAM_CIV:
{
if ( target_team == TEAM_TERROR_RUSSIAN || target_team == TEAM_TERROR_ARTIC )
return R_FR;
else if ( target_team == TEAM_CIV || target_team == TEAM_CT )
return R_AL;
}
break;
case TEAM_CT:
{
if ( target_team == TEAM_TERROR_RUSSIAN || target_team == TEAM_TERROR_ARTIC )
return R_NM;
else if ( target_team == TEAM_CIV || target_team == TEAM_CT )
return R_AL;
}
break;
case TEAM_TERROR_RUSSIAN:
{
if ( target_team == TEAM_TERROR_ARTIC || target_team == TEAM_CT )
return R_NM;
else if ( target_team == TEAM_TERROR_RUSSIAN )
return R_AL;
else if ( target_team == TEAM_CIV )
return R_NO;
}
break;
case TEAM_TERROR_ARTIC:
{
if ( target_team == TEAM_TERROR_RUSSIAN || target_team == TEAM_CT )
return R_NM;
else if ( target_team == TEAM_TERROR_ARTIC )
return R_AL;
else if ( target_team == TEAM_CIV )
return R_NO;
}
break;
}
return R_DL;
}
5 changes: 3 additions & 2 deletions dlls/czeror/czero_human_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,15 @@ enum CSDSTeams
{
TEAM_CT = 0, // Player ally (or player)
TEAM_CIV, // Civillian, ignored
TEAM_TERROR1, // Terror Team 1
TEAM_TERROR2, // Terror Team 2
TEAM_TERROR_RUSSIAN, // Terror Team 1 (terror_russian)
TEAM_TERROR_ARTIC, // Terror Team 2 (terror_artic)
};

namespace CZero
{
const char *GetVoiceLang( const char *szSentence, CSDSLanguage lang, CSDSTeamVoice team );
CSDSTeams GetEnemyTeam(CBaseEntity* pEnemy);
int GetTeamRelationShip(CBaseEntity *me, CBaseEntity *target);
}

class CZeroHumanBase_Pistol : public CBarney
Expand Down
4 changes: 2 additions & 2 deletions dlls/czeror/terror_arctic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void CTerrorArtic_Pistol::StartMonster()

void CTerrorArtic_Pistol::Spawn()
{
pev->team = CSDSTeams::TEAM_TERROR2;
pev->team = CSDSTeams::TEAM_TERROR_ARTIC;
m_VoiceLang = CSDSLanguage::LANG_RU;
m_TeamVoice = CSDSTeamVoice::VOICE_T;
UTIL_SetSize(pev, _tinyhull, _tinyhull);
Expand Down Expand Up @@ -138,7 +138,7 @@ void CTerrorArtic_Grunt::StartMonster()

void CTerrorArtic_Grunt::Spawn()
{
pev->team = CSDSTeams::TEAM_TERROR2;
pev->team = CSDSTeams::TEAM_TERROR_ARTIC;
m_VoiceLang = CSDSLanguage::LANG_RU;
m_TeamVoice = CSDSTeamVoice::VOICE_T;
UTIL_SetSize(pev, _tinyhull, _tinyhull);
Expand Down
4 changes: 2 additions & 2 deletions dlls/czeror/terror_russian.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void CTerrorRussian_Pistol::StartMonster()

void CTerrorRussian_Pistol::Spawn()
{
pev->team = CSDSTeams::TEAM_TERROR1;
pev->team = CSDSTeams::TEAM_TERROR_RUSSIAN;
m_VoiceLang = CSDSLanguage::LANG_RU;
m_TeamVoice = CSDSTeamVoice::VOICE_T;
UTIL_SetSize(pev, _tinyhull, _tinyhull);
Expand Down Expand Up @@ -139,7 +139,7 @@ void CTerrorRussian_Grunt::StartMonster()

void CTerrorRussian_Grunt::Spawn()
{
pev->team = CSDSTeams::TEAM_TERROR1;
pev->team = CSDSTeams::TEAM_TERROR_RUSSIAN;
m_VoiceLang = CSDSLanguage::LANG_RU;
m_TeamVoice = CSDSTeamVoice::VOICE_T;
UTIL_SetSize(pev, _tinyhull, _tinyhull);
Expand Down
42 changes: 1 addition & 41 deletions dlls/osprey.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -796,47 +796,7 @@ void COsprey::Update()

int COsprey::IRelationship(CBaseEntity* pTarget)
{
CSDSTeams target_team = CZero::GetEnemyTeam(pTarget);
switch ( pev->team )
{
case TEAM_CIV:
{
if ( target_team == TEAM_TERROR1 || target_team == TEAM_TERROR2 )
return R_FR;
else if ( target_team == TEAM_CIV || target_team == TEAM_CT )
return R_AL;
}
break;
case TEAM_CT:
{
if ( target_team == TEAM_TERROR1 || target_team == TEAM_TERROR2 )
return R_NM;
else if ( target_team == TEAM_CIV || target_team == TEAM_CT )
return R_AL;
}
break;
case TEAM_TERROR1:
{
if ( target_team == TEAM_TERROR2 || target_team == TEAM_CT )
return R_NM;
else if ( target_team == TEAM_TERROR1 )
return R_AL;
else if ( target_team == TEAM_CIV )
return R_NO;
}
break;
case TEAM_TERROR2:
{
if ( target_team == TEAM_TERROR1 || target_team == TEAM_CT )
return R_NM;
else if ( target_team == TEAM_TERROR2 )
return R_AL;
else if ( target_team == TEAM_CIV )
return R_NO;
}
break;
}
return R_DL;
return CZero::GetTeamRelationShip(this, pTarget);
}

bool COsprey::KeyValue(KeyValueData* pkvd)
Expand Down
42 changes: 1 addition & 41 deletions dlls/turret.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1152,47 +1152,7 @@ int CBaseTurret::Classify()

int CBaseTurret::IRelationship(CBaseEntity* pTarget)
{
CSDSTeams target_team = CZero::GetEnemyTeam(pTarget);
switch ( pev->team )
{
case TEAM_CIV:
{
if ( target_team == TEAM_TERROR1 || target_team == TEAM_TERROR2 )
return R_FR;
else if ( target_team == TEAM_CIV || target_team == TEAM_CT )
return R_AL;
}
break;
case TEAM_CT:
{
if ( target_team == TEAM_TERROR1 || target_team == TEAM_TERROR2 )
return R_NM;
else if ( target_team == TEAM_CIV || target_team == TEAM_CT )
return R_AL;
}
break;
case TEAM_TERROR1:
{
if ( target_team == TEAM_TERROR2 || target_team == TEAM_CT )
return R_NM;
else if ( target_team == TEAM_TERROR1 )
return R_AL;
else if ( target_team == TEAM_CIV )
return R_NO;
}
break;
case TEAM_TERROR2:
{
if ( target_team == TEAM_TERROR1 || target_team == TEAM_CT )
return R_NM;
else if ( target_team == TEAM_TERROR2 )
return R_AL;
else if ( target_team == TEAM_CIV )
return R_NO;
}
break;
}
return R_DL;
return CZero::GetTeamRelationShip(this, pTarget);
}


Expand Down

0 comments on commit 93ded61

Please sign in to comment.