Пример #1
0
void C_NEOPlayer::UpdateThermoptic()
{
	if ( m_iThermoptic != m_iOldThermoptic )
	{
		if ( m_iThermoptic == 1 )
		{
			EmitSound( "NeoPlayer.ThermOpticOn" );

			dlight_t* light = effects->CL_AllocDlight( LIGHT_INDEX_TE_DYNAMIC + index );

			light->origin = GetAbsOrigin();
			light->radius = 96.f;
			light->color.r = 64;
			light->color.b = 64;
			light->color.b = 255;
			light->color.exponent = 10;
			light->die = gpGlobals->curtime + 0.5f;
			light->decay = 192.f;
		}

		else
			EmitSound( "NeoPlayer.ThermOpticOff" );
	}

	Vector vel;
	EstimateAbsVelocity( vel );

	float speed = vel.Length2D();

	if ( speed <= 20.f )
		m_flUnknown -= (gpGlobals->curtime - m_fLastThinkTime) * 1.1f;
	else
		m_flUnknown = speed * 0.004 * (gpGlobals->curtime - m_fLastThinkTime) * m_flUnknown;

	if ( m_flUnknown < 0.f )
		m_flUnknown = 0.f;

	if ( m_flUnknown > 1.f )
		m_flUnknown = 1.f;

	if ( !m_iThermoptic || gpGlobals->curtime >= (m_flUnknown2 + 1.f) )
	{
		m_nRenderFX = kRenderFxNone;
		m_iOldThermoptic = m_iThermoptic;
	}

	else
	{
		m_nRenderFX = kRenderFxDistort;
		m_iOldThermoptic = 1;
		m_flUnknown = 1.f - m_flUnknown;
	}
}
Пример #2
0
void C_ASW_Alien::FireEvent( const Vector& origin, const QAngle& angles, int event, const char *options )
{
	if ( event == AE_ASW_FOOTSTEP || event == AE_MARINE_FOOTSTEP )
	{
		Vector vel;
		EstimateAbsVelocity( vel );
		surfacedata_t *pSurface = GetGroundSurface();
		if (pSurface)
			MarineStepSound( pSurface, GetAbsOrigin(), vel );
	}
	else if (event == AE_REMOVE_CLIENT_AIM)
	{
		IASW_Client_Aim_Target::Remove( this );
	}
	else if ( event == AE_RAGDOLL )
	{

	}
	BaseClass::FireEvent(origin, angles, event, options);
}
Пример #3
0
	void CWeaponDODBase::OnDataChanged( DataUpdateType_t type )
	{
		if ( m_iState == WEAPON_NOT_CARRIED && m_iOldState != WEAPON_NOT_CARRIED ) 
		{
			// we are being notified of the weapon being dropped
			// add an interpolation history so the movement is smoother

			// Now stick our initial velocity into the interpolation history 
			CInterpolatedVar< Vector > &interpolator = GetOriginInterpolator();

			interpolator.ClearHistory();
			float changeTime = GetLastChangeTime( LATCH_SIMULATION_VAR );

			// Add a sample 1 second back.
			Vector vCurOrigin = GetLocalOrigin() - m_vInitialDropVelocity;
			interpolator.AddToHead( changeTime - 1.0, &vCurOrigin, false );

			// Add the current sample.
			vCurOrigin = GetLocalOrigin();
			interpolator.AddToHead( changeTime, &vCurOrigin, false );

			Vector estVel;
			EstimateAbsVelocity( estVel );

			/*Msg( "estimated velocity ( %.1f %.1f %.1f )  initial velocity ( %.1f %.1f %.1f )\n",
				estVel.x,
				estVel.y,
				estVel.z,
				m_vInitialDropVelocity.m_Value.x,
				m_vInitialDropVelocity.m_Value.y,
				m_vInitialDropVelocity.m_Value.z );*/

			OnWeaponDropped();
		}

		BaseClass::OnDataChanged( type );

		if ( GetPredictable() && !ShouldPredict() )
			ShutdownPredictable();
	}
Пример #4
0
bool C_ASW_Door::IsMoving()
{
	Vector vel;
	EstimateAbsVelocity(vel);
	return vel.LengthSqr() > 0;
}
Пример #5
0
bool CAutoAirblast::inEntityLoop(int index)
{
	if(!variables[0].bGet())
		return false;

	CEntity<> ent{index};

	if(ent.isNull())
	{
		targets.erase(index);
		return false;
	}

	if(ent->IsDormant())
	{
		targets.erase(index);
		return false;
	}

	// if the projectile is from our own team we dont want or need to reflect it
	if(ent.get<int>(gEntVars.iTeam) == gLocalPlayerVars.team)
	{
		targets.erase(index);
		return false;
	}

	classId id = ent->GetClientClass()->iClassID;

	Vector vel;

	switch(id)
	{
	case classId::CTFProjectile_Arrow:
		//case classId::CTFProjectile_Cleaver:
		//case classId::CTFProjectile_EnergyBall:
	case classId::CTFProjectile_Flare:
		//case classId::CTFProjectile_GrapplingHook:
		//case classId::CTFProjectile_HealingBolt:
	case classId::CTFProjectile_Jar:
	case classId::CTFProjectile_JarMilk:
	case classId::CTFProjectile_Rocket:
	case classId::CTFProjectile_SentryRocket:
		//case classId::CTFProjectile_SpellBats:
		//case classId::CTFProjectile_SpellFireball:
		//case classId::CTFProjectile_SpellKartBats:
		//case classId::CTFProjectile_SpellKartOrb:
		//case classId::CTFProjectile_SpellLightningOrb:
		//case classId::CTFProjectile_SpellMeteorShower:
		//case classId::CTFProjectile_SpellMirv:
		//case classId::CTFProjectile_SpellPumpkin:
		//case classId::CTFProjectile_SpellSpawnBoss:
		//case classId::CTFProjectile_SpellSpawnHorde:
		//case classId::CTFProjectile_SpellSpawnZombie:
		//case classId::CTFProjectile_SpellTransposeTeleport:
		//case classId::CTFProjectile_Throwable:
		//case classId::CTFProjectile_ThrowableBreadMonster:
		//case classId::CTFProjectile_ThrowableBrick:
		//case classId::CTFProjectile_ThrowableRepel:
	case classId::CTFGrenadePipebombProjectile:
		// since it is a projectile, we can get its velocity
		vel = EstimateAbsVelocity(ent.castToPointer<CBaseEntity>());
		break;
	default:
		targets.erase(index);
		return false;
	}

	Vector origin;
	ent->GetWorldSpaceCenter(origin);
	
	Vector eyePos = gLocalPlayerVars.pred.origin + CEntity<>{ me }.get<Vector>(gEntVars.vecViewOffset);

	float latency = gInts.Engine->GetNetChannelInfo()->GetLatency(FLOW_INCOMING) + gInts.Engine->GetNetChannelInfo()->GetLatency(FLOW_OUTGOING);

	Vector target = origin + (vel * latency);

	targets[index] = (target - eyePos).Length();

	return true;
}
void C_ASW_Simple_Drone::UpdatePoseParams()
{
	VPROF_BUDGET( "C_ASW_Simple_Drone::UpdatePoseParams", VPROF_BUDGETGROUP_ASW_CLIENT );
	// update pose params based on velocity and our angles

	// calculate the angle difference between our facing and our velocity
	Vector v;
	EstimateAbsVelocity(v);	
	float travel_yaw = anglemod(UTIL_VecToYaw(v));
	float current_yaw = anglemod( GetLocalAngles().y );

	// Draw a green triangle on the ground for the travel yaw
	if (cl_asw_drone_travel_yaw.GetBool())
	{
		float flBaseSize = 10;
		float flHeight = 80;
		Vector vBasePos = GetAbsOrigin() + Vector( 0, 0, 5 );
		QAngle angles( 0, 0, 0 );
		Vector vForward, vRight, vUp;
		angles[YAW] = travel_yaw;
		AngleVectors( angles, &vForward, &vRight, &vUp );
		debugoverlay->AddTriangleOverlay( vBasePos+vRight*flBaseSize/2, vBasePos-vRight*flBaseSize/2, vBasePos+vForward*flHeight, 0, 255, 0, 255, false, 0.01 );		
	}

	// calculate our fraction of full anim velocity
	float speed_fraction = 0;
	float ground_speed = GetRunSpeed();
	if (ground_speed > 0)
		speed_fraction = clamp<float>(
			(v.Length()) / ground_speed,
			0.0f, 1.0f);
	speed_fraction = 1.0f - speed_fraction;

	// smooth out the travel yaw to prevent sudden changes in move_yaw pose parameter
	if (m_flCurrentTravelYaw == -1)
		m_flCurrentTravelYaw = travel_yaw;
	else
	{
		float travel_diff = AngleDiff(m_flCurrentTravelYaw, travel_yaw);
		if (travel_diff < 0)
			travel_diff = -travel_diff;
		travel_diff = clamp<float>(travel_diff, 32.0f, 256.0f);	// alter the yaw by this amount - i.e. faster if the angle is bigger, but clamped
		if (speed_fraction > 0.75f)	// change the angle even quicker if we're moving very slowly
		{
			travel_diff *= (2.0f + ((speed_fraction - 0.75f) * 8.0f));
		}
		if (speed_fraction < 1.0f)	// don't bother adjusting the yaw if we're standing still
			m_flCurrentTravelYaw = AI_ClampYaw( travel_diff * cl_asw_drone_travel_yaw_rate.GetFloat(), m_flCurrentTravelYaw, travel_yaw, gpGlobals->frametime );
		else
			m_flCurrentTravelYaw = travel_yaw;	// if we're standing still, immediately change
		//Msg("travel=%.1f current_travel=%.1f current=%.1f t=%f\n",
			//travel_yaw, m_flCurrentTravelYaw, current_yaw, gpGlobals->curtime);
		travel_yaw = m_flCurrentTravelYaw;
	}

	// set the move_yaw pose parameter
	float diff = AngleDiff(travel_yaw, current_yaw);

	// Draw a green triangle on the ground for the move yaw
	if (cl_asw_drone_travel_yaw.GetBool())
	{
		float flBaseSize = 10;
		float flHeight = 80;
		Vector vBasePos = GetAbsOrigin() + Vector( 0, 0, 5 );
		QAngle angles( 0, 0, 0 );
		Vector vForward, vRight, vUp;
		angles[YAW] = travel_yaw;
		AngleVectors( angles, &vForward, &vRight, &vUp );
		debugoverlay->AddTriangleOverlay( vBasePos+vRight*flBaseSize/2, vBasePos-vRight*flBaseSize/2, vBasePos+vForward*flHeight, 0, 0, 255, 255, false, 0.01 );		

		angles[YAW] = diff;
		AngleVectors( angles, &vForward, &vRight, &vUp );
		debugoverlay->AddTriangleOverlay( vBasePos+vRight*flBaseSize/2, vBasePos-vRight*flBaseSize/2, vBasePos+vForward*flHeight, 255, 0, 0, 255, false, 0.01 );
	}
	
	
	diff = clamp<float>(diff, -180.0f, 180.0f);
	int pose_index = LookupPoseParameter( "move_yaw" );
	if (pose_index >= 0)
	{
		SetPoseParameter(pose_index, diff);
	}
	
	// smooth out our speed fraction to prevent sudden changes to idle_move pose parameter
	//Msg("sf=%f cts=%f gs=%f vl=%f\n", speed_fraction, m_flCurrentTravelSpeed,
		//ground_speed, v.Length());
	if (m_flCurrentTravelSpeed == -1)
	{
		m_flCurrentTravelSpeed = speed_fraction;
	}
	else
	{
		if (m_flCurrentTravelSpeed < speed_fraction)
		{
			m_flCurrentTravelSpeed = clamp<float>(
				m_flCurrentTravelSpeed + gpGlobals->frametime,
				0.0f, speed_fraction);
		}
		else
		{
			m_flCurrentTravelSpeed = clamp<float>(
				m_flCurrentTravelSpeed - gpGlobals->frametime * 3.0f,
				speed_fraction, 1.0f);
		}
		speed_fraction = m_flCurrentTravelSpeed;
	}
	
	// set the idle_move pose parameter
	pose_index = LookupPoseParameter( "idle_move" );
	if (pose_index >= 0)
	{
		SetPoseParameter(pose_index, 100.0f * speed_fraction);
	}
}