当前位置: 首页>>代码示例>>C++>>正文


C++ CHL2MP_Player::IncrementFragCount方法代码示例

本文整理汇总了C++中CHL2MP_Player::IncrementFragCount方法的典型用法代码示例。如果您正苦于以下问题:C++ CHL2MP_Player::IncrementFragCount方法的具体用法?C++ CHL2MP_Player::IncrementFragCount怎么用?C++ CHL2MP_Player::IncrementFragCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CHL2MP_Player的用法示例。


在下文中一共展示了CHL2MP_Player::IncrementFragCount方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: StartTouch

//-----------------------------------------------------------------------------
// Can the player be set as the parent?
//-----------------------------------------------------------------------------
void CTriggerCTFCapture::StartTouch(CBaseEntity *pOther)
{
	if (!pOther->IsPlayer()) //Nothing else should trigger this.
		return;

	//Defines
	CHL2MP_Player *pPlayer = ToHL2MPPlayer(pOther);
	CtfFlag *pFlag = NULL;
	bool m_bHomeFlagTaken = false;

	if (!pPlayer || !pPlayer->IsAlive()) //Still alive?
		return;

	if (sv_ctf_capturestyle.GetInt() > 1)
	{
		while ((pFlag = static_cast<CtfFlag*>(gEntList.FindEntityByClassname(pFlag, "ctf_flag"))) != NULL)
		{
			if (pFlag->iTeam == pPlayer->GetTeamNumber()) //This flag is an enemy flag, we want the player's team's flag.
				continue;

			if (pFlag->GetAbsOrigin() != pFlag->FlagOrigin) //This flag belongs to the player's team. Is it at home?
				m_bHomeFlagTaken = true;
		}
	}


	while ((pFlag = static_cast<CtfFlag*>(gEntList.FindEntityByClassname(pFlag, "ctf_flag"))) != NULL)
	{
		if (pFlag->GetParent() && pFlag->GetParent() == pPlayer) //So the flag has a parent.. and it's the player who touched the trigger.
		{
			int TeamNumber = pPlayer->GetTeamNumber();

			//For team affected by the trigger.
			switch (m_iAffectedTeam)
			{
			case 0:
				iTeam = TeamNumber;
				break;
			case 1:
				iTeam = TEAM_BRITISH;
				break;
			case 2:
				iTeam = TEAM_AMERICANS;
				break;
			}

			if (TeamNumber != iTeam) //Trigger isn't for this player's team. Die.
				return;
			//

			if (m_bHomeFlagTaken) //The player's team's flag is taken. So we cannot cap an enemy flag.
			{
				ClientPrint(pPlayer, CTF_DENY_CAPTURE); //Let the player know.
				return; //Die here.
			}

			//Assuming we've made it thus far, you're probably carrying a flag that belongs to the enemy. Go ahead and cap it.
			pFlag->PlaySound(GetAbsOrigin(), m_iSound); //Play the capture sound.

			pFlag->ResetFlag();

			g_Teams[TeamNumber]->AddScore(m_iTeamBonus); //Adds the team score bonus.
			pPlayer->IncrementFragCount(m_iPlayerBonus); //Give the player the points.

			//reset the capturer's speed
			//pPlayer->SetSpeedModifier(0);
			pPlayer->RemoveSpeedModifier(ESpeedModID::Flag); //BG3 - Awesome - removed to more robust speed modifier system

			pFlag->PrintAlert(CTF_CAPTURE, pPlayer->GetPlayerName(), pFlag->cFlagName);

			//Do the log stuff.
			CTeam *team = pPlayer->GetTeam();

			UTIL_LogPrintf("\"%s<%i><%s><%s>\" triggered \"ctf_flag_capture\"\n",
				pPlayer->GetPlayerName(),
				pPlayer->GetUserID(),
				pPlayer->GetNetworkIDString(),
				team ? team->GetName() : "");
			//

			m_OnFlagCaptured.FireOutput(this, this); //Fire the OnFlagCaptured output, set it last just in case.
		}
	}
}
开发者ID:BG2-Dev-Team,项目名称:BG2-Code,代码行数:87,代码来源:hl2_triggers.cpp


注:本文中的CHL2MP_Player::IncrementFragCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。