void				game_cl_TeamDeathmatch::net_import_state		(NET_Packet& P)
{
	bool teamsEqual = (!teams.empty())?(teams[0].score == teams[1].score) : false;
	inherited::net_import_state	(P);
	m_bFriendlyIndicators = !!P.r_u8();
	m_bFriendlyNames = !!P.r_u8();
	if (!teams.empty())
	{	
		if (teamsEqual)
		{
			if (teams[0].score != teams[1].score)
			{
				if (Level().CurrentViewEntity())
				{
					if (teams[0].score > teams[1].score)
						PlaySndMessage(ID_TEAM1_LEAD);
					else
						PlaySndMessage(ID_TEAM2_LEAD);
				}
			}
		}
		else
		{
			if (teams[0].score == teams[1].score)
				if (Level().CurrentViewEntity())
					PlaySndMessage(ID_TEAMS_EQUAL);
		}
	};
}
Example #2
0
void				game_cl_Deathmatch::OnSwitchPhase			(u32 old_phase, u32 new_phase)
{
	inherited::OnSwitchPhase(old_phase, new_phase);
	
	if (!m_game_ui)
		return;

	switch (new_phase)
	{
	case GAME_PHASE_INPROGRESS:
		{
			WinnerName[0] = 0;
			m_game_ui->ShowPlayersList(false);
			m_game_ui->UpdateTeamPanels();
		}break;
	case GAME_PHASE_PLAYER_SCORES:
		{
			m_game_ui->UpdateTeamPanels();
			if (local_player)
			{
				if (!xr_strcmp(WinnerName, local_player->getName()))
				{
					PlaySndMessage(ID_YOU_WON);
				}
			}			
		}break;
	default:
		{			
		}break;
	};
}
Example #3
0
void game_cl_Deathmatch::net_import_state	(NET_Packet& P)
{
	inherited::net_import_state	(P);

	m_s32FragLimit				= P.r_s32();
	m_s32TimeLimit				= P.r_s32() * 60000;
	m_u32ForceRespawn			= P.r_u32() * 1000;
	m_cl_dwWarmUp_Time			= P.r_u32();
	m_bDamageBlockIndicators	= !!P.r_u8();
	// Teams
	u16							t_count;
	P.r_u16						(t_count);
	teams.clear					();

	for (u16 t_it=0; t_it<t_count; ++t_it)
	{
		game_TeamState	ts;
		P.r				(&ts,sizeof(game_TeamState));
		teams.push_back	(ts);
	};

	switch (Phase())
	{
	case GAME_PHASE_PLAYER_SCORES:
		{
			P.r_stringZ(WinnerName);
			bool NeedSndMessage = (xr_strlen(WinnerName) != 0);
			if (NeedSndMessage && local_player && !xr_strcmp(WinnerName, local_player->getName()))
			{
				PlaySndMessage(ID_YOU_WON);
			}
		}break;
	}
}
void				game_cl_TeamDeathmatch::PlayRankChangesSndMessage ()
{
	if (local_player)
	{
		switch (local_player->rank)
		{
		case 0:
			break;		
		default:
			if (local_player->team == 1)
				PlaySndMessage(ID_TEAM1_RANK_0 +local_player->rank);
			if (local_player->team == 2)
				PlaySndMessage(ID_TEAM2_RANK_0 +local_player->rank);
			break;
		}
	}
};
void				game_cl_TeamDeathmatch::OnSwitchPhase			(u32 old_phase, u32 new_phase)
{
	inherited::OnSwitchPhase(old_phase, new_phase);
	switch (new_phase)
	{
	case GAME_PHASE_TEAM1_SCORES:
		{
			if (Level().CurrentViewEntity())
				PlaySndMessage(ID_TEAM1_WIN);
		}break;
	case GAME_PHASE_TEAM2_SCORES:
		{
			if (Level().CurrentViewEntity())
				PlaySndMessage(ID_TEAM2_WIN);
		}break;
	default:
		{			
		}break;
	};
}
Example #6
0
void				game_cl_Deathmatch::PlayRankChangesSndMessage()
{
	if (local_player)
	{
		switch (local_player->rank)
		{
		case 0:
			break;		
		default:
			PlaySndMessage(ID_RANK_0+local_player->rank);
			break;
		}
	}
}
Example #7
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();
	}
}
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);
	}
}