Example #1
0
void CBuffer::UpdateInfo(tstring& s)
{
	tstring p;

	s = "";
	s += "MACRO-BUFFER INFO\n";
	s += "Network extender\n \n";

	if (GetPlayerOwner())
	{
		s += "Team: " + GetPlayerOwner()->GetPlayerName() + "\n";
		if (GetDigitanksPlayer() == DigitanksGame()->GetCurrentLocalDigitanksPlayer())
			s += " Friendly\n \n";
		else
			s += " Hostile\n \n";
	}
	else
	{
		s += "Team: Neutral\n \n";
	}

	if (IsConstructing())
	{
		s += "(Constructing)\n";
		s += tsprintf(tstring("Turns left: %d\n"), GetTurnsRemainingToConstruct());
		return;
	}

	s += tsprintf(tstring("Fleet Points: %d\n"), FleetPoints());
	s += tsprintf(tstring("Bandwidth: %.1f/turn\n"), Bandwidth());
	s += tsprintf(tstring("Network Size: %d\n"), (int)GetDataFlowRadius());
	s += tsprintf(tstring("Efficiency: %d\n"), (int)(GetChildEfficiency() * 100));
}
Example #2
0
CWreckage* CDigitanksEntity::CreateWreckage()
{
	// Figure out what to do about structures later.
	if (dynamic_cast<CDigitank*>(this) == NULL)
		return NULL;

	CWreckage* pWreckage = GameServer()->Create<CWreckage>("CWreckage");
	pWreckage->SetGlobalOrigin(GetRenderOrigin());
	pWreckage->SetGlobalAngles(GetRenderAngles());
	pWreckage->SetModel(GetModelID());
	pWreckage->SetGlobalGravity(Vector(0, 0, DigitanksGame()->GetGravity()));
	pWreckage->SetOldPlayer(GetDigitanksPlayer());

	pWreckage->CalculateVisibility();

	CDigitank* pTank = dynamic_cast<CDigitank*>(this);
	if (pTank)
		pWreckage->SetTurretModel(pTank->GetTurretModel());

	bool bColorSwap = GetPlayerOwner() && (dynamic_cast<CDigitank*>(this));
	if (bColorSwap)
		pWreckage->SetColorSwap(GetPlayerOwner()->GetColor());

	return pWreckage;
}
Example #3
0
void CSupplyLine::PostRender() const
{
	BaseClass::PostRender();

	if (!GameServer()->GetRenderer()->IsRenderingTransparent())
		return;

	if (!m_hSupplier || !m_hEntity)
		return;

	Vector vecDestination = m_hEntity->GetGlobalOrigin();

	Vector vecPath = vecDestination - m_hSupplier->GetGlobalOrigin();
	vecPath.z = 0;

	float flDistance = vecPath.Length2D();
	Vector vecDirection = vecPath.Normalized();
	size_t iSegments = (size_t)(flDistance/3);

	CRenderingContext r(GameServer()->GetRenderer(), true);
	if (DigitanksGame()->ShouldRenderFogOfWar())
		r.UseFrameBuffer(DigitanksGame()->GetDigitanksRenderer()->GetVisibilityMaskedBuffer());

	Color clrTeam(255, 255, 255, 255);
	if (GetPlayerOwner())
		clrTeam = GetPlayerOwner()->GetColor();
	clrTeam = (Vector(clrTeam) + Vector(1,1,1))/2;

	CRopeRenderer oRope(GameServer()->GetRenderer(), s_hSupplyBeam, DigitanksGame()->GetTerrain()->GetPointHeight(m_hSupplier->GetGlobalOrigin()) + Vector(0, 0, 2), 2.5f);
	if (dynamic_cast<CStructure*>(m_hEntity.GetPointer()))
	{
		oRope.SetTextureScale(500000);
		oRope.SetTextureOffset(-(float)fmod(GameServer()->GetGameTime(), 1));
	}
	else
	{
		oRope.SetTextureScale(5);
		oRope.SetTextureOffset(-(float)fmod(GameServer()->GetGameTime(), 1)*2);
	}

	float flVisibility = 1;
	CDigitanksEntity* pDTEnt = dynamic_cast<CDigitanksEntity*>(m_hEntity.GetPointer());
	if (pDTEnt)
		flVisibility = pDTEnt->GetVisibility();

	for (size_t i = 1; i < iSegments; i++)
	{
		if (m_flIntegrity < 1 && i%2 == 0)
			clrTeam.SetAlpha((int)(50 * m_flIntegrity * flVisibility));
		else
			clrTeam.SetAlpha((int)(255 * m_flIntegrity * flVisibility));

		oRope.SetColor(clrTeam);

		float flCurrentDistance = ((float)i*flDistance)/iSegments;
		oRope.AddLink(DigitanksGame()->GetTerrain()->GetPointHeight(m_hSupplier->GetGlobalOrigin() + vecDirection*flCurrentDistance) + Vector(0, 0, 2));
	}

	oRope.Finish(DigitanksGame()->GetTerrain()->GetPointHeight(vecDestination) + Vector(0, 0, 2));
}
Example #4
0
void CDigitanksEntity::InterceptSupplyLines()
{
	// Haha... no.
	if (dynamic_cast<CSupplyLine*>(this))
		return;

	if (!GetPlayerOwner())
		return;

	for (size_t i = 0; i < GameServer()->GetMaxEntities(); i++)
	{
		CBaseEntity* pEntity = CBaseEntity::GetEntity(i);
		if (!pEntity)
			continue;

		CSupplyLine* pSupplyLine = dynamic_cast<CSupplyLine*>(pEntity);
		if (!pSupplyLine)
			continue;

		if (pSupplyLine->GetPlayerOwner() == GetPlayerOwner())
			continue;

		if (!pSupplyLine->GetPlayerOwner())
			continue;

		if (!pSupplyLine->GetSupplier() || !pSupplyLine->GetEntity())
			continue;

		Vector vecEntity = GetGlobalOrigin();
		vecEntity.z = 0;

		Vector vecSupplier = pSupplyLine->GetSupplier()->GetGlobalOrigin();
		vecSupplier.z = 0;

		Vector vecUnit = pSupplyLine->GetEntity()->GetGlobalOrigin();
		vecUnit.z = 0;

		if (DistanceToLineSegment(vecEntity, vecSupplier, vecUnit) > GetBoundingRadius()+4)
			continue;

		bool bFound = false;
		for (size_t j = 0; j < m_ahSupplyLinesIntercepted.size(); j++)
		{
			if (pSupplyLine == m_ahSupplyLinesIntercepted[j])
			{
				bFound = true;
				break;
			}
		}

		if (!bFound)
		{
			pSupplyLine->Intercept(0.2f);
			m_ahSupplyLinesIntercepted.push_back(pSupplyLine);
		}
	}
}
// -----------------------------------------------------------------------------
// Purpose:
// -----------------------------------------------------------------------------
bool CTFWeaponBaseMelee::Holster( CBaseCombatWeapon *pSwitchingTo )
{
	m_flSmackTime = -1.0f;
	if ( GetPlayerOwner() )
	{
		GetPlayerOwner()->m_flNextAttack = gpGlobals->curtime + 0.5;
	}
	return BaseClass::Holster( pSwitchingTo );
}
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 > gpGlobals->curtime)
		return true;
		
	// check to see if we're ready to reload
	if (m_fInSpecialReload == 0)
	{
		pPlayer->SetAnimation( PLAYER_RELOAD );

		SendWeaponAnim( ACT_SHOTGUN_RELOAD_START );
		m_fInSpecialReload = 1;
		pPlayer->m_flNextAttack = gpGlobals->curtime + 0.5;
		m_flNextPrimaryAttack = gpGlobals->curtime + 0.5;
		m_flNextSecondaryAttack = gpGlobals->curtime + 0.5;
		SetWeaponIdleTime( gpGlobals->curtime + 0.5 );
		return true;
	}
	else if (m_fInSpecialReload == 1)
	{
		if (m_flTimeWeaponIdle > gpGlobals->curtime)
			return true;
		// was waiting for gun to move to side
		m_fInSpecialReload = 2;

		SendWeaponAnim( ACT_VM_RELOAD );
		SetWeaponIdleTime( gpGlobals->curtime + 0.45 );
	}
	else
	{
		// Add them to the clip
		m_iClip1 += 1;
		
#ifdef GAME_DLL
		SendReloadEvents();
#endif
		
		CSDKPlayer *pPlayer = GetPlayerOwner();

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

		m_fInSpecialReload = 1;
	}

	return true;
}
Example #7
0
void CStructure::StartTurn()
{
	BaseClass::StartTurn();

	FindGround();

	if (!GetSupplier() && !dynamic_cast<CCPU*>(this))
	{
		if (GetPlayerOwner())
			GetPlayerOwner()->RemoveUnit(this);
		SetSupplier(NULL);
	}

	if (GetSupplier() && !GetSupplier()->GetPlayerOwner())
	{
		GetSupplier()->RemoveChild(this);
		if (GetPlayerOwner())
			GetPlayerOwner()->RemoveUnit(this);
		SetSupplier(NULL);
	}

	if (GetPlayerOwner() == NULL)
		return;

	if (IsConstructing())
	{
		m_iTurnsToConstruct--;

		if (m_iTurnsToConstruct == (size_t)0)
		{
			GetDigitanksPlayer()->AppendTurnInfo(tstring("Construction finished on ") + GetEntityName());
			CompleteConstruction();

			GetDigitanksPlayer()->AddActionItem(this, ACTIONTYPE_NEWSTRUCTURE);
		}
		else
			GetDigitanksPlayer()->AppendTurnInfo(tsprintf(tstring("Constructing ") + GetEntityName() + " (%d turns left)", m_iTurnsToConstruct.Get()));
	}

	if (IsUpgrading())
	{
		m_iTurnsToUpgrade--;

		if (m_iTurnsToUpgrade == (size_t)0)
		{
			GetDigitanksPlayer()->AppendTurnInfo(GetEntityName() + " finished upgrading.");

			UpgradeComplete();
		}
		else
			GetDigitanksPlayer()->AppendTurnInfo(tsprintf(tstring("Upgrading ") + GetEntityName() + " (%d turns left)", GetTurnsToUpgrade()));
	}
}
void CWeaponUSP::PrimaryAttack()
{
	CCSPlayer *pPlayer = GetPlayerOwner();

	if ( m_bSilencerOn )
	{
		if ( !FBitSet( pPlayer->GetFlags(), FL_ONGROUND ) )
			USPFire( (1.3) * (1 - m_flAccuracy), 0.225, false );
		else if (pPlayer->GetAbsVelocity().Length2D() > 0)
			USPFire( (0.25) * (1 - m_flAccuracy), 0.225, false );
		else if ( FBitSet( pPlayer->GetFlags(), FL_DUCKING ) )
			USPFire( (0.125) * (1 - m_flAccuracy), 0.225, false );
		else
			USPFire( (0.15) * (1 - m_flAccuracy), 0.225, false );
	}
	else
	{
		if ( !FBitSet( pPlayer->GetFlags(), FL_ONGROUND ) )
			USPFire( (1.2) * (1 - m_flAccuracy), 0.225, false );
		else if (pPlayer->GetAbsVelocity().Length2D() > 0)
			USPFire( (0.225) * (1 - m_flAccuracy), 0.225, false );
		else if ( FBitSet( pPlayer->GetFlags(), FL_DUCKING ) )
			USPFire( (0.08) * (1 - m_flAccuracy), 0.225, false );
		else
			USPFire( (0.1) * (1 - m_flAccuracy), 0.225, false );
	}

}
Example #9
0
void CWeaponAug::AUGFire(float flSpread, bool bZoomed)
{
    float flCycleTime = GetCSWpnData().m_flCycleTime;

    if (bZoomed)
        flCycleTime = 0.135f;

    if (!CSBaseGunFire(flSpread, flCycleTime, true))
        return;

    CMomentumPlayer *pPlayer = GetPlayerOwner();

    // CSBaseGunFire can kill us, forcing us to drop our weapon, if we shoot something that explodes
    if (!pPlayer)
        return;

    if (pPlayer->GetAbsVelocity().Length2D() > 5)
        pPlayer->KickBack(1, 0.45, 0.275, 0.05, 4, 2.5, 7);

    else if (!FBitSet(pPlayer->GetFlags(), FL_ONGROUND))
        pPlayer->KickBack(1.25, 0.45, 0.22, 0.18, 5.5, 4, 5);

    else if (FBitSet(pPlayer->GetFlags(), FL_DUCKING))
        pPlayer->KickBack(0.575, 0.325, 0.2, 0.011, 3.25, 2, 8);

    else
        pPlayer->KickBack(0.625, 0.375, 0.25, 0.0125, 3.5, 2.25, 8);
}
//=====================================================================================//
// Purpose: Performs the screen shake and it checks to see if we hit an entity to
//          handle the proper damage
//			An entity here can be another player or a wood plank
//=====================================================================================//
void CTDPBludgeonWeaponBase::Hit( trace_t &tr, Activity nHitActivity )
{
	// Do we have a valid owner holding the weapon?
	CTDPPlayer *pPlayer = GetPlayerOwner();
	if ( !pPlayer )
		return;

	// Let's shake the screen a little
	AddViewKick();

	// if tr.m_pEnt is not NULL it means we have hit a target
	if ( tr.m_pEnt != NULL )
	{
		Vector vForward;
		pPlayer->EyeVectors( &vForward, NULL, NULL );
		VectorNormalize( vForward );

		// Process the damage and send it to the entity we just hit
		CTakeDamageInfo dmgInfo( GetOwner(), GetOwner(), GetDamageForActivity( nHitActivity ), DMG_CLUB );
		CalculateMeleeDamageForce( &dmgInfo, vForward, tr.endpos );
		tr.m_pEnt->DispatchTraceAttack( dmgInfo, vForward, &tr );
		ApplyMultiDamage();

#if defined( GAME_DLL )
		// Now hit all triggers along the ray that...
		TraceAttackToTriggers( dmgInfo, tr.startpos, tr.endpos, vForward );
#endif
	}

	// Apply an impact effect
	ImpactEffect( tr );
}
//=====================================================================================//
// Purpose: Controls the attacks and the call of WeaponIdle() method
//=====================================================================================//
void CTDPBludgeonWeaponBase::ItemPostFrame()
{
	// Do we have a valid owner holding the weapon?
	CTDPPlayer *pPlayer = GetPlayerOwner();
	if ( !pPlayer )
		return;

	static int lastButton = 0;

	//TDP_TODO
	if ( pPlayer->m_nButtons & IN_ATTACK3 && m_flNextSecondaryAttack <= gpGlobals->curtime && (lastButton != pPlayer->m_afButtonPressed) )
	{	
		ThirdAttack();
	}
	lastButton = pPlayer->m_afButtonPressed;

	// Is the player pressing the secondary attack button and is it time for the next
	// secondary attack?
	if ( pPlayer->m_nButtons & IN_ATTACK2 && m_flNextSecondaryAttack <= gpGlobals->curtime )
		SecondaryAttack();

	// Is the player pressing the primary attack button and is it time for the next
	// primary attack?
	if ( pPlayer->m_nButtons & IN_ATTACK && m_flNextPrimaryAttack <= gpGlobals->curtime )
		PrimaryAttack();

	// If the player is not pressing any of the attack buttons let's try to idle
	if ( !( pPlayer->m_nButtons & IN_ATTACK3 || pPlayer->m_nButtons & IN_ATTACK2 || pPlayer->m_nButtons & IN_ATTACK ) )
		WeaponIdle();

	//BaseClass::ItemPostFrame(); // Make this conditionnal

	return;
}
Example #12
0
bool CWeaponBaseGun::Reload()
{
    CMomentumPlayer *pPlayer = GetPlayerOwner();
    if (!pPlayer)
        return false;

    if (pPlayer->GetAmmoCount(GetPrimaryAmmoType()) <= 0)
        return false;

    int iResult = DefaultReload(GetMaxClip1(), GetMaxClip2(), ACT_VM_RELOAD);
    if (!iResult)
        return false;

    pPlayer->SetAnimation(PLAYER_RELOAD);

#ifndef CLIENT_DLL
    if ((iResult) && (pPlayer->GetFOV() != pPlayer->GetDefaultFOV()))
    {
        pPlayer->SetFOV(pPlayer, pPlayer->GetDefaultFOV());
    }
#endif

    m_flAccuracy = 0.2;
    pPlayer->m_iShotsFired = 0;
    m_bDelayFire = false;

    return true;
}
Example #13
0
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CTFMinigun::WindUp( void )
{
	// Get the player owning the weapon.
	CTFPlayer *pPlayer = ToTFPlayer( GetPlayerOwner() );
	if ( !pPlayer )
		return;

	// Play wind-up animation and sound (SPECIAL1).
	SendWeaponAnim( ACT_MP_ATTACK_STAND_PREFIRE );

	// Set the appropriate firing state.
	m_iWeaponState = AC_STATE_STARTFIRING;
	pPlayer->m_Shared.AddCond( TF_COND_AIMING );

#ifndef CLIENT_DLL
	pPlayer->StopRandomExpressions();
#endif

#ifdef CLIENT_DLL 
	WeaponSoundUpdate();
#endif


	// Update player's speed
	pPlayer->TeamFortress_SetSpeed();
}
Example #14
0
//-----------------------------------------------------------------------------
// Purpose:
// NOTE: Should this be put into fire gun
//-----------------------------------------------------------------------------
void CTFWeaponBaseGun::DoFireEffects()
{
	CTFPlayer *pPlayer = ToTFPlayer( GetPlayerOwner() );
	if ( !pPlayer )
		return;

	// Muzzle flash on weapon.
	bool bMuzzleFlash = true;

	// We no longer need this
	/*
	if ( pPlayer->IsPlayerClass( TF_CLASS_HEAVYWEAPONS ) )
	{
		//CTFWeaponBase *pWeapon = pPlayer->GetActiveTFWeapon();
		//if ( pWeapon && pWeapon->GetWeaponID() == TF_WEAPON_MINIGUN )
		if (pPlayer->IsActiveTFWeapon(TF_WEAPON_MINIGUN))
		{
			bMuzzleFlash = false;
		}
	}*/

	if ( bMuzzleFlash )
	{
		pPlayer->DoMuzzleFlash();
	}
}
Example #15
0
void CWeaponG3SG1::G3SG1Fire(float flSpread)
{
    CMomentumPlayer *pPlayer = GetPlayerOwner();
    if (!pPlayer)
        return;

    // If we are not zoomed in, or we have very recently zoomed and are still transitioning, the bullet diverts more.
    if (pPlayer->GetFOV() == pPlayer->GetDefaultFOV() || (gpGlobals->curtime < m_zoomFullyActiveTime))
        flSpread += 0.025;

    // Mark the time of this shot and determine the accuracy modifier based on the last shot fired...
    m_flAccuracy = 0.55 + (0.3) * (gpGlobals->curtime - m_flLastFire);

    if (m_flAccuracy > 0.98)
        m_flAccuracy = 0.98;

    m_flLastFire = gpGlobals->curtime;

    if (!CSBaseGunFire(flSpread, GetCSWpnData().m_flCycleTime, true))
        return;

    // Adjust the punch angle.
    QAngle angle = pPlayer->GetPunchAngle();
    angle.x -= SharedRandomFloat("G3SG1PunchAngleX", 0.75, 1.75) + (angle.x / 4);
    angle.y += SharedRandomFloat("G3SG1PunchAngleY", -0.75, 0.75);
    pPlayer->SetPunchAngle(angle);
}
void CWeaponCSBaseGun::ItemPostFrame()
{
	CCSPlayer *pPlayer = GetPlayerOwner();

	if ( !pPlayer )
		return;

	//GOOSEMAN : Return zoom level back to previous zoom level before we fired a shot. This is used only for the AWP.
	// And Scout.
	if ( (m_flNextPrimaryAttack <= gpGlobals->curtime) && (pPlayer->m_bResumeZoom == TRUE) )
	{
#ifndef CLIENT_DLL
		pPlayer->SetFOV( pPlayer, pPlayer->m_iLastZoom, 0.05f );
		m_zoomFullyActiveTime = gpGlobals->curtime + 0.05f;// Make sure we think that we are zooming on the server so we don't get instant acc bonus

		if ( pPlayer->GetFOV() == pPlayer->m_iLastZoom )
		{
			// return the fade level in zoom.
			pPlayer->m_bResumeZoom = false;
		}
#endif
	}

	BaseClass::ItemPostFrame();
}
Example #17
0
void CSupplier::OnTeamChange()
{
	if (!GetPlayerOwner())
	{
		for (size_t i = 0; i < m_ahChildren.size(); i++)
		{
			if (!m_ahChildren[i])
				continue;

			m_ahChildren[i]->SetSupplier(NULL);

			CStructure* pStructure = dynamic_cast<CStructure*>(m_ahChildren[i].GetPointer());
			if (!pStructure)
				continue;

			if (pStructure->GetPlayerOwner())
			{
				pStructure->GetPlayerOwner()->RemoveUnit(pStructure);
				DigitanksGame()->OnDisabled(pStructure, NULL, NULL);
			}
		}
	}

	BaseClass::OnTeamChange();
	UpdateTendrils();

	// This happens in UpdateTendrils() but do it again here anyway because UpdateTendrils only does it if there's a new tendril created.
	DigitanksGame()->GetTerrain()->DirtyChunkTexturesWithinDistance(GetGlobalOrigin(), GetDataFlowRadius() + GetBoundingRadius());
}
Example #18
0
bool CSupplier::IsAvailableAreaActive(int iArea) const
{
	if (iArea != 1)
		return BaseClass::IsAvailableAreaActive(iArea);

	if (!GetDigitanksPlayer())
		return false;

	if (!GetDigitanksPlayer()->GetPrimaryCPU())
		return false;

	unittype_t ePreviewStructure = GetDigitanksPlayer()->GetPrimaryCPU()->GetPreviewStructure();
	if (ePreviewStructure == STRUCTURE_PSU || ePreviewStructure == STRUCTURE_BATTERY)
		return false;

	if (GetPlayerOwner() != DigitanksGame()->GetCurrentLocalDigitanksPlayer())
		return false;

	if (IsConstructing())
		return false;

	// In build mode show everybody, otherwise only show the selected structure.
	if (DigitanksGame()->GetControlMode() == MODE_BUILD || GetDigitanksPlayer()->IsSelected(this))
		return true;

	return false;
}
//-----------------------------------------------------------------------------
// 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
}
void CWeaponScout::SCOUTFire( float flSpread )
{
    CCSPlayer *pPlayer = GetPlayerOwner();
    if (pPlayer == NULL)
    {
        Assert(pPlayer != NULL);
        return;
    }

    // If we are not zoomed in, or we have very recently zoomed and are still transitioning, the bullet diverts more.
    if (pPlayer->GetFOV() == pPlayer->GetDefaultFOV() || (gpGlobals->curtime < m_zoomFullyActiveTime))
    {
        flSpread += 0.025;
    }

    if (pPlayer->GetFOV() != pPlayer->GetDefaultFOV())
    {
        pPlayer->m_bResumeZoom = true;
        pPlayer->m_iLastZoom = pPlayer->GetFOV();

#ifndef CLIENT_DLL
        pPlayer->SetFOV( pPlayer, pPlayer->GetDefaultFOV(), 0.05f );
#endif
    }

    if ( !CSBaseGunFire( flSpread, GetCSWpnData().m_flCycleTime, true ) )
        return;

    QAngle angle = pPlayer->GetPunchAngle();
    angle.x -= 2;
    pPlayer->SetPunchAngle( angle );
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
bool CTFWeaponBaseMelee::CalcIsAttackCriticalHelper( void )
{
	CTFPlayer *pPlayer = ToTFPlayer( GetPlayerOwner() );
	if ( !pPlayer )
		return false;

	int nCvarValue = tf_weapon_criticals_melee.GetInt();

	if ( nCvarValue == 0 )
		return false;

	if ( nCvarValue == 1 && !tf_weapon_criticals.GetBool() )
		return false;

	float flPlayerCritMult = pPlayer->GetCritMult();

	float flCritChance = TF_DAMAGE_CRIT_CHANCE_MELEE * flPlayerCritMult;
	CALL_ATTRIB_HOOK_FLOAT( flCritChance, mult_crit_chance );

	// If the chance is 0, just bail.
	if ( flCritChance == 0.0f )
		return false;

	return ( RandomInt( 0, WEAPON_RANDOM_RANGE-1 ) <= flCritChance * WEAPON_RANDOM_RANGE );
}
	bool CWeaponDODBase::ShouldRemoveOnRoundRestart()
	{
		if ( GetPlayerOwner() )
			return false;
		else
			return true;
	}
Example #23
0
bool CWeaponMP5::Deploy( )
{
	CSDKPlayer *pPlayer = GetPlayerOwner();
	pPlayer->m_iShotsFired = 0;

	return BaseClass::Deploy();
}
void CC4::WeaponIdle()
{
	if ( m_bStartedArming )
	{
		m_bStartedArming = false; //if the player releases the attack button cancel the arming sequence

		#if !defined( CLIENT_DLL )
			CCSPlayer *pPlayer = GetPlayerOwner();

			// release the player from being frozen
			pPlayer->ResetMaxSpeed();

			m_flNextPrimaryAttack = gpGlobals->curtime + 1.0;

			pPlayer->SetProgressBarTime( 0 );
		#endif 

		/*
		if(m_bBombPlacedAnimation == true) //this means the placement animation is canceled
			SendWeaponAnim( C4_DRAW, UseDecrement() ? 1: 0);
		else
			SendWeaponAnim( C4_IDLE1, UseDecrement() ? 1: 0);
		*/
	}

	if (m_flTimeWeaponIdle > gpGlobals->curtime)
		return;

	//UTIL_Remove( this );
}
Example #25
0
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CTFMinigun::WindDown( void )
{
	// Get the player owning the weapon.
	CTFPlayer *pPlayer = ToTFPlayer( GetPlayerOwner() );
	if ( !pPlayer )
		return;

	SendWeaponAnim( ACT_MP_ATTACK_STAND_POSTFIRE );

	// Set the appropriate firing state.
	m_iWeaponState = AC_STATE_IDLE;
	pPlayer->m_Shared.RemoveCond( TF_COND_AIMING );
#ifdef CLIENT_DLL
	WeaponSoundUpdate();
#else
	pPlayer->ClearWeaponFireScene();
#endif

	// Time to weapon idle.
	m_flTimeWeaponIdle = gpGlobals->curtime + 2.0;

	// Update player's speed
	pPlayer->TeamFortress_SetSpeed();

#ifdef CLIENT_DLL
	m_flBarrelTargetVelocity = 0;
#endif
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CTFFlareGun::LaunchProjectile(void)
{
	// Get the player owning the weapon.
	CTFPlayer *pPlayer = ToTFPlayer(GetPlayerOwner());
	if (!pPlayer)
		return;

	CalcIsAttackCritical();

	SendWeaponAnim(ACT_VM_PRIMARYATTACK);

	pPlayer->SetAnimation(PLAYER_ATTACK1);
	pPlayer->DoAnimationEvent(PLAYERANIMEVENT_ATTACK_PRIMARY);

	FireProjectile(pPlayer);

#if !defined( CLIENT_DLL ) 
	pPlayer->SpeakWeaponFire();
	CTF_GameStats.Event_PlayerFiredWeapon(pPlayer, IsCurrentAttackACrit());
#endif

	// Set next attack times.
	m_flNextPrimaryAttack = gpGlobals->curtime + m_pWeaponInfo->GetWeaponData(m_iWeaponMode).m_flTimeFireDelay;

	SetWeaponIdleTime(gpGlobals->curtime + SequenceDuration());

	// Check the reload mode and behave appropriately.
	if (m_bReloadsSingly)
	{
		m_iReloadMode.Set(TF_RELOAD_START);
	}
}
Example #27
0
void CWeaponBaseGun::DoFireEffects()
{
    CMomentumPlayer *pPlayer = GetPlayerOwner();

    if (pPlayer)
        pPlayer->DoMuzzleFlash();
}
void CWeaponElite::WeaponIdle()
{
	CCSPlayer *pPlayer = GetPlayerOwner();
	if ( !pPlayer )
		return;

	if (m_flTimeWeaponIdle > gpGlobals->curtime)
		return;

	if ( pPlayer->HasShield() )
	{
		SetWeaponIdleTime( gpGlobals->curtime + 20 );
		
		//MIKETODO: shields
		//if ( FBitSet(m_iWeaponState, WPNSTATE_SHIELD_DRAWN) )
		//	 SendWeaponAnim( GLOCK18_SHIELD_IDLE, UseDecrement() ? 1:0 );
	}
	else
	{
		// only idle if the slid isn't back
		if (m_iClip1 != 0)
		{
			if ( m_iClip1 == 1 )
				SendWeaponAnim( ACT_VM_IDLE_EMPTY_LEFT );
			else
				SendWeaponAnim( ACT_VM_IDLE );
		}
	}
}
Example #29
0
void CWeaponBaseGun::ItemPostFrame()
{
    CMomentumPlayer *pPlayer = GetPlayerOwner();

    if (!pPlayer)
        return;

    if ((m_flNextPrimaryAttack <= gpGlobals->curtime) && (pPlayer->m_bResumeZoom))
    {
#ifndef CLIENT_DLL
        pPlayer->SetFOV(pPlayer, pPlayer->m_iLastZoomFOV, 0.05f);
        
        // Make sure we think that we are zooming on the server so we don't get instant acc bonus
        m_zoomFullyActiveTime = gpGlobals->curtime + 0.05f; 

        if (pPlayer->GetFOV() == pPlayer->m_iLastZoomFOV)
        {
            // return the fade level in zoom.
            pPlayer->m_bResumeZoom = false;
        }
#endif
    }
    ProcessAnimationEvents();
    BaseClass::ItemPostFrame();
}
Example #30
0
void CWeaponUSP::PrimaryAttack()
{
	CCSPlayer *pPlayer = GetPlayerOwner();
	if ( !pPlayer )
		return;

	if ( m_bSilencerOn )
	{
		if ( !FBitSet( pPlayer->GetFlags(), FL_ONGROUND ) )
			USPFire( 1.3f * (1 - m_flAccuracy) );
		else if (pPlayer->GetAbsVelocity().Length2D() > 5)
			USPFire( 0.25f * (1 - m_flAccuracy) );
		else if ( FBitSet( pPlayer->GetFlags(), FL_DUCKING ) )
			USPFire( 0.125f * (1 - m_flAccuracy) );
		else
			USPFire( 0.15f * (1 - m_flAccuracy) );
	}
	else
	{
		if ( !FBitSet( pPlayer->GetFlags(), FL_ONGROUND ) )
			USPFire( 1.2f * (1 - m_flAccuracy ) );
		else if (pPlayer->GetAbsVelocity().Length2D() > 5)
			USPFire( 0.225f * (1 - m_flAccuracy) );
		else if ( FBitSet( pPlayer->GetFlags(), FL_DUCKING ) )
			USPFire( 0.08f * (1 - m_flAccuracy) );
		else
			USPFire( 0.1f * (1 - m_flAccuracy) );
	}

}