Ejemplo n.º 1
0
void game_cl_TeamDeathmatch::shedule_Update			(u32 dt)
{
	CStringTable st;
	string512	msg;

	if(!m_game_ui && HUD().GetUI() ) m_game_ui = smart_cast<CUIGameTDM*>( HUD().GetUI()->UIGame() );
	inherited::shedule_Update(dt);

	if (!m_game_ui) return;
	//---------------------------------------------------------
	if (m_game_ui->m_pUITeamSelectWnd && m_game_ui->m_pUITeamSelectWnd->IsShown() && !CanCallTeamSelectMenu())
		StartStopMenu(m_game_ui->m_pUITeamSelectWnd,true);
	//---------------------------------------------------------
	
	switch (m_phase)
	{
	case GAME_PHASE_TEAM1_SCORES:
		{
			sprintf_s(msg, /*team %s wins*/ *st.translate("mp_team_wins"), CTeamInfo::GetTeam_name(1));
			m_game_ui->SetRoundResultCaption(msg);

			SetScore();
		}break;
	case GAME_PHASE_TEAM2_SCORES:
		{
			sprintf_s(msg, /*team %s wins*/ *st.translate("mp_team_wins"), CTeamInfo::GetTeam_name(2));
			m_game_ui->SetRoundResultCaption(msg);
			
			SetScore();
			
		}break;
	case GAME_PHASE_INPROGRESS:
		{
			if (local_player && !local_player->IsSkip())
			{			
				if (Level().CurrentEntity() && Level().CurrentEntity()->CLS_ID == CLSID_SPECTATOR)
				{
					if (!(pCurBuyMenu && pCurBuyMenu->IsShown()) && 
						!(pCurSkinMenu && pCurSkinMenu->IsShown()) &&
						!(m_game_ui->m_pMapDesc && m_game_ui->m_pMapDesc->IsShown()) &&
						(HUD().GetUI() && HUD().GetUI()->GameIndicatorsShown())
						)
					{
						if (!m_bTeamSelected)
							m_game_ui->SetPressJumpMsgCaption("mp_press_jump2select_team");
					};
				};
				SetScore();
			};
		}break;
	default:
		{
		}break;
	};

}
Ejemplo n.º 2
0
void game_cl_TeamDeathmatch::TranslateGameMessage	(u32 msg, NET_Packet& P)
{
	CStringTable st;
	string512 Text;
//	LPSTR	Color_Teams[3]	= {"%c[255,255,255,255]", "%c[255,64,255,64]", "%c[255,64,64,255]"};
	char	Color_Main[]	= "%c[255,192,192,192]";
//	LPSTR	TeamsNames[3]	= {"Zero Team", "Team Green", "Team Blue"};

	switch(msg)	{
	case GAME_EVENT_PLAYER_JOIN_TEAM: //tdm
		{
			string64 PlayerName;
			P.r_stringZ	(PlayerName);
			u16 Team;
			P.r_u16		(Team);

			sprintf_s(Text, "%s%s %s%s %s%s",
							"",//no color
							PlayerName,
							Color_Main,
							*st.translate("mp_joined"),
							CTeamInfo::GetTeam_color_tag(int(Team)),							
							CTeamInfo::GetTeam_name(int(Team)));
			CommonMessageOut(Text);
			//---------------------------------------
			Msg("%s %s %s", PlayerName, *st.translate("mp_joined"),
				CTeamInfo::GetTeam_name(int(Team)));
		}break;

	case PLAYER_CHANGE_TEAM://tdm
		{
			u16 PlayerID, OldTeam, NewTeam;
			P.r_u16 (PlayerID);
			P.r_u16 (OldTeam);
			P.r_u16 (NewTeam);

			game_PlayerState* pPlayer = GetPlayerByGameID(PlayerID);
			if (!pPlayer) break;

			sprintf_s(Text, "%s%s %s%s %s%s", 
							CTeamInfo::GetTeam_color_tag(int(OldTeam)), 
							pPlayer->name, 
							Color_Main, 
							*st.translate("mp_switched_to"),
							CTeamInfo::GetTeam_color_tag(int(NewTeam)), 
							CTeamInfo::GetTeam_name(int(NewTeam)));
			CommonMessageOut(Text);
			//---------------------------------------
			Msg("%s *s %s", pPlayer->name, *st.translate("mp_switched_to"), CTeamInfo::GetTeam_name(int(NewTeam)));
		}break;

	default:
		inherited::TranslateGameMessage(msg,P);
	};
}
Ejemplo n.º 3
0
void game_cl_GameState::TranslateGameMessage	(u32 msg, NET_Packet& P)
{
	CStringTable st;

	string512 Text;
	char	Color_Main[]	= "%c[255,192,192,192]";
	LPSTR	Color_Teams[3]	= {"%c[255,255,240,190]", "%c[255,64,255,64]", "%c[255,64,64,255]"};

	switch (msg)
	{
	case GAME_EVENT_PLAYER_CONNECTED:
		{

#ifdef BATTLEYE
			if ( g_pGameLevel && Level().battleye_system.GetTestClient() )
			{
				bool res_battleye = Level().battleye_system.LoadClient();
				VERIFY( res_battleye );
			}
#endif // BATTLEYE

			string64 PlayerName;
			P.r_stringZ(PlayerName);
			
			sprintf_s(Text, "%s%s %s%s",Color_Teams[0],PlayerName,Color_Main,*st.translate("mp_connected"));
			CommonMessageOut(Text);
			//---------------------------------------
			Msg("%s connected", PlayerName);
		}break;
	case GAME_EVENT_PLAYER_DISCONNECTED:
		{
			string64 PlayerName;
			P.r_stringZ(PlayerName);

			sprintf_s(Text, "%s%s %s%s",Color_Teams[0],PlayerName,Color_Main,*st.translate("mp_disconnected"));
			CommonMessageOut(Text);
			//---------------------------------------
			Msg("%s disconnected", PlayerName);
		}break;
	case GAME_EVENT_PLAYER_ENTERED_GAME:
		{
			string64 PlayerName;
			P.r_stringZ(PlayerName);

			sprintf_s(Text, "%s%s %s%s",Color_Teams[0],PlayerName,Color_Main,*st.translate("mp_entered_game"));
			CommonMessageOut(Text);
		}break;
	default:
		{
			R_ASSERT2(0,"Unknown Game Message");
		}break;
	};

}
Ejemplo n.º 4
0
void CUIGameCTA::ShowBuySpawn(s32 spawn_cost)
{
    VERIFY			(m_pBuySpawnMsgBox);
    VERIFY			(Game().local_player);

    if (m_pBuySpawnMsgBox->IsShown())
        return;

    CStringTable	st;
    LPCSTR	format_str		= st.translate("mp_press_yes2pay").c_str();
    VERIFY(format_str);
    size_t	pay_frm_size	= xr_strlen(format_str)*sizeof(char) + 64;
    PSTR	pay_frm_str		= static_cast<char*>(_alloca(pay_frm_size));

    xr_sprintf(
        pay_frm_str,
        pay_frm_size,
        format_str,
        abs(Game().local_player->money_for_round),
        abs(spawn_cost)
    );

    m_pBuySpawnMsgBox->SetText(pay_frm_str);
    m_pBuySpawnMsgBox->ShowDialog(true);
}
Ejemplo n.º 5
0
bool game_cl_ArtefactHunt::NeedToSendReady_Spectator(int key, game_PlayerState* ps)
{
	CStringTable		st;
	bool res = ( GAME_PHASE_PENDING	== Phase() && kWPN_FIRE == key) || 
		( (kJUMP == key) && GAME_PHASE_INPROGRESS==Phase() && 
		CanBeReady());

	if ((Phase() == GAME_PHASE_INPROGRESS) &&  
		(kJUMP==key) &&
		m_cl_dwWarmUp_Time)
	{
		return res;
	}
	
	if ((GAME_PHASE_INPROGRESS==Phase()) && (kJUMP==key) &&
		(iReinforcementTime!=0) && 
		(!m_game_ui->m_pBuySpawnMsgBox->IsShown()) && 
		local_player && (local_player->money_for_round+m_iSpawn_Cost)>=0) 
	{
		string1024				BuySpawnText;
		xr_sprintf				(BuySpawnText, *st.translate("mp_press_yes2pay"), 
								abs(local_player->money_for_round), abs(m_iSpawn_Cost));
		m_game_ui->m_pBuySpawnMsgBox->SetText(BuySpawnText);

		if (m_bTeamSelected && m_bSkinSelected)
			m_game_ui->m_pBuySpawnMsgBox->ShowDialog(true);

		return false;
	};
	return res;
}
Ejemplo n.º 6
0
void UIPlayerItem::GetTextParamValue(game_PlayerState const * ps, 
									 shared_str const & param_name,
									 buffer_vector<char> & dest)
{
	VERIFY(ps);
	if (param_name.equal("mp_name"))
	{
		strcpy_s(dest.begin(), dest.size(), ps->name);
	} else if (param_name.equal("mp_frags"))
	{
		sprintf_s(dest.begin(), dest.size(), "%d", ps->m_iRivalKills - ps->m_iSelfKills);
	} else if (param_name.equal("mp_deaths"))
	{
		sprintf_s(dest.begin(), dest.size(), "%d", ps->m_iDeaths);
	} else if (param_name.equal("mp_artefacts"))
	{
		sprintf_s(dest.begin(), dest.size(), "%d", ps->af_count);
	} else if (param_name.equal("mp_spots"))
	{
		sprintf_s(dest.begin(), dest.size(), "%d", m_checkPoints);
	}else if (param_name.equal("mp_status"))
	{
		CStringTable st;
		if (ps->testFlag(GAME_PLAYER_FLAG_READY))
			strcpy_s(dest.begin(), dest.size(), st.translate("st_mp_ready").c_str());
	} else if (param_name.equal("mp_ping"))
	{
		sprintf_s(dest.begin(), dest.size(), "%d", ps->ping);
	}
}
Ejemplo n.º 7
0
void game_sv_GameState::MapRotation_ListMaps	()
{
	if (m_pMapRotation_List.empty())
	{
		Msg ("- Currently there are no any maps in list.");
		return;
	}
	CStringTable st;
	Msg("- ----------- Maps ---------------");
	for (u32 i=0; i<m_pMapRotation_List.size(); i++)
	{
		SMapRot& R = m_pMapRotation_List[i];
		if (i==0)
			Msg("~   %d. %s (%s) (current)", i+1, st.translate(R.map_name).c_str(), R.map_name.c_str());
		else
			Msg("  %d. %s (%s)", i+1, st.translate(R.map_name).c_str(), R.map_name.c_str());
	}
	Msg("- --------------------------------");
};
Ejemplo n.º 8
0
void	CMainMenu::OnSessionTerminate				(LPCSTR reason)
{
	if ( m_NeedErrDialog == SessionTerminate && (Device.dwTimeGlobal - m_start_time) < 8000 )
		return;

	m_start_time = Device.dwTimeGlobal;
	CStringTable	st;
	LPCSTR str = st.translate("ui_st_kicked_by_server").c_str();
	LPSTR		text;

	if ( reason && xr_strlen(reason) && reason[0] == '@' )
	{
		STRCONCAT( text, reason + 1 );
	}
	else
	{
		STRCONCAT( text, str, " ", reason );
	}
	
	m_pMB_ErrDlgs[SessionTerminate]->SetText(st.translate(text).c_str());
	SetErrorDialog(CMainMenu::SessionTerminate);
}
Ejemplo n.º 9
0
void CSpectator::GetSpectatorString		(string1024& pStr)
{
	if (!pStr) return;
	if (GameID() == GAME_SINGLE) return;
	
	xr_string	SpectatorMsg;
	CStringTable st;
	switch (cam_active)
	{
	case eacFreeFly:
		{
			SpectatorMsg = *st.translate("mp_spectator");
			SpectatorMsg += " ";
			SpectatorMsg += *st.translate("mp_free_fly");
		}break;
	case eacFirstEye:
		{
			SpectatorMsg = *st.translate("mp_spectator");
			SpectatorMsg += " ";
			SpectatorMsg += *st.translate("mp_first_eye");
			SpectatorMsg += " ";
//			SpectatorMsg = "SPECTATOR (First-Eye): ";
			SpectatorMsg += m_pActorToLookAt->Name();			

		}break;
	case eacFreeLook:
		{
			SpectatorMsg = *st.translate("mp_spectator");
			SpectatorMsg += " ";
			SpectatorMsg += *st.translate("mp_free_look");
			SpectatorMsg += " ";
//			SpectatorMsg = "SPECTATOR (Free-Look):";
			SpectatorMsg += m_pActorToLookAt->Name();
		}break;
	case eacLookAt:
		{
			SpectatorMsg = *st.translate("mp_spectator");
			SpectatorMsg += " ";
			SpectatorMsg += *st.translate("mp_look_at");
			SpectatorMsg += " ";
//			SpectatorMsg = "SPECTATOR (Look-At):";
			SpectatorMsg += m_pActorToLookAt->Name();
		}break;
	};
	strcpy_s(pStr, SpectatorMsg.c_str());
};
Ejemplo n.º 10
0
void CHUDTarget::Render()
{
	VERIFY		(g_bRendering);

	CObject*	O		= Level().CurrentEntity();
	if (0==O)	return;
	CEntity*	E		= smart_cast<CEntity*>(O);
	if (0==E)	return;

	Fvector p1				= Device.vCameraPosition;
	Fvector dir				= Device.vCameraDirection;
	
	// Render cursor
	u32 C				= C_DEFAULT;
	
	FVF::TL				PT;
	Fvector				p2;
	p2.mad				(p1,dir,RQ.range);
	PT.transform		(p2,Device.mFullTransform);
	float				di_size = C_SIZE/powf(PT.p.w,.2f);

	CGameFont* F		= HUD().Font().pFontGraffiti19Russian;
	F->SetAligment		(CGameFont::alCenter);
	F->OutSetI			(0.f,0.05f);

	if (psHUD_Flags.test(HUD_CROSSHAIR_DIST)){
		F->SetColor		(C);
		F->OutNext		("%4.1f",RQ.range);
	}

	if (psHUD_Flags.test(HUD_INFO)){ 
		if (RQ.O){
			CEntityAlive*	E		= smart_cast<CEntityAlive*>	(RQ.O);
			CEntityAlive*	pCurEnt = smart_cast<CEntityAlive*>	(Level().CurrentEntity());
			PIItem			l_pI	= smart_cast<PIItem>		(RQ.O);

			if (IsGameTypeSingle())
			{
				CInventoryOwner* our_inv_owner		= smart_cast<CInventoryOwner*>(pCurEnt);
				if (E && E->g_Alive() && !E->cast_base_monster())
				{
//.					CInventoryOwner* our_inv_owner		= smart_cast<CInventoryOwner*>(pCurEnt);
					CInventoryOwner* others_inv_owner	= smart_cast<CInventoryOwner*>(E);

					if(our_inv_owner && others_inv_owner){

						switch(RELATION_REGISTRY().GetRelationType(others_inv_owner, our_inv_owner))
						{
						case ALife::eRelationTypeEnemy:
							C = C_ON_ENEMY; break;
						case ALife::eRelationTypeNeutral:
							C = C_ON_NEUTRAL; break;
						case ALife::eRelationTypeFriend:
							C = C_ON_FRIEND; break;
						}

					if (fuzzyShowInfo>0.5f){
						CStringTable	strtbl		;
						F->SetColor	(subst_alpha(C,u8(iFloor(255.f*(fuzzyShowInfo-0.5f)*2.f))));
						F->OutNext	("%s", *strtbl.translate(others_inv_owner->Name()) );
						F->OutNext	("%s", *strtbl.translate(others_inv_owner->CharacterInfo().Community().id()) );
					}
					}

					fuzzyShowInfo += SHOW_INFO_SPEED*Device.fTimeDelta;
				}
				else 
					if (l_pI && our_inv_owner && RQ.range < 2.0f*our_inv_owner->inventory().GetTakeDist())
					{
						if (fuzzyShowInfo>0.5f){
							F->SetColor	(subst_alpha(C,u8(iFloor(255.f*(fuzzyShowInfo-0.5f)*2.f))));
							F->OutNext	("%s",l_pI->Name/*Complex*/());
						}
						fuzzyShowInfo += SHOW_INFO_SPEED*Device.fTimeDelta;
					}
			}
			else
			{
				if (E && (E->GetfHealth()>0))
				{
					if (pCurEnt && GameID() == GAME_SINGLE){	
						if (GameID() == GAME_DEATHMATCH)			C = C_ON_ENEMY;
						else{	
							if (E->g_Team() != pCurEnt->g_Team())	C = C_ON_ENEMY;
							else									C = C_ON_FRIEND;
						};
						if (RQ.range >= recon_mindist() && RQ.range <= recon_maxdist()){
							float ddist = (RQ.range - recon_mindist())/(recon_maxdist() - recon_mindist());
							float dspeed = recon_minspeed() + (recon_maxspeed() - recon_minspeed())*ddist;
							fuzzyShowInfo += Device.fTimeDelta/dspeed;
						}else{
							if (RQ.range < recon_mindist()) fuzzyShowInfo += recon_minspeed()*Device.fTimeDelta;
							else fuzzyShowInfo = 0;
						};

						if (fuzzyShowInfo>0.5f){
							clamp(fuzzyShowInfo,0.f,1.f);
							int alpha_C = iFloor(255.f*(fuzzyShowInfo-0.5f)*2.f);
							u8 alpha_b	= u8(alpha_C & 0x00ff);
							F->SetColor	(subst_alpha(C,alpha_b));
							F->OutNext	("%s",*RQ.O->cName());
						}
					}
				};
			};

		}else{
			fuzzyShowInfo -= HIDE_INFO_SPEED*Device.fTimeDelta;
		}
		clamp(fuzzyShowInfo,0.f,1.f);
	}

	//отрендерить кружочек или крестик
	if(!m_bShowCrosshair){
		// actual rendering
		u32			vOffset;
		FVF::TL*	pv		= (FVF::TL*)RCache.Vertex.Lock(4,hGeom.stride(),vOffset);
		
		float			size_x = float(Device.dwWidth)	* di_size;
		float			size_y = float(Device.dwHeight) * di_size;
		size_y = size_x;

		float			w_2		= Device.fWidth_2;
		float			h_2		= Device.fHeight_2;

		// Convert to screen coords
		float cx		    = (PT.p.x+1)*w_2;
		float cy		    = (PT.p.y+1)*h_2;

		pv->set				(cx - size_x, cy + size_y, C, 0, 1); ++pv;
		pv->set				(cx - size_x, cy - size_y, C, 0, 0); ++pv;
		pv->set				(cx + size_x, cy + size_y, C, 1, 1); ++pv;
		pv->set				(cx + size_x, cy - size_y, C, 1, 0); ++pv;

		// unlock VB and Render it as triangle LIST
		RCache.Vertex.Unlock(4,hGeom.stride());
		RCache.set_Shader	(hShader);
		RCache.set_Geometry	(hGeom);
		RCache.Render		(D3DPT_TRIANGLELIST,vOffset,0,4,0,2);
	}else{
		//отрендерить прицел
		HUDCrosshair.cross_color	= C;
		HUDCrosshair.OnRender		();
	}
}
Ejemplo n.º 11
0
void	CGameSpy_Browser::ReadServerInfo	(ServerInfo* pServerInfo, void* pServer)
{
	CStringTable st;

	if (!pServer || !pServerInfo) return;
	sprintf_s(pServerInfo->m_Address, "%s:%d", xrGS_SBServerGetPublicAddress(pServer), xrGS_SBServerGetPublicQueryPort(pServer));
	sprintf_s(pServerInfo->m_HostName, "%s", xrGS_SBServerGetPublicAddress(pServer));
	sprintf_s(pServerInfo->m_ServerName, "%s", xrGS_SBServerGetStringValue(pServer, m_pQR2->xrGS_RegisteredKey(HOSTNAME_KEY), pServerInfo->m_HostName));

	sprintf_s(pServerInfo->m_SessionName, "%s", xrGS_SBServerGetStringValue(pServer, m_pQR2->xrGS_RegisteredKey(MAPNAME_KEY), "Unknown"));	
	sprintf_s(pServerInfo->m_ServerGameType, "%s", xrGS_SBServerGetStringValue(pServer, m_pQR2->xrGS_RegisteredKey(GAMETYPE_KEY), "Unknown"));
	pServerInfo->m_bPassword	= xrGS_SBServerGetBoolValue(pServer, m_pQR2->xrGS_RegisteredKey(PASSWORD_KEY), SBFalse) == SBTrue;
	pServerInfo->m_bUserPass	= xrGS_SBServerGetBoolValue(pServer, m_pQR2->xrGS_RegisteredKey(G_USER_PASSWORD_KEY), SBFalse) == SBTrue;

#ifdef BATTLEYE
	pServerInfo->m_bBattlEye	= xrGS_SBServerGetBoolValue(pServer, m_pQR2->xrGS_RegisteredKey(G_BATTLEYE_KEY), SBFalse) == SBTrue;
#endif // BATTLEYE

	pServerInfo->m_Ping = (s16)(xrGS_SBServerGetPing(pServer) & 0xffff);
	pServerInfo->m_ServerNumPlayers = (s16)xrGS_SBServerGetIntValue(pServer, m_pQR2->xrGS_RegisteredKey(NUMPLAYERS_KEY), 0);
	pServerInfo->m_ServerMaxPlayers = (s16)xrGS_SBServerGetIntValue(pServer, m_pQR2->xrGS_RegisteredKey(MAXPLAYERS_KEY), 32);
	pServerInfo->m_ServerNumTeams = (s16)xrGS_SBServerGetIntValue(pServer, m_pQR2->xrGS_RegisteredKey(NUMTEAMS_KEY), 0);
	pServerInfo->m_Port		= (s16)xrGS_SBServerGetIntValue(pServer, m_pQR2->xrGS_RegisteredKey(HOSTPORT_KEY), 0);
	pServerInfo->m_HPort	= (s16)xrGS_SBServerGetPublicQueryPort(pServer);
	pServerInfo->m_bDedicated	= (xrGS_SBServerGetBoolValue(pServer, m_pQR2->xrGS_RegisteredKey(DEDICATED_KEY), SBFalse)) == SBTrue;
	pServerInfo->m_GameType = (u8)xrGS_SBServerGetIntValue(pServer, m_pQR2->xrGS_RegisteredKey(GAMETYPE_NAME_KEY), 0);
	if (pServerInfo->m_GameType == 0)
	{
		if (!xr_strcmp(pServerInfo->m_ServerGameType, "deathmatch"))
			pServerInfo->m_GameType = GAME_DEATHMATCH;
		else if (!xr_strcmp(pServerInfo->m_ServerGameType, "teamdeathmatch"))
			pServerInfo->m_GameType = GAME_TEAMDEATHMATCH;
		else if (!xr_strcmp(pServerInfo->m_ServerGameType, "artefacthunt"))
			pServerInfo->m_GameType = GAME_ARTEFACTHUNT;
	}
	sprintf_s(pServerInfo->m_ServerVersion, "%s", xrGS_SBServerGetStringValue(pServer, m_pQR2->xrGS_RegisteredKey(GAMEVER_KEY), "--"));

	//--------- Read Game Infos ---------------------------//
	pServerInfo->m_aInfos.clear();
	pServerInfo->m_aPlayers.clear();
	pServerInfo->m_aTeams.clear();
	//-------------------------------------------------------//
	if (xrGS_SBServerHasFullKeys(pServer) == SBFalse) return;

//	pServerInfo->m_aInfos.push_back(GameInfo("Version:", pServerInfo->m_ServerVersion));
	pServerInfo->m_aInfos.push_back(GameInfo(*st.translate("mp_si_servername"), pServerInfo->m_ServerName));
	pServerInfo->m_aInfos.push_back(GameInfo(*st.translate("mp_si_version"), pServerInfo->m_ServerVersion));
	
#ifdef BATTLEYE
	ADD_BOOL_INFO(pServerInfo, pServer, "BattlEye", G_BATTLEYE_KEY);
#endif // BATTLEYE

	ADD_INT_INFO_N (pServerInfo, pServer, 1, "Max ping", "", G_MAX_PING_KEY);	
	ADD_BOOL_INFO(pServerInfo, pServer, *st.translate("mp_si_maprotation"), G_MAP_ROTATION_KEY);
	
	pServerInfo->m_aInfos.push_back(
		GameInfo(*st.translate("mp_si_voting"), 
		(xrGS_SBServerGetBoolValue(pServer, m_pQR2->xrGS_RegisteredKey(G_VOTING_ENABLED_KEY), SBFalse) == SBTrue) ?
			*st.translate("mp_si_enabled") : *st.translate("mp_si_disabled")));

//	ADD_BOOL_INFO(pServerInfo, pServer, *st.translate("mp_si_voting"), G_VOTING_ENABLED_KEY);
	//-----------------------------------------------------------------------
	pServerInfo->m_aInfos.push_back(GameInfo(*st.translate("mp_si_spectatormodes"), ""));
	int SpectrModes = xrGS_SBServerGetIntValue(pServer, m_pQR2->xrGS_RegisteredKey(G_SPECTATOR_MODES_KEY), 0);
	
	pServerInfo->m_aInfos.push_back(GameInfo(*st.translate("mp_si_free_fly"), ((SpectrModes & (1<<CSpectator::eacFreeFly	)) != 0) ? *st.translate("mp_si_yes") : *st.translate("mp_si_no")));
	pServerInfo->m_aInfos.push_back(GameInfo(*st.translate("mp_si_first_eye"), ((SpectrModes & (1<<CSpectator::eacFirstEye	)) != 0) ? *st.translate("mp_si_yes") : *st.translate("mp_si_no")));
	pServerInfo->m_aInfos.push_back(GameInfo(*st.translate("mp_si_look_at"), ((SpectrModes & (1<<CSpectator::eacLookAt	)) != 0) ? *st.translate("mp_si_yes") : *st.translate("mp_si_no")));
	pServerInfo->m_aInfos.push_back(GameInfo(*st.translate("mp_si_free_look"), ((SpectrModes & (1<<CSpectator::eacFreeLook	)) != 0) ? *st.translate("mp_si_yes") : *st.translate("mp_si_no")));
	if (pServerInfo->m_GameType != GAME_DEATHMATCH)
		pServerInfo->m_aInfos.push_back(GameInfo(*st.translate("mp_si_team_only"), ((SpectrModes & (1<<CSpectator::eacMaxCam	)) != 0) ? *st.translate("mp_si_yes") : *st.translate("mp_si_no")));
	//-----------------------------------------------------------------------
	
	if (pServerInfo->m_GameType == GAME_DEATHMATCH || pServerInfo->m_GameType == GAME_TEAMDEATHMATCH) 
	{
		ADD_INT_INFO_N (pServerInfo, pServer, 1, *st.translate("mp_si_fraglimit"), "", G_FRAG_LIMIT_KEY);	
	}

	ADD_TIME_INFO(pServerInfo, pServer, 1.0f, *st.translate("mp_si_time_limit"), "%.0f %s",*st.translate("mp_si_min"), G_TIME_LIMIT_KEY);

	if (xrGS_SBServerGetIntValue(pServer, m_pQR2->xrGS_RegisteredKey(G_DAMAGE_BLOCK_TIME_KEY), 0) != 0)
	{
		pServerInfo->m_aInfos.push_back(GameInfo(*st.translate("mp_si_invinsibility"), ""));
		ADD_BOOL_INFO(pServerInfo, pServer, *st.translate("mp_si_invinsibility_indicators"), G_DAMAGE_BLOCK_INDICATOR_KEY);
		ADD_TIME_INFO(pServerInfo, pServer, 1.0f, *st.translate("mp_si_invinsibility_time"), "%.f %s",*st.translate("mp_si_sec"), G_DAMAGE_BLOCK_TIME_KEY);
	}	

	ADD_BOOL_INFO(pServerInfo, pServer, *st.translate("mp_si_anomalies"), G_ANOMALIES_ENABLED_KEY);
	if ((xrGS_SBServerGetBoolValue(pServer, m_pQR2->xrGS_RegisteredKey(G_ANOMALIES_ENABLED_KEY), SBFalse)) == SBTrue)
	{
		if (xrGS_SBServerGetIntValue(pServer, m_pQR2->xrGS_RegisteredKey(G_ANOMALIES_TIME_KEY),0) != 0)
		{
			ADD_TIME_INFO(pServerInfo, pServer, 1.0f, *st.translate("mp_si_anomalies_period"), "%.1f %s",*st.translate("mp_si_min"), G_ANOMALIES_TIME_KEY);
		}
		else
			pServerInfo->m_aInfos.push_back(GameInfo(*st.translate("mp_si_anomalies_period"), *st.translate("mp_si_infinite")));
	}

	ADD_TIME_INFO(pServerInfo, pServer, 1.0f, *st.translate("mp_si_forcerespawn"), "%.f %s",*st.translate("mp_si_sec"), G_FORCE_RESPAWN_KEY);
	ADD_TIME_INFO(pServerInfo, pServer, 1.0f, *st.translate("mp_si_warmuptime"), "%.0f %s",*st.translate("mp_si_sec"), G_WARM_UP_TIME_KEY);

	if (pServerInfo->m_GameType == GAME_TEAMDEATHMATCH || pServerInfo->m_GameType == GAME_ARTEFACTHUNT)
	{
		ADD_BOOL_INFO(pServerInfo, pServer, *st.translate("mp_si_autoteam_balance"), G_AUTO_TEAM_BALANCE_KEY);
		ADD_BOOL_INFO(pServerInfo, pServer, *st.translate("mp_si_autoteam_swap"), G_AUTO_TEAM_SWAP_KEY);
		ADD_BOOL_INFO(pServerInfo, pServer, *st.translate("mp_si_friendly_indicators"), G_FRIENDLY_INDICATORS_KEY);
		ADD_BOOL_INFO(pServerInfo, pServer, *st.translate("mp_si_friendly_names"), G_FRIENDLY_NAMES_KEY);

		ADD_INT_INFO_N (pServerInfo, pServer, 1/100.0f, *st.translate("mp_si_friendly_fire"), " %%", G_FRIENDLY_FIRE_KEY);
	};

	if (pServerInfo->m_GameType == GAME_ARTEFACTHUNT)
	{
		pServerInfo->m_aInfos.push_back(GameInfo(*st.translate("mp_si_artefacts"), ""));
		ADD_INT_INFO(pServerInfo, pServer, *st.translate("mp_si_afcount"),					G_ARTEFACTS_COUNT_KEY	);

		ADD_TIME_INFO(pServerInfo, pServer, 1.0f, *st.translate("mp_si_afstaytime"), "%.2f %s",*st.translate("mp_si_min"), G_ARTEFACT_STAY_TIME_KEY);
		ADD_TIME_INFO(pServerInfo, pServer, 1.0f, *st.translate("mp_si_afrespawntime"), "%.0f %s",*st.translate("mp_si_sec"), G_ARTEFACT_RESPAWN_TIME_KEY);

		int Reinforcement = atoi(xrGS_SBServerGetStringValue(pServer, m_pQR2->xrGS_RegisteredKey(G_REINFORCEMENT_KEY), "0"));		
		switch (Reinforcement)
		{
		case -1:
			pServerInfo->m_aInfos.push_back(GameInfo(*st.translate("mp_si_players_respawn"), *st.translate("mp_si_artefact_captured")));
			break;
		case 0:
			pServerInfo->m_aInfos.push_back(GameInfo(*st.translate("mp_si_players_respawn"), *st.translate("mp_si_any_time")));
			break;
		default:
			ADD_TIME_INFO(pServerInfo, pServer, 1.0f, *st.translate("mp_si_players_respawn"), "%.0f %s",*st.translate("mp_si_sec"), G_REINFORCEMENT_KEY);
			break;
		}

		ADD_BOOL_INFO(pServerInfo, pServer, *st.translate("mp_si_shielded_bases"),					G_SHIELDED_BASES_KEY	);
		ADD_BOOL_INFO(pServerInfo, pServer, *st.translate("mp_si_return_players"),					G_RETURN_PLAYERS_KEY	);
		ADD_BOOL_INFO(pServerInfo, pServer, *st.translate("mp_si_afbearer_cant_sprint"),			G_BEARER_CANT_SPRINT_KEY);
	}
	
	//--------- Read Players Info -------------------------//	
	for (int i=0; i<pServerInfo->m_ServerNumPlayers; i++)
	{
		PlayerInfo PInfo;
		sprintf_s(PInfo.Name, "%s", xrGS_SBServerGetPlayerStringValue(pServer, i,	"player", "Unknown"));
		PInfo.Frags =		s16(xrGS_SBServerGetPlayerIntValue(pServer, i,			"score", 0));
		PInfo.Deaths =		u16(xrGS_SBServerGetPlayerIntValue(pServer, i,			"deaths", 0));
		PInfo.Rank =		u8(xrGS_SBServerGetPlayerIntValue(pServer, i,			"skill", 0));
		PInfo.Team =		u8(xrGS_SBServerGetPlayerIntValue(pServer, i,			"team", 0));
		PInfo.Spectator =	(xrGS_SBServerGetPlayerIntValue(pServer, i,				"spectator", 1)) != 0;
		PInfo.Artefacts =	u8(xrGS_SBServerGetPlayerIntValue(pServer, i,			"artefacts", 0));

		pServerInfo->m_aPlayers.push_back(PInfo);
	};
	//----------- Read Team Info ---------------------------//
	if (pServerInfo->m_GameType == GAME_TEAMDEATHMATCH || pServerInfo->m_GameType == GAME_ARTEFACTHUNT)
	{
		for (int i=0; i<pServerInfo->m_ServerNumTeams; i++)
		{
			TeamInfo TI;
			TI.Score = u8(xrGS_SBServerGetTeamIntValue(pServer, i, "t_score", 0));
			pServerInfo->m_aTeams.push_back(TI);
		}		
	}
};
Ejemplo n.º 12
0
void game_cl_Deathmatch::OnVoteStart(NET_Packet& P)
{
	CStringTable st;
	inherited::OnVoteStart(P);

	string1024	Command = "";
	string64	Player = "";
	P.r_stringZ(Command);
	P.r_stringZ(Player);
	m_dwVoteEndTime = Level().timeServer() + P.r_u32();
	
	if(m_game_ui)
	{
		string4096 CmdName = "";
		string1024 NewCmd; xr_strcpy(NewCmd, Command);
		string1024 CmdParams[MAX_VOTE_PARAMS] = {"", "", "", "", ""};
		sscanf	(Command,"%s %s %s %s %s %s", CmdName, CmdParams[0], CmdParams[1], CmdParams[2], CmdParams[3], CmdParams[4]);

		if (!xr_strcmp(CmdName, "restart"))
		{
			xr_sprintf(NewCmd, "%s", 
				*st.translate("mp_restart")
				);
		}
		else if (!xr_strcmp(CmdName, "restart_fast"))
		{
			xr_sprintf(NewCmd, "%s", 
				*st.translate("mp_restart_fast")
				);
		}
		else if (!xr_strcmp(CmdName, "kick"))
		{
			xr_sprintf(NewCmd, "%s %s", 
				*st.translate("mp_kick"), 
				CmdParams[0]
				);
			for (int i=1; i<MAX_VOTE_PARAMS; i++)
			{
				if (xr_strlen(CmdParams[i]))
				{
					xr_strcat(NewCmd, " ");
					xr_strcat(NewCmd, CmdParams[i]);
				}
			}
		}
		else if (!xr_strcmp(CmdName, "ban"))
		{
			xr_sprintf(NewCmd, "%s %s", 
				*st.translate("mp_ban"), 
				CmdParams[0]
				);
			for (int i=1; i<MAX_VOTE_PARAMS; i++)
			{
				if (xr_strlen(CmdParams[i]))
				{
					xr_strcat(NewCmd, " ");
					xr_strcat(NewCmd, CmdParams[i]);
				}
			}
		}
		else if (!xr_strcmp(CmdName, "changemap"))
		{
			xr_sprintf(NewCmd, "%s %s", 
				*st.translate("mp_change_map"), 
				*st.translate(CmdParams[0])
				);
		}
		else if (!xr_strcmp(CmdName, "changeweather"))
		{
			xr_sprintf(NewCmd, "%s %s", 
				*st.translate("mp_change_weather"), 
				*st.translate(CmdParams[0])
				);
		}

		
		string1024 VoteStr;
		xr_sprintf(VoteStr, *st.translate("mp_voting_started"), NewCmd, Player);		
		


		m_game_ui->SetVoteMessage(VoteStr);
		m_game_ui->SetVoteTimeResultMsg("");
		if (!m_pVoteRespondWindow)
            m_pVoteRespondWindow = xr_new<CUIVote>();
		m_pVoteRespondWindow->SetVoting(VoteStr);
	};
};
Ejemplo n.º 13
0
void game_cl_Deathmatch::shedule_Update			(u32 dt)
{
	CStringTable st;

	inherited::shedule_Update(dt);

	if(g_dedicated_server)	return;

	//fake	
	if(m_game_ui)
	{
		m_game_ui->SetTimeMsgCaption		(NULL);
		m_game_ui->SetRoundResultCaption	(NULL);
		m_game_ui->SetSpectatorMsgCaption	(NULL);
		m_game_ui->SetPressJumpMsgCaption	(NULL);
		m_game_ui->SetPressBuyMsgCaption	(NULL);
		m_game_ui->SetForceRespawnTimeCaption(NULL);
		m_game_ui->SetWarmUpCaption			(NULL);
	};
//	if (CurrentGameUI() && CurrentGameUI()->UIMainIngameWnd)
//		CurrentGameUI()->UIMainIngameWnd->ZoneCounter().SetText("");

	switch (Phase())
	{
	case GAME_PHASE_INPROGRESS:
		{
			//m_game_ui->ShowPlayersList(false);

			Check_Invincible_Players();
			
			if (!m_game_ui)
				break;

			if (m_s32TimeLimit && m_cl_dwWarmUp_Time == 0)
			{
				if (Level().timeServer()<(m_start_time + m_s32TimeLimit))
				{
					u32 lts = Level().timeServer();
					u32 Rest = (m_start_time + m_s32TimeLimit) - lts;
					string64 S;
					ConvertTime2String(&S, Rest);
					m_game_ui->SetTimeMsgCaption(S);
				}
				else
				{
					m_game_ui->SetTimeMsgCaption("00:00:00");
				}
			};
			game_PlayerState* lookat_player = Game().lookat_player();
			if(local_player && !local_player->IsSkip())
			{
				if (m_bFirstRun)
				{
					m_bFirstRun = FALSE;
					if (!Level().IsDemoPlayStarted() && Level().CurrentEntity())
					{
						VERIFY( m_game_ui );
						m_bFirstRun = m_game_ui->ShowServerInfo() ? FALSE : TRUE;
					}

					GetActiveVoting();
				};

				if (lookat_player)
				{
					string256 MoneyStr;
					xr_sprintf(MoneyStr, "%d", lookat_player->money_for_round);
					m_game_ui->ChangeTotalMoneyIndicator(MoneyStr);
				}				

				m_game_ui->SetPressJumpMsgCaption(NULL);
				m_game_ui->SetPressBuyMsgCaption(NULL);				

				if (m_cl_dwWarmUp_Time > Level().timeServer())
				{
					u32 TimeRemains = m_cl_dwWarmUp_Time - Level().timeServer();
					string64 S;
					ConvertTime2String(&S, TimeRemains);
					string1024 tmpStr = "";
					if (TimeRemains > 10000)
						strconcat(sizeof(tmpStr),tmpStr, *st.translate("mp_time2start"), " ", S);
					else
					{
						if (TimeRemains < 1000)
							strconcat(sizeof(tmpStr),tmpStr, *st.translate("mp_go"), "");
						else
						{
							static u32 dwLastTimeRemains = 10;
							u32 dwCurTimeRemains = TimeRemains/1000;
							if (dwLastTimeRemains != dwCurTimeRemains)
							{
								if (dwCurTimeRemains > 0 && dwCurTimeRemains <= 5)
									PlaySndMessage(ID_COUNTDOWN_1 + dwCurTimeRemains - 1);
							}
							dwLastTimeRemains = dwCurTimeRemains;
							_itoa(dwCurTimeRemains, S, 10);								
							strconcat(sizeof(tmpStr),tmpStr, *st.translate("mp_ready"), "...", S);
						}
					};
					
					m_game_ui->SetWarmUpCaption(tmpStr);
				}

				if (Level().CurrentEntity() && smart_cast<CSpectator*>(Level().CurrentEntity()))
				{
					if (!(pCurBuyMenu && pCurBuyMenu->IsShown()) && 
						!(pCurSkinMenu && pCurSkinMenu->IsShown()) &&
						!m_game_ui->IsServerInfoShown() &&
						(CurrentGameUI() && CurrentGameUI()->GameIndicatorsShown())
						)
					{
						if (!m_bSkinSelected)
							m_game_ui->SetPressJumpMsgCaption("mp_press_jump2select_skin");
						else
							m_game_ui->SetPressJumpMsgCaption("mp_press_jump2start");

						if (CanCallBuyMenu())
							m_game_ui->SetPressBuyMsgCaption("mp_press_to_buy");						
					};
				};

				if (Level().CurrentControlEntity() && 
					smart_cast<CSpectator*>(Level().CurrentControlEntity()) &&
					(CurrentGameUI()->GameIndicatorsShown())
					)
				{
					
					CSpectator* pSpectator = smart_cast<CSpectator*>(Level().CurrentControlEntity());
					if (pSpectator)
					{
						string1024 SpectatorStr = "";
						pSpectator->GetSpectatorString(SpectatorStr);
						m_game_ui->SetSpectatorMsgCaption(SpectatorStr);
					}
				}

				u32 CurTime = Level().timeServer();
				if (IsVotingEnabled() && IsVotingActive() && m_dwVoteEndTime>=CurTime)
				{
					u32 TimeLeft = m_dwVoteEndTime - Level().timeServer();
					string1024 VoteTimeResStr;
					u32 SecsLeft = (TimeLeft % 60000) / 1000;
					u32 MinitsLeft = (TimeLeft - SecsLeft) / 60000;

					u32 NumAgreed = 0;
					PLAYERS_MAP_IT I;
					I	= players.begin();
					for(;I!=players.end(); ++I)
					{
						game_PlayerState* ps = I->second;
						if (ps->m_bCurrentVoteAgreed == 1) NumAgreed++;
					}
					
					xr_sprintf	(VoteTimeResStr, st.translate("mp_timeleft").c_str(), MinitsLeft, SecsLeft, float(NumAgreed)/players.size());
					m_game_ui->SetVoteTimeResultMsg(VoteTimeResStr);
				};

				if (	local_player->testFlag(GAME_PLAYER_FLAG_VERY_VERY_DEAD) && 
						m_u32ForceRespawn &&
						!local_player->testFlag(GAME_PLAYER_FLAG_SPECTATOR)		)
				{
					u32 Rest			= m_u32ForceRespawn - local_player->DeathTime;
					string64			S;
					ConvertTime2String	(&S, Rest);
					string128			FullS;
					xr_sprintf				(FullS, "%s : %s", *st.translate("mp_time2respawn"), S);

					m_game_ui->SetForceRespawnTimeCaption(FullS);
				};


				if (Level().CurrentViewEntity())
				{
					game_PlayerState* ps = GetPlayerByGameID(Level().CurrentViewEntity()->ID());
					
					if (ps && m_game_ui) 
						m_game_ui->SetRank(ps->team, ps->rank);

					if (ps && m_game_ui) 
						m_game_ui->SetFraglimit(ps->frags(), m_s32FragLimit);
				}
			};
		}break;
	case GAME_PHASE_PENDING:
		{
			if (!m_game_ui)
				break;

			m_game_ui->UpdateTeamPanels();
			m_game_ui->ShowPlayersList(true);
		}break;
	case GAME_PHASE_PLAYER_SCORES:
		{
			if (!m_game_ui)
				break;

			string128 resstring;
			xr_sprintf(resstring, st.translate("mp_player_wins").c_str(), WinnerName);
			m_game_ui->SetRoundResultCaption(resstring);

			SetScore();
			m_game_ui->UpdateTeamPanels();
			m_game_ui->ShowPlayersList(true);
		}break;
	};
	
	//-----------------------------------------
	if (!CanCallBuyMenu()) HideBuyMenu();
		
	if (pCurSkinMenu && pCurSkinMenu->IsShown() && !CanCallSkinMenu())
		pCurSkinMenu->HideDialog();
	//-----------------------------------------------
	
	//-----------------------------------------------
	//if (m_game_ui->m_pInventoryMenu && m_game_ui->m_pInventoryMenu->IsShown() && !CanCallInventoryMenu())
	//	StartStopMenu(m_game_ui->m_pInventoryMenu,true);
	if ( m_game_ui && m_game_ui->ActorMenu().IsShown() && !CanCallInventoryMenu() )
	{
		m_game_ui->HideActorMenu();
	}
		
	//-----------------------------------------

	u32 cur_game_state = Phase();
	//if(m_game_ui->m_pMapDesc && m_game_ui->m_pMapDesc->IsShown() && cur_game_state!=GAME_PHASE_INPROGRESS)
	//{
	//	m_game_ui->m_pMapDesc->HideDialog();
	//}

	if(pCurSkinMenu && pCurSkinMenu->IsShown() && cur_game_state!=GAME_PHASE_INPROGRESS)
	{
		pCurSkinMenu->HideDialog();
	}
}
Ejemplo n.º 14
0
void CUIStatsPlayerList::Update()
{

	static string512 teaminfo;
	if (m_prev_upd_time > Device.dwTimeContinual - 100)
		return;

	DEFINE_VECTOR	(game_PlayerState*,ItemVec,ItemIt);
	ItemVec			items;

	m_prev_upd_time = Device.dwTimeContinual;
	game_cl_GameState::PLAYERS_MAP_IT I=Game().players.begin();
	game_cl_GameState::PLAYERS_MAP_IT E=Game().players.end();

	items.clear			();
	u32 pl_count = 0;
	int pl_frags = 0;
	u32	pl_artefacts = 0;
	for (;I!=E;++I)		
	{
		game_PlayerState* p = (game_PlayerState*) I->second;
		if (!p || p->team != m_CurTeam) 
			continue;
		if (m_bStatus_mode || 
			m_bSpectator && p->testFlag(GAME_PLAYER_FLAG_SPECTATOR) ||
			!m_bSpectator && !p->testFlag(GAME_PLAYER_FLAG_SPECTATOR)) 
		{
			items.push_back(I->second);
			// add to team info
			pl_frags+=p->frags();            
		}
	};
	pl_count = items.size();

    CStringTable st;
    if (GameID() == eGameIDArtefactHunt && !m_bSpectator)
	{
		game_cl_ArtefactHunt* game = static_cast<game_cl_ArtefactHunt*>(&Game());
		pl_artefacts = game->teams[m_CurTeam - 1].score;
        sprintf_s(teaminfo, "%s: %u, %s: %u, %s: %d",*st.translate("mp_artefacts_upcase"),pl_artefacts, *st.translate("mp_players"), pl_count, *st.translate("mp_frags_upcase"),pl_frags );
		m_header_text->SetText(teaminfo);
	}
	else if (GameID() == eGameIDTeamDeathmatch && !m_bSpectator)
	{
		game_cl_TeamDeathmatch* game = static_cast<game_cl_TeamDeathmatch*>(&Game());
		pl_frags = game->teams[m_CurTeam - 1].score;
		sprintf_s(teaminfo, "%s: %d, %s: %u", *st.translate("mp_frags_upcase"), pl_frags, *st.translate("mp_players"), pl_count);
		m_header_text->SetText(teaminfo);
	}	

	if (m_bSpectator)
	{
		if(items.empty())
		{
			Clear();
			ShowHeader(false);
			return;
		}
		else
			ShowHeader(true);
	}

    std::sort(items.begin(), items.end(), DM_Compare_Players);

	int n = (int)items.size();
	n -= m_pad->GetChildWndList().size();

	if (n<0)	
	{
		n = abs(n);
		for (int i = 0; i<n; i++)
            m_pad->DetachChild(*(m_pad->GetChildWndList().begin()));
		m_flags.set			(eNeedRecalc,TRUE);
	}
	else
	{		
		for (int i = 0; i<n; i++)
		{
            CUIStatsPlayerInfo* pi = new CUIStatsPlayerInfo(&m_field_info, m_i.f, m_i.c);
			pi->InitPlayerInfo( Fvector2().set(0,0), Fvector2().set(this->GetDesiredChildWidth(),m_i.h) );
			CUIScrollView::AddWindow(pi, true);
			m_flags.set			(eNeedRecalc,TRUE);
		}
	}

	R_ASSERT(items.size() == m_pad->GetChildWndList().size());

	WINDOW_LIST_it	it		= m_pad->GetChildWndList().begin();
	ItemIt			itit	= items.begin();

	for (; it != m_pad->GetChildWndList().end(); it++, itit++)
	{
		CUIStatsPlayerInfo* pi = smart_cast<CUIStatsPlayerInfo*>(*it);
		R_ASSERT(pi);
		game_PlayerState* ps = static_cast<game_PlayerState*>(*itit);
		pi->SetInfo(ps);
	}

	// update player info

	CUIScrollView::Update();	
}
Ejemplo n.º 15
0
void game_cl_ArtefactHunt::shedule_Update			(u32 dt)
{
	CStringTable st;
	string1024 msg;

	inherited::shedule_Update		(dt);

	if (g_dedicated_server)
		return;

	if (!m_game_ui)
		return;

	//out game information
	m_game_ui->SetBuyMsgCaption			(NULL);
	m_game_ui->SetPressBuyMsgCaption	(NULL);	

	switch (m_phase)
	{
	case GAME_PHASE_INPROGRESS:
		{
			if (local_player)
			{
				if (local_player->testFlag(GAME_PLAYER_FLAG_ONBASE) &&
					!local_player->testFlag(GAME_PLAYER_FLAG_VERY_VERY_DEAD))
				{
					m_bBuyEnabled = TRUE;
				}
				else
				{
					m_bBuyEnabled = FALSE;
				};
			};			

			if (local_player && Level().CurrentControlEntity())
			{
				if (smart_cast<CActor*>(Level().CurrentControlEntity()))
				{
					if(m_game_ui) m_game_ui->SetBuyMsgCaption("");
					if (m_bBuyEnabled)
					{
						if (!(pCurBuyMenu && pCurBuyMenu->IsShown()) && 
							!(pCurSkinMenu && pCurSkinMenu->IsShown()))
						{					
							xr_sprintf(msg, *st.translate("mp_press_to_buy"), "B");
							if(m_game_ui) m_game_ui->SetBuyMsgCaption(msg);
						};
					}					
					
					if (m_game_ui)
					{
						if (local_player->testFlag(GAME_PLAYER_FLAG_VERY_VERY_DEAD))
							m_game_ui->SetPressJumpMsgCaption("mp_press_fire2spectator");
						else
							m_game_ui->SetPressJumpMsgCaption(NULL);
					};
				}
				else
				{					
					if(m_game_ui) m_game_ui->SetBuyMsgCaption(NULL);
					if (m_bTeamSelected && m_bSkinSelected)
					{
						if (iReinforcementTime != 0)
						{
							if (!m_game_ui->m_pBuySpawnMsgBox->IsShown() &&
								(local_player->money_for_round+m_iSpawn_Cost)>=0)
							{
								if (m_game_ui) m_game_ui->SetPressJumpMsgCaption("mp_press_jump2pay_spaw");
							}
							else
							{
								if (m_game_ui) m_game_ui->SetPressJumpMsgCaption(NULL);
							}
						}
						else
						{
							if (m_game_ui) m_game_ui->SetPressJumpMsgCaption("mp_press_jump2spawn");
						};
					}
					else
					{
						if (!m_bTeamSelected)
							if (m_game_ui) m_game_ui->SetPressJumpMsgCaption("mp_press_jump2select_team");
							else
								if (!m_bSkinSelected)
									if (m_game_ui) m_game_ui->SetPressJumpMsgCaption("mp_press_jump2select_skin");
					}
				};				
			}

			if (local_player)
			{
				game_TeamState team0 = teams[0];
				game_TeamState team1 = teams[1];

				if (dReinforcementTime > 0 && Level().CurrentViewEntity() && m_cl_dwWarmUp_Time == 0)
				{
					u32 CurTime = Level().timeServer();
					u32 dTime;
					if (s32(CurTime) > dReinforcementTime) dTime = 0;
					else dTime = iCeil(float(dReinforcementTime - CurTime) / 1000);
							
					string128 _buff;
					m_game_ui->m_pReinforcementInidcator->SetText(itoa(dTime,_buff,10));
				}else
					m_game_ui->m_pReinforcementInidcator->SetText("0");

				s16 lt = local_player->team;
				if (lt>=0)
				{
//					if(m_game_ui) m_game_ui->SetScoreCaption	(teams[0].score, teams[1].score);
				};				
			};
			SetScore();
		}break;
	case GAME_PHASE_TEAM1_ELIMINATED:
		{
			m_game_ui->SetRoundResultCaption("Team Green ELIMINATED!");
			SetScore();
		}break;
	case GAME_PHASE_TEAM2_ELIMINATED:
		{
			m_game_ui->SetRoundResultCaption("Team Blue ELIMINATED!");
			SetScore();
		}break;
	default:
		{
			
		}break;
	};

	if (m_game_ui->m_pBuySpawnMsgBox->IsShown())
	{
		if (m_phase != GAME_PHASE_INPROGRESS || (!local_player || !local_player->testFlag(GAME_PLAYER_FLAG_VERY_VERY_DEAD)))
		{
			m_game_ui->m_pBuySpawnMsgBox->HideDialog();
		};
	};
	//-------------------------------------------

}
Ejemplo n.º 16
0
void game_cl_ArtefactHunt::TranslateGameMessage	(u32 msg, NET_Packet& P)
{
	CStringTable st;
	string512 Text;
	string512 tmp;
//	LPSTR	Color_Teams[3]		= {"%c[255,255,255,255]", "%c[255,64,255,64]", "%c[255,64,64,255]"};
	char	Color_Main[]		= "%c[255,192,192,192]";
	char	Color_Artefact[]	= "%c[255,255,255,0]";
//	LPSTR	TeamsNames[3]		= {"Zero Team", "Team Green", "Team Blue"};

	switch(msg)	{
//-------------------UI MESSAGES
	case GAME_EVENT_ARTEFACT_TAKEN: //ahunt
		{
			u16 PlayerID, Team;
			P.r_u16 (PlayerID);
			P.r_u16 (Team);

			game_PlayerState* pPlayer = GetPlayerByGameID(PlayerID);
			if (!pPlayer) break;

			if (m_reward_generator)
				m_reward_generator->OnPlayerTakeArtefact(pPlayer);

			xr_sprintf(tmp, "%s%s", "%s%s %s", *st.translate("mp_has_tak_art"));

			xr_sprintf(Text, tmp, 
				CTeamInfo::GetTeam_color_tag(int(Team)), 
				pPlayer->getName(), 
				Color_Main,
				Color_Artefact);
			
			if(CurrentGameUI()) CurrentGameUI()->CommonMessageOut(Text);

			if (!Game().local_player) break;
			if (Game().local_player->GameID == PlayerID)
				PlaySndMessage(ID_AF_TEAM1_TAKE + ModifyTeam(Game().local_player->team));
			else
				if (Game().local_player->team == Team)
					PlaySndMessage(ID_AF_TEAM1_TAKE_R + ModifyTeam(Game().local_player->team));
				else
					PlaySndMessage(ID_AF_TEAM1_TAKE_ENEMY + ModifyTeam(Game().local_player->team));
		}break;
	case GAME_EVENT_ARTEFACT_DROPPED: //ahunt
		{
			u16 PlayerID, Team;
			P.r_u16 (PlayerID);
			P.r_u16 (Team);

			game_PlayerState* pPlayer = GetPlayerByGameID(PlayerID);
			if (!pPlayer) break;
			
			if (m_reward_generator)
				m_reward_generator->OnPlayerDropArtefact(pPlayer);

            xr_sprintf(tmp, "%s%s", "%s%s %s", *st.translate("mp_has_drop_art"));

			xr_sprintf(Text, tmp, 
				CTeamInfo::GetTeam_color_tag(int(Team)), 
				pPlayer->getName(), 
				Color_Main,
				Color_Artefact);
			if(CurrentGameUI()) CurrentGameUI()->CommonMessageOut(Text);

//			pMessageSounds[0].play_at_pos(NULL, Fvector().set(0,0,0), sm_2D, 0);
			PlaySndMessage(ID_AF_LOST);
		}break;
	case GAME_EVENT_ARTEFACT_ONBASE: //ahunt
		{
			u16 PlayerID, Team;
			P.r_u16 (PlayerID);
			P.r_u16 (Team);

			game_PlayerState* pPlayer = GetPlayerByGameID(PlayerID);
			if (!pPlayer) break;

			if (m_reward_generator)
				m_reward_generator->OnPlayerBringArtefact(pPlayer);

			xr_sprintf(tmp, "%s%s", "%s%s %s", *st.translate("mp_scores"));

			xr_sprintf(Text, tmp, 
				CTeamInfo::GetTeam_color_tag(int(Team)), 
				CTeamInfo::GetTeam_name(int(Team)),
				Color_Main);
			if(CurrentGameUI()) CurrentGameUI()->CommonMessageOut(Text);
			
			if (!Game().local_player) break;
			if (Game().local_player->GameID == PlayerID)
				PlaySndMessage(ID_AF_TEAM1_ONBASE + ModifyTeam(Game().local_player->team));
			else
				if (Game().local_player->team == Team)
					PlaySndMessage(ID_AF_TEAM1_ONBASE_R + ModifyTeam(Game().local_player->team));
				else
					PlaySndMessage(ID_AF_TEAM1_ONBASE_ENEMY + ModifyTeam(Game().local_player->team));
		}break;
	case GAME_EVENT_ARTEFACT_SPAWNED: //ahunt
		{
			xr_sprintf(Text, "%s%s", 
				Color_Main, *st.translate("mp_art_spowned"));
			if(CurrentGameUI()) CurrentGameUI()->CommonMessageOut(Text);
			if (m_reward_generator)
				m_reward_generator->OnArtefactSpawned();

			PlaySndMessage(ID_NEW_AF);
		}break;
	case GAME_EVENT_ARTEFACT_DESTROYED:  //ahunt
		{
			xr_sprintf(Text, "%s%s", 
				Color_Main, *st.translate("mp_art_destroyed"));
			u16 ArtefactID = P.r_u16();
			//-------------------------------------------
			CObject* pObj = Level().Objects.net_Find(ArtefactID);
			if (pObj && xr_strlen(m_Eff_Af_Disappear))
				PlayParticleEffect(m_Eff_Af_Disappear.c_str(), pObj->Position());
			//-------------------------------------------
			if(CurrentGameUI()) CurrentGameUI()->CommonMessageOut(Text);
		}break;
	default:
		inherited::TranslateGameMessage(msg,P);
	}
}