//-----------------------------------------------------------------------------
// Purpose: 
// Input  : &info - 
// Output : Returns true on success, false on failure.
//-----------------------------------------------------------------------------
void CNPC_CombineAce::Event_Killed( const CTakeDamageInfo &info )
{
	if (!(g_Language.GetInt() == LANGUAGE_GERMAN || UTIL_IsLowViolence()) && info.GetDamageType() & (DMG_BLAST | DMG_CRUSH) && !(info.GetDamageType() & (DMG_DISSOLVE)) && !PlayerHasMegaPhysCannon())
	{
		Vector vecDamageDir = info.GetDamageForce();
		SpawnBlood(GetAbsOrigin(), g_vecAttackDir, BloodColor(), info.GetDamage());
		DispatchParticleEffect("headshotspray", GetAbsOrigin(), GetAbsAngles(), this);
		EmitSound("Gore.Headshot");
		float flFadeTime = 25.0;

		CGib::SpawnSpecificGibs(this, 1, 750, 1500, "models/gibs/soldier_ace_head.mdl", flFadeTime);

		Vector vecRagForce;
		vecRagForce.x = random->RandomFloat(-400, 400);
		vecRagForce.y = random->RandomFloat(-400, 400);
		vecRagForce.z = random->RandomFloat(0, 250);

		Vector vecRagDmgForce = (vecRagForce + vecDamageDir);

		CBaseEntity *pLeftArmGib = CreateRagGib("models/gibs/soldier_ace_left_arm.mdl", GetAbsOrigin(), GetAbsAngles(), vecRagDmgForce, flFadeTime, IsOnFire());
		if (pLeftArmGib)
		{
			color32 color = pLeftArmGib->GetRenderColor();
			pLeftArmGib->SetRenderColor(color.r, color.g, color.b, color.a);
		}

		CBaseEntity *pRightArmGib = CreateRagGib("models/gibs/soldier_ace_right_arm.mdl", GetAbsOrigin(), GetAbsAngles(), vecRagDmgForce, flFadeTime, IsOnFire());
		if (pRightArmGib)
		{
			color32 color = pRightArmGib->GetRenderColor();
			pRightArmGib->SetRenderColor(color.r, color.g, color.b, color.a);
		}

		CBaseEntity *pTorsoGib = CreateRagGib("models/gibs/soldier_ace_torso.mdl", GetAbsOrigin(), GetAbsAngles(), vecRagDmgForce, flFadeTime, IsOnFire());
		if (pTorsoGib)
		{
			color32 color = pTorsoGib->GetRenderColor();
			pTorsoGib->SetRenderColor(color.r, color.g, color.b, color.a);
		}

		CBaseEntity *pPelvisGib = CreateRagGib("models/gibs/soldier_ace_pelvis.mdl", GetAbsOrigin(), GetAbsAngles(), vecRagDmgForce, flFadeTime, IsOnFire());
		if (pPelvisGib)
		{
			color32 color = pPelvisGib->GetRenderColor();
			pPelvisGib->SetRenderColor(color.r, color.g, color.b, color.a);
		}

		CBaseEntity *pLeftLegGib = CreateRagGib("models/gibs/soldier_ace_left_leg.mdl", GetAbsOrigin(), GetAbsAngles(), vecRagDmgForce, flFadeTime, IsOnFire());
		if (pLeftLegGib)
		{
			color32 color = pLeftLegGib->GetRenderColor();
			pLeftLegGib->SetRenderColor(color.r, color.g, color.b, color.a);
		}

		CBaseEntity *pRightLegGib = CreateRagGib("models/gibs/soldier_ace_right_leg.mdl", GetAbsOrigin(), GetAbsAngles(), vecRagDmgForce, flFadeTime, IsOnFire());
		if (pRightLegGib)
		{
			color32 color = pRightLegGib->GetRenderColor();
			pRightLegGib->SetRenderColor(color.r, color.g, color.b, color.a);
		}

		//now add smaller gibs.
		CGib::SpawnSpecificGibs(this, 3, 750, 1500, "models/gibs/pgib_p3.mdl", flFadeTime);
		CGib::SpawnSpecificGibs(this, 3, 750, 1500, "models/gibs/pgib_p4.mdl", flFadeTime);

		if (!m_bNoArmor && combine_ace_shieldspawnmode.GetInt() > 0)
		{
			pArmor->Remove();
			DropItem("item_shield", WorldSpaceCenter() + RandomVector(-4, 4), RandomAngle(0, 360));
		}

		Vector forceVector = CalcDamageForceVector(info);

		// Drop any weapon that I own
		if (VPhysicsGetObject())
		{
			Vector weaponForce = forceVector * VPhysicsGetObject()->GetInvMass();
			Weapon_Drop(m_hActiveWeapon, NULL, &weaponForce);
		}
		else
		{
			Weapon_Drop(m_hActiveWeapon);
		}

		if (info.GetAttacker()->IsPlayer())
		{
			((CSingleplayRules*)GameRules())->NPCKilled(this, info);
		}

		UTIL_Remove(this);
		SetThink(NULL);
		return;
	}

	// Don't bother if we've been told not to, or the player has a megaphyscannon
	if ( combine_ace_spawn_health.GetBool() == false || PlayerHasMegaPhysCannon() )
	{
		BaseClass::Event_Killed( info );
		return;
	}

	SetEyeState(ACE_EYE_DEAD);

	if (!m_bNoArmor && combine_ace_shieldspawnmode.GetInt() > 0)
	{
		pArmor->Remove();
	}

	CBasePlayer *pPlayer = ToBasePlayer( info.GetAttacker() );

	if ( !pPlayer )
	{
		CPropVehicleDriveable *pVehicle = dynamic_cast<CPropVehicleDriveable *>( info.GetAttacker() ) ;
		if ( pVehicle && pVehicle->GetDriver() && pVehicle->GetDriver()->IsPlayer() )
		{
			pPlayer = assert_cast<CBasePlayer *>( pVehicle->GetDriver() );
		}
	}

	if ( pPlayer != NULL )
	{
		// Elites drop alt-fire ammo, so long as they weren't killed by dissolving.
#ifdef HL2_EPISODIC
		if (HasSpawnFlags(SF_COMBINE_NO_AR2DROP) == false)
#endif
		{
			if (FClassnameIs(GetActiveWeapon(), "weapon_ar2"))
			{
				CBaseEntity *pItem = DropItem("item_ammo_ar2_altfire", WorldSpaceCenter() + RandomVector(-4, 4), RandomAngle(0, 360));

				if (pItem)
				{
					IPhysicsObject *pObj = pItem->VPhysicsGetObject();

					if (pObj)
					{
						Vector			vel = RandomVector(-64.0f, 64.0f);
						AngularImpulse	angImp = RandomAngularImpulse(-300.0f, 300.0f);

						vel[2] = 0.0f;
						pObj->AddVelocity(&vel, &angImp);
					}

					if (info.GetDamageType() & DMG_DISSOLVE)
					{
						CBaseAnimating *pAnimating = dynamic_cast<CBaseAnimating*>(pItem);

						if (pAnimating)
						{
							pAnimating->Dissolve(NULL, gpGlobals->curtime, false, ENTITY_DISSOLVE_NORMAL);
						}
					}
					else
					{
						WeaponManager_AddManaged(pItem);
					}
				}
			}
			else if (FClassnameIs(GetActiveWeapon(), "weapon_smg1"))
			{
				CBaseEntity *pItem = DropItem("item_ammo_smg1_grenade", WorldSpaceCenter() + RandomVector(-4, 4), RandomAngle(0, 360));

				if (pItem)
				{
					IPhysicsObject *pObj = pItem->VPhysicsGetObject();

					if (pObj)
					{
						Vector			vel = RandomVector(-64.0f, 64.0f);
						AngularImpulse	angImp = RandomAngularImpulse(-300.0f, 300.0f);

						vel[2] = 0.0f;
						pObj->AddVelocity(&vel, &angImp);
					}

					if (info.GetDamageType() & DMG_DISSOLVE)
					{
						CBaseAnimating *pAnimating = dynamic_cast<CBaseAnimating*>(pItem);

						if (pAnimating)
						{
							pAnimating->Dissolve(NULL, gpGlobals->curtime, false, ENTITY_DISSOLVE_NORMAL);
						}
					}
					else
					{
						WeaponManager_AddManaged(pItem);
					}
				}
			}
		}

		CHalfLife2 *pHL2GameRules = static_cast<CHalfLife2 *>(g_pGameRules);

		// Attempt to drop health
		if ( pHL2GameRules->NPC_ShouldDropHealth( pPlayer ) )
		{
			DropItem( "item_healthvial", WorldSpaceCenter()+RandomVector(-4,4), RandomAngle(0,360) );
			pHL2GameRules->NPC_DroppedHealth();
		}

		if (!m_bNoArmor && combine_ace_shieldspawnmode.GetInt() > 0)
		{
			DropItem("item_shield", WorldSpaceCenter() + RandomVector(-4, 4), RandomAngle(0, 360));
		}
	}

	BaseClass::Event_Killed( info );
}
Beispiel #2
0
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
int CNPC_Blob::ComputeBatchSize()
{
	int batchSize = m_Elements.Count() / ( 100 / blob_batchpercent.GetInt() );
	return batchSize;
}
Beispiel #3
0
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void CNPC_Blob::RunAI()
{
	BaseClass::RunAI();

	if( !m_bInitialized )
	{
		// m_bInitialized is set to false in the constructor. So this bit of
		// code runs one time, the first time I think.
		Msg("I need to initialize\n");
		InitializeElements();
		m_bInitialized = true;
		return;
	}

	int iIdealNumElements = blob_numelements.GetInt();
	if( iIdealNumElements != m_iNumElements )
	{
		int delta = iIdealNumElements - m_iNumElements;

		if( delta < 0 )
		{
			delta = -delta;
			delta = MIN(delta, 5 );
			RemoveExcessElements( delta );
			
			if( m_iReconfigureElement > m_iNumElements )
			{
				// Start this index over at zero, if it is past the new end of the utlvector.
				m_iReconfigureElement = 0;
			}
		}
		else
		{
			delta = MIN(delta, 5 );
			AddNewElements( delta );
		}
	
		RecomputeIdealElementDist();
	}

	ComputeCentroid();

	if( npc_blob_show_centroid.GetBool() )
	{
		NDebugOverlay::Cross3D( m_vecCentroid + Vector( 0, 0, 12 ), 32, 0, 255, 0, false, 0.025f );
	}

	if( npc_blob_use_threading.GetBool() )
	{
		IterRangeParallel( this, &CNPC_Blob::DoBlobBatchedAI, 0, m_Elements.Count() );
	}
	else
	{
		DoBlobBatchedAI( 0, m_Elements.Count() );
	}

	if( GetEnemy() != NULL )
	{
		float flEnemyDistSqr = m_vecCentroid.DistToSqr( GetEnemy()->GetAbsOrigin() );

		if( flEnemyDistSqr <= Square( 32.0f ) )
		{
			if( GetEnemy()->Classify() == CLASS_COMBINE )
			{
				if( !m_bEatCombineHack )
				{
					variant_t var;

					var.SetFloat( 0 );
					g_EventQueue.AddEvent( GetEnemy(), "HitByBugBait", 0.0f, this, this );
					g_EventQueue.AddEvent( GetEnemy(), "SetHealth", var, 3.0f, this, this );
					m_bEatCombineHack = true;

					blob_radius.SetValue( 48.0f );
					RecomputeIdealElementDist();
				}
			}
			else
			{
				CTakeDamageInfo info;

				info.SetAttacker( this );
				info.SetInflictor( this );
				info.SetDamage( 5 );
				info.SetDamageType( DMG_SLASH );
				info.SetDamageForce( Vector( 0, 0, 1 ) );

				GetEnemy()->TakeDamage( info );
			}
		}
	}

	SetNextThink( gpGlobals->curtime + npc_blob_think_interval.GetFloat() );
}
//---------------------------------------------------------------------------------
// Purpose: Reset everyones kills streaks
//---------------------------------------------------------------------------------
void	ProcessQuakeDeath(IGameEvent *event)
{
	player_t	attacker;
	player_t	victim;
	bool		headshot;
	char		weapon_name[128];

	if (war_mode) return;
	if (mani_quake_sounds.GetInt() == 0) return;

	// Get kill information
	attacker.user_id = event->GetInt("attacker", -1);
	victim.user_id = event->GetInt("userid", -1);
	headshot = event->GetBool("headshot", false);
	Q_strcpy(weapon_name, event->GetString("weapon", ""));
	
	if (victim.user_id == -1)
	{
		return;
	}

	if (!FindPlayerByUserID(&victim)) return;

	if (attacker.user_id == -1 || attacker.user_id == 0)
	{
		// World attacked
		return;
	}

	// Suicide
	if (attacker.user_id == victim.user_id) 
	{
		ResetQuakePlayer (victim.index - 1);
		return;
	}

	// Get attacker information
	if (!FindPlayerByUserID(&attacker)) return;

	if (gpManiGameType->IsTeamPlayAllowed())
	{
		// Team based game
		if (attacker.team == victim.team)
		{
			PlayQuakeSound(&attacker, &victim, MANI_QUAKE_SOUND_TEAMKILLER, mani_quake_team_killer_mode.GetInt());
			ShowQuakeSound(&attacker, &victim, mani_quake_team_killer_mode.GetInt(), "%s", Translate(NULL, 815, "%s%s", attacker.name, victim.name));
			// On same team so reset their score
			ResetQuakePlayer (attacker.index - 1);
			return;
		}
	}

	ResetQuakePlayer(victim.index - 1);

	// Need to prioritize sounds
	// 1 - First Blood (first kill)
	// 2 - Humiliation (knife kill)
	// 3 - Dominating
	// 4 - Killing Spree
	// 5 - Monster Kill (multiple kills in one go
	// 6 - Unstoppable
	// 7 - Ultra Kill
	// 8 - God Like
	// 9 - Wicked Sick
	// 10 - Ludicrous Kill
	// 11 - Holy Shit
	// 12 - Head shot 
	
	bool multi_kill;
	int	 kill_streak;

	kill_streak = IncrementKillStreak (attacker.index - 1, &multi_kill);

	// First Blood
	if (quake_first_blood && mani_quake_firstblood_mode.GetInt() != 0)
	{
		quake_first_blood = false;
		PlayQuakeSound(&attacker, &victim, MANI_QUAKE_SOUND_FIRSTBLOOD, mani_quake_firstblood_mode.GetInt());
		ShowQuakeSound(&attacker, &victim, mani_quake_firstblood_visual_mode.GetInt(), "%s", Translate(NULL, 801,"%s", attacker.name));
		return;
	}

	// Humiliation
	if ((FStrEq(mani_quake_humiliation_weapon.GetString(), weapon_name) || FStrEq(mani_quake_humiliation_weapon2.GetString(), weapon_name))
		&& mani_quake_humiliation_mode.GetInt() != 0)
	{
		PlayQuakeSound(&attacker, &victim, MANI_QUAKE_SOUND_HUMILIATION, mani_quake_humiliation_mode.GetInt());
		ShowQuakeSound(&attacker, &victim, mani_quake_humiliation_visual_mode.GetInt(), "%s", Translate(NULL, 802, "%s%s", victim.name, attacker.name));
		return;
	}

	// Multi Kill
	if (multi_kill && mani_quake_multi_kill_mode.GetInt() != 0)
	{
		PlayQuakeSound(&attacker, &victim, MANI_QUAKE_SOUND_MULTIKILL, mani_quake_multi_kill_mode.GetInt());
		ShowQuakeSound(&attacker, &victim, mani_quake_multi_kill_visual_mode.GetInt(), "%s", Translate(NULL, 803, "%s", attacker.name));
		return;
	}

	// Dominating
	if (kill_streak == mani_quake_dominating_trigger_count.GetInt() && mani_quake_dominating_mode.GetInt() != 0)
	{
		PlayQuakeSound(&attacker, &victim, MANI_QUAKE_SOUND_DOMINATING, mani_quake_dominating_mode.GetInt());
		ShowQuakeSound(&attacker, &victim, mani_quake_dominating_visual_mode.GetInt(), "%s", Translate(NULL, 804, "%s", attacker.name));
		return;
	}

	// Rampage
	if (kill_streak == mani_quake_rampage_trigger_count.GetInt() && mani_quake_rampage_mode.GetInt() != 0)
	{
		PlayQuakeSound(&attacker, &victim, MANI_QUAKE_SOUND_RAMPAGE, mani_quake_rampage_mode.GetInt());
		ShowQuakeSound(&attacker, &victim, mani_quake_rampage_visual_mode.GetInt(), "%s", Translate(NULL, 805, "%s", attacker.name));
		return;
	}

	// Killing Spree
	if (kill_streak == mani_quake_killing_spree_trigger_count.GetInt() && mani_quake_killing_spree_mode.GetInt() != 0)
	{
		PlayQuakeSound(&attacker, &victim, MANI_QUAKE_SOUND_KILLINGSPREE, mani_quake_killing_spree_mode.GetInt());
		ShowQuakeSound(&attacker, &victim, mani_quake_killing_spree_visual_mode.GetInt(), "%s", Translate(NULL, 806, "%s", attacker.name));
		return;
	}

	// Monster Kill
	if (kill_streak == mani_quake_monster_kill_trigger_count.GetInt() && mani_quake_monster_kill_mode.GetInt() != 0)
	{
		PlayQuakeSound(&attacker, &victim, MANI_QUAKE_SOUND_MONSTERKILL, mani_quake_monster_kill_mode.GetInt());
		ShowQuakeSound(&attacker, &victim, mani_quake_monster_kill_visual_mode.GetInt(), "%s", Translate(NULL, 807, "%s", attacker.name));
		return;
	}

	// Unstoppable
	if (kill_streak == mani_quake_unstoppable_trigger_count.GetInt() && mani_quake_unstoppable_mode.GetInt() != 0)
	{
		PlayQuakeSound(&attacker, &victim, MANI_QUAKE_SOUND_UNSTOPPABLE, mani_quake_unstoppable_mode.GetInt());
		ShowQuakeSound(&attacker, &victim, mani_quake_unstoppable_visual_mode.GetInt(), "%s", Translate(NULL, 808, "%s", attacker.name));
		return;
	}

	// Ultra Kill
	if (kill_streak == mani_quake_ultra_kill_trigger_count.GetInt() && mani_quake_ultra_kill_mode.GetInt() != 0)
	{
		PlayQuakeSound(&attacker, &victim, MANI_QUAKE_SOUND_ULTRAKILL, mani_quake_ultra_kill_mode.GetInt());
		ShowQuakeSound(&attacker, &victim, mani_quake_ultra_kill_visual_mode.GetInt(), "%s", Translate(NULL, 809, "%s", attacker.name));
		return;
	}

	// God Like
	if (kill_streak == mani_quake_god_like_trigger_count.GetInt() && mani_quake_god_like_mode.GetInt() != 0)
	{
		PlayQuakeSound(&attacker, &victim, MANI_QUAKE_SOUND_GODLIKE, mani_quake_god_like_mode.GetInt());
		ShowQuakeSound(&attacker, &victim, mani_quake_god_like_visual_mode.GetInt(), "%s", Translate(NULL, 810, "%s", attacker.name));
		return;
	}

	// Wicked Sick
	if (kill_streak == mani_quake_wicked_sick_trigger_count.GetInt() && mani_quake_wicked_sick_mode.GetInt() != 0)
	{
		PlayQuakeSound(&attacker, &victim, MANI_QUAKE_SOUND_WICKEDSICK, mani_quake_wicked_sick_mode.GetInt());
		ShowQuakeSound(&attacker, &victim, mani_quake_wicked_sick_visual_mode.GetInt(), "%s", Translate(NULL, 811, "%s", attacker.name));
		return;
	}

	// Ludicrous Kill
	if (kill_streak == mani_quake_ludicrous_kill_trigger_count.GetInt() && mani_quake_ludicrous_kill_mode.GetInt() != 0)
	{
		PlayQuakeSound(&attacker, &victim, MANI_QUAKE_SOUND_LUDICROUSKILL, mani_quake_ludicrous_kill_mode.GetInt());
		ShowQuakeSound(&attacker, &victim, mani_quake_ludicrous_kill_visual_mode.GetInt(), "%s", Translate(NULL, 812, "%s", attacker.name));
		return;
	}

	// Holy Shit
	if (kill_streak == mani_quake_holy_shit_trigger_count.GetInt() && mani_quake_holy_shit_mode.GetInt() != 0)
	{
		PlayQuakeSound(&attacker, &victim, MANI_QUAKE_SOUND_HOLYSHIT, mani_quake_holy_shit_mode.GetInt());
		ShowQuakeSound(&attacker, &victim, mani_quake_holy_shit_visual_mode.GetInt(), "%s", Translate(NULL, 813, "%s", attacker.name));
		return;
	}

	// Head shot
	if (headshot && mani_quake_headshot_mode.GetInt() != 0)
	{
		PlayQuakeSound(&attacker, &victim, MANI_QUAKE_SOUND_HEADSHOT, mani_quake_headshot_mode.GetInt());
		ShowQuakeSound(&attacker, &victim, mani_quake_headshot_visual_mode.GetInt(), "%s", Translate(NULL, 814, "%s", attacker.name));
		return;
	}


}
//-----------------------------------------------------------------------------
// Purpose: Give the buster a slight attraction to striders.
//			Ported back from the magnade.
//-----------------------------------------------------------------------------
void CWeaponStriderBuster::BusterFlyThink()
{
	if (IsAttachedToStrider())
		return; // early out. Think no more.

	// If we're nosediving, forget about magnetism.
	if ( m_bNoseDiving )
	{
		if ( VPhysicsGetObject() )
			VPhysicsGetObject()->ApplyForceCenter( Vector( 0, 0, striderbuster_dive_force.GetFloat() ) );
		SetNextThink(gpGlobals->curtime + 0.01f);
		return;
	}

	// seek?	
	const float magradius = 38.0 * sk_striderbuster_magnet_multiplier.GetFloat(); // radius of strider hull times multiplier
	if (magradius > 0 &&
		GetMoveType() == MOVETYPE_VPHYSICS &&
		VPhysicsGetObject()
		)
	{
		// find the nearest enemy.
		CBaseEntity *pList[16];
		Vector origin = GetAbsOrigin();

		// do a find in box ( a little faster than sphere )
		int count;
		{
			Vector mins,maxs;
			mins = origin; 
			mins -= magradius;
			
			maxs = origin; 
			maxs += magradius;

			count = UTIL_EntitiesInBox(pList, 16, mins, maxs, FL_NPC); 
		}

		float magradiusSq = Square( magradius );	
		float nearestDistSq = magradiusSq + 1;
		int bestFit = -1;
		Vector toTarget(0.0f, 0.0f, 0.0f); // will be garbage unless something good is found
		CNPC_Strider *pBestStrider  = NULL;

		for ( int ii = 0 ; ii < count ; ++ii )
		{
			CNPC_Strider *pStrider = dynamic_cast<CNPC_Strider *>(pList[ii]);
			if ( pStrider && !pStrider->CarriedByDropship() ) // ShouldStickToEntity() doesn't work because the strider NPC isn't what we glue to
			{
				// get distance squared
				VectorSubtract( pStrider->GetAdjustedOrigin(), GetAbsOrigin(), toTarget );

				//NDebugOverlay::Line( GetAbsOrigin(), GetAbsOrigin() + toTarget, 128, 0, 128, false, 0.1 );

				float dSq = toTarget.LengthSqr();
				if (dSq < nearestDistSq)
				{
					bestFit = ii; nearestDistSq = dSq;
					pBestStrider = pStrider;
				}
			}
		}

		if (bestFit >= 0) // we found something and should attract towards it. (hysterisis later?)
		{
			if ( striderbuster_debugseek.GetBool() )
			{
				NDebugOverlay::Circle( GetAbsOrigin() + toTarget, magradius, 255, 255, 255, 255, true, .1 );
				NDebugOverlay::Cross3D( GetAbsOrigin() + toTarget, magradius, 255, 255, 255, true, .1 );
			}

			// force magnitude. 
			float magnitude = GetMass() * striderbuster_magnetic_force_strider.GetFloat();
			int falloff = striderbuster_falloff_power.GetInt();
			switch (falloff) 
			{
			case 1:
				VPhysicsGetObject()->ApplyForceCenter( toTarget * (magnitude / nearestDistSq) ); // dividing through by distance squared normalizes toTarget and gives a linear falloff
				break;
			case 2:
				VPhysicsGetObject()->ApplyForceCenter( toTarget * (magnitude / (nearestDistSq * sqrtf(nearestDistSq))) ); // dividing through by distance cubed normalizes toTarget and gives a quadratic falloff
				break;
			case 3:
				VPhysicsGetObject()->ApplyForceCenter( toTarget * (magnitude / (nearestDistSq * nearestDistSq)) ); // dividing through by distance fourth normalizes toTarget and gives a cubic falloff
				break;
			case 4:
				{
					Vector toTarget;
					pBestStrider->GetAttachment( "buster_target", toTarget );

					if ( striderbuster_debugseek.GetBool() )
					{
						NDebugOverlay::Cross3D( toTarget, magradius, 255, 0, 255, true, .1 );
						NDebugOverlay::Cross3D( toTarget, magradius, 255, 0, 255, true, .1 );
					}

					toTarget -= GetAbsOrigin();
					toTarget.NormalizeInPlace();
					VPhysicsGetObject()->ApplyForceCenter( toTarget * magnitude );

				}
				break;
			default: // arbitrary powers
				VPhysicsGetObject()->ApplyForceCenter( toTarget * (magnitude * powf(nearestDistSq,(falloff+1.0f)/2)) );  // square root for distance instead of squared, add one to normalize toTarget 
				break;
			}
		}

		SetNextThink(gpGlobals->curtime + 0.01f);
	}
}
Beispiel #6
0
void CASW_Director::UpdateSpawningState()
{
	if ( m_bFinale )				// in finale, just keep spawning aliens forever
	{
		m_bSpawningAliens = true;

		if ( asw_director_debug.GetBool() )
		{
			engine->Con_NPrintf( 8, "%s: %f %s", m_bSpawningAliens ? "Spawning aliens" : "Relaxing",
				m_SustainTimer.HasStarted() ? m_SustainTimer.GetRemainingTime() : -1,
				"Finale" );
		}
		return;
	}

	//=====================================================================================
	// Main director rollercoaster logic
	//   Spawns aliens until a peak intensity is reached, then gives the marines a breather
	//=====================================================================================

	if ( !m_bSpawningAliens )			// not spawning aliens, we're in a relaxed state
	{
		if ( !m_SustainTimer.HasStarted() )
		{
			if ( GetMaxIntensity() < 1.0f )	// don't start our relax timer until the marines have left the peak
			{
				if ( m_bInitialWait )		// just do a short delay before starting combat at the beginning of a mission
				{
					m_SustainTimer.Start( RandomFloat( 3.0f, 16.0f ) );
					m_bInitialWait = false;
				}
				else
				{
					m_SustainTimer.Start( RandomFloat( asw_director_relaxed_min_time.GetFloat(), asw_director_relaxed_max_time.GetFloat() ) );
				}
			}
		}
		else if ( m_SustainTimer.IsElapsed() )		// TODO: Should check their intensity meters are below a certain threshold?  Should probably also not wait if they run too far ahead
		{
			m_bSpawningAliens = true;
			m_bReachedIntensityPeak = false;
			m_SustainTimer.Invalidate();
			m_fTimeBetweenAliens = 0;
			m_AlienSpawnTimer.Invalidate();
		}
	}
	else								// we're spawning aliens
	{
		if ( m_bReachedIntensityPeak )
		{
			// hold the peak intensity for a while, then drop back to the relaxed state
			if ( !m_SustainTimer.HasStarted() )
			{
				m_SustainTimer.Start( RandomFloat( asw_director_peak_min_time.GetFloat(), asw_director_peak_max_time.GetFloat() ) );
			}
			else if ( m_SustainTimer.IsElapsed() )
			{
				m_bSpawningAliens = false;
				m_SustainTimer.Invalidate();
			}
		}
		else
		{
			if ( GetMaxIntensity() >= 1.0f )
			{
				m_bReachedIntensityPeak = true;
			}
		}
	}

	if ( asw_director_debug.GetInt() > 0 )
	{
		engine->Con_NPrintf( 8, "%s: %f %s", m_bSpawningAliens ? "Spawning aliens" : "Relaxing",
			m_SustainTimer.HasStarted() ? m_SustainTimer.GetRemainingTime() : -1,
			m_bReachedIntensityPeak ? "Peaked" : "Not peaked" );
	}
}
Beispiel #7
0
bool AdminCache::CanAdminTarget(AdminId id, AdminId target)
{
	/** 
	 * Zeroth, if the targeting AdminId is INVALID_ADMIN_ID, targeting fails.
	 * First, if the targeted AdminId is INVALID_ADMIN_ID, targeting succeeds.
	 */

	if (id == INVALID_ADMIN_ID)
	{
		return false;
	}

	if (target == INVALID_ADMIN_ID)
	{
		return true;
	}

	if (id == target)
	{
		return true;
	}

	AdminUser *pUser = (AdminUser *)m_pMemory->GetAddress(id);
	if (!pUser || pUser->magic != USR_MAGIC_SET)
	{
		return false;
	}

	AdminUser *pTarget = (AdminUser *)m_pMemory->GetAddress(target);
	if (!pTarget || pTarget->magic != USR_MAGIC_SET)
	{
		return false;
	}

	/** 
	 * Second, if the targeting admin is root, targeting succeeds.
	 */
	if (pUser->eflags & ADMFLAG_ROOT)
	{
		return true;
	}

	/** Fourth, if the targeted admin is immune from targeting admin. */
	int mode = sm_immunity_mode.GetInt();
	switch (mode)
	{
		case 1:
		{
			if (pTarget->immunity_level > pUser->immunity_level)
			{
				return false;
			}
			break;
		}
		case 3:
		{
			/* If neither has any immunity, let this pass. */
			if (!pUser->immunity_level && !pTarget->immunity_level)
			{
				return true;
			}
			/* Don't break, go to the next case. */
		}
		case 2:
		{
			if (pTarget->immunity_level >= pUser->immunity_level)
			{
				return false;
			}
			break;
		}
	}

	/** 
	 * Fifth, if the targeted admin has specific immunity from the
	 *  targeting admin via group immunities, targeting fails.
	 */
	//:TODO: speed this up... maybe with trie hacks.
	//idea is to insert %d.%d in the trie after computing this and use it as a cache lookup.
	//problem is the trie cannot delete prefixes, so we'd have a problem with invalidations.
	if (pTarget->grp_count > 0 && pUser->grp_count > 0)
	{
		int *grp_table = (int *)m_pMemory->GetAddress(pTarget->grp_table);
		int *src_table = (int *)m_pMemory->GetAddress(pUser->grp_table);
		GroupId id, other;
		unsigned int num;
		for (unsigned int i=0; i<pTarget->grp_count; i++)
		{
			id = grp_table[i];
			num = GetGroupImmunityCount(id);
			for (unsigned int j=0; j<num; i++)
			{
				other = GetGroupImmunity(id, j);
				for (unsigned int k=0; k<pUser->grp_count; k++)
				{
					if (other == src_table[k])
					{
						return false;
					}
				}
			}
		}
	}
	
	return true;
}
Beispiel #8
0
void CGlowOverlay::Draw( bool bCacheFullSceneState )
{
	extern ConVar	r_drawsprites;
	if( !r_drawsprites.GetBool() )
		return;
	
	// Get the vector to the sun.
	Vector vToGlow;
	
	if( m_bDirectional )
		vToGlow = m_vDirection;
	else
		vToGlow = m_vPos - CurrentViewOrigin();

	VectorNormalize( vToGlow );

	float flDot = vToGlow.Dot( CurrentViewForward() );

	UpdateGlowObstruction( vToGlow, bCacheFullSceneState );
	if( m_flGlowObstructionScale == 0 )
		return;
	
	bool bWireframe = ShouldDrawInWireFrameMode() || (r_drawsprites.GetInt() == 2);
	
	CMatRenderContextPtr pRenderContext( materials );

	for( int iSprite=0; iSprite < m_nSprites; iSprite++ )
	{
		CGlowSprite *pSprite = &m_Sprites[iSprite];
 
		// Figure out the color and size to draw it.
		float flHorzSize, flVertSize;
		Vector vColor;
		CalcSpriteColorAndSize( flDot, pSprite, &flHorzSize, &flVertSize, &vColor );
	
		// If we're alpha'd out, then don't bother
		if ( vColor.LengthSqr() < 0.00001f )
			continue;
		
		// Setup the basis to draw the sprite.
		Vector vBasePt, vUp, vRight;
		CalcBasis( vToGlow, flHorzSize, flVertSize, vBasePt, vUp, vRight );

		//Get our diagonal radius
		float radius = (vRight+vUp).Length();
		if ( R_CullSphere( view->GetFrustum(), 5, &vBasePt, radius ) )
			continue;

		// Get our material (deferred default load)
		if ( m_Sprites[iSprite].m_pMaterial == NULL )
		{
			m_Sprites[iSprite].m_pMaterial = materials->FindMaterial( "sprites/light_glow02_add_noz", TEXTURE_GROUP_CLIENT_EFFECTS );
		}

		Assert( m_Sprites[iSprite].m_pMaterial );
		static unsigned int		nHDRColorScaleCache = 0;
		IMaterialVar *pHDRColorScaleVar = m_Sprites[iSprite].m_pMaterial->FindVarFast( "$hdrcolorscale", &nHDRColorScaleCache );
		if( pHDRColorScaleVar )
		{
			pHDRColorScaleVar->SetFloatValue( m_flHDRColorScale );
		}

		// Draw the sprite.
		IMesh *pMesh = pRenderContext->GetDynamicMesh( false, 0, 0, m_Sprites[iSprite].m_pMaterial );

		CMeshBuilder builder;
		builder.Begin( pMesh, MATERIAL_QUADS, 1 );
		
		Vector vPt;
		
		vPt = vBasePt - vRight + vUp;
		builder.Position3fv( vPt.Base() );
		builder.Color4f( VectorExpand(vColor), 1 );
		builder.TexCoord2f( 0, 0, 1 );
		builder.AdvanceVertex();
		
		vPt = vBasePt + vRight + vUp;
		builder.Position3fv( vPt.Base() );
		builder.Color4f( VectorExpand(vColor), 1 );
		builder.TexCoord2f( 0, 1, 1 );
		builder.AdvanceVertex();
		
		vPt = vBasePt + vRight - vUp;
		builder.Position3fv( vPt.Base() );
		builder.Color4f( VectorExpand(vColor), 1 );
		builder.TexCoord2f( 0, 1, 0 );
		builder.AdvanceVertex();
		
		vPt = vBasePt - vRight - vUp;
		builder.Position3fv( vPt.Base() );
		builder.Color4f( VectorExpand(vColor), 1 );
		builder.TexCoord2f( 0, 0, 0 );
		builder.AdvanceVertex();
		
		builder.End( false, true );

		if( bWireframe )
		{
			IMaterial *pWireframeMaterial = materials->FindMaterial( "debug/debugwireframevertexcolor", TEXTURE_GROUP_OTHER );
			pRenderContext->Bind( pWireframeMaterial );
			
			// Draw the sprite.
			IMesh *pMesh = pRenderContext->GetDynamicMesh( false, 0, 0, pWireframeMaterial );
			
			CMeshBuilder builder;
			builder.Begin( pMesh, MATERIAL_QUADS, 1 );
			
			Vector vPt;
			
			vPt = vBasePt - vRight + vUp;
			builder.Position3fv( vPt.Base() );
			builder.Color3f( 1.0f, 0.0f, 0.0f );
			builder.AdvanceVertex();
			
			vPt = vBasePt + vRight + vUp;
			builder.Position3fv( vPt.Base() );
			builder.Color3f( 1.0f, 0.0f, 0.0f );
			builder.AdvanceVertex();
			
			vPt = vBasePt + vRight - vUp;
			builder.Position3fv( vPt.Base() );
			builder.Color3f( 1.0f, 0.0f, 0.0f );
			builder.AdvanceVertex();
			
			vPt = vBasePt - vRight - vUp;
			builder.Position3fv( vPt.Base() );
			builder.Color3f( 1.0f, 0.0f, 0.0f );
			builder.AdvanceVertex();
			
			builder.End( false, true );
		}
	}
}
Beispiel #9
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
int CObjectSapper::GetBaseHealth( void )
{
	int iBaseHealth = obj_sapper_health.GetInt();
	CALL_ATTRIB_HOOK_INT_ON_OTHER( GetOwner(), iBaseHealth, mult_sapper_health );
	return iBaseHealth;
}
void CRagdollLRURetirement::Update( float frametime ) // EPISODIC VERSION
{
	VPROF( "CRagdollLRURetirement::Update" );
	// Compress out dead items
	int i, next;

	int iMaxRagdollCount = m_iMaxRagdolls;

	if ( iMaxRagdollCount == -1 )
	{
		iMaxRagdollCount = g_ragdoll_maxcount.GetInt();
	}

	// fade them all for the low violence version
	if ( g_RagdollLVManager.IsLowViolence() )
	{
		iMaxRagdollCount = 0;
	}
	m_iRagdollCount = 0;
	m_iSimulatedRagdollCount = 0;

	// First, find ragdolls that are good candidates for deletion because they are not
	// visible at all, or are in a culled visibility box
	for ( i = m_LRU.Head(); i < m_LRU.InvalidIndex(); i = next )
	{
		next = m_LRU.Next(i);
		CBaseAnimating *pRagdoll = m_LRU[i].Get();
		if ( pRagdoll )
		{
			m_iRagdollCount++;
			IPhysicsObject *pObject = pRagdoll->VPhysicsGetObject();
			if (pObject && !pObject->IsAsleep())
			{
				m_iSimulatedRagdollCount++;
			}
			if ( m_LRU.Count() > iMaxRagdollCount )
			{
				//Found one, we're done.
				if ( ShouldRemoveThisRagdoll( m_LRU[i] ) == true )
				{
#ifdef CLIENT_DLL
					m_LRU[ i ]->SUB_Remove();
#else
					m_LRU[ i ]->SUB_StartFadeOut( 0 );
#endif

					m_LRU.Remove(i);
					return;
				}
			}
		}
		else 
		{
			m_LRU.Remove(i);
		}
	}

	//////////////////////////////
	///   EPISODIC ALGORITHM   ///
	//////////////////////////////
	// If we get here, it means we couldn't find a suitable ragdoll to remove,
	// so just remove the furthest one.
	int furthestOne = m_LRU.Head();
	float furthestDistSq = 0;
#ifdef CLIENT_DLL
	C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
#else
	CBasePlayer  *pPlayer = UTIL_GetLocalPlayer();
#endif

	if (pPlayer && m_LRU.Count() > iMaxRagdollCount) // find the furthest one algorithm
	{
		Vector PlayerOrigin = pPlayer->GetAbsOrigin();
		// const CBasePlayer *pPlayer = UTIL_GetLocalPlayer();
	
		for ( i = m_LRU.Head(); i < m_LRU.InvalidIndex(); i = next )
		{
			CBaseAnimating *pRagdoll = m_LRU[i].Get();

			next = m_LRU.Next(i);
			IPhysicsObject *pObject = pRagdoll->VPhysicsGetObject();
			if ( pRagdoll && (pRagdoll->GetEffectEntity() || ( pObject && !pObject->IsAsleep()) ) )
				continue;

			if ( pRagdoll )
			{
				// float distToPlayer = (pPlayer->GetAbsOrigin() - pRagdoll->GetAbsOrigin()).LengthSqr();
				float distToPlayer = (PlayerOrigin - pRagdoll->GetAbsOrigin()).LengthSqr();

				if (distToPlayer > furthestDistSq)
				{
					furthestOne = i;
					furthestDistSq = distToPlayer;
				}
			}
			else // delete bad rags first.
			{
				furthestOne = i;
				break;
			}
		}

#ifdef CLIENT_DLL
		m_LRU[ furthestOne ]->SUB_Remove();
#else
		m_LRU[ furthestOne ]->SUB_StartFadeOut( 0 );
#endif

	}
	else // fall back on old-style pick the oldest one algorithm
	{
		for ( i = m_LRU.Head(); i < m_LRU.InvalidIndex(); i = next )
		{
			if ( m_LRU.Count() <=  iMaxRagdollCount )
				break;

			next = m_LRU.Next(i);

			CBaseAnimating *pRagdoll = m_LRU[i].Get();

			//Just ignore it until we're done burning/dissolving.
			IPhysicsObject *pObject = pRagdoll->VPhysicsGetObject();
			if ( pRagdoll && (pRagdoll->GetEffectEntity() || ( pObject && !pObject->IsAsleep()) ) )
				continue;

	#ifdef CLIENT_DLL
			m_LRU[ i ]->SUB_Remove();
	#else
			m_LRU[ i ]->SUB_StartFadeOut( 0 );
	#endif
			m_LRU.Remove(i);
		}
	}
}
void CRagdollLRURetirement::Update( float frametime ) // Non-episodic version
{
	VPROF( "CRagdollLRURetirement::Update" );
	// Compress out dead items
	int i, next;

	int iMaxRagdollCount = m_iMaxRagdolls;

	if ( iMaxRagdollCount == -1 )
	{
		iMaxRagdollCount = g_ragdoll_maxcount.GetInt();
	}

	// fade them all for the low violence version
	if ( g_RagdollLVManager.IsLowViolence() )
	{
		iMaxRagdollCount = 0;
	}
	m_iRagdollCount = 0;
	m_iSimulatedRagdollCount = 0;

	for ( i = m_LRU.Head(); i < m_LRU.InvalidIndex(); i = next )
	{
		next = m_LRU.Next(i);
		CBaseAnimating *pRagdoll = m_LRU[i].Get();
		if ( pRagdoll )
		{
			m_iRagdollCount++;
			IPhysicsObject *pObject = pRagdoll->VPhysicsGetObject();
			if (pObject && !pObject->IsAsleep())
			{
				m_iSimulatedRagdollCount++;
			}
			if ( m_LRU.Count() > iMaxRagdollCount )
			{
				//Found one, we're done.
				if ( ShouldRemoveThisRagdoll( m_LRU[i] ) == true )
				{
#ifdef CLIENT_DLL
					m_LRU[ i ]->SUB_Remove();
#else
					m_LRU[ i ]->SUB_StartFadeOut( 0 );
#endif

					m_LRU.Remove(i);
					return;
				}
			}
		}
		else 
		{
			m_LRU.Remove(i);
		}
	}


	//////////////////////////////
	///   ORIGINAL ALGORITHM   ///
	//////////////////////////////
	// not episodic -- this is the original mechanism

	for ( i = m_LRU.Head(); i < m_LRU.InvalidIndex(); i = next )
	{
		if ( m_LRU.Count() <=  iMaxRagdollCount )
			break;

		next = m_LRU.Next(i);

		CBaseAnimating *pRagdoll = m_LRU[i].Get();

		//Just ignore it until we're done burning/dissolving.
		if ( pRagdoll && pRagdoll->GetEffectEntity() )
			continue;

#ifdef CLIENT_DLL
		m_LRU[ i ]->SUB_Remove();
#else
		m_LRU[ i ]->SUB_StartFadeOut( 0 );
#endif
		m_LRU.Remove(i);
	}
}
Beispiel #12
0
//-----------------------------------------------------------------------------
// By default all driveable vehicles use the curve defined by the convar.
//-----------------------------------------------------------------------------
int C_PropVehicleDriveable::GetJoystickResponseCurve() const
{
    return joy_response_move_vehicle.GetInt();
}
Beispiel #13
0
void CVoiceStatus::UpdateServerState(bool bForce)
{
	// Can't do anything when we're not in a level.
	if( !g_bLevelInitialized )
	{
		if( voice_clientdebug.GetInt() )
		{
			Msg( "CVoiceStatus::UpdateServerState: g_bLevelInitialized\n" );
		}

		return;
	}
	
	int bCVarModEnable = !!voice_modenable.GetInt();
	if(bForce || m_bServerModEnable != bCVarModEnable)
	{
		m_bServerModEnable = bCVarModEnable;

		char str[256];
		Q_snprintf(str, sizeof(str), "VModEnable %d", m_bServerModEnable);
		engine->ServerCmd(str);

		if( voice_clientdebug.GetInt() )
		{
			Msg( "CVoiceStatus::UpdateServerState: Sending '%s'\n", str );
		}
	}

	char str[2048];
	Q_strncpy(str,"vban",sizeof(str));
	bool bChange = false;

	for(unsigned long dw=0; dw < VOICE_MAX_PLAYERS_DW; dw++)
	{	
		unsigned long serverBanMask = 0;
		unsigned long banMask = 0;
		for(unsigned long i=0; i < 32; i++)
		{
			int playerIndex = ( dw * 32 + i );
			if ( playerIndex >= MAX_PLAYERS )
				break;

			player_info_t pi;

			if ( !engine->GetPlayerInfo( i+1, &pi ) )
				continue;

			if ( m_BanMgr.GetPlayerBan( pi.guid ) )
			{
				banMask |= 1 << i;
			}

			if ( m_ServerBannedPlayers[playerIndex] )
			{
				serverBanMask |= 1 << i;
			}
		}

		if ( serverBanMask != banMask )
		{
			bChange = true;
		}

		// Ok, the server needs to be updated.
		char numStr[512];
		Q_snprintf(numStr,sizeof(numStr), " %x", banMask);
		Q_strncat(str, numStr, sizeof(str), COPY_ALL_CHARACTERS);
	}

	if(bChange || bForce)
	{
		if( voice_clientdebug.GetInt() )
		{
			Msg( "CVoiceStatus::UpdateServerState: Sending '%s'\n", str );
		}

		engine->ServerCmd( str, false );	// Tell the server..
	}
	else
	{
		if( voice_clientdebug.GetInt() )
		{
			Msg( "CVoiceStatus::UpdateServerState: no change\n" );
		}
	}
	
	m_LastUpdateServerState = gpGlobals->curtime;
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CNPC_CombineAce::Spawn( void )
{
	Precache();

	SetModel( "models/combine_ace_soldier.mdl" );

	//Give him a random amount of grenades on spawn
	if (combine_ace_spawnwithgrenades.GetBool())
	{
		if (g_pGameRules->IsSkillLevel(SKILL_HARD))
		{
			m_iNumGrenades = random->RandomInt(2, 3);
		}
		else if (g_pGameRules->IsSkillLevel(SKILL_VERYHARD))
		{
			m_iNumGrenades = random->RandomInt(4, 6);
		}
		else if (g_pGameRules->IsSkillLevel(SKILL_NIGHTMARE))
		{
			m_iNumGrenades = random->RandomInt(8, 12);
		}
		else
		{
			m_iNumGrenades = random->RandomInt(0, 2);
		}
	}

	m_fIsElite = true;
	m_fIsAce = true;

	// Stronger, tougher.
	SetHealth(sk_combine_ace_health.GetFloat());
	SetMaxHealth(sk_combine_ace_health.GetFloat());
	SetKickDamage(sk_combine_ace_kick.GetFloat());

	CapabilitiesAdd( bits_CAP_ANIMATEDFACE );
	CapabilitiesAdd( bits_CAP_MOVE_SHOOT );
	CapabilitiesAdd( bits_CAP_MOVE_JUMP );
	CapabilitiesAdd( bits_CAP_DOORS_GROUP );

	int attachment = LookupAttachment("eyes");

	// Start up the eye glow
	m_pEyeSprite = CSprite::SpriteCreate("sprites/redglow1.vmt", GetLocalOrigin(), false);

	if (m_pEyeSprite != NULL)
	{
		m_pEyeSprite->SetAttachment(this, attachment);
		m_pEyeSprite->SetTransparency(kRenderTransAdd, 255, 255, 255, 200, kRenderFxNone);
		m_pEyeSprite->SetScale(0.25f);
	}

	// Start up the eye trail
	m_pEyeTrail = CSpriteTrail::SpriteTrailCreate("sprites/bluelaser1.vmt", GetLocalOrigin(), false);

	if (m_pEyeTrail != NULL)
	{
		m_pEyeTrail->SetAttachment(this, attachment);
		m_pEyeTrail->SetTransparency(kRenderTransAdd, 255, 0, 0, 200, kRenderFxNone);
		m_pEyeTrail->SetStartWidth(8.0f);
		m_pEyeTrail->SetLifeTime(0.75f);
	}

	SetEyeState(ACE_EYE_DORMANT);

	if (combine_ace_shieldspawnmode.GetInt() == 1)
	{
		SpawnArmorPieces();
	}
	else if (combine_ace_shieldspawnmode.GetInt() > 1)
	{
		int iShieldRandom = random->RandomInt(0, 3);
		if (iShieldRandom == 0)
		{
			SpawnArmorPieces();
		}
		else
		{
			pArmor = NULL;
			m_bNoArmor = true;
		}
	}
	else
	{
		pArmor = NULL;
		m_bNoArmor = true;
	}

	BaseClass::Spawn();

#if HL2_EPISODIC
	if (m_iUseMarch && !HasSpawnFlags(SF_NPC_START_EFFICIENT))
	{
		Msg( "Soldier %s is set to use march anim, but is not an efficient AI. The blended march anim can only be used for dead-ahead walks!\n", GetDebugName() );
	}
#endif
}
	bool PrintCStrikeEvent( IGameEvent *event )	// print Mod specific logs
	{
		const char *eventName = event->GetName();
	
		// messages that don't have a user associated to them
		if ( !Q_strncmp( eventName, "round_end", Q_strlen("round_end") ) )
		{
			const int winner = event->GetInt( "winner" );
			const int reason = event->GetInt( "reason" );
			const char *msg = event->GetString( "message" );
			msg++; // remove the '#' char

			switch( reason )
			{
			case Game_Commencing:
				UTIL_LogPrintf( "World triggered \"Game_Commencing\"\n" );
				return true;
				break;
			}

			CTeam *ct = GetGlobalTeam( TEAM_CT );
			CTeam *ter = GetGlobalTeam( TEAM_TERRORIST );
			Assert( ct && ter );

			switch ( winner )
			{
			case WINNER_CT:
				UTIL_LogPrintf( "Team \"%s\" triggered \"%s\" (CT \"%i\") (T \"%i\")\n", ct->GetName(), msg, ct->GetScore(), ter->GetScore() );
				break;
			case WINNER_TER:
				UTIL_LogPrintf( "Team \"%s\" triggered \"%s\" (CT \"%i\") (T \"%i\")\n", ter->GetName(), msg, ct->GetScore(), ter->GetScore() );
				break;
			case WINNER_DRAW:
			default:
				UTIL_LogPrintf( "World triggered \"%s\" (CT \"%i\") (T \"%i\")\n", msg, ct->GetScore(), ter->GetScore() );
				break;
			}	

			UTIL_LogPrintf( "Team \"CT\" scored \"%i\" with \"%i\" players\n", ct->GetScore(), ct->GetNumPlayers() );
			UTIL_LogPrintf( "Team \"TERRORIST\" scored \"%i\" with \"%i\" players\n", ter->GetScore(), ter->GetNumPlayers() );
			
			UTIL_LogPrintf("World triggered \"Round_End\"\n");
			return true;
		}
		else if ( !Q_strncmp( eventName, "server_", strlen("server_")) )
		{
			return false; // ignore server_ messages
		}
		
		const int userid = event->GetInt( "userid" );
		CBasePlayer *pPlayer = UTIL_PlayerByUserId( userid );
		if ( !pPlayer )
		{
			return false;
		}

		if ( FStrEq( eventName, "player_hurt" ) )
		{
			const int attackerid = event->GetInt("attacker" );
			const char *weapon = event->GetString( "weapon" );
			CBasePlayer *pAttacker = UTIL_PlayerByUserId( attackerid );
			if ( !pAttacker )
			{
				return false;
			}

			bool isTeamAttack = ( (pPlayer->GetTeamNumber() == pAttacker->GetTeamNumber() ) && (pPlayer != pAttacker) );
			int detail = mp_logdetail.GetInt();
			if ( ( isTeamAttack && ( detail & LOG_DETAIL_TEAMMATE_ATTACKS ) ) ||
				( !isTeamAttack && ( detail & LOG_DETAIL_ENEMY_ATTACKS ) ) )
			{
				int hitgroup = event->GetInt( "hitgroup" );
				const char *hitgroupStr = "GENERIC";
				switch ( hitgroup )
				{
				case HITGROUP_GENERIC:
					hitgroupStr = "generic";
					break;
				case HITGROUP_HEAD:
					hitgroupStr = "head";
					break;
				case HITGROUP_CHEST:
					hitgroupStr = "chest";
					break;
				case HITGROUP_STOMACH:
					hitgroupStr = "stomach";
					break;
				case HITGROUP_LEFTARM:
					hitgroupStr = "left arm";
					break;
				case HITGROUP_RIGHTARM:
					hitgroupStr = "right arm";
					break;
				case HITGROUP_LEFTLEG:
					hitgroupStr = "left leg";
					break;
				case HITGROUP_RIGHTLEG:
					hitgroupStr = "right leg";
					break;
				}

				UTIL_LogPrintf( "\"%s<%i><%s><%s>\" attacked \"%s<%i><%s><%s>\" with \"%s\" (damage \"%d\") (damage_armor \"%d\") (health \"%d\") (armor \"%d\") (hitgroup \"%s\")\n",  
					pAttacker->GetPlayerName(),
					attackerid,
					pAttacker->GetNetworkIDString(),
					pAttacker->GetTeam()->GetName(),
					pPlayer->GetPlayerName(),
					userid,
					pPlayer->GetNetworkIDString(),
					pPlayer->GetTeam()->GetName(),
					weapon,
					event->GetInt( "dmg_health" ),
					event->GetInt( "dmg_armor" ),
					event->GetInt( "health" ),
					event->GetInt( "armor" ),
					hitgroupStr );
			}
			return true;
		}
		else if ( !Q_strncmp( eventName, "player_death", Q_strlen("player_death") ) )
		{
			const int attackerid = event->GetInt("attacker" );
			const char *weapon = event->GetString( "weapon" );
			const bool headShot = (event->GetInt( "headshot" ) == 1);
			CBasePlayer *pAttacker = UTIL_PlayerByUserId( attackerid );

			if ( pPlayer == pAttacker )  
			{  
				UTIL_LogPrintf( "\"%s<%i><%s><%s>\" committed suicide with \"%s\"\n",  
								pPlayer->GetPlayerName(),
								userid,
								pPlayer->GetNetworkIDString(),
								pPlayer->GetTeam()->GetName(),
								weapon
								);
			}
			else if ( pAttacker )
			{
				UTIL_LogPrintf( "\"%s<%i><%s><%s>\" killed \"%s<%i><%s><%s>\" with \"%s\"%s\n",  
								pAttacker->GetPlayerName(),
								attackerid,
								pAttacker->GetNetworkIDString(),
								pAttacker->GetTeam()->GetName(),
								pPlayer->GetPlayerName(),
								userid,
								pPlayer->GetNetworkIDString(),
								pPlayer->GetTeam()->GetName(),
								weapon,
								headShot ? " (headshot)":""
								);								
			}
			else
			{  
				// killed by the world
				UTIL_LogPrintf( "\"%s<%i><%s><%s>\" committed suicide with \"world\"\n",
								pPlayer->GetPlayerName(),
								userid,
								pPlayer->GetNetworkIDString(),
								pPlayer->GetTeam()->GetName()
								);
			}
			return true;
		}
		else if ( !Q_strncmp( eventName, "round_start", Q_strlen("round_start") ) )
		{
			UTIL_LogPrintf("World triggered \"Round_Start\"\n");
			return true;
		}
		else if ( !Q_strncmp( eventName, "hostage_follows", Q_strlen("hostage_follows") ) )
		{
			UTIL_LogPrintf( "\"%s<%i><%s><CT>\" triggered \"Touched_A_Hostage\"\n",
								pPlayer->GetPlayerName(),
								userid,
								pPlayer->GetNetworkIDString()
								);
			return true;
		}
		else if ( !Q_strncmp( eventName, "hostage_killed", Q_strlen("hostage_killed") ) )
		{
			UTIL_LogPrintf( "\"%s<%i><%s><%s>\" triggered \"Killed_A_Hostage\"\n", 
								pPlayer->GetPlayerName(),
								userid,
								pPlayer->GetNetworkIDString(),
								pPlayer->GetTeam()->GetName()
								);
			return true;
		}
		else if ( !Q_strncmp( eventName, "hostage_rescued", Q_strlen("hostage_rescued") ) )
		{
			UTIL_LogPrintf("\"%s<%i><%s><CT>\" triggered \"Rescued_A_Hostage\"\n",
								pPlayer->GetPlayerName(),
								userid,
								pPlayer->GetNetworkIDString()
								);
			return true;
		}
		else if ( !Q_strncmp( eventName, "bomb_planted", Q_strlen("bomb_planted") ) )
		{
			UTIL_LogPrintf("\"%s<%i><%s><TERRORIST>\" triggered \"Planted_The_Bomb\"\n", 
								pPlayer->GetPlayerName(),
								userid,
								pPlayer->GetNetworkIDString()
								);
			return true;
		}
		else if ( !Q_strncmp( eventName, "bomb_defused", Q_strlen("bomb_defused") ) )
		{
			UTIL_LogPrintf("\"%s<%i><%s><CT>\" triggered \"Defused_The_Bomb\"\n", 
								pPlayer->GetPlayerName(),
								userid,
								pPlayer->GetNetworkIDString()
								);
			return true;
		}
		else if ( !Q_strncmp( eventName, "bomb_dropped", Q_strlen("bomb_dropped") ) )
		{
			UTIL_LogPrintf("\"%s<%i><%s><TERRORIST>\" triggered \"Dropped_The_Bomb\"\n", 
								pPlayer->GetPlayerName(),
								userid,
								pPlayer->GetNetworkIDString()
								);
			return true;
		}
		else if ( !Q_strncmp( eventName, "bomb_begindefuse", Q_strlen("bomb_begindefuse") ) )
		{
			const bool haskit = (event->GetInt( "haskit" ) == 1);
			UTIL_LogPrintf("\"%s<%i><%s><CT>\" triggered \"%s\"\n", 
								pPlayer->GetPlayerName(),
								userid,
								pPlayer->GetNetworkIDString(),
								haskit ? "Begin_Bomb_Defuse_With_Kit" : "Begin_Bomb_Defuse_Without_Kit"
								);
			return true;
		}
		else if ( !Q_strncmp( eventName, "bomb_pickup", Q_strlen("bomb_pickup") ) )
		{
			UTIL_LogPrintf("\"%s<%i><%s><TERRORIST>\" triggered \"Got_The_Bomb\"\n", 
								pPlayer->GetPlayerName(),
								userid,
								pPlayer->GetNetworkIDString()
								);
			return true;
		}	
		
// unused events:
//hostage_hurt
//bomb_exploded

		return false;
	}
//-----------------------------------------------------------------------------
// Purpose: Runs movement commands for the player
// Input  : *player - 
//			*ucmd - 
//			*moveHelper - 
// Output : void CPlayerMove::RunCommand
//-----------------------------------------------------------------------------
void CPlayerMove::RunCommand ( CBasePlayer *player, CUserCmd *ucmd, IMoveHelper *moveHelper )
{
	const float playerCurTime = player->m_nTickBase * TICK_INTERVAL; 
	const float playerFrameTime = player->m_bGamePaused ? 0 : TICK_INTERVAL;
	const float flTimeAllowedForProcessing = player->ConsumeMovementTimeForUserCmdProcessing( playerFrameTime );
	if ( !player->IsBot() && ( flTimeAllowedForProcessing < playerFrameTime ) )
	{
		// Make sure that the activity in command is erased because player cheated or dropped too many packets
		double dblWarningFrequencyThrottle = sv_maxusrcmdprocessticks_warning.GetFloat();
		if ( dblWarningFrequencyThrottle >= 0 )
		{
			static double s_dblLastWarningTime = 0;
			double dblTimeNow = Plat_FloatTime();
			if ( !s_dblLastWarningTime || ( dblTimeNow - s_dblLastWarningTime >= dblWarningFrequencyThrottle ) )
			{
				s_dblLastWarningTime = dblTimeNow;
				Warning( "sv_maxusrcmdprocessticks_warning at server tick %u: Ignored client %s usrcmd (%.6f < %.6f)!\n", gpGlobals->tickcount, player->GetPlayerName(), flTimeAllowedForProcessing, playerFrameTime );
			}
		}
		return; // Don't process this command
	}

	StartCommand( player, ucmd );

	// Set globals appropriately
	gpGlobals->curtime		=  playerCurTime;
	gpGlobals->frametime	=  playerFrameTime;

	// Prevent hacked clients from sending us invalid view angles to try to get leaf server code to crash
	if ( !ucmd->viewangles.IsValid() || !IsEntityQAngleReasonable(ucmd->viewangles) )
	{
		ucmd->viewangles = vec3_angle;
	}

	// Add and subtract buttons we're forcing on the player
	ucmd->buttons |= player->m_afButtonForced;
	ucmd->buttons &= ~player->m_afButtonDisabled;

	if ( player->m_bGamePaused )
	{
		// If no clipping and cheats enabled and noclipduring game enabled, then leave
		//  forwardmove and angles stuff in usercmd
		if ( player->GetMoveType() == MOVETYPE_NOCLIP &&
			 sv_cheats->GetBool() && 
			 sv_noclipduringpause.GetBool() )
		{
			gpGlobals->frametime = TICK_INTERVAL;
		}
	}

	/*
	// TODO:  We can check whether the player is sending more commands than elapsed real time
	cmdtimeremaining -= ucmd->msec;
	if ( cmdtimeremaining < 0 )
	{
	//	return;
	}
	*/

	g_pGameMovement->StartTrackPredictionErrors( player );

	CommentarySystem_PePlayerRunCommand( player, ucmd );

	// Do weapon selection
	if ( ucmd->weaponselect != 0 )
	{
		CBaseCombatWeapon *weapon = dynamic_cast< CBaseCombatWeapon * >( CBaseEntity::Instance( ucmd->weaponselect ) );
		if ( weapon )
		{
			VPROF( "player->SelectItem()" );
			player->SelectItem( weapon->GetName(), ucmd->weaponsubtype );
		}
	}

	IServerVehicle *pVehicle = player->GetVehicle();

	// Latch in impulse.
	if ( ucmd->impulse )
	{
		// Discard impulse commands unless the vehicle allows them.
		// FIXME: UsingStandardWeapons seems like a bad filter for this. The flashlight is an impulse command, for example.
		if ( !pVehicle || player->UsingStandardWeaponsInVehicle() )
		{
			player->m_nImpulse = ucmd->impulse;
		}
	}

	// Update player input button states
	VPROF_SCOPE_BEGIN( "player->UpdateButtonState" );
	player->UpdateButtonState( ucmd->buttons );
	VPROF_SCOPE_END();

	CheckMovingGround( player, TICK_INTERVAL );

	g_pMoveData->m_vecOldAngles = player->pl.v_angle;

	// Copy from command to player unless game .dll has set angle using fixangle
	if ( player->pl.fixangle == FIXANGLE_NONE )
	{
		player->pl.v_angle = ucmd->viewangles;
	}
	else if( player->pl.fixangle == FIXANGLE_RELATIVE )
	{
		player->pl.v_angle = ucmd->viewangles + player->pl.anglechange;
	}

	// Call standard client pre-think
	RunPreThink( player );

	// Call Think if one is set
	RunThink( player, TICK_INTERVAL );

	// Setup input.
	SetupMove( player, ucmd, moveHelper, g_pMoveData );

	// Let the game do the movement.
	if ( !pVehicle )
	{
		VPROF( "g_pGameMovement->ProcessMovement()" );
		Assert( g_pGameMovement );
		g_pGameMovement->ProcessMovement( player, g_pMoveData );
	}
	else
	{
		VPROF( "pVehicle->ProcessMovement()" );
		pVehicle->ProcessMovement( player, g_pMoveData );
	}
			
	// Copy output
	FinishMove( player, ucmd, g_pMoveData );

	// If we have to restore the view angle then do so right now
	if ( !player->IsBot() && ( gpGlobals->tickcount - player->GetLockViewanglesTickNumber() < sv_maxusrcmdprocessticks_holdaim.GetInt() ) )
	{
		player->pl.v_angle = player->GetLockViewanglesData();
	}

	// Let server invoke any needed impact functions
	VPROF_SCOPE_BEGIN( "moveHelper->ProcessImpacts" );
	moveHelper->ProcessImpacts();
	VPROF_SCOPE_END();

	RunPostThink( player );

	g_pGameMovement->FinishTrackPredictionErrors( player );

	FinishCommand( player );

	// Let time pass
	if ( gpGlobals->frametime > 0 )
	{
		player->m_nTickBase++;
	}
}
Beispiel #17
0
void CASW_Director::UpdateHorde()
{
	if ( asw_director_debug.GetInt() > 0 )
	{
		if ( m_bHordeInProgress )
		{
			engine->Con_NPrintf( 11, "Horde in progress.  Left to spawn = %d", ASWSpawnManager()->GetHordeToSpawn() );
		}
		engine->Con_NPrintf( 12, "Next Horde due: %f", m_HordeTimer.GetRemainingTime() );

		engine->Con_NPrintf( 15, "Awake aliens: %d\n", ASWSpawnManager()->GetAwakeAliens() );
		engine->Con_NPrintf( 16, "Awake drones: %d\n", ASWSpawnManager()->GetAwakeDrones() );
	}

	bool bHordesEnabled = m_bHordesEnabled || asw_horde_override.GetBool();
	if ( !bHordesEnabled || !ASWSpawnManager() )
		return;

	if ( !m_HordeTimer.HasStarted() )
	{
		float flDuration = RandomFloat( asw_horde_interval_min.GetFloat(), asw_horde_interval_max.GetFloat() );
		if ( m_bFinale )
		{
			flDuration = RandomFloat( 5.0f, 10.0f );
		}
		if ( asw_director_debug.GetBool() )
		{
			Msg( "Will be spawning a horde in %f seconds\n", flDuration );
		}
		m_HordeTimer.Start( flDuration );
	}
	else if ( m_HordeTimer.IsElapsed() )
	{
		if ( ASWSpawnManager()->GetAwakeDrones() < 25 )
		{
			int iNumAliens = RandomInt( asw_horde_size_min.GetInt(), asw_horde_size_max.GetInt() );

			if ( ASWSpawnManager()->AddHorde( iNumAliens ) )
			{
				if ( asw_director_debug.GetBool() )
				{
					Msg("Created horde of size %d\n", iNumAliens);
				}
				m_bHordeInProgress = true;

				if ( ASWGameRules() )
				{
					ASWGameRules()->BroadcastSound( "Spawner.Horde" );
				}
				m_HordeTimer.Invalidate();
			}
			else
			{
				// if we failed to find a horde position, try again shortly.
				m_HordeTimer.Start( RandomFloat( 10.0f, 16.0f ) );
			}
		}
		else
		{
			// if there are currently too many awake aliens, then wait 10 seconds before trying again
			m_HordeTimer.Start( 10.0f );
		}
	}
}
static int get_activity_flags()
{
	return sm_show_activity.GetInt();
}
Beispiel #19
0
//================================================================================
// Devuelve el framerate del navegador. Más framerate es igual a una navegación
// más fluida a costa de un rendimiento menor en el motor.
//================================================================================
int CefBasePanel::GetFramerate()
{
    return cl_web_ui_fps.GetInt();
}
static int get_immunity_mode()
{
	return sm_immunity_mode.GetInt();
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CPropJeep::Think(void)
{
	BaseClass::Think();

/*
	CBasePlayer	*pPlayer = UTIL_GetLocalPlayer();

	if ( m_bEngineLocked )
	{
		m_bUnableToFire = true;
		
		if ( pPlayer != NULL )
		{
			pPlayer->m_Local.m_iHideHUD |= HIDEHUD_VEHICLE_CROSSHAIR;
		}
	}
	else
	{
		// Start this as false and update it again each frame
		m_bUnableToFire = false;

		if ( pPlayer != NULL )
		{
			pPlayer->m_Local.m_iHideHUD &= ~HIDEHUD_VEHICLE_CROSSHAIR;
		}
	}
*/

	// Water!?
	HandleWater();

	SetSimulationTime( gpGlobals->curtime );
	
	SetNextThink( gpGlobals->curtime );
	SetAnimatedEveryTick( true );

    if ( !m_bInitialHandbrake )	// after initial timer expires, set the handbrake
	{
		m_bInitialHandbrake = true;
		m_VehiclePhysics.SetHandbrake( true );
		m_VehiclePhysics.Think();
	}

	// Check overturned status.
	if ( !IsOverturned() )
	{
		m_flOverturnedTime = 0.0f;
	}
	else
	{
		m_flOverturnedTime += gpGlobals->frametime;
	}

	// spin gun if charging cannon
	//FIXME: Don't bother for E3
	if ( m_bCannonCharging )
	{
		m_nSpinPos += JEEP_GUN_SPIN_RATE;
		SetPoseParameter( JEEP_GUN_SPIN, m_nSpinPos );
	}

	// Aim gun based on the player view direction.
	if ( m_hPlayer && !m_bExitAnimOn && !m_bEnterAnimOn )
	{
		Vector vecEyeDir, vecEyePos;
		m_hPlayer->EyePositionAndVectors( &vecEyePos, &vecEyeDir, NULL, NULL );

		// Trace out from the player's eye point.
		Vector	vecEndPos = vecEyePos + ( vecEyeDir * MAX_TRACE_LENGTH );
		trace_t	trace;
		UTIL_TraceLine( vecEyePos, vecEndPos, MASK_SHOT, this, COLLISION_GROUP_NONE, &trace );

		// See if we hit something, if so, adjust end position to hit location.
		if ( trace.fraction < 1.0 )
		{
   			vecEndPos = vecEyePos + ( vecEyeDir * MAX_TRACE_LENGTH * trace.fraction );
		}

		//m_vecLookCrosshair = vecEndPos;
		AimGunAt( &vecEndPos, 0.1f );
	}

	StudioFrameAdvance();

	// If the enter or exit animation has finished, tell the server vehicle
	if ( IsSequenceFinished() && (m_bExitAnimOn || m_bEnterAnimOn) )
	{
		if ( m_bEnterAnimOn )
		{
			m_VehiclePhysics.ReleaseHandbrake();
			StartEngine();

			// HACKHACK: This forces the jeep to play a sound when it gets entered underwater
			if ( m_VehiclePhysics.IsEngineDisabled() )
			{
				CBaseServerVehicle *pServerVehicle = dynamic_cast<CBaseServerVehicle *>(GetServerVehicle());
				if ( pServerVehicle )
				{
					pServerVehicle->SoundStartDisabled();
				}
			}

			// The first few time we get into the jeep, print the jeep help
			if ( m_iNumberOfEntries < hud_jeephint_numentries.GetInt() )
			{
				UTIL_HudHintText( m_hPlayer, "#Valve_Hint_JeepKeys" );
				m_iNumberOfEntries++;
			}
		}
		
		// If we're exiting and have had the tau cannon removed, we don't want to reset the animation
		GetServerVehicle()->HandleEntryExitFinish( m_bExitAnimOn, true );
	}

	// See if the ammo crate needs to close
	if ( ( m_flAmmoCrateCloseTime < gpGlobals->curtime ) && ( GetSequence() == LookupSequence( "ammo_open" ) ) )
	{
		m_flAnimTime = gpGlobals->curtime;
		m_flPlaybackRate = 0.0;
		SetCycle( 0 );
		ResetSequence( LookupSequence( "ammo_close" ) );
	}
	else if ( ( GetSequence() == LookupSequence( "ammo_close" ) ) && IsSequenceFinished() )
	{
		m_flAnimTime = gpGlobals->curtime;
		m_flPlaybackRate = 0.0;
		SetCycle( 0 );
		ResetSequence( LookupSequence( "idle" ) );

		CPASAttenuationFilter sndFilter( this, "PropJeep.AmmoClose" );
		EmitSound( sndFilter, entindex(), "PropJeep.AmmoClose" );
	}
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CWeaponExtinguisher::ItemPostFrame( void )
{	
	CBasePlayer *pOwner = ToBasePlayer( GetOwner() );

	if ( pOwner == NULL )
		return;

	//Only shoot if we have ammo
	if ( pOwner->GetAmmoCount(m_iSecondaryAmmoType) <= 0 )
	{
		StopJet();
		return;
	}
	
	//See if we should try and extinguish fires
	if ( pOwner->m_nButtons & IN_ATTACK )
	{
		//Drain ammo
		if ( m_flNextPrimaryAttack < gpGlobals->curtime  )
		{
			pOwner->RemoveAmmo( 1, m_iSecondaryAmmoType );
			m_flNextPrimaryAttack = gpGlobals->curtime + EXTINGUISHER_AMMO_RATE;
		}

		//If we're just run out...
		if ( pOwner->GetAmmoCount(m_iSecondaryAmmoType) <= 0 )
		{
			StopJet();
			return;
		}

		//Turn the jet on
		StartJet();

		Vector	vTestPos, vMuzzlePos;
		Vector	vForward, vRight, vUp;

		pOwner->EyeVectors( &vForward, &vRight, &vUp );
		
		vMuzzlePos	= pOwner->Weapon_ShootPosition( );
		
		//FIXME: Need to get the exact same muzzle point!

		//FIXME: This needs to be adjusted so the server collision matches the visuals on the client
		vMuzzlePos	+= vForward * 15.0f;
		vMuzzlePos	+= vRight * 6.0f;
		vMuzzlePos	+= vUp * -4.0f;

		QAngle aTmp;
		VectorAngles( vForward, aTmp );
		aTmp[PITCH] += 10;
		AngleVectors( aTmp, &vForward );

		vTestPos	= vMuzzlePos + ( vForward * fire_extinguisher_distance.GetInt() );

		trace_t	tr;
		UTIL_TraceLine( vMuzzlePos, vTestPos, MASK_SHOT, this, COLLISION_GROUP_NONE, &tr );

		//Extinguish the fire where we hit
		FireSystem_ExtinguishInRadius( tr.endpos, fire_extinguisher_radius.GetInt(), fire_extinguisher_strength.GetFloat() );

		//Debug visualization
		if ( fire_extinguisher_debug.GetInt() )
		{
			int	radius = fire_extinguisher_radius.GetInt();

			NDebugOverlay::Line( vMuzzlePos, tr.endpos, 0, 0, 128, false, 0.0f );
			
			NDebugOverlay::Box( vMuzzlePos, Vector(-1, -1, -1), Vector(1, 1, 1), 0, 0, 128, false, 0.0f );
			NDebugOverlay::Box( tr.endpos, Vector(-2, -2, -2), Vector(2, 2, 2), 0, 0, 128, false, 0.0f );
			NDebugOverlay::Box( tr.endpos, Vector(-radius, -radius, -radius), Vector(radius, radius, radius), 0, 0, 255, false, 0.0f );
		}
	}
	else
	{
		StopJet();
	}
}
/*
==============================
GetLookSpring

==============================
*/
float CInput::GetLookSpring( void )
{
	return lookspring.GetInt();
}
void AppendPlayerInformation(ISteamHTTP *pSteamHttp, HTTPRequestHandle httpRequest, CSteamAPIContext *pSteamAPIContext, CBasePlayer *pPlayer, bool bAnonymous)
{
	// Local DS
	time_t rawtime;
	struct tm* timeinfo;

	time(&rawtime);
	timeinfo = localtime(&rawtime);
	char* local_ds = asctime(timeinfo);

	char* newLine = strstr(local_ds, "\n");
	if (newLine)
	{
		*newLine = 0;
	}

	pSteamHttp->SetHTTPRequestGetOrPostParameter(httpRequest, "localdatetime", local_ds);

	// Build DS
	char build_ds[64];
	Q_snprintf(build_ds, sizeof(build_ds), "%s,%s", __DATE__, __TIME__);
	pSteamHttp->SetHTTPRequestGetOrPostParameter(httpRequest, "builddatetime", build_ds);

	// DxLevel
	pSteamHttp->SetHTTPRequestGetOrPostParameter(httpRequest, "dxlevel", ConVarRef("mat_dxlevel").GetString());

	if (pPlayer)
	{
		// Position
		char player_position[32];
		Vector player_pos = pPlayer->GetLocalOrigin();
		Q_snprintf(player_position, sizeof(player_position), "%.2f,%.2f,%.2f", player_pos.x, player_pos.y, player_pos.z);
		pSteamHttp->SetHTTPRequestGetOrPostParameter(httpRequest, "position", player_position);

		// Angles
		char player_angles[32];
		QAngle player_ang = pPlayer->GetLocalAngles();
		Q_snprintf(player_angles, sizeof(player_angles), "%.2f,%.2f,%.2f", player_ang.x, player_ang.y, player_ang.z);
		pSteamHttp->SetHTTPRequestGetOrPostParameter(httpRequest, "angles", player_angles);

		// Health
		char player_health[16];
		Q_snprintf(player_health, sizeof(player_health), "%i", pPlayer->GetHealth());
		pSteamHttp->SetHTTPRequestGetOrPostParameter(httpRequest, "health", player_health);

		// Weapon
		CBaseCombatWeapon *pWeapon = pPlayer->GetActiveWeapon();
		if (pWeapon)
		{
			pSteamHttp->SetHTTPRequestGetOrPostParameter(httpRequest, "weapon", pWeapon->GetClassname());
		}
	}

	// Cheats
	char cheats_enabled[8];
	Q_snprintf(cheats_enabled, sizeof(cheats_enabled), "%i", (ConVarRef("sv_cheats").GetBool() || ConVarRef("developer").GetBool()));
	pSteamHttp->SetHTTPRequestGetOrPostParameter(httpRequest, "cheats", cheats_enabled);

	// Map
#ifdef CLIENT_DLL
	char mapname[256];
	V_FileBase(engine->GetLevelName(), mapname, sizeof(mapname));
	pSteamHttp->SetHTTPRequestGetOrPostParameter(httpRequest, "level", mapname);
#else
	pSteamHttp->SetHTTPRequestGetOrPostParameter(httpRequest, "level", gpGlobals->mapname.ToCStr());
#endif

	if (pSteamAPIContext)
	{
		// Language
		pSteamHttp->SetHTTPRequestGetOrPostParameter(httpRequest, "language", pSteamAPIContext->SteamUtils()->GetSteamUILanguage());
	}

	// Platform
	char *			platform = "unknown";
	if (IsPC())		platform = "pc";
	if (IsOSX())	platform = "osx";
	if (IsLinux())	platform = "linux";
	if (IsX360())	platform = "360";
	if (IsPS3())	platform = "ps3";
	pSteamHttp->SetHTTPRequestGetOrPostParameter(httpRequest, "platform", platform);

	// Player ID
	if (bAnonymous == false)
	{
		if (ae_uniqueplayerid.GetInt() == 0)
			GenerateUniquePlayerId(pSteamAPIContext);
		pSteamHttp->SetHTTPRequestGetOrPostParameter(httpRequest, "playerid", ae_uniqueplayerid.GetString());
	}
}
Beispiel #25
0
void CGameRules::Think()
{
	GetVoiceGameMgr()->Update( gpGlobals->frametime );
	SetSkillLevel( skill.GetInt() );
}
//---------------------------------------------------------------------------------
// Purpose: Level has initialised
//---------------------------------------------------------------------------------
void		ManiWarmupTimer::PlayerSpawn(player_t *player_ptr)
{
	if (war_mode) return;
	if (mani_warmup_timer.GetInt() == 0) return;
	if (!check_timer) return;
	if (!gpManiGameType->IsValidActiveTeam(player_ptr->team)) return;
	if (fire_restart == false) return;

	respawn_list[player_ptr->index - 1].needs_respawn = false;

	if (player_ptr->is_bot)
	{
		if (mani_warmup_timer_knives_only.GetInt() == 1)
		{
			// Set cash to zero and strip weapons
			Prop_SetVal(player_ptr->entity, MANI_PROP_ACCOUNT, 0);
			CBaseEntity *pPlayer = player_ptr->entity->GetUnknown()->GetBaseEntity();
			CBaseCombatCharacter *pCombat = CBaseEntity_MyCombatCharacterPointer(pPlayer);

			CBaseCombatWeapon *pWeapon1 = CBaseCombatCharacter_Weapon_GetSlot(pCombat, 0);
			CBaseCombatWeapon *pWeapon2 = CBaseCombatCharacter_Weapon_GetSlot(pCombat, 1);
			CBasePlayer *pBase = (CBasePlayer*) pPlayer;
			if (pWeapon1)
			{
				CBasePlayer_RemovePlayerItem(pBase, pWeapon1);
			}

			if (pWeapon2)
			{
				CBasePlayer_RemovePlayerItem(pBase, pWeapon2);
			}

			CBaseCombatWeapon *pWeapon = CBaseCombatCharacter_Weapon_GetSlot(pCombat, 2);
			if (pWeapon)
			{
				CBaseCombatCharacter_Weapon_Switch(pCombat, pWeapon, 0);
			}

			CBaseEntity *weaponc4 = (CBaseEntity*)CGlobalEntityList_FindEntityByClassname(NULL, "weapon_c4");
			if (weaponc4)
			{
				CCSUTILRemove(weaponc4);
			}
		}
	}

	// Unlimited grenades
	if (mani_warmup_timer_unlimited_grenades.GetInt() == 1 && (gpManiGameType->IsGameType(MANI_GAME_CSS) || gpManiGameType->IsGameType(MANI_GAME_CSGO)))
	{
		GiveItem(player_ptr->entity, "weapon_hegrenade");
	}

	for (int i = 0; i < 5; i ++)
	{
		if (item_name[i][0] != '\0')
		{
			// Ignore assault suit if not CSS
			if (i == 0 && 
				(!gpManiGameType->IsGameType(MANI_GAME_CSS) && !gpManiGameType->IsGameType(MANI_GAME_CSGO)) &&
				strcmp(item_name[i], "item_assaultsuit") == 0)
			{
				continue;
			}

			GiveItem(player_ptr->entity, item_name[i]);
		}
	}
}
Beispiel #27
0
const char *GetBlobModelName()
{
	int index = npc_blob_use_model.GetInt();

	return pszBlobModels[ index ];
}
//---------------------------------------------------------------------------------
// Purpose: Game Frame has been run
//---------------------------------------------------------------------------------
void		ManiWarmupTimer::GameFrame(void)
{

	if (war_mode) return;
	if (!check_timer) return;
	if (ProcessPluginPaused()) return;

	if (mp_friendlyfire && mp_friendlyfire->GetInt() != 0 && mani_warmup_timer_disable_ff.GetInt() == 1)
		{
		friendly_fire = true;
		mp_friendlyfire->SetValue(0);
		}

	if (gpGlobals->curtime > next_check)
	{
		if (mani_warmup_timer_show_countdown.GetInt())
		{
			int time_left = mani_warmup_timer.GetInt() - ((int) gpGlobals->curtime);
			CSayToAll("Warmup timer %i", time_left);
		}

		next_check = gpGlobals->curtime + 1.0;
		if (gpGlobals->curtime > mani_warmup_timer.GetFloat())
		{
			check_timer = false;
			mani_warmup_in_progress.SetValue(0);
			if (friendly_fire && mani_warmup_timer_disable_ff.GetInt() == 1)
			{
				// Reset Friendly Fire value
				mp_friendlyfire->SetValue(1);
			}
		}

		if (fire_restart && gpGlobals->curtime > mani_warmup_timer.GetFloat() - 1)
		{
			engine->ServerCommand("mp_restartgame 1\n");
			fire_restart = false;
		}

		if ((gpManiGameType->IsGameType(MANI_GAME_CSS) || gpManiGameType->IsGameType(MANI_GAME_CSGO)) &&
			mani_warmup_timer_knives_only.GetInt() != 0 && 
			mani_warmup_timer_knives_respawn.GetInt() == 1 &&
			mani_warmup_timer_unlimited_grenades.GetInt() == 0)
		{
			for (int i = 0; i < max_players; i++)
			{
				if (!respawn_list[i].needs_respawn) continue;

				if (respawn_list[i].time_to_respawn < gpGlobals->curtime)
				{
					respawn_list[i].needs_respawn = false;

					player_t player;
					player.index = i + 1;
					if (!FindPlayerByIndex(&player)) continue;

					if (player.team != 2 && player.team != 3) return;

					// Remove rag doll if there
					//				CBaseEntity *pRagDoll = Prop_GetRagDoll(player.entity);
					//				if (pRagDoll)
					//				{
					//					CCSUTILRemove(pRagDoll);
					//				}

					CUtlVector<CBaseEntity*> ragdolls;
					CBaseEntity *ragdoll = (CBaseEntity*)CGlobalEntityList_FindEntityByClassname(NULL, "cs_ragdoll");

					while (ragdoll) 
					{
						ragdolls.AddToTail(ragdoll);
						ragdoll = (CBaseEntity*)CGlobalEntityList_FindEntityByClassname(ragdoll, "cs_ragdoll");
					}

					for (int x = 0; x < ragdolls.Count(); x++) 
					{
						CCSUTILRemove(ragdolls[x]);
					}

					CBaseEntity *pCBE = EdictToCBE(player.entity);
					if (pCBE)
					{
						CCSRoundRespawn(pCBE);
					}
				}
			}
		}

		if ((gpManiGameType->IsGameType(MANI_GAME_CSS) || gpManiGameType->IsGameType(MANI_GAME_CSGO)) &&
			mani_warmup_infinite_ammo.GetInt() == 1)
		{
			this->GiveAllAmmo(); 
		}
	}
}
Beispiel #29
0
void CInput::CreateMove ( int sequence_number, float input_sample_frametime, bool active )
{	
	CUserCmd *cmd = &m_pCommands[ sequence_number % MULTIPLAYER_BACKUP ];
	CVerifiedUserCmd *pVerified = &m_pVerifiedCommands[ sequence_number % MULTIPLAYER_BACKUP ];

	cmd->Reset();

	cmd->command_number = sequence_number;
	cmd->tick_count = gpGlobals->tickcount;

	QAngle viewangles;

	if ( active || sv_noclipduringpause.GetInt() )
	{
		// Determine view angles
		AdjustAngles ( input_sample_frametime );

		// Determine sideways movement
		ComputeSideMove( cmd );

		// Determine vertical movement
		ComputeUpwardMove( cmd );

		// Determine forward movement
		ComputeForwardMove( cmd );

		// Scale based on holding speed key or having too fast of a velocity based on client maximum
		//  speed.
		ScaleMovements( cmd );

		// Allow mice and other controllers to add their inputs
		ControllerMove( input_sample_frametime, cmd );
	}
	else
	{
		// need to run and reset mouse input so that there is no view pop when unpausing
		if ( !m_fCameraInterceptingMouse && m_fMouseActive )
		{
			float mx, my;
			GetAccumulatedMouseDeltasAndResetAccumulators( &mx, &my );
			ResetMouse();
		}
	}
	// Retreive view angles from engine ( could have been set in IN_AdjustAngles above )
	engine->GetViewAngles( viewangles );

	// Latch and clear impulse
	cmd->impulse = in_impulse;
	in_impulse = 0;

	// Latch and clear weapon selection
	if ( m_hSelectedWeapon != NULL )
	{
		C_BaseCombatWeapon *weapon = m_hSelectedWeapon;

		cmd->weaponselect = weapon->entindex();
		cmd->weaponsubtype = weapon->GetSubType();

		// Always clear weapon selection
		m_hSelectedWeapon = NULL;
	}

	// Set button and flag bits
	cmd->buttons = GetButtonBits( 1 );

	// Using joystick?
	if ( in_joystick.GetInt() )
	{
		if ( cmd->forwardmove > 0 )
		{
			cmd->buttons |= IN_FORWARD;
		}
		else if ( cmd->forwardmove < 0 )
		{
			cmd->buttons |= IN_BACK;
		}
	}

	// Use new view angles if alive, otherwise user last angles we stored off.
	if ( g_iAlive )
	{
		VectorCopy( viewangles, cmd->viewangles );
		VectorCopy( viewangles, m_angPreviousViewAngles );
	}
	else
	{
		VectorCopy( m_angPreviousViewAngles, cmd->viewangles );
	}

	// Let the move manager override anything it wants to.
	if ( g_pClientMode->CreateMove( input_sample_frametime, cmd ) )
	{
		// Get current view angles after the client mode tweaks with it
		engine->SetViewAngles( cmd->viewangles );
	}

	m_flLastForwardMove = cmd->forwardmove;

	cmd->random_seed = MD5_PseudoRandom( sequence_number ) & 0x7fffffff;

	HLTVCamera()->CreateMove( cmd );

#if defined( HL2_CLIENT_DLL )
	// copy backchannel data
	int i;
	for (i = 0; i < m_EntityGroundContact.Count(); i++)
	{
		cmd->entitygroundcontact.AddToTail( m_EntityGroundContact[i] );
	}
	m_EntityGroundContact.RemoveAll();
#endif

	pVerified->m_cmd = *cmd;
	pVerified->m_crc = cmd->GetChecksum();
}
void CASW_Mission_Chooser_Source_Local::AddToSavedCampaignList(const char *szSaveName)
{
	// find out what campaign this save is for
	char szFullFileName[256];
	Q_snprintf(szFullFileName, sizeof(szFullFileName), "save/%s", szSaveName);
	KeyValues *pSaveKeyValues = new KeyValues( szSaveName );
	if (pSaveKeyValues->LoadFromFile(g_pFullFileSystem, szFullFileName))
	{
		const char *pCampaignName = pSaveKeyValues->GetString("CampaignName");
		// check the campaign exists
		char tempfile[MAX_PATH];
		Q_snprintf( tempfile, sizeof( tempfile ), "resource/campaigns/%s.txt", pCampaignName );
		if (g_pFullFileSystem->FileExists(tempfile))
		{
			ASW_Mission_Chooser_Saved_Campaign item;
			Q_snprintf(item.m_szSaveName, sizeof(item.m_szSaveName), "%s", szSaveName);
			Q_snprintf(item.m_szCampaignName, sizeof(item.m_szCampaignName), "%s", pCampaignName);
			Q_snprintf(item.m_szDateTime, sizeof(item.m_szDateTime), "%s", pSaveKeyValues->GetString("DateTime"));
			//Msg("save %s multiplayer %d\n", szSaveName, pSaveKeyValues->GetInt("Multiplayer"));
			item.m_bMultiplayer = (pSaveKeyValues->GetInt("Multiplayer") > 0);
			//Msg("item multiplayer = %d\n", item.m_bMultiplayer);

			// check subsections for player names and player IDs, concat them into two strings
			char namebuffer[256];
			char idbuffer[512];
			namebuffer[0] = '\0';
			idbuffer[0] = '\0';
			int namepos = 0;
			int idpos = 0;
			KeyValues *pkvSubSection = pSaveKeyValues->GetFirstSubKey();
			while ( pkvSubSection )
			{
				if ((Q_stricmp(pkvSubSection->GetName(), "PLAYER")==0) && namepos < 253)
				{
					const char *pName = pkvSubSection->GetString("PlayerName");
					if (pName && pName[0] != '\0')
					{
						int namelength = Q_strlen(pName);
						for (int charcopy=0; charcopy<namelength && namepos<253; charcopy++)
						{
							namebuffer[namepos] = pName[charcopy];
							namepos++;
						}
						namebuffer[namepos] = ' '; namepos++;
						namebuffer[namepos] = '\0';
					}
				}
				if ((Q_stricmp(pkvSubSection->GetName(), "DATA")==0) && idpos < 253)
				{
					const char *pID = pkvSubSection->GetString("DataBlock");
					if (pID && pID[0] != '\0')
					{
						int idlength = Q_strlen(pID);
						for (int charcopy=0; charcopy<idlength && idpos<253; charcopy++)
						{
							idbuffer[idpos] = pID[charcopy];
							idpos++;
						}
						idbuffer[idpos] = ' '; idpos++;
						idbuffer[idpos] = '\0';
					}
				}
				pkvSubSection = pkvSubSection->GetNextKey();
			}
			Q_snprintf(item.m_szPlayerNames, sizeof(item.m_szPlayerNames), "%s", namebuffer);
			Q_snprintf(item.m_szPlayerIDs, sizeof(item.m_szPlayerIDs), "%s", idbuffer);
			item.m_iMissionsComplete = pSaveKeyValues->GetInt("NumMissionsComplete");
			m_SavedCampaignList.Insert( item );
		}
	}
	pSaveKeyValues->deleteThis();

	// check if there's now too many save games
	int iNumMultiplayer = GetNumSavedCampaigns(true, NULL);
	if (iNumMultiplayer > asw_max_saves.GetInt())
	{
		// find the oldest one
		ASW_Mission_Chooser_Saved_Campaign* pChosen = false;
		int iChosen = -1;
		for (int i=m_SavedCampaignList.Count()-1; i>=0; i--)
		{
			if (m_SavedCampaignList[i].m_bMultiplayer)
			{
				pChosen = &m_SavedCampaignList[i];
				iChosen = i;
				break;
			}			
		}
		// delete if found
		if (iChosen != -1 && pChosen)
		{
			char buffer[MAX_PATH];
			Q_snprintf(buffer, sizeof(buffer), "save/%s", pChosen->m_szSaveName);
			Msg("Deleting save %s as we have too many\n", buffer);
			g_pFullFileSystem->RemoveFile( buffer, "GAME" );
			m_SavedCampaignList.Remove(iChosen);
		}
	}
}