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


C++ CCharacter::GameServer方法代码示例

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


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

示例1: ConRescue

void CGameContext::ConRescue(IConsole::IResult *pResult, void *pUserData)
{
	CGameContext *pSelf = (CGameContext *)pUserData;
	CCharacter* pChr = pSelf->m_apPlayers[pResult->m_ClientID]->GetCharacter();

	if(!g_Config.m_SvRescue)
	{
		pSelf->SendChatTarget(pResult->m_ClientID, "Rescue is not activated.");
		return;
	}

	if(!pChr)
	{
		pSelf->SendChatTarget(pResult->m_ClientID, "You are not alive!");
		return;
	}
	
	
	if(pChr->m_DeepFreeze)
	{
		pSelf->SendChatTarget(pResult->m_ClientID, "You are deepfreezed, undeepfreeze first!");
		return;
	}
	if(!pChr->IsAlive())
	{
		pSelf->SendChatTarget(pResult->m_ClientID, "You are not alive!");
		return;
	}
	// unfreeze if pressed second time
	if(pChr->m_RescueFlags & RESCUEFLAG_CAN_UNFREEZE)
	{
		pChr->m_RescueFlags &= ~RESCUEFLAG_CAN_UNFREEZE;
		if(pChr->m_FreezeTime && pChr->m_TileIndex != TILE_FREEZE && pChr->m_TileFIndex != TILE_FREEZE && pChr->Core()->m_Pos == pChr->m_RescuePos)
		{
			pChr->UnFreeze();
			return;
		}
	}
	if(pChr->m_FreezeTime == 0)
		return;
    
	if(pChr->m_LastRescue) // sv_rescue_delay
		return;

	if(pChr->m_RescueOverride)
	{
		pSelf->SendChatTarget(pResult->m_ClientID, "Rescue is disabled by the map.");
		return;
	}

	if(pChr->m_RescuePos == vec2(0,0))
	{
		pSelf->SendChatTarget(pResult->m_ClientID, "No position saved!");
		return;
	}


	// reset players' hook
	for(int i = 0; i < MAX_CLIENTS; i++)
	{
		if(pSelf->m_apPlayers[i])
		{
			CCharacter* pChr2 = pSelf->m_apPlayers[i]->GetCharacter();
			//who hooks me?
			if(pChr2 && pChr2->Core()->m_HookedPlayer == pResult->m_ClientID)
			{
				//Release hook
				pChr2->Core()->m_HookedPlayer = -1;
				pChr2->Core()->m_HookState = HOOK_RETRACTED;
				pChr2->Core()->m_HookPos = pChr2->Core()->m_Pos;
			}
		}
	}
	if(g_Config.m_SvRescueEffects)
	{
		//Blood effect
		pChr->GameServer()->CreateDeath(pChr->m_Pos, pResult->m_ClientID);
		//Spawn effect
		pChr->GameServer()->CreatePlayerSpawn(pChr->m_RescuePos);
	}
	//Teleport player
	pChr->Core()->m_Pos = pChr->m_PrevPos = pChr->m_Pos = pChr->m_RescuePos;
	pChr->Core()->m_Vel = vec2(0.f, 0.f); // reset momentum

	if(pChr->m_RescueFlags)
	{
		// disarm player
		if(pChr->m_RescueFlags & RESCUEFLAG_DISARM)
		{
			bool disarmed = false;
			for(int i = WEAPON_SHOTGUN; i < NUM_WEAPONS; i++)
			{
				if(pChr->GetWeaponGot(i) && i != WEAPON_NINJA)
				{
					pChr->SetWeaponGot(i, false);
					pChr->SetWeaponAmmo(i, 0);
					disarmed = true;
				}
			}
			if(disarmed)
//.........这里部分代码省略.........
开发者ID:ftk,项目名称:XXLDDRace,代码行数:101,代码来源:ddracechat.cpp


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