Ejemplo n.º 1
0
void CDataManager::SavePositions()
{
    if (IsSendingData())
        return;

    d->m_flNextPositionsUpdate = gpGlobals->curtime + da_data_positions_interval.GetFloat();

    for (int i = 1; i <= gpGlobals->maxClients; i++)
    {
        CSDKPlayer *pPlayer = ToSDKPlayer(UTIL_PlayerByIndex( i ));
        if (!pPlayer)
            continue;

        if (pPlayer->IsBot())
            continue;

        if (!pPlayer->IsAlive())
            continue;

        d->m_avecPlayerPositions.AddToTail(pPlayer->GetAbsOrigin());

        if (pPlayer->IsInThirdPerson())
            d->m_iThirdPersonActive++;
        else
            d->m_iThirdPersonInactive++;
    }

    ConVarRef sv_cheats("sv_cheats");
    d->m_bCheated |= sv_cheats.GetBool();
}
void CWeaponSDKBase::SendReloadEvents()
{
	CSDKPlayer *pPlayer = dynamic_cast< CSDKPlayer* >( GetOwner() );
	if ( !pPlayer )
		return;

	// Send a message to any clients that have this entity to play the reload.
	CPASFilter filter( pPlayer->GetAbsOrigin() );
	filter.RemoveRecipient( pPlayer );

	UserMessageBegin( filter, "ReloadEffect" );
	WRITE_SHORT( pPlayer->entindex() );
	MessageEnd();

	// Make the player play his reload animation.
	pPlayer->DoAnimationEvent( PLAYERANIMEVENT_RELOAD );
}
Ejemplo n.º 3
0
void CDataManager::SavePositions()
{
	if (IsSendingData())
		return;

	m_flNextPositionsUpdate = gpGlobals->curtime + da_data_positions_interval.GetFloat();

	for (int i = 1; i <= gpGlobals->maxClients; i++)
	{
		CSDKPlayer *pPlayer = ToSDKPlayer(UTIL_PlayerByIndex( i ));
		if (!pPlayer)
			continue;

		if (pPlayer->IsBot())
			continue;

		if (!pPlayer->IsAlive())
			continue;

		m_avecPlayerPositions.AddToTail(pPlayer->GetAbsOrigin());
	}
}
Ejemplo n.º 4
0
bool CWeaponShotgun::Reload()
{
	CSDKPlayer *pPlayer = GetPlayerOwner();

	if (pPlayer->GetAmmoCount( m_iPrimaryAmmoType ) <= 0 || m_iClip1 == GetMaxClip1())
		return true;

	// don't reload until recoil is done
	if (m_flNextPrimaryAttack > GetCurrentTime())
		return true;
		
	CBaseViewModel *vm = pPlayer->GetViewModel( m_nViewModelIndex );
	float flSpeedMultiplier = GetSDKWpnData().m_flReloadTimeMultiplier;

	// check to see if we're ready to reload
	if (m_iInSpecialReload == 0)
	{
		pPlayer->SetAnimation( PLAYER_RELOAD );

		float flStartTime = 0.5f * flSpeedMultiplier;

		pPlayer->DoAnimationEvent( PLAYERANIMEVENT_RELOAD );

		SendWeaponAnim( ACT_SHOTGUN_RELOAD_START );
		m_iInSpecialReload = 1;

		/* this is the only part of the reload sequence that can't be interrupted, seems unnecessary
		pPlayer->m_flNextAttack = GetCurrentTime() + flStartTime;
		m_flNextPrimaryAttack = GetCurrentTime() + flStartTime;
		m_flNextSecondaryAttack = GetCurrentTime() + flStartTime;
		*/

		SetWeaponIdleTime( GetCurrentTime() + flStartTime );

		if (vm)
			vm->SetPlaybackRate( 1/flSpeedMultiplier );

		pPlayer->Instructor_LessonLearned("reload");
		return true;
	}
	else if (m_iInSpecialReload == 1)
	{
		if (m_flTimeWeaponIdle > GetCurrentTime())
			return true;
		// was waiting for gun to move to side
		m_iInSpecialReload = 2;

		float flReloadTime = 0.45 * flSpeedMultiplier;

		SendWeaponAnim( ACT_VM_RELOAD );
		SetWeaponIdleTime( GetCurrentTime() + flReloadTime );

		pPlayer->DoAnimationEvent( PLAYERANIMEVENT_RELOAD_LOOP );

		if (vm)
			vm->SetPlaybackRate( 1/flSpeedMultiplier );
	}
	else if ( m_iInSpecialReload == 2 ) // Sanity, make sure it's actually in the right state.
	{
		// Add them to the clip
		m_iClip1 += 1;

#ifdef GAME_DLL
		// Send a message to any clients that have this entity to play the reload.
		CPASFilter filter( pPlayer->GetAbsOrigin() );
		filter.RemoveRecipient( pPlayer );

		UserMessageBegin( filter, "ReloadEffect" );
		WRITE_SHORT( pPlayer->entindex() );
		MessageEnd();
#endif

		if ( pPlayer )
		{
			bool bConsume = true;
			if (pPlayer->IsStyleSkillActive(SKILL_MARKSMAN))
				bConsume = false;

			if (bConsume)
				pPlayer->RemoveAmmo( 1, m_iPrimaryAmmoType );
		}

		if ( pPlayer->GetAmmoCount( m_iPrimaryAmmoType ) <= 0 || m_iClip1 == GetMaxClip1() )
			pPlayer->DoAnimationEvent( PLAYERANIMEVENT_RELOAD_END );

		m_iInSpecialReload = 1;
	}

	return true;
}