void CPortalStatsDisplayScreen::UpdateTextFields( C_PropPortalStatsDisplay *pPropPortalStatsDisplay )
{
	bool bIsTime = pPropPortalStatsDisplay->IsTime();
	float fNumPlayer = pPropPortalStatsDisplay->GetNumPlayerDisplay();
	float fNumGoal = pPropPortalStatsDisplay->GetNumGoalDisplay();

	// Figure out colors

	Color *( pColors[ 3 ] ) = { &m_cUnknown, &m_cFail, &m_cPass };

	int iColor = pPropPortalStatsDisplay->GetGoalSuccess() + 1;

	m_pNumPlayerLabel->SetFgColor( ( fNumPlayer != 0.0f ) ? ( *pColors[ iColor ] ) : ( m_cInvisible ) );
	m_pNumGoalLabel->SetFgColor( ( pPropPortalStatsDisplay->GetGoalVisible() ) ? ( *pColors[ iColor ] ) : ( m_cInvisible ) );

	// Fill in labels

	CFmtStr str;

	if ( !bIsTime )
	{
		str.sprintf( "%.0f", fNumPlayer );
		m_pNumPlayerLabel->SetText( str );

		str.sprintf( "%.0f", fNumGoal );
		m_pNumGoalLabel->SetText( str );
	}
	else
	{
		// break seconds into mnutes and seconds
		int iMinutes = static_cast<int>( fNumPlayer / 60.0f );
		int iHours = iMinutes / 60;
		iMinutes %= 60;
		int iSeconds = static_cast<int>( fNumPlayer ) % 60;
		MakeTimeString( str, iHours, iMinutes, iSeconds );
		m_pNumPlayerLabel->SetText( str );

		// break seconds into mnutes and seconds
		iMinutes = static_cast<int>( fNumGoal / 60.0f );
		iHours = iMinutes / 60;
		iMinutes %= 60;
		iSeconds = static_cast<int>( fNumGoal ) % 60;
		MakeTimeString( str, iHours, iMinutes, iSeconds );
		m_pNumGoalLabel->SetText( str );
	}

	// Draw cheated label when needed
	m_pCheatedLabel->SetVisible( pPropPortalStatsDisplay->HasCheated() );
}
Beispiel #2
0
//-----------------------------------------------------------------------------------------------------
int CFuncNavBlocker::DrawDebugTextOverlays( void )
{
	int offset = BaseClass::DrawDebugTextOverlays();

	if (m_debugOverlays & OVERLAY_TEXT_BIT) 
	{
		CFmtStr str;

		// FIRST_GAME_TEAM skips TEAM_SPECTATOR and TEAM_UNASSIGNED, so we can print
		// useful team names in a non-game-specific fashion.
		for ( int i=FIRST_GAME_TEAM; i<FIRST_GAME_TEAM + MAX_NAV_TEAMS; ++i )
		{
			if ( IsBlockingNav( i ) )
			{
				CTeam *team = GetGlobalTeam( i );
				if ( team )
				{
					EntityText( offset++, str.sprintf( "blocking team %s", team->GetName() ), 0 );
				}
				else
				{
					EntityText( offset++, str.sprintf( "blocking team %d", i ), 0 );
				}
			}
		}

		NavAreaCollector collector( true );
		Extent extent;
		extent.Init( this );
		TheNavMesh->ForAllAreasOverlappingExtent( collector, extent );

		for ( int i=0; i<collector.m_area.Count(); ++i )
		{
			CNavArea *area = collector.m_area[i];
			Extent areaExtent;
			area->GetExtent( &areaExtent );
			debugoverlay->AddBoxOverlay( vec3_origin, areaExtent.lo, areaExtent.hi, vec3_angle, 0, 255, 0, 10, NDEBUG_PERSIST_TILL_NEXT_SERVER );
		}
	}

	return offset;
}
void MakeTimeString( CFmtStr &str, int iHours, int iMinutes, int iSeconds )
{
	if ( iHours )
	{
		if ( iMinutes < 10 )
		{
			if ( iSeconds < 10 )
				str.sprintf( "%d:0%d:0%d", iHours, iMinutes, iSeconds );
			else
				str.sprintf( "%d:0%d:%d", iHours, iMinutes, iSeconds );
		}
		else
		{
			if ( iSeconds < 10 )
				str.sprintf( "%d:%d:0%d", iHours, iMinutes, iSeconds );
			else
				str.sprintf( "%d:%d:%d", iHours, iMinutes, iSeconds );
		}
	}
	else
	{
		if ( iSeconds < 10 )
			str.sprintf( "%d:0%d", iMinutes, iSeconds );
		else
			str.sprintf( "%d:%d", iMinutes, iSeconds );
	}
}
void CNPC_Portal_FloorTurret::RopesOn( void )
{
	for ( int iRope = 0; iRope < PORTAL_FLOOR_TURRET_NUM_ROPES; ++iRope )
	{
		// Make a rope if it doesn't exist
		if ( !m_hRopes[ iRope ] )
		{
			CFmtStr str;

			int iStartIndex = LookupAttachment( str.sprintf( "Wire%i_start", iRope + 1 ) );
			int iEndIndex = LookupAttachment( str.sprintf( "Wire%i_end", iRope + 1 ) );

			m_hRopes[ iRope ] = CRopeKeyframe::Create( this, this, iStartIndex, iEndIndex );
			if ( m_hRopes[ iRope ] )
			{
				m_hRopes[ iRope ]->m_Width = 0.7;
				m_hRopes[ iRope ]->m_nSegments = ROPE_MAX_SEGMENTS;
				m_hRopes[ iRope ]->EnableWind( false );
				m_hRopes[ iRope ]->SetupHangDistance( 9.0f );
				m_hRopes[ iRope ]->m_bConstrainBetweenEndpoints = true;;
			}
		}
	}
}
	void CSingleplayRules::NPCKilled(CBaseEntity *pVictim, const CTakeDamageInfo &info)
	{
		CBasePlayer *pEntity = UTIL_GetLocalPlayer();
		if (pVictim->m_isRareEntity)
		{
			switch (GetSkillLevel())
			{
			case SKILL_EASY:
				if (g_fr_economy.GetBool())
				{
					pEntity->AddMoney(3 * sk_money_multiplier1.GetInt());
				}
				if (!g_fr_classic.GetBool())
				{
					pEntity->AddXP(5 * sk_exp_multiplier1.GetInt());
				}
				break;

			case SKILL_MEDIUM:
				if (g_fr_economy.GetBool())
				{
					pEntity->AddMoney(3 * sk_money_multiplier2.GetInt());
				}
				if (!g_fr_classic.GetBool())
				{
					pEntity->AddXP(5 * sk_exp_multiplier2.GetInt());
				}
				break;

			case SKILL_HARD:
				if (g_fr_economy.GetBool())
				{
					pEntity->AddMoney(3 * sk_money_multiplier3.GetInt());
				}
				if (!g_fr_classic.GetBool())
				{
					pEntity->AddXP(5 * sk_exp_multiplier3.GetInt());
				}
				break;

			case SKILL_VERYHARD:
				if (g_fr_economy.GetBool())
				{
					pEntity->AddMoney(3 * sk_money_multiplier4.GetInt());
				}
				if (!g_fr_classic.GetBool())
				{
					pEntity->AddXP(5 * sk_exp_multiplier4.GetInt());
				}
				break;

			case SKILL_NIGHTMARE:
				if (g_fr_economy.GetBool())
				{
					pEntity->AddMoney(3 * sk_money_multiplier5.GetInt());
				}
				if (!g_fr_classic.GetBool())
				{
					pEntity->AddXP(5 * sk_exp_multiplier5.GetInt());
				}
				break;
			}
		}
		else
		{
			switch (GetSkillLevel())
			{
			case SKILL_EASY:
				if (g_fr_economy.GetBool())
				{
					pEntity->AddMoney(2 * sk_money_multiplier1.GetInt());
				}
				if (!g_fr_classic.GetBool())
				{
					pEntity->AddXP(3 * sk_exp_multiplier1.GetInt());
				}
				break;

			case SKILL_MEDIUM:
				if (g_fr_economy.GetBool())
				{
					pEntity->AddMoney(2 * sk_money_multiplier2.GetInt());
				}
				if (!g_fr_classic.GetBool())
				{
					pEntity->AddXP(3 * sk_exp_multiplier2.GetInt());
				}
				break;

			case SKILL_HARD:
				if (g_fr_economy.GetBool())
				{
					pEntity->AddMoney(2 * sk_money_multiplier3.GetInt());
				}
				if (!g_fr_classic.GetBool())
				{
					pEntity->AddXP(3 * sk_exp_multiplier3.GetInt());
				}
				break;

			case SKILL_VERYHARD:
				if (g_fr_economy.GetBool())
				{
					pEntity->AddMoney(2 * sk_money_multiplier4.GetInt());
				}
				if (!g_fr_classic.GetBool())
				{
					pEntity->AddXP(3 * sk_exp_multiplier4.GetInt());
				}
				break;

			case SKILL_NIGHTMARE:
				if (g_fr_economy.GetBool())
				{
					pEntity->AddMoney(2 * sk_money_multiplier5.GetInt());
				}
				if (!g_fr_classic.GetBool())
				{
					pEntity->AddXP(3 * sk_exp_multiplier5.GetInt());
				}
				break;
			}
		}
		pEntity->IncrementFragCount(1);

#define KILLING_SPREE_AMOUNT	5
#define KILLING_FRENZY_AMOUNT	10
#define OVERKILL_AMOUNT	15
#define RAMPAGE_AMOUNT	20
#define UNSTOPPABLE_AMOUNT	25
#define INCONCEIVABLE_AMOUNT	30
#define INVINCIBLE_AMOUNT	35
#define GODLIKE_AMOUNT	40

		if (info.GetInflictor() == pEntity)
		{
			if (sv_player_voice.GetBool())
			{
				if (sv_player_voice_kill.GetBool())
				{
					int killvoicerandom = random->RandomInt(0, sv_player_voice_kill_freq.GetInt());
					if (killvoicerandom == 0)
					{
						pEntity->EmitSound("Player.VoiceKill");
					}
				}
			}
		}

		if (sv_killingspree.GetBool())
		{
			int m_iKillsInSpree = pEntity->FragCount();

			if (m_iKillsInSpree == KILLING_SPREE_AMOUNT)
			{
				CFmtStr hint;
				hint.sprintf("#Valve_Hud_KILLINGSPREE");
				pEntity->ShowLevelMessage(hint.Access());
				if (g_fr_economy.GetBool())
				{
					pEntity->AddMoney(2);
				}
				if (!g_fr_classic.GetBool())
				{
					pEntity->AddXP(3);
				}
			}
			if (m_iKillsInSpree == KILLING_FRENZY_AMOUNT)
			{
				CFmtStr hint;
				hint.sprintf("#Valve_Hud_KILLINGFRENZY");
				pEntity->ShowLevelMessage(hint.Access());
				if (g_fr_economy.GetBool())
				{
					pEntity->AddMoney(4);
				}
				if (!g_fr_classic.GetBool())
				{
					pEntity->AddXP(6);
				}
			}
			if (m_iKillsInSpree == OVERKILL_AMOUNT)
			{
				CFmtStr hint;
				hint.sprintf("#Valve_Hud_OVERKILL");
				pEntity->ShowLevelMessage(hint.Access());
				if (g_fr_economy.GetBool())
				{
					pEntity->AddMoney(6);
				}
				if (!g_fr_classic.GetBool())
				{
					pEntity->AddXP(9);
				}
			}
			if (m_iKillsInSpree == RAMPAGE_AMOUNT)
			{
				CFmtStr hint;
				hint.sprintf("#Valve_Hud_RAMPAGE");
				pEntity->ShowLevelMessage(hint.Access());
				if (g_fr_economy.GetBool())
				{
					pEntity->AddMoney(8);
				}
				if (!g_fr_classic.GetBool())
				{
					pEntity->AddXP(12);
				}
			}
			if (m_iKillsInSpree == UNSTOPPABLE_AMOUNT)
			{
				CFmtStr hint;
				hint.sprintf("#Valve_Hud_UNSTOPPABLE");
				pEntity->ShowLevelMessage(hint.Access());
				if (g_fr_economy.GetBool())
				{
					pEntity->AddMoney(10);
				}
				if (!g_fr_classic.GetBool())
				{
					pEntity->AddXP(15);
				}
			}
			if (m_iKillsInSpree == INCONCEIVABLE_AMOUNT)
			{
				CFmtStr hint;
				hint.sprintf("#Valve_Hud_INCONCEIVABLE");
				pEntity->ShowLevelMessage(hint.Access());
				if (g_fr_economy.GetBool())
				{
					pEntity->AddMoney(12);
				}
				if (!g_fr_classic.GetBool())
				{
					pEntity->AddXP(18);
				}
			}
			if (m_iKillsInSpree == INVINCIBLE_AMOUNT)
			{
				CFmtStr hint;
				hint.sprintf("#Valve_Hud_INVINCIBLE");
				pEntity->ShowLevelMessage(hint.Access());
				if (g_fr_economy.GetBool())
				{
					pEntity->AddMoney(14);
				}
				if (!g_fr_classic.GetBool())
				{
					pEntity->AddXP(21);
				}
			}
			if (m_iKillsInSpree == GODLIKE_AMOUNT)
			{
				CFmtStr hint;
				hint.sprintf("#Valve_Hud_GODLIKE");
				pEntity->ShowLevelMessage(hint.Access());
				if (g_fr_economy.GetBool())
				{
					pEntity->AddMoney(16);
				}
				if (!g_fr_classic.GetBool())
				{
					pEntity->AddXP(24);
				}
			}
		}

		if (pVictim->m_isRareEntity)
		{
			if (g_fr_classic.GetBool())
			{
				pEntity->LevelUpClassic();
			}
		}
	}
Beispiel #6
0
//-----------------------------------------------------------------------------
// Purpose: Handle grenade detonate in-air (even when no ammo is left)
//-----------------------------------------------------------------------------
void CWeaponOICW::ItemPostFrame(void)
{
	CBasePlayer *pOwner = ToBasePlayer(GetOwner());
	if (!pOwner)
		return;

	if ((pOwner->m_nButtons & IN_ATTACK) == false)
	{
		m_nShotsFired = 0;
	}

	//Zoom in
	if (pOwner->m_afButtonPressed & IN_ATTACK2)
	{
		if (m_iFireMode == 0)
		{
			Zoom();
		}
		else if (m_iFireMode == 1)
		{
			if (m_flNextSecondaryAttack <= gpGlobals->curtime)
			{
				if (pOwner->GetAmmoCount(m_iSecondaryAmmoType) <= 0)
				{
					if (m_flNextEmptySoundTime < gpGlobals->curtime)
					{
						WeaponSound(EMPTY);
						m_flNextSecondaryAttack = m_flNextEmptySoundTime = gpGlobals->curtime + 0.5;
					}
				}
				else if (pOwner->GetWaterLevel() == 3 && m_bAltFiresUnderwater == false)
				{
					// This weapon doesn't fire underwater
					WeaponSound(EMPTY);
					m_flNextPrimaryAttack = gpGlobals->curtime + 0.2;
					return;
				}
				else
				{
					GrenadeAttack();
				}
			}
		}
	}

	//Throw a grenade.
	if (pOwner->m_afButtonPressed & IN_ATTACK3)
	{
		if (m_iFireMode == 0)
		{
			if (m_bZoomed)
			{
				Zoom();
			}
			CFmtStr hint;
			hint.sprintf("#Valve_OICW_Grenades");
			pOwner->ShowLevelMessage(hint.Access());
			m_iFireMode = 1;
			WeaponSound(EMPTY);
		}
		else if (m_iFireMode == 1)
		{
			CFmtStr hint;
			hint.sprintf("#Valve_OICW_Scope");
			pOwner->ShowLevelMessage(hint.Access());
			m_iFireMode = 0;
			WeaponSound(EMPTY);
		}
	}

	//Allow a refire as fast as the player can click
	if (m_bZoomed && ((pOwner->m_nButtons & IN_ATTACK) == false) && (m_flSoonestPrimaryAttack < gpGlobals->curtime))
	{
		m_flNextPrimaryAttack = gpGlobals->curtime - 0.1f;
	}

	//Don't kick the same when we're zoomed in
	if (m_bZoomed)
	{
		m_fFireDuration = 0.05f;
	}

	BaseClass::ItemPostFrame();
}
HSCRIPT VScriptCompileScript( const char *pszScriptName, bool bWarnMissing )
{
    if ( !g_pScriptVM )
    {
        return NULL;
    }

    static const char *pszExtensions[] =
    {
        "",		// SL_NONE
        ".gm",	// SL_GAMEMONKEY
        ".nut",	// SL_SQUIRREL
        ".lua", // SL_LUA
        ".py",  // SL_PYTHON
    };

    const char *pszVMExtension = pszExtensions[g_pScriptVM->GetLanguage()];
    const char *pszIncomingExtension = V_strrchr( pszScriptName , '.' );
    if ( pszIncomingExtension && V_strcmp( pszIncomingExtension, pszVMExtension ) != 0 )
    {
        Log_Warning( LOG_VScript, "Script file type does not match VM type\n" );
        return NULL;
    }

    CFmtStr scriptPath;
    if ( pszIncomingExtension )
    {
        scriptPath.sprintf( "scripts/vscripts/%s", pszScriptName );
    }
    else
    {
        scriptPath.sprintf( "scripts/vscripts/%s%s", pszScriptName,  pszVMExtension );
    }

    const char *pBase;
    CUtlBuffer bufferScript;

    if ( g_pScriptVM->GetLanguage() == SL_PYTHON )
    {
        // python auto-loads raw or precompiled modules - don't load data here
        pBase = NULL;
    }
    else
    {
        bool bResult = filesystem->ReadFile( scriptPath, "GAME", bufferScript );

        if( !bResult )
        {
            Log_Warning( LOG_VScript, "Script not found (%s) \n", scriptPath.operator const char *() );
            Assert( "Error running script" );
        }

        pBase = (const char *) bufferScript.Base();

        if ( !pBase || !*pBase )
        {
            return NULL;
        }
    }


    const char *pszFilename = V_strrchr( scriptPath, '/' );
    pszFilename++;
    HSCRIPT hScript = g_pScriptVM->CompileScript( pBase, pszFilename );
    if ( !hScript )
    {
        Log_Warning( LOG_VScript, "FAILED to compile and execute script file named %s\n", scriptPath.operator const char *() );
        Assert( "Error running script" );
    }
    return hScript;
}