void CBaseNetworkedPlayer::BecomeRagdollOnClient()
{
	// The the clientside entity makes its own ragdoll if it can
	EntityMessageBegin(this,true);
		WRITE_BYTE( BECOME_RAGDOLL );
	MessageEnd();
			
	// A dedicated entity is also created to ensure that clients who aren't in
	// PVS when the player dies or who connect later on see a ragdoll too
	RemoveRagdollEntity();

	CBaseNetworkedRagdoll* pRagdoll = (CBaseNetworkedRagdoll*)CreateEntityByName(ragdoll_ent_name);
	m_hRagdoll = pRagdoll;
	pRagdoll->m_hPlayer = this;

	pRagdoll->m_nModelIndex = m_nModelIndex;
		
	pRagdoll->m_vecForce = GetAbsVelocity() * 20;
	pRagdoll->m_nForceBone = m_nForceBone;

	pRagdoll->SetAbsOrigin( GetAbsOrigin() );
	pRagdoll->SetAbsAngles( GetAbsAngles() );

	pRagdoll->Spawn();
}
void CEnvScreenEffect::InputSendColorValue( inputdata_t &inputdata )
{
	m_ColorValue = inputdata.value.Color32();

	EntityMessageBegin( this );
		WRITE_BYTE( 4 );
	MessageEnd();
}
void CEnvScreenEffect::InputSendFloatValue( inputdata_t &inputdata )
{
	m_flValue = inputdata.value.Float();

	EntityMessageBegin( this );
		WRITE_BYTE( 3 );
	MessageEnd();
}
void CEnvScreenEffect::InputSendIntValue( inputdata_t &inputdata )
{
	m_iValue = inputdata.value.Int();

	EntityMessageBegin( this );
		WRITE_BYTE( 2 );
	MessageEnd();
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CEnvScreenEffect::InputStartEffect( inputdata_t &inputdata )
{
	m_OnStartEffect.FireOutput( this, this );

	EntityMessageBegin( this );
		WRITE_BYTE( 0 );
	MessageEnd();
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CEnvScreenEffect::InputStopEffect( inputdata_t &inputdata )
{
	m_flDuration = inputdata.value.Float();

	// Send the stop notification
	EntityMessageBegin( this );
		WRITE_BYTE( 1 );
	MessageEnd();
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CEnvScreenEffect::InputStartEffect( inputdata_t &inputdata )
{
	// Take the duration as our value
	m_flDuration = inputdata.value.Float();

	EntityMessageBegin( this );
		WRITE_BYTE( 0 );
	MessageEnd();
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CEnvScreenEffect::InputStopEffect( inputdata_t &inputdata )
{
	m_OnStopEffect.FireOutput( this, this );

	// Send the stop notification
	EntityMessageBegin( this );
		WRITE_BYTE( 1 );
	MessageEnd();
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CVehicleMortar::OnFinishedDeploy( void )
{
	BaseClass::OnFinishedDeploy();

	EntityMessageBegin( this, true );
		WRITE_STRING( "OnDeployed" );
	MessageEnd();
	
	m_flMortarYaw = 0;
	m_flMortarPitch = 45;
}
Example #10
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CGrenadeHopwire::EndThink( void )
{
	if ( hopwire_vortex.GetBool() )
	{
		EntityMessageBegin( this, true );
			WRITE_BYTE( 1 );
		MessageEnd();
	}

	SetThink( &CBaseEntity::SUB_Remove );
	SetNextThink( gpGlobals->curtime + 1.0f );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CVehicleMortar::OnFinishedUnDeploy( void )
{
	BaseClass::OnFinishedUnDeploy();

	// Called when we are deployed.
	EntityMessageBegin( this, true );
		WRITE_STRING( "OnUndeployed" );
	MessageEnd();

	m_flMortarYaw = 0;
	m_flMortarPitch = 0;
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CPropAPC2::FireMachineGun( void )
{
	if ( m_flMachineGunTime > gpGlobals->curtime )
		return;

	// If we're still firing the salvo, fire quickly
	m_iMachineGunBurstLeft--;
	if ( m_iMachineGunBurstLeft > 0 )
	{
		m_flMachineGunTime = gpGlobals->curtime + MACHINE_GUN_BURST_TIME;
	}
	else
	{
		// Reload the salvo
		m_iMachineGunBurstLeft = MACHINE_GUN_BURST_SIZE;
		m_flMachineGunTime = gpGlobals->curtime + MACHINE_GUN_BURST_PAUSE_TIME;
	}

	Vector vecMachineGunShootPos;
	QAngle vecMachineGunAngles;
	GetAttachment( m_nMachineGunMuzzleAttachment, vecMachineGunShootPos, vecMachineGunAngles );

	Vector vecMachineGunDir;
	AngleVectors( vecMachineGunAngles, &vecMachineGunDir );
	
	// Fire the round
	int	bulletType = GetAmmoDef()->Index("StriderMiniGun");
	FireBulletsInfo_t info;
		info.m_iShots = 1;
		info.m_vecSrc = vecMachineGunShootPos;
		info.m_vecDirShooting = vecMachineGunDir;
		info.m_vecSpread = VECTOR_CONE_8DEGREES;
		info.m_pAttacker =	(CBaseEntity *) m_hPlayer;
		info.m_flDistance = MAX_TRACE_LENGTH;
		info.m_iAmmoType =  bulletType;
		info.m_flDamage = 30;
		info.m_iPlayerDamage= 30;
		info.m_iTracerFreq = 1;
		FireBullets( info );
		EntityMessageBegin( this, true );
				WRITE_BYTE( APC_MSG_MACHINEGUN );
				WRITE_VEC3COORD(vecMachineGunShootPos);
				WRITE_VEC3COORD(vecMachineGunDir);
				WRITE_VEC3COORD(VECTOR_CONE_8DEGREES);
				WRITE_BYTE( bulletType );
	MessageEnd();
	DoMuzzleFlash();
	m_iAmmoCount--; 
	EmitSound( "Weapon_AR2.Single" );
}
Example #13
0
//------------------------------------------------------------------------------
// Purpose : Propagate force to each link in the rope.  Check for loops
// Input   :
// Output  :
//------------------------------------------------------------------------------
void CRopeKeyframe::PropagateForce(CBaseEntity *pActivator, CBaseEntity *pCaller, CBaseEntity *pFirstLink, float x, float y, float z)
{
	EntityMessageBegin( this, true );
		WRITE_FLOAT( x );
		WRITE_FLOAT( y );
		WRITE_FLOAT( z );
	MessageEnd();

	// UNDONE: Doesn't deal with intermediate loops
	// Propagate to next segment
	CRopeKeyframe *pNextLink = dynamic_cast<CRopeKeyframe*>((CBaseEntity *)m_hEndPoint);
	if (pNextLink && pNextLink != pFirstLink)
	{
		pNextLink->PropagateForce(pActivator, pCaller, pFirstLink, x, y, z);
	}
}
Example #14
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CGrenadeHopwire::CombatThink( void )
{
	// Stop the grenade from moving
	AddEFlags( EF_NODRAW );
	AddFlag( FSOLID_NOT_SOLID );
	VPhysicsDestroyObject();
	SetAbsVelocity( vec3_origin );
	SetMoveType( MOVETYPE_NONE );

	// Do special behaviors if there are any striders in the area
	KillStriders();

	// FIXME: Replace
	//EmitSound("NPC_Strider.Shoot");
	//EmitSound("d3_citadel.weapon_zapper_beam_loop2");

	// Quick screen flash
	CBasePlayer *pPlayer = ToBasePlayer( GetThrower() );
	color32 white = { 255,255,255,255 };
	UTIL_ScreenFade( pPlayer, white, 0.2f, 0.0f, FFADE_IN );

	// Create the vortex controller to pull entities towards us
	if ( hopwire_vortex.GetBool() )
	{
		m_hVortexController = CGravityVortexController::Create( GetAbsOrigin(), 512, 150, 3.0f );

		// Start our client-side effect
		EntityMessageBegin( this, true );
			WRITE_BYTE( 0 );
		MessageEnd();
		
		// Begin to stop in two seconds
		SetThink( &CGrenadeHopwire::EndThink );
		SetNextThink( gpGlobals->curtime + 2.0f );
	}
	else
	{
		// Remove us immediately
		SetThink( &CBaseEntity::SUB_Remove );
		SetNextThink( gpGlobals->curtime + 0.1f );
	}
}
void QUA_helicopter::Dispara(void)
{
	if (m_flWaitAttack<=gpGlobals->curtime) {
	Vector vecMachineGunShootPos;
	QAngle vecMachineGunAngles;
	GetAttachment( m_nMachineGunMuzzleAttachment, vecMachineGunShootPos, vecMachineGunAngles );

	Vector vecMachineGunDir = DondeApuntaPlayer() - vecMachineGunShootPos;
	VectorNormalize(vecMachineGunDir);
	//AngleVectors( vecMachineGunAngles, &vecMachineGunDir );
	
	// Fire the round
	FireBulletsInfo_t info;
		info.m_iShots = 1;
		info.m_vecSrc = vecMachineGunShootPos;
		info.m_vecDirShooting = vecMachineGunDir;
		info.m_vecSpread = VECTOR_CONE_PRECALCULATED;
		info.m_pAttacker =	(CBaseEntity *) m_hPlayer;
		info.m_flDistance = MAX_TRACE_LENGTH;
		info.m_iAmmoType =  m_iAmmoType;
		info.m_flDamage = 60;
		info.m_iPlayerDamage= 60;
		info.m_iTracerFreq = 1;
		FireBullets( info );
	EntityMessageBegin( this, true );
				WRITE_BYTE( HELICOPTER_MSG_MACHINEGUN );
				WRITE_VEC3COORD(vecMachineGunShootPos);
				WRITE_VEC3COORD(vecMachineGunDir);
				WRITE_VEC3COORD(VECTOR_CONE_PRECALCULATED);
				WRITE_BYTE( m_iAmmoType );
	MessageEnd();
	DoMuzzleFlash();
	m_iAmmoCount--; // Descontamos ametralladora.
	EmitSound( "Weapon_AR2.Single" );
	}
}
Example #16
0
//Called from PhysicsSimulate() or ReceiveMessage()
bool CDHLProjectile::OnTouch( trace_t &touchtr, bool bDecalOnly /*= false*/, ITraceFilter* pTraceFilter /*= NULL*/ )
{
	//Direction
	Vector vecDir = touchtr.endpos - touchtr.startpos;
	if ( vecDir == vec3_origin ) //Sometimes endpos==startpos so we need to get dir from velocity instead
	{
		#ifdef CLIENT_DLL
			vecDir = GetLocalVelocity();
		#else
			vecDir = m_vecCurVelocity;
		#endif
		VectorNormalize( vecDir );
	}

	CBaseEntity* ent = touchtr.m_pEnt;
	if ( !ent )
		return false;

	if ( touchtr.DidHit() )
	{
		//Never collide with self, shooter, or other projectiles
		if ( ent == this || dynamic_cast<CDHLProjectile*>(ent)
			|| ent == (CBaseEntity*)m_pShooter )
			//|| ( (m_iType == DHL_PROJECTILE_TYPE_COMBATKNIFE) && (ent == m_pFiringWeapon) ) ) //Combat knife - don't collide with weapon ent
			return false;

		//Hack: Sometimes hits are registered prematurely (usually to the torso area) with no hitbox.  Pretend nothing happened unless one is found.
		if ( ent->IsPlayer() && touchtr.hitgroup == 0 )
			return false;

		//Check friendly fire
		if ( CheckFriendlyFire( ent ) )
		{
			if ( !bDecalOnly )
			{
				ClearMultiDamage();

				//Do damage
				CTakeDamageInfo	dmgInfo( this, GetOwnerEntity(), m_iDamage, DMG_BULLET  );
				if ( m_iType == DHL_PROJECTILE_TYPE_COMBATKNIFE )
				{
					//CalculateMeleeDamageForce( &dmgInfo, vecDir, touchtr.endpos, 0.01f );
					Vector vecForce = vecDir;
					VectorNormalize( vecForce );
					//vecForce *= 10.0f; //Ripped from C_ClientRagdoll::ImpactTrace
					dmgInfo.SetDamageForce( vecForce );

					#ifndef CLIENT_DLL
						if ( IsOnFire() )
						{
							CBaseAnimating* pBAnim = dynamic_cast<CBaseAnimating*>(ent);
							if ( pBAnim )
								pBAnim->Ignite( 10.0f, false );
						}
					#endif
				}
				else
					CalculateBulletDamageForce( &dmgInfo, m_iAmmoType, vecDir, touchtr.endpos, 1.0f );
				dmgInfo.SetDamagePosition( touchtr.endpos );
				ent->DispatchTraceAttack( dmgInfo, vecDir, &touchtr );
				ApplyMultiDamage();
			}

			#ifdef CLIENT_DLL
				if ( ent->GetCollisionGroup() == COLLISION_GROUP_BREAKABLE_GLASS )
					return false;

				//Decals and such
				if ( !( touchtr.surface.flags & SURF_SKY ) && !touchtr.allsolid )
				{
					IPredictionSystem::SuppressEvents( false );
					if ( (m_iType == DHL_PROJECTILE_TYPE_BULLET || m_iType == DHL_PROJECTILE_TYPE_PELLET) )
					{
						UTIL_ImpactTrace( &touchtr, DMG_BULLET );
					}
					if ( m_iType == DHL_PROJECTILE_TYPE_COMBATKNIFE )
						PlayImpactSound( touchtr.m_pEnt, touchtr, touchtr.endpos, touchtr.surface.surfaceProps );
					IPredictionSystem::SuppressEvents( !prediction->IsFirstTimePredicted() );
				}
			#endif
		}

		if ( pTraceFilter && m_iType != DHL_PROJECTILE_TYPE_COMBATKNIFE )
		{
			PenetrationData_t nPenetrationData = DHLShared::TestPenetration( touchtr, m_pShooter, pTraceFilter, 
				m_iTimesPenetrated, m_flDistanceTravelled, m_iAmmoType );
			if ( nPenetrationData.m_bShouldPenetrate )
			{
				m_flDistanceTravelled += GetLocalOrigin().DistTo( nPenetrationData.m_vecNewBulletPos );
				MoveProjectileToPosition( nPenetrationData.m_vecNewBulletPos );
				m_iTimesPenetrated++;
				return true; //Keep going - but don't do anything else in this frame of PhysicsSimulate()
			}
		}
	
		//We're done unless what we hit was breakable glass
		if ( ent->GetCollisionGroup() != COLLISION_GROUP_BREAKABLE_GLASS )
		{
			#ifdef CLIENT_DLL
				m_bCollided = true;
				AddEffects( EF_NODRAW );
				if ( m_pTrail ) //NULL pointer here sometimes somehow...
					m_pTrail->AddEffects( EF_NODRAW );
			#else
				EntityMessageBegin( this );
					WRITE_BYTE( MSG_NOTIFY_REMOVAL );
				MessageEnd();
				
				if ( touchtr.DidHitWorld() && m_iType == DHL_PROJECTILE_TYPE_COMBATKNIFE && !( touchtr.surface.flags & SURF_SKY ) )
				{
					CBaseCombatWeapon* pKnifeEnt = assert_cast<CBaseCombatWeapon*>(CreateEntityByName( "weapon_combatknife" ));
					if ( pKnifeEnt )
					{
						pKnifeEnt->AddSpawnFlags( SF_NORESPAWN ); //Needed for weapon spawn & VPhysics setup to work correctly
						pKnifeEnt->SetAbsOrigin( touchtr.endpos );
						QAngle angles = vec3_angle;
						Vector vecKnifeDir = touchtr.startpos - touchtr.endpos;
						VectorAngles( vecKnifeDir, angles );
						angles[PITCH] -= 15.0f; //Correct for the .mdl being offset a bit
						pKnifeEnt->SetLocalAngles( angles );
						DispatchSpawn( pKnifeEnt );

						//Spawns vphys object and sets it up, essentially a copy of CWeaponHL2MPBase::FallInit()
						pKnifeEnt->VPhysicsDestroyObject();
						//Using SOLID_VPHYSICS instead of SOLID_BBOX (as ordinary weapons do) helps resolve some of the client side collision oddities
						Assert( pKnifeEnt->VPhysicsInitNormal( SOLID_VPHYSICS, FSOLID_NOT_STANDABLE | FSOLID_TRIGGER, true ) );
						pKnifeEnt->SetPickupTouch(); //Sets up automagic removal after time
						IPhysicsObject* pKnifePhys = pKnifeEnt->VPhysicsGetObject();
						if ( pKnifePhys )
						{
							//Knives are solid to bullets...the only way to make them non-solid to bullets is to do SetSolid( SOLID_NONE ) or AddSolidFlags( FSOLID_NOT_SOLID )
							//which breaks the +use pickup even with FSOLID_TRIGGER set.  Let's just call it a feature :)
							pKnifePhys->EnableMotion( false );
							pKnifePhys->EnableCollisions( false );
						}

						if ( IsOnFire() )
							pKnifeEnt->Ignite( 10.0f, false );
					}
				}

				//SetThink( &CDHLProjectile::SUB_Remove );
				//SetNextThink( gpGlobals->curtime + 0.1 );
				//SUB_Remove();
				//SetMoveType( MOVETYPE_NONE );
				m_flRemoveAt = gpGlobals->curtime + 0.1f; //Give the notification message a head start so that the client will have time to react
			#endif
		}
	}
	return true;
}