From e42999bc4e1c17b6790f631df0550472e2ca3f4b Mon Sep 17 00:00:00 2001 From: mittorn Date: Tue, 27 Sep 2016 19:59:29 +0000 Subject: [PATCH] Coop imporvements --- dlls/client.cpp | 5 +++++ dlls/combat.cpp | 17 +++++++++++++++-- dlls/effects.cpp | 9 +++++++++ dlls/multiplay_gamerules.cpp | 6 ++++++ dlls/player.cpp | 25 +++++++++++++++++++------ dlls/triggers.cpp | 9 +++++++-- dlls/util.cpp | 16 ++++++++++++++++ dlls/util.h | 1 + 8 files changed, 78 insertions(+), 10 deletions(-) diff --git a/dlls/client.cpp b/dlls/client.cpp index b730778b..ffc83b94 100644 --- a/dlls/client.cpp +++ b/dlls/client.cpp @@ -492,6 +492,11 @@ void ClientCommand( edict_t *pEntity ) if ( g_flWeaponCheat != 0.0 ) DumpProps(); } + else if( FStrEq(pcmd, "unblock") ) + { + if ( mp_coop.value ) + UTIL_CleanSpawnPoint( pev->origin, 150 ); + } else { // tell the user they entered an unknown command diff --git a/dlls/combat.cpp b/dlls/combat.cpp index 4decf69f..5c50c192 100644 --- a/dlls/combat.cpp +++ b/dlls/combat.cpp @@ -592,6 +592,7 @@ void CBaseMonster::Killed( entvars_t *pevAttacker, int iGib ) { unsigned int cCount = 0; BOOL fDone = FALSE; + int classs = Classify(); if( HasMemory( bits_MEMORY_KILLED ) ) { @@ -603,8 +604,20 @@ void CBaseMonster::Killed( entvars_t *pevAttacker, int iGib ) Remember( bits_MEMORY_KILLED ); CBaseEntity *activator = CBaseEntity::Instance( pevAttacker ); - if( activator && activator->IsPlayer() ) - activator->AddPoints( 1, true ); + if( classs == CLASS_HUMAN_PASSIVE || classs == CLASS_PLAYER_ALLY ) + { + if( activator && activator->IsPlayer() ) + { + activator->pev->frags -= 30; + activator->AddPoints( 0, true ); + activator->pev->frags -= 50; + } + } + else if( classs >= 5 ) + { + if( activator && activator->IsPlayer() ) + activator->AddPoints( 1, true ); + } // clear the deceased's sound channels.(may have been firing or reloading when killed) EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "common/null.wav", 1, ATTN_NORM ); diff --git a/dlls/effects.cpp b/dlls/effects.cpp index 65306fc6..e5218ffa 100644 --- a/dlls/effects.cpp +++ b/dlls/effects.cpp @@ -1944,6 +1944,15 @@ void CFade::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType if( pev->spawnflags & SF_FADE_MODULATE ) fadeFlags |= FFADE_MODULATE; + if( mp_coop.value ) + { + if( pev->dmg_take > 1 ) + pev->dmg_take = 1; + + if( pev->dmg_save > 1 ) + pev->dmg_save = 1; + } + if( mp_coop.value || pev->spawnflags & SF_FADE_ONLYONE ) { if( !pActivator || pActivator->IsNetClient() ) diff --git a/dlls/multiplay_gamerules.cpp b/dlls/multiplay_gamerules.cpp index bd3fb28e..be100079 100644 --- a/dlls/multiplay_gamerules.cpp +++ b/dlls/multiplay_gamerules.cpp @@ -645,6 +645,12 @@ void CHalfLifeMultiplay::PlayerKilled( CBasePlayer *pVictim, entvars_t *pKiller, else // if a player dies in a deathmatch game and the killer is a client, award the killer some points pKiller->frags += IPointsForKill( peKiller, pVictim ); + if( pKiller->frags < -50 ) + { + char cmd[10] = {}; + snprintf( cmd, 10, "kick %d\n", ENTINDEX(pKiller->pContainingEntity) - 1 ); + SERVER_COMMAND( cmd ); + } FireTargets( "game_playerkill", ktmp, ktmp, USE_TOGGLE, 0 ); } diff --git a/dlls/player.cpp b/dlls/player.cpp index 2f67ac2f..637d96b2 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -1586,6 +1586,12 @@ void CBasePlayer::AddPoints( int score, BOOL bAllowNegativeScore ) } pev->frags += score; + if( pev->frags < -50 ) + { + char cmd[10] = {}; + snprintf( cmd, 10, "kick %d\n", ENTINDEX(pev->pContainingEntity) - 1 ); + SERVER_COMMAND( cmd ); + } MESSAGE_BEGIN( MSG_ALL, gmsgScoreInfo ); WRITE_BYTE( ENTINDEX( edict() ) ); @@ -2649,14 +2655,21 @@ edict_t *EntSelectSpawnPoint( CBaseEntity *pPlayer ) // we haven't found a place to spawn yet, so kill any guy at the first spawn point and spawn there if( !FNullEnt( pSpot ) ) { - CBaseEntity *ent = NULL; - while( ( ent = UTIL_FindEntityInSphere( ent, pSpot->pev->origin, 128 ) ) != NULL ) + if( mp_coop.value ) { - // if ent is a client, kill em (unless they are ourselves) - if( ent->IsPlayer() && !(ent->edict() == player) ) - ent->TakeDamage( VARS( INDEXENT( 0 ) ), VARS( INDEXENT( 0 ) ), 300, DMG_GENERIC ); + UTIL_CleanSpawnPoint( pSpot->pev->origin, 128 ); + } + else + { + CBaseEntity *ent = NULL; + while( ( ent = UTIL_FindEntityInSphere( ent, pSpot->pev->origin, 128 ) ) != NULL ) + { + // if ent is a client, kill em (unless they are ourselves) + if( ent->IsPlayer() && !(ent->edict() == player) ) + ent->TakeDamage( VARS( INDEXENT( 0 ) ), VARS( INDEXENT( 0 ) ), 300, DMG_GENERIC ); + } + goto ReturnSpot; } - goto ReturnSpot; } } diff --git a/dlls/triggers.cpp b/dlls/triggers.cpp index b9d51ca3..2807a445 100644 --- a/dlls/triggers.cpp +++ b/dlls/triggers.cpp @@ -27,6 +27,7 @@ #include "saverestore.h" #include "trains.h" // trigger_camera has train functionality #include "gamerules.h" +#include "game.h" #define SF_TRIGGER_PUSH_START_OFF 2//spawnflag that makes trigger_push spawn turned OFF #define SF_TRIGGER_HURT_TARGETONCE 1// Only fire hurt target once @@ -78,8 +79,11 @@ void CFrictionModifier::Spawn( void ) // Sets toucher's friction to m_frictionFraction (1.0 = normal friction) void CFrictionModifier::ChangeFriction( CBaseEntity *pOther ) { - if( pOther->pev->movetype != MOVETYPE_BOUNCEMISSILE && pOther->pev->movetype != MOVETYPE_BOUNCE ) - pOther->pev->friction = m_frictionFraction; + if( !mp_coop.value ) + { + if( pOther->pev->movetype != MOVETYPE_BOUNCEMISSILE && pOther->pev->movetype != MOVETYPE_BOUNCE ) + pOther->pev->friction = m_frictionFraction; + } } // Sets toucher's friction to m_frictionFraction (1.0 = normal friction) @@ -1878,6 +1882,7 @@ void CBaseTrigger::TeleportTouch( CBaseEntity *pOther ) Vector tmp = VARS( pentTarget )->origin; + UTIL_CleanSpawnPoint( tmp, 150 ); if( pOther->IsPlayer() ) { tmp.z -= pOther->pev->mins.z;// make origin adjustments in case the teleportee is a player. (origin in center, not at feet) diff --git a/dlls/util.cpp b/dlls/util.cpp index 47eaf2f8..b6eaee70 100644 --- a/dlls/util.cpp +++ b/dlls/util.cpp @@ -1578,6 +1578,22 @@ void UTIL_StripToken( const char *pKey, char *pDest ) pDest[i] = 0; } +void UTIL_CleanSpawnPoint( Vector origin, float dist ) +{ + CBaseEntity *ent = NULL; + while( ( ent = UTIL_FindEntityInSphere( ent, origin, dist ) ) != NULL ) + { + if( ent->IsPlayer() ) + { + TraceResult tr = {0}; + UTIL_TraceHull( ent->pev->origin + Vector( 0, 0, 36), ent->pev->origin + Vector( RANDOM_FLOAT( -150, 150 ), RANDOM_FLOAT( -150, 150 ), 0 ), dont_ignore_monsters, human_hull, ent->edict(), &tr); + //UTIL_TraceModel( ent->pev->origin + Vector( 0, 0, 36), ent->pev->origin + Vector( RANDOM_FLOAT( -150, 150 ), RANDOM_FLOAT( -150, 150 ), 0 ), 0, ent->edict(), &tr); + + UTIL_SetOrigin(ent->pev, tr.vecEndPos); + } + } +} + // -------------------------------------------------------------- // // CSave diff --git a/dlls/util.h b/dlls/util.h index 8b4ecf8b..adbd45fd 100644 --- a/dlls/util.h +++ b/dlls/util.h @@ -568,3 +568,4 @@ int UTIL_SharedRandomLong( unsigned int seed, int low, int high ); float UTIL_SharedRandomFloat( unsigned int seed, float low, float high ); float UTIL_WeaponTimeBase( void ); +void UTIL_CleanSpawnPoint( Vector origin, float radius );