//-----------------------------------------------------------------------------
// Animation event handlers
//-----------------------------------------------------------------------------
void CWeaponZMFists::HandleAnimEventMeleeHit( CBaseCombatCharacter *pOperator )
{
	//do the trace stuff here so we can pass it to the Hit() function
	trace_t traceHit;

	// Try a ray
	CBasePlayer *pOwner = ToBasePlayer(pOperator);
	if ( !pOwner )
		return;

	Vector swingStart = pOwner->Weapon_ShootPosition( );
	Vector forward;

	pOwner->EyeVectors( &forward, NULL, NULL );

	Vector swingEnd = swingStart + forward * GetRange();

#ifndef CLIENT_DLL
	CHL2MP_Player *pPlayer = ToHL2MPPlayer( GetPlayerOwner() );
	// Move other players back to history positions based on local player's lag
	lagcompensation->StartLagCompensation( pPlayer, pPlayer->GetCurrentCommand() );
#endif
	UTIL_TraceLine( swingStart, swingEnd, MASK_SHOT_HULL, pOwner, COLLISION_GROUP_NONE, &traceHit );
	Hit( traceHit, ACT_VM_HITCENTER);
#ifndef CLIENT_DLL
	// Move other players back to history positions based on local player's lag
	lagcompensation->FinishLagCompensation( pPlayer );
#endif
}
示例#2
0
// called by ClientKill and DeadThink
void respawn( CBaseEntity *pEdict, bool fCopyCorpse )
{
	/*CHL2MP_Player *pPlayer = ToHL2MPPlayer( pEdict );

	if ( pPlayer )
	{
		if ( gpGlobals->curtime > pPlayer->GetDeathTime() + DEATH_ANIMATION_TIME )
		{		
			// respawn player
			pPlayer->Spawn();			
		}
		else
		{
			pPlayer->SetNextThink( gpGlobals->curtime + 0.1f );
		}
	}*/
	CHL2MP_Player *pPlayer = ToHL2MPPlayer( pEdict );

	if ( pPlayer )
	{
		//BG2 - Draco - Start(this is the part that supresses respawns when mp_respawnstyle != 0)
		//if ( gpGlobals->curtime > pPlayer->GetDeathTime() + DEATH_ANIMATION_TIME )
		//BG2 - Tjoppen - assume this function only gets called if we're allowed to respawn/spawn

		// respawn player
		pPlayer->Spawn();
	}
}
示例#3
0
//-----------------------------------------------------------------------------
// Purpose: Create a new Bot and put it in the game.
// Output : Pointer to the new Bot, or NULL if there's no free clients.
//-----------------------------------------------------------------------------
CBasePlayer *BotPutInServer( bool bFrozen, int iTeam )
{
	g_iNextBotTeam = iTeam;

	char botname[ 64 ];
	Q_snprintf( botname, sizeof( botname ), "Bot%02i", BotNumber );

	// This is an evil hack, but we use it to prevent sv_autojointeam from kicking in.

	edict_t *pEdict = engine->CreateFakeClient( botname );

	if (!pEdict)
	{
		Msg( "Failed to create Bot.\n");
		return NULL;
	}

	// Allocate a CBasePlayer for the bot, and call spawn
	//ClientPutInServer( pEdict, botname );
	CHL2MP_Player *pPlayer = ((CHL2MP_Player *)CBaseEntity::Instance( pEdict ));
	pPlayer->ClearFlags();
	pPlayer->AddFlag( FL_CLIENT | FL_FAKECLIENT );

	if ( bFrozen )
		pPlayer->AddEFlags( EFL_BOT_FROZEN );

	BotNumber++;

	g_BotData[pPlayer->entindex()-1].m_WantedTeam = iTeam;
	g_BotData[pPlayer->entindex()-1].m_flJoinTeamTime = gpGlobals->curtime + 0.3;

	return pPlayer;
}
示例#4
0
CHL2MP_Player* CHL2MP_Player::FindNearestAlly()
{
	//Credits goes to JailBreak Source for this

	const Vector &  vAbsOrigin      = GetAbsOrigin();
	float           closestDistSq   = FLT_MAX;
	CHL2MP_Player * pNearest        = NULL;
	float           distSq;

	for (int i = 1; i <= gpGlobals->maxClients; i++ )
	{
		CHL2MP_Player *pPlayer = ToHL2MPPlayer(UTIL_PlayerByIndex( i ));
		if ( pPlayer && pPlayer != this)
		{
			if(pPlayer->GetTeamNumber() != this->GetTeamNumber())
				continue;

			distSq = ( vAbsOrigin - pPlayer->GetAbsOrigin() ).LengthSqr();

			if(distSq > closestDistSq)
				continue;

			closestDistSq = distSq;
			pNearest = pPlayer;
		}
	}
	return pNearest;
}
//-----------------------------------------------------------------------------
// Purpose: 
// Output : Returns true on success, false on failure.
//-----------------------------------------------------------------------------
bool CBaseHL2MPCombatWeapon::Deploy( void )
{
	// If we should be lowered, deploy in the lowered position
	// We have to ask the player if the last time it checked, the weapon was lowered
	if ( GetOwner() && GetOwner()->IsPlayer() )
	{
		CHL2MP_Player *pPlayer = assert_cast<CHL2MP_Player*>( GetOwner() );
		if ( pPlayer->IsWeaponLowered() )
		{
			if ( SelectWeightedSequence( ACT_VM_IDLE_LOWERED ) != ACTIVITY_NOT_AVAILABLE )
			{
				if ( DefaultDeploy( (char*)GetViewModel(), (char*)GetWorldModel(), ACT_VM_IDLE_LOWERED, (char*)GetAnimPrefix() ) )
				{
					m_bLowered = true;

					// Stomp the next attack time to fix the fact that the lower idles are long
					pPlayer->SetNextAttack( gpGlobals->curtime + 1.0 );
					m_flNextPrimaryAttack = gpGlobals->curtime + 1.0;
					m_flNextSecondaryAttack	= gpGlobals->curtime + 1.0;
					return true;
				}
			}
		}
	}

	m_bLowered = false;
	return BaseClass::Deploy();
}
void CWeaponCrowbar::PrimaryAttack()
{
	CHL2MP_Player *pPlayer = ToHL2MPPlayer( GetOwner() );
	if (pPlayer)
	{
#ifndef CLIENT_DLL
		if (pPlayer->gorephased)
		{
			//BB: JAM Request... sneak attacks
			pPlayer->DoGorePhase();
			pPlayer->covenStatusEffects &= pPlayer->covenStatusEffects & ~COVEN_FLAG_PHASE;
			pPlayer->SetStatusTime(COVEN_BUFF_PHASE, 0.0f);
		}
		if (pPlayer->covenClassID == COVEN_CLASSID_FIEND && pPlayer->covenStatusEffects & COVEN_FLAG_DODGE)
		{
			pPlayer->VampireUnDodge();
		}
#else
		/*C_BasePlayer *local = C_BasePlayer::GetLocalPlayer();
		C_BaseHLPlayer *pPlayer2 = (C_BaseHLPlayer *)local;
		if (pPlayer2->covenClassID == COVEN_CLASSID_FIEND && pPlayer2->GetRenderColor().a < 255)
			return;*/
		//second half of sneak attacks
		/*C_BasePlayer *local = C_BasePlayer::GetLocalPlayer();
		C_BaseHLPlayer *pPlayer2 = (C_BaseHLPlayer *)local;
		if (pPlayer2->GetEffects() & EF_NODRAW)
		{
			return;
		}*/
#endif
	}
	BaseClass::PrimaryAttack();
}
示例#7
0
//Pose la mine sur son support une fois l'animation terminée
void CWeaponMine::FinishAttach( void ){
	CHL2MP_Player *pOwner = ToHL2MPPlayer( GetOwner() );
	if (!pOwner)
		return;

	Vector vecSrc, vecAiming;
	vecSrc = pOwner->EyePosition();
	QAngle angles = pOwner->GetLocalAngles();
	AngleVectors( angles, &vecAiming );
	trace_t tr;
	UTIL_TraceLine( vecSrc, vecSrc + (vecAiming * 60), MASK_SOLID, pOwner, COLLISION_GROUP_NONE, &tr );
	
	if (tr.fraction < 1.0)
	{		
		if (tr.m_pEnt)
		{
			//On attache pas la mine sur une entité vivante
			CBaseEntity *pEntity = tr.m_pEnt;
			CBaseCombatCharacter *pBCC = ToBaseCombatCharacter( pEntity );
			if (pBCC){
				m_bAttachMine  = false;
				m_bNeedReload = true;
				return;
			}

#ifndef CLIENT_DLL
			//On vérifie qu'il n 'y a pas déjà une mine sur le support visé
			CBaseEntity* pResult = gEntList.FindEntityByClassname(NULL,"npc_mine");
			while (pResult)
			{
				if((pResult->GetAbsOrigin() - tr.endpos).Length() < MINE_DISTANCE){
					m_bAttachMine  = false;
					m_bNeedReload = true;
					return;
				}

				pResult = gEntList.FindEntityByClassname(pResult,"npc_mine");
			}

			if (pEntity && !(pEntity->GetFlags() & FL_CONVEYOR))
			{
				QAngle angles;
				VectorAngles(tr.plane.normal, angles);
				angles.x += 90;

				CBaseEntity *pEnt = CBaseEntity::Create( "npc_mine", tr.endpos + tr.plane.normal * 3, angles, NULL );
				CNPCMine *pMine = (CNPCMine *)pEnt;
				pMine->m_hOwner = GetOwner();
				ChooseMineColor(pMine);
				pMine->AttachToEntity( pEntity );

				pOwner->RemoveAmmo( 1, m_iSecondaryAmmoType );
			}
#endif
		}
	}

	m_bAttachMine  = false;
	m_bNeedReload = true;
}
示例#8
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CWeaponFrag::ItemPostFrame( void )
{
	if( m_fDrawbackFinished )
	{
		CHL2MP_Player *pOwner = ToHL2MPPlayer( GetOwner() );

		if (pOwner)
		{
			switch( m_AttackPaused )
			{
			case GRENADE_PAUSED_PRIMARY:
				if( !(pOwner->m_nButtons & IN_ATTACK) )
				{
					SendWeaponAnim( ACT_VM_THROW );
					pOwner->DoAnimationEvent( PLAYERANIMEVENT_ATTACK_PRIMARY );
					m_fDrawbackFinished = false;
				}
				break;

			case GRENADE_PAUSED_SECONDARY:
				if( !(pOwner->m_nButtons & IN_ATTACK2) )
				{
					//See if we're ducking
					if ( pOwner->m_nButtons & IN_DUCK )
					{
						//Send the weapon animation
						SendWeaponAnim( ACT_VM_SECONDARYATTACK );
					}
					else
					{
						//Send the weapon animation
						SendWeaponAnim( ACT_VM_HAULBACK );
					}
					//Tony; the grenade really should have a secondary anim. but it doesn't on the player.
					pOwner->DoAnimationEvent( PLAYERANIMEVENT_ATTACK_PRIMARY );

					m_fDrawbackFinished = false;
				}
				break;

			default:
				break;
			}
		}
	}

	BaseClass::ItemPostFrame();

	if ( m_bRedraw )
	{
		if ( IsViewModelSequenceFinished() )
		{
			Reload();
		}
	}
}
示例#9
0
// called by ClientKill and DeadThink
void respawn( CBaseEntity *pEdict, bool fCopyCorpse )
{
	CHL2MP_Player *pPlayer = ToHL2MPPlayer( pEdict );
	if ( pPlayer )
	{
		if ( gpGlobals->curtime > pPlayer->GetDeathTime() + DEATH_ANIMATION_TIME )
			pPlayer->Spawn();
		else
			pPlayer->SetNextThink( gpGlobals->curtime + 0.1f );
	}
}
示例#10
0
/*
===========
ClientPutInServer

called each time a player is spawned into the game
============
*/
void ClientPutInServer( edict_t *pEdict, const char *playername )
{
	// Allocate a CBaseTFPlayer for pev, and call spawn
	CHL2MP_Player *pPlayer = CHL2MP_Player::CreatePlayer( "player", pEdict );
#ifdef HL2SB
	if( pPlayer )
		pPlayer->SetPlayerName( playername );
#else
	pPlayer->SetPlayerName( playername );
#endif
}
示例#11
0
//-----------------------------------------------------------------------------
// Purpose: Get the damage amount for the animation we're doing
// Input  : hitActivity - currently played activity
// Output : Damage amount
//-----------------------------------------------------------------------------
float CWeaponCrowbar::GetDamageForActivity( Activity hitActivity )
{	
	CBasePlayer *pPlayer  = ToBasePlayer( GetOwner() );
	
	if ( pPlayer == NULL )
		return 0;

	CHL2MP_Player *pHLPlayer = (CHL2MP_Player *)pPlayer;

	float baseDMG = 5.0f + pHLPlayer->myStrength();

	return baseDMG + random->RandomInt(0,20);
}
示例#12
0
bool CItemMoney::MyTouch( CBasePlayer *pPlayer )
{
	if ( pPlayer != m_taker )
		return false;

	CPASAttenuationFilter sndFilter( pPlayer );
	pPlayer->EmitSound( sndFilter, pPlayer->entindex(), "Buttons.snd2" );

	CHL2MP_Player * p = ToHL2MPPlayer( pPlayer );
	p->AddMoney( m_iAmount );

	return true;
}
示例#13
0
void CHL2MPRules::CheckAllPlayersReady( void )
{
    for (int i = 1; i <= gpGlobals->maxClients; i++ )
    {
        CHL2MP_Player *pPlayer = (CHL2MP_Player*) UTIL_PlayerByIndex( i );

        if ( !pPlayer )
            continue;
        if ( !pPlayer->IsReady() )
            return;
    }
    m_bHeardAllPlayersReady = true;
}
示例#14
0
void CWeaponBaseballBat::PrimaryAttack( void )
{
	BaseClass::PrimaryAttack();

	//HACK - our model crashes the decompiler and all the original files are lost so we can't fix the messed up activities
	SendWeaponAnim( ACT_VM_HITCENTER );

	CHL2MP_Player *pOwner = ToHL2MPPlayer( GetOwner() );
	if ( !pOwner )
		return;

	pOwner->SetAnimation( PLAYER_ATTACK1 );
	pOwner->DoAnimationEvent( PLAYERANIMEVENT_ATTACK_PRIMARY );
}
//------------------------------------------------------------------------------
// Purpose :
// Input   :
// Output  :
//------------------------------------------------------------------------------
void CBaseHL2MPBludgeonWeapon::PrimaryAttack()
{

#ifndef CLIENT_DLL
    CHL2MP_Player *pPlayer = ToHL2MPPlayer( GetPlayerOwner() );
    // Move other players back to history positions based on local player's lag
    lagcompensation->StartLagCompensation( pPlayer, pPlayer->GetCurrentCommand() );
#endif
    Swing( false );
#ifndef CLIENT_DLL
    // Move other players back to history positions based on local player's lag
    lagcompensation->FinishLagCompensation( pPlayer );
#endif

}
示例#16
0
bool CHL2MPRules::ClientCommand( CBaseEntity *pEdict, const CCommand &args )
{
#ifndef CLIENT_DLL
    if( BaseClass::ClientCommand( pEdict, args ) )
        return true;


    CHL2MP_Player *pPlayer = (CHL2MP_Player *) pEdict;

    if ( pPlayer->ClientCommand( args ) )
        return true;
#endif

    return false;
}
示例#17
0
//-----------------------------------------------------------------------------
// Purpose:
// Input  :
// Output :
//-----------------------------------------------------------------------------
void CWeapon_SLAM::TripmineAttach( void )
{
	CHL2MP_Player *pOwner  = ToHL2MPPlayer( GetOwner() );
	if (!pOwner)
	{
		return;
	}

	m_bAttachTripmine = false;

	Vector vecSrc, vecAiming;

	// Take the eye position and direction
	vecSrc = pOwner->EyePosition();
	
	QAngle angles = pOwner->GetLocalAngles();

	AngleVectors( angles, &vecAiming );

	trace_t tr;

	UTIL_TraceLine( vecSrc, vecSrc + (vecAiming * 128), MASK_SOLID, pOwner, COLLISION_GROUP_NONE, &tr );
	
	if (tr.fraction < 1.0)
	{
		CBaseEntity *pEntity = tr.m_pEnt;
		if (pEntity && !(pEntity->GetFlags() & FL_CONVEYOR))
		{

#ifndef CLIENT_DLL
			QAngle angles;
			VectorAngles(tr.plane.normal, angles);

			angles.x += 90;

			CBaseEntity *pEnt = CBaseEntity::Create( "npc_tripmine", tr.endpos + tr.plane.normal * 3, angles, NULL );

			CTripmineGrenade *pMine = (CTripmineGrenade *)pEnt;
			pMine->m_hOwner = GetOwner();
			// Attempt to attach to entity, or just sit still in place.
			pMine->AttachToEntity( pEntity );

#endif

			pOwner->RemoveAmmo( 1, m_iSecondaryAmmoType );
		}
	}
}
示例#18
0
//-----------------------------------------------------------------------------
// Purpose:
// Input  :
// Output :
//-----------------------------------------------------------------------------
bool CWeapon_SLAM::CanAttachSLAM( void )
{
	CHL2MP_Player *pOwner = ToHL2MPPlayer( GetOwner() );

	if (!pOwner)
	{
		return false;
	}

	Vector vecSrc, vecAiming;

	// Take the eye position and direction
	vecSrc = pOwner->EyePosition();
	
	QAngle angles = pOwner->GetLocalAngles();

	AngleVectors( angles, &vecAiming );

	trace_t tr;

	Vector	vecEnd = vecSrc + (vecAiming * 42);
	UTIL_TraceLine( vecSrc, vecEnd, MASK_SOLID, pOwner, COLLISION_GROUP_NONE, &tr );
	
	if (tr.fraction < 1.0)
	{
		// Don't attach to a living creature
		if (tr.m_pEnt)
		{
			CBaseEntity *pEntity = tr.m_pEnt;
			CBaseCombatCharacter *pBCC		= ToBaseCombatCharacter( pEntity );
			if (pBCC)
			{
				return false;
			}
		}
		return true;
	}
	else
	{
		return false;
	}
}
//-----------------------------------------------------------------------------
// Purpose: 
//
//
//-----------------------------------------------------------------------------
void CWeaponShotgun::PrimaryAttack( void )
{
	// Only the player fires this way so we can cast
	CHL2MP_Player *pPlayer = ToHL2MPPlayer( GetOwner() );

	if (!pPlayer)
	{
		return;
	}

	// MUST call sound before removing a round from the clip of a CMachineGun
	WeaponSound(SINGLE);

	pPlayer->DoMuzzleFlash();

	SendWeaponAnim( ACT_VM_PRIMARYATTACK );

	// Don't fire again until fire animation has completed
	m_flNextPrimaryAttack = gpGlobals->curtime + SequenceDuration();
	m_iClip1 -= 1;

	// player "shoot" animation
	pPlayer->DoAnimationEvent( PLAYERANIMEVENT_ATTACK_PRIMARY );


	Vector	vecSrc		= pPlayer->Weapon_ShootPosition( );
	Vector	vecAiming	= pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES );	

	FireBulletsInfo_t info( 7, vecSrc, vecAiming, GetBulletSpread(), MAX_TRACE_LENGTH, m_iPrimaryAmmoType );
	info.m_pAttacker = pPlayer;

	// Fire the bullets, and force the first shot to be perfectly accuracy
	pPlayer->FireBullets( info );
	
	QAngle punch;
	punch.Init( SharedRandomFloat( "shotgunpax", -2, -1 ), SharedRandomFloat( "shotgunpay", -2, 2 ), 0 );
	pPlayer->ViewPunch( punch );

	if (!m_iClip1 && pPlayer->GetAmmoCount(m_iPrimaryAmmoType) <= 0)
	{
		// HEV suit - indicate out of ammo condition
		pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0); 
	}

	m_bNeedPump = true;
}
//-----------------------------------------------------------------------------
// Purpose: Override so only reload one shell at a time
// Input  :
// Output :
//-----------------------------------------------------------------------------
bool CWeaponShotgun::StartReload( void )
{
	if ( m_bNeedPump )
		return false;

	CHL2MP_Player *pOwner = ToHL2MPPlayer( GetOwner() );
	
	if ( pOwner == NULL )
		return false;

	if (pOwner->GetAmmoCount(m_iPrimaryAmmoType) <= 0)
		return false;

	if (m_iClip1 >= GetMaxClip1())
		return false;


	int j = MIN(1, pOwner->GetAmmoCount(m_iPrimaryAmmoType));

	if (j <= 0)
		return false;

	SendWeaponAnim( ACT_SHOTGUN_RELOAD_START );

	//Tony; BUG BUG BUG!!! shotgun does one shell at a time!!! -- player model only has a single reload!!! so I'm just going to dispatch the singular for now.
	pOwner->DoAnimationEvent( PLAYERANIMEVENT_RELOAD );

	// Make shotgun shell visible
	SetBodygroup(1,0);

	pOwner->m_flNextAttack = gpGlobals->curtime;
	m_flNextPrimaryAttack = gpGlobals->curtime + SequenceDuration();

	m_bInReload = true;
	return true;
}
示例#21
0
//-----------------------------------------------------------------------------
// Purpose: Create a new Bot and put it in the game.
// Output : Pointer to the new Bot, or NULL if there's no free clients.
//-----------------------------------------------------------------------------
CBasePlayer *BotPutInServer( bool bFrozen, int iTeam )
{
    g_iNextBotTeam = iTeam;

    char botname[ 64 ];
    Q_snprintf( botname, sizeof( botname ), "Bot%02i", BotNumber );

    // This is an evil hack, but we use it to prevent sv_autojointeam from kicking in.

    edict_t *pEdict = engine->CreateFakeClient( botname );

    if (!pEdict)
    {
        Msg( "Failed to create Bot.\n");
        return NULL;
    }

    // Allocate a CBasePlayer for the bot, and call spawn
    //ClientPutInServer( pEdict, botname );
    CHL2MP_Player *pPlayer = ((CHL2MP_Player *)CBaseEntity::Instance( pEdict ));
    pPlayer->ClearFlags();
    pPlayer->AddFlag( FL_CLIENT | FL_FAKECLIENT );

    if ( bFrozen )
        pPlayer->AddEFlags( EFL_BOT_FROZEN );

    BotNumber++;

    g_BotData[pPlayer->entindex()-1].m_WantedTeam = iTeam;
    g_BotData[pPlayer->entindex()-1].m_flJoinTeamTime = gpGlobals->curtime + 0.3;

    //DHL - Skillet - Spawn the bot
    pPlayer->ChangeTeam( TEAM_UNASSIGNED ); //This is required for PickDefaultSpawnTeam() to work
    pPlayer->Spawn();
    //pPlayer->SetModelName( MAKE_STRING(bot_playermodel.GetString()) );
    if ( Q_strlen( bot_playermodel.GetString() ) > 2 )
        pPlayer->SetModel( bot_playermodel.GetString() );

    return pPlayer;
}
示例#22
0
void CHL2MPRules::RestartGame()
{
    // bounds check
    if ( mp_timelimit.GetInt() < 0 )
    {
        mp_timelimit.SetValue( 0 );
    }
    m_flGameStartTime = gpGlobals->curtime;
    if ( !IsFinite( m_flGameStartTime.Get() ) )
    {
        Warning( "Trying to set a NaN game start time\n" );
        m_flGameStartTime.GetForModify() = 0.0f;
    }

    CleanUpMap();

    // now respawn all players
    for (int i = 1; i <= gpGlobals->maxClients; i++ )
    {
        CHL2MP_Player *pPlayer = (CHL2MP_Player*) UTIL_PlayerByIndex( i );

        if ( !pPlayer )
            continue;

        if ( pPlayer->GetActiveWeapon() )
        {
            pPlayer->GetActiveWeapon()->Holster();
        }
        pPlayer->RemoveAllItems( true );
        respawn( pPlayer, false );
        pPlayer->Reset();
    }

    // Respawn entities (glass, doors, etc..)

    CTeam *pRebels = GetGlobalTeam( TEAM_REBELS );
    CTeam *pCombine = GetGlobalTeam( TEAM_COMBINE );

    if ( pRebels )
    {
        pRebels->SetScore( 0 );
    }

    if ( pCombine )
    {
        pCombine->SetScore( 0 );
    }

    m_flIntermissionEndTime = 0;
    m_flRestartGameTime = 0.0;
    m_bCompleteReset = false;

    IGameEvent * event = gameeventmanager->CreateEvent( "round_start" );
    if ( event )
    {
        event->SetInt("fraglimit", 0 );
        event->SetInt( "priority", 6 ); // HLTV event priority, not transmitted

        event->SetString("objective","DEATHMATCH");

        gameeventmanager->FireEvent( event );
    }
}
void CHL2MPRules::RestartGame()
{
	// bounds check
	if ( mp_timelimit.GetInt() < 0 )
	{
		mp_timelimit.SetValue( 0 );
	}
	m_flGameStartTime = gpGlobals->curtime;
	if ( !IsFinite( m_flGameStartTime.Get() ) )
	{
		Warning( "Trying to set a NaN game start time\n" );
		m_flGameStartTime.GetForModify() = 0.0f;
	}

	// Pre Map Cleanup
	for (int i = 1; i <= gpGlobals->maxClients; i++ )
	{
		CHL2MP_Player *pPlayer = (CHL2MP_Player*) UTIL_PlayerByIndex( i );

		if ( !pPlayer )
			continue;

		//Tony; if they aren't a spectator, make sure they get cleaned up before entities are removed!
		if ( pPlayer->GetTeamNumber() != TEAM_SPECTATOR )
		{
				// If they're in a vehicle, make sure they get out!
				if ( pPlayer->IsInAVehicle() )
					pPlayer->LeaveVehicle();

				QAngle angles = pPlayer->GetLocalAngles();

				angles.x = 0;
				angles.z = 0;

				pPlayer->SetLocalAngles( angles );
				CBaseCombatWeapon *pWeapon = (CBaseCombatWeapon*)pPlayer->GetActiveWeapon();
				if (pWeapon)
				{
					pPlayer->Weapon_Detach( pWeapon );
					UTIL_Remove( pWeapon );
				}
		}
		pPlayer->RemoveAllItems(true);
		pPlayer->ClearActiveWeapon();
		pPlayer->Reset();
	}

	CleanUpMap();
	
	// now that everything is cleaned up, respawn everyone.
	for (int i = 1; i <= gpGlobals->maxClients; i++ )
	{
		CHL2MP_Player *pPlayer = (CHL2MP_Player*) UTIL_PlayerByIndex( i );

		if ( !pPlayer )
			continue;

		//Tony; if they aren't a spectator, respawn them.
		if ( pPlayer->GetTeamNumber() != TEAM_SPECTATOR )
			pPlayer->Spawn();
	}

	CTeam *pRebels = GetGlobalTeam( TEAM_REBELS );
	CTeam *pCombine = GetGlobalTeam( TEAM_COMBINE );

	if ( pRebels )
	{
		pRebels->SetRoundScore( 0 );
	}

	if ( pCombine )
	{
		pCombine->SetRoundScore( 0 );
	}

	m_flIntermissionEndTime = 0;
	m_flRestartGameTime = 0.0;		
	m_bCompleteReset = false;

	IGameEvent * event = gameeventmanager->CreateEvent( "round_start" );
	if ( event )
	{
		event->SetInt("fraglimit", 0 );
		event->SetInt( "priority", 6 ); // HLTV event priority, not transmitted

		event->SetString("objective","DEATHMATCH");

		gameeventmanager->FireEvent( event );
	}
}
示例#24
0
//-----------------------------------------------------------------------------
// Can the player be set as the parent?
//-----------------------------------------------------------------------------
void CTriggerCTFCapture::StartTouch(CBaseEntity *pOther)
{
	if (!pOther->IsPlayer()) //Nothing else should trigger this.
		return;

	//Defines
	CHL2MP_Player *pPlayer = ToHL2MPPlayer(pOther);
	CtfFlag *pFlag = NULL;
	bool m_bHomeFlagTaken = false;

	if (!pPlayer || !pPlayer->IsAlive()) //Still alive?
		return;

	if (sv_ctf_capturestyle.GetInt() > 1)
	{
		while ((pFlag = static_cast<CtfFlag*>(gEntList.FindEntityByClassname(pFlag, "ctf_flag"))) != NULL)
		{
			if (pFlag->iTeam == pPlayer->GetTeamNumber()) //This flag is an enemy flag, we want the player's team's flag.
				continue;

			if (pFlag->GetAbsOrigin() != pFlag->FlagOrigin) //This flag belongs to the player's team. Is it at home?
				m_bHomeFlagTaken = true;
		}
	}


	while ((pFlag = static_cast<CtfFlag*>(gEntList.FindEntityByClassname(pFlag, "ctf_flag"))) != NULL)
	{
		if (pFlag->GetParent() && pFlag->GetParent() == pPlayer) //So the flag has a parent.. and it's the player who touched the trigger.
		{
			int TeamNumber = pPlayer->GetTeamNumber();

			//For team affected by the trigger.
			switch (m_iAffectedTeam)
			{
			case 0:
				iTeam = TeamNumber;
				break;
			case 1:
				iTeam = TEAM_BRITISH;
				break;
			case 2:
				iTeam = TEAM_AMERICANS;
				break;
			}

			if (TeamNumber != iTeam) //Trigger isn't for this player's team. Die.
				return;
			//

			if (m_bHomeFlagTaken) //The player's team's flag is taken. So we cannot cap an enemy flag.
			{
				ClientPrint(pPlayer, CTF_DENY_CAPTURE); //Let the player know.
				return; //Die here.
			}

			//Assuming we've made it thus far, you're probably carrying a flag that belongs to the enemy. Go ahead and cap it.
			pFlag->PlaySound(GetAbsOrigin(), m_iSound); //Play the capture sound.

			pFlag->ResetFlag();

			g_Teams[TeamNumber]->AddScore(m_iTeamBonus); //Adds the team score bonus.
			pPlayer->IncrementFragCount(m_iPlayerBonus); //Give the player the points.

			//reset the capturer's speed
			//pPlayer->SetSpeedModifier(0);
			pPlayer->RemoveSpeedModifier(ESpeedModID::Flag); //BG3 - Awesome - removed to more robust speed modifier system

			pFlag->PrintAlert(CTF_CAPTURE, pPlayer->GetPlayerName(), pFlag->cFlagName);

			//Do the log stuff.
			CTeam *team = pPlayer->GetTeam();

			UTIL_LogPrintf("\"%s<%i><%s><%s>\" triggered \"ctf_flag_capture\"\n",
				pPlayer->GetPlayerName(),
				pPlayer->GetUserID(),
				pPlayer->GetNetworkIDString(),
				team ? team->GetName() : "");
			//

			m_OnFlagCaptured.FireOutput(this, this); //Fire the OnFlagCaptured output, set it last just in case.
		}
	}
}