void CMenuPlayer::UpdateControls() { const RANK* pRank = g_pPlayerStats->GetRank(); if (pRank) m_pRank->GetColumn(1)->SetString(LoadTempString(pRank->nNameId)); else m_pRank->GetColumn(1)->SetString("<error>"); char szTmp[32]; sprintf(szTmp,"%d",g_pPlayerStats->GetTotalSkillPoints()); m_pTotal->GetColumn(1)->SetString(szTmp); m_pTotal->Show(!IsMultiplayerGame()); sprintf(szTmp,"%d",g_pPlayerStats->GetAvailSkillPoints()); m_pAvail->GetColumn(1)->SetString(szTmp); m_pAvail->Show(!IsMultiplayerGame()); for (uint8 i = 0; i < kNumSkills; i++) { eSkill skl = (eSkill)i; if (m_pSkills[i]) { eSkillLevel lvl = (eSkillLevel)g_pPlayerStats->GetSkillLevel(skl); m_pSkills[i]->SetSkillLevel(lvl); } } if (m_Popup.IsVisible()) UpdatePopup(); }
void CCheatMgr::BootPlayer(CParsedMsg &cMsg) { if (!IsMultiplayerGame()) return; CClientInfoMgr *pCIMgr = g_pGameClientShell->GetInterfaceMgr( )->GetClientInfoMgr(); if (!pCIMgr) return; if( cMsg.GetArgCount() < 2 ) return; // The full name of the player might be split between several // arguments of the message so build the name from all arguments // except the name of the actual cheat (Arg 1). char szPlayerName[MAX_PLAYER_NAME] = {0}; cMsg.ReCreateMsg( szPlayerName, sizeof( szPlayerName ), 1 ); CLIENT_INFO* pInfo = pCIMgr->GetFirstClient(); while (pInfo && stricmp(pInfo->sName.c_str(),szPlayerName) != 0) pInfo = pInfo->pNext; if (pInfo) { // Tell the server SendCheatMessage( CHEAT_BOOT, pInfo->nID ); } }
bool CScreenJoin::IsCurrentGame(const char *pAddr) { if (!IsMultiplayerGame( )) return false; uint32 aAddr[4]; uint32 nPort = 0; aAddr[0] = 0; aAddr[1] = 0; aAddr[2] = 0; aAddr[3] = 0; sscanf(pAddr, "%d.%d.%d.%d:%d", &aAddr[0], &aAddr[1], &aAddr[2], &aAddr[3], &nPort); uint8 nServerAddr[4]; uint16 nServerPort; g_pLTClient->GetServerIPAddress(nServerAddr, &nServerPort); if ((aAddr[0] == (uint32)nServerAddr[0]) && (aAddr[1] == (uint32)nServerAddr[1]) && (aAddr[2] == (uint32)nServerAddr[2]) && (aAddr[3] == (uint32)nServerAddr[3]) && (nPort == (uint32)nServerPort)) return true; else return false; }
PickupItem::PickupItem() : GameBase(OT_MODEL) { MakeTransitionable(); m_fRespawnDelay = 10.0f; m_bRotate = LTFALSE; m_bBounce = LTFALSE; m_dwFlags = 0; m_bMoveToFloor = LTTRUE; m_bTouchPickup = LTFALSE; m_bActivatePickup = LTTRUE; m_bWasPickedUp = false; m_bRespawn = (IsMultiplayerGame( ) ? LTTRUE : LTFALSE); // Pick up items glow and can be seen with spy vision. Also we // assume they are moveable so they won't show bullet holes... m_dwUserFlags = USRFLG_GLOW | /*USRFLG_SPY_VISION |*/ USRFLG_MOVEABLE; m_hstrPickupCommand = LTNULL; m_hstrSoundFile = LTNULL; m_hstrRespawnSoundFile = LTNULL; m_hstrModelOverride = LTNULL; m_hPlayerObj = LTNULL; m_vScale.Init(1.0f, 1.0f, 1.0f); m_nTeamId = INVALID_TEAM; }
void CCheatMgr::SetClipMode(LTBOOL bMode) { #ifdef _FINAL // Can't do this in multiplayer. if(IsMultiplayerGame()) return; #endif // _FINAL if (!g_pPlayerMgr) return; s_CheatInfo[CHEAT_CLIP].bActive = bMode; g_pPlayerMgr->SetSpectatorMode(bMode); // Tell the server SendCheatMessage(CHEAT_CLIP, bMode); if (bMode) { g_pChatMsgs->AddMessage("Spectator mode enabled",kMsgCheatConfirm); } else { g_pChatMsgs->AddMessage("Spectator mode disabled",kMsgCheatConfirm); } // If we were in invisible mode before changing to spectator mode // change us back... if (!g_pPlayerMgr->IsSpectatorMode() && g_pPlayerMgr->IsInvisibleMode()) { SetInvisible(LTTRUE); } }
void CCheatMgr::SetInvisible(LTBOOL bMode) { #ifdef _FINAL // Can't do this in multiplayer. if(IsMultiplayerGame()) return; #endif // _FINAL // Don't ghost when in spectator mode... if (!g_pPlayerMgr || g_pPlayerMgr->IsSpectatorMode()) return; s_CheatInfo[CHEAT_INVISIBLE].bActive = bMode; g_pPlayerMgr->SetInvisibleMode(bMode); // Tell the server SendCheatMessage(CHEAT_INVISIBLE, bMode); if (bMode) { g_pChatMsgs->AddMessage("I see dead people...", kMsgCheatConfirm); } else { g_pChatMsgs->AddMessage("I live...again.", kMsgCheatConfirm); } }
bool CServerMissionMgr::FinishExitLevel( ) { TRACE( "CServerMissionMgr::FinishExitLevel:\n" ); // No longer waiting for exitlevel messages back from client. m_bExitingLevel = false; // Clear out the playertracker. m_PlayerTracker.Term( ); // Tell the players to handle an exit level. CPlayerObj::PlayerObjList::const_iterator iter = CPlayerObj::GetPlayerObjList( ).begin( ); while( iter != CPlayerObj::GetPlayerObjList( ).end( )) { CPlayerObj* pPlayerObj = *iter; pPlayerObj->HandleExit( m_bNewMission ); iter++; } // Save the keepalives between levels. bool bSaveKeepAlives = true; if( m_bNewMission ) { // Clear out our objectives... g_pGameServerShell->ResetObjectives(); // Clear working save dir since we're starting fresh. g_pServerSaveLoadMgr->ClearWorkingDir( ); // If this is mp, then consider this to be a new game. Saves between // missions is only available in sp which allows skills to be saved. if( IsMultiplayerGame( )) { // Tell the gameservershell it's a new game. g_pGameServerShell->SetLGFlags( LOAD_NEW_GAME ); bSaveKeepAlives = false; } } // Default to failure. bool bRet = false; // Do transition. if( m_bTransitionLevels ) { m_bTransitionLevels = false; bRet = g_pServerSaveLoadMgr->TransitionLevels( m_sCurrentWorldName ); } // Do switch. else { bRet = g_pServerSaveLoadMgr->SwitchLevels( m_sCurrentWorldName, bSaveKeepAlives ); } // Unpause the server now that we're done switching levels. g_pGameServerShell->PauseGame( LTFALSE ); return bRet; }
// ----------------------------------------------------------------------- // // // ROUTINE: CMissionMgr::StartGameNew // // PURPOSE: Start the game from the beginning. // // ----------------------------------------------------------------------- // bool CMissionMgr::StartGameNew( ) { // Default to use the first mission. int nFirstMission = 0; // Starting new game. g_pInterfaceMgr->StartingNewGame( ); // If this is a multiplayer game, then get use the campaign file to determine // the first mission. if( IsMultiplayerGame( )) { // Get the first mission to play from the missions file. char szMission[4]; CUserProfile* pUserProfile = g_pProfileMgr->GetCurrentProfile( ); char const* pszCampaignFile = GetCampaignFile( pUserProfile->m_ServerGameOptions ); if (!CWinUtil::FileExist( pszCampaignFile )) return false; CWinUtil::WinGetPrivateProfileString( "MissionList", "Mission0", "0", szMission, ARRAY_LEN( szMission ), pszCampaignFile ); nFirstMission = atoi( szMission ); } // Get the level name for the first mission/level. char const* pszLevelFilename = GetLevelFromMission( nFirstMission, 0 ); if( !pszLevelFilename ) return false; // Start from the first level. if( !StartGameFromLevel( pszLevelFilename )) return false; return true; }
CGrenade::CGrenade() : CProjectile() { // Uncomment these lines to use normal, non-point collide physics. // (point collide physics is faster and should be used whenever // possible). //m_dwFlags &= ~FLAG_POINTCOLLIDE; //m_dwFlags |= FLAG_SOLID | FLAG_CLIENTNONSOLID; m_vDims.Init(5.0f, 5.0f, 5.0f); m_bSpinGrenade = !IsMultiplayerGame(); m_bUpdating = LTTRUE; m_fPitch = 0.0f; m_fYaw = 0.0f; m_fRoll = 0.0f; m_fPitchVel = 0.0f; m_fYawVel = 0.0f; m_fRollVel = 0.0f; m_cBounces = 0; m_hBounceSnd = LTNULL; m_eContainerCode = CC_NO_CONTAINER; m_eLastHitSurface = ST_UNKNOWN; m_bRotatedToRest = LTFALSE; ResetRotationVel(); }
void CMenuSystem::OnFocus(LTBOOL bFocus) { ClearSelection(); m_List.ClearSelection(); if( bFocus ) { // Hide the save/load controls if we are a remote client. if ( !g_pClientMultiplayerMgr->IsConnectedToRemoteServer( ) && ( g_pGameClientShell->GetGameType() == eGameTypeSingle || g_pGameClientShell->GetGameType() == eGameTypeCooperative ) ) { m_pSaveCtrl->Show( LTTRUE ); m_pLoadCtrl->Show( LTTRUE ); } else { m_pSaveCtrl->Show( LTFALSE ); m_pLoadCtrl->Show( LTFALSE ); } m_pSaveCtrl->Enable(g_pClientSaveLoadMgr->CanSaveGame()); if (IsMultiplayerGame()) { m_pPlayerCtrl->Show( LTTRUE ); m_pTeamCtrl->Show( IsTeamGameType() ); m_pHostCtrl->Show( !g_pClientMultiplayerMgr->IsConnectedToRemoteServer( ) ); m_pServerCtrl->Show(g_pClientMultiplayerMgr->IsConnectedToRemoteServer( )); if (g_pClientMultiplayerMgr->IsConnectedToRemoteServer( )) { std::string str = g_pClientMultiplayerMgr->GetStartGameRequest( ).m_HostInfo.m_sName; str += " : "; str += g_pClientMultiplayerMgr->GetStartGameRequest( ).m_TCPAddress; m_pServerCtrl->SetString(str.c_str()); } } else { m_pPlayerCtrl->Show( LTFALSE ); m_pTeamCtrl->Show( LTFALSE ); m_pHostCtrl->Show( LTFALSE ); m_pServerCtrl->Show( LTFALSE ); } if (m_fScale != g_pInterfaceResMgr->GetXRatio()) { SetScale(g_pInterfaceResMgr->GetXRatio()); } SetSelection(GetIndex(&m_List)); m_List.ClearSelection(); m_List.NextSelection(); } }
bool CLoadingScreen::NeedsPostLoadScreen() const { // Always go to postload screen if in mp. We may need to wait there for other players. if( IsMultiplayerGame( )) return true; // Only go to postload if we had a briefing for sp. return ( !m_briefing.empty( )); }
bool CServerMissionMgr::ExitLevelToSavedGame( char const* pszNewLevel ) { TRACE( "CServerMissionMgr::ExitLevelToSavedGame\n" ); // Check if we're already exiting a level. if( m_bExitingLevel ) return true; // Verify inputs. if( !pszNewLevel ) { ASSERT( !"CServerMissionMgr::ExitLevelToSavedGame: Invalid inputs." ); return false; } // Default to this not being a mission change. m_bNewMission = false; // Check if the new level is a new mission. int nCurMission = m_nCurrentMission; if( !SetMissionBasedOnLevel( pszNewLevel )) return false; // If we switch to a custom level, then consider it a new mission. if( m_bCustomLevel ) { m_bNewMission = true; m_nCurCampaignIndex = -1; } // If it's not a custom world, check if our mission changed. else { m_bNewMission = ( nCurMission != m_nCurrentMission ); // If we had a mission switch, advance our campaign index. if( m_bNewMission ) { // See if we can find the campaign index from our previous position. m_nCurCampaignIndex = FindNextCampaignIndex( m_nCurCampaignIndex, m_nCurrentMission ); } } if (IsMultiplayerGame()) { // Tell clients we're exiting. Don't wait for their response. CAutoMessage cMsg; cMsg.Writeuint8( MID_EXIT_LEVEL ); cMsg.WriteString( m_sCurrentWorldName ); cMsg.Writebool( m_bNewMission ); cMsg.Writebool( false ); cMsg.Writebool( false ); g_pLTServer->SendToClient(cMsg.Read(), LTNULL, MESSAGE_GUARANTEED); } return true; }
void CWeaponFX::PlayImpactDing() { if (!IsMultiplayerGame()) return; CCharacterFX* pCharFX = g_pGameClientShell->GetMoveMgr()->GetCharacterFX(); if (pCharFX) { pCharFX->PlayDingSound(); } }
void CScreenRatings::Escape() { //quit or return to game? HLOCALOBJ hPlayerObj = g_pLTClient->GetClientObject(); if (g_pGameClientShell->IsWorldLoaded() && hPlayerObj && (!g_pPlayerMgr->IsPlayerDead() || IsMultiplayerGame( ))) { g_pInterfaceMgr->ChangeState(GS_PLAYING); } else { CBaseScreen::Escape(); } }
bool CMissionMgr::HandleEndGame( ILTMessage_Read& msg ) { // Go to the main menu. g_pInterfaceMgr->ChangeState(GS_SCREEN); m_bGameOver = true; if (g_pGameClientShell->IsRunningPerformanceTest()) { //since our history was cleared by loading the level... rebuild it g_pInterfaceMgr->GetScreenMgr()->AddScreenToHistory( SCREEN_ID_MAIN ); g_pInterfaceMgr->GetScreenMgr()->AddScreenToHistory( SCREEN_ID_OPTIONS ); //we're done performance testing go back to performance screen g_pInterfaceMgr->SwitchToScreen(SCREEN_ID_PERFORMANCE); } else if (IsMultiplayerGame()) { switch( g_pGameClientShell->GetGameType( )) { case eGameTypeCooperative: g_pInterfaceMgr->SwitchToScreen(SCREEN_ID_END_COOP_MISSION); break; case eGameTypeDeathmatch: case eGameTypeTeamDeathmatch: case eGameTypeDoomsDay: g_pInterfaceMgr->SwitchToScreen(SCREEN_ID_END_DM_MISSION); break; } } else { g_pInterfaceMgr->SwitchToScreen(SCREEN_ID_END_MISSION); //record the completion CRegMgr* pRegMgr = g_pVersionMgr->GetRegMgr(); if (pRegMgr->IsValid()) { pRegMgr->Set("EndGame",1); } } return true; }
void CScreenGame::OnFocus(LTBOOL bFocus) { CUserProfile *pProfile = g_pProfileMgr->GetCurrentProfile(); if (bFocus) { pProfile->SetGameOptions(); m_nDifficulty = pProfile->m_nDifficulty; m_nSubtitles = pProfile->m_nSubtitles; m_bGore = pProfile->m_bGore; m_bAlwaysRun = pProfile->m_bAlwaysRun; m_nLayout = pProfile->m_nLayout; m_nHeadBob = pProfile->m_nHeadBob; m_nWeaponSway = pProfile->m_nWeaponSway; m_nMsgDur = pProfile->m_nMsgDur; m_bAutoWeaponSwitch = pProfile->m_bAutoWeaponSwitch; m_bLoadScreenTips = pProfile->m_bLoadScreenTips; m_bVehicleContour = pProfile->m_bVehicleContour; m_pDifficultyCtrl->Enable( !(g_pLTClient->IsConnected() && IsMultiplayerGame()) ); UpdateData(LTFALSE); } else { UpdateData(); pProfile->m_nDifficulty = m_nDifficulty; pProfile->m_nSubtitles = m_nSubtitles; pProfile->m_bGore = !!m_bGore; pProfile->m_bAlwaysRun = m_bAlwaysRun; pProfile->m_nLayout = m_nLayout; pProfile->m_nHeadBob = m_nHeadBob; pProfile->m_nWeaponSway = m_nWeaponSway; pProfile->m_nMsgDur = m_nMsgDur; pProfile->m_bAutoWeaponSwitch = m_bAutoWeaponSwitch; pProfile->m_bLoadScreenTips = m_bLoadScreenTips; pProfile->m_bVehicleContour = m_bVehicleContour; pProfile->ApplyGameOptions(); pProfile->Save(); } CBaseScreen::OnFocus(bFocus); }
LTRESULT CTO2GameServerShell::OnServerInitialized() { LTRESULT nResult = CGameServerShell::OnServerInitialized(); // Don't do anything special if we're playing single-player if (!IsMultiplayerGame( )) { SetServerDir(0); return nResult; } IServerDirectory *pServerDir = Factory_Create_IServerDirectory_Titan( false, *g_pLTServer, NULL ); if( !pServerDir ) { ASSERT( !"ServerDir is NULL!" ); return LT_ERROR; } SetServerDir(pServerDir); // Set the game's name pServerDir->SetGameName(g_pVersionMgr->GetNetGameName()); // Set the version pServerDir->SetVersion(g_pVersionMgr->GetNetVersion()); pServerDir->SetRegion(g_pVersionMgr->GetNetRegion()); // Set up the network messaging header CAutoMessage cMsg; cMsg.Writeuint8(0xD); // SMSG_MESSAGE cMsg.Writeuint8(MID_MULTIPLAYER_SERVERDIR); pServerDir->SetNetHeader(*cMsg.Read()); StartupInfo_Titan startupInfo; startupInfo.m_sGameSpyName = "nolf2"; // Obfuscate the secret key a little. startupInfo.m_sGameSpySecretKey = "g"; startupInfo.m_sGameSpySecretKey += "3"; startupInfo.m_sGameSpySecretKey += "F"; startupInfo.m_sGameSpySecretKey += "o"; startupInfo.m_sGameSpySecretKey += "6"; startupInfo.m_sGameSpySecretKey += "x"; cMsg.Writeuint32(( uint32 )&startupInfo ); pServerDir->SetStartupInfo( *cMsg.Read( )); return nResult; }
bool CScreenPreload::UpdateInterfaceSFX() { if( m_bFirstUpdate ) { m_bFirstUpdate = false; FirstUpdate( ); } if (!CBaseScreen::UpdateInterfaceSFX()) return false; ChainFXList::iterator iter = m_Chains.begin(); bool bAnyActive = false; while (iter != m_Chains.end() && !bAnyActive) { CChainedFX *pChain = (*iter); pChain->Update(); bAnyActive = !pChain->IsIntroDone(); iter++; } bAnyActive = bAnyActive || !UpdateCDKeyValidation( ); if (!bAnyActive ) { bool bSuccess = true; if (m_bWaitingToExit) bSuccess = g_pMissionMgr->FinishExitLevel( ); else bSuccess = g_pMissionMgr->FinishStartGame( ); if (!bSuccess) { if (IsMultiplayerGame()) g_pInterfaceMgr->ConnectionFailed(g_pClientMultiplayerMgr->GetLastConnectionResult()); else g_pInterfaceMgr->LoadFailed(); } } return bAnyActive; }
void CHUDChatInput::Show(bool bShow, bool bTeam) { m_bVisible = bShow; m_nHistory = -1; g_pChatMsgs->ShowHistory(bShow); //only set the team flag when showing the ChatInput. We will need to // access the flag after it is hidden. if (bShow) m_bTeamMessage = bTeam; m_EditCtrl.Show(bShow); g_pGameClientShell->SetInputState(!bShow); g_pLTClient->ClearInput(); if (bShow) { m_pStr->SetText(LoadTempString(IDS_SAY)); m_szChatStr[0] = 0; Update(); } // Pause the server in single player while chatting... if( !IsMultiplayerGame() ) { g_pGameClientShell->PauseGame( !!bShow, true ); } // Send the Message to the server CAutoMessage cMsg; cMsg.Writeuint8(MID_PLAYER_CHATMODE); cMsg.Writeuint8((uint8)bShow); g_pLTClient->SendToServer(cMsg.Read(), MESSAGE_GUARANTEED); m_EditCtrl.UpdateData(!bShow); }
void GameBase::SetNextUpdate(LTFLOAT fDelta, eUpdateControl eControl) { if (!m_hObject) return; fDelta = fDelta <= 0.0f ? 0.0f : fDelta; g_pLTServer->SetNextUpdate(m_hObject, fDelta); if (eControl == eControlDeactivation) { if (fDelta == 0.0f) { if (!IsMultiplayerGame()) { g_pLTServer->SetDeactivationTime(m_hObject, 0.001f); } g_pLTServer->SetObjectState(m_hObject, OBJSTATE_AUTODEACTIVATE_NOW); } else { g_pLTServer->SetDeactivationTime(m_hObject, fDelta + 1.0f); } } }
void CMenuPlayer::UpdatePopup() { eSkill skl = (eSkill)g_nSkill; eSkillLevel lvl = (eSkillLevel)g_pPlayerStats->GetSkillLevel(skl); eSkillLevel nxt = (eSkillLevel)(g_pPlayerStats->GetSkillLevel(skl) + 1); m_Name.SetString(GetSkillName(skl)); m_Level.SetString(GetSkillLevelName(lvl)); m_Header.GetColumn(2)->Show(!IsMultiplayerGame()); uint8 nMax = g_pSkillsButeMgr->GetNumModifiers(skl); for (uint8 m = 0; m < kMaxModifiers; ++m) { if (m < nMax) { m_Mods[m].GetColumn(0)->SetString(LoadTempString(g_pSkillsButeMgr->GetModifierNameId(skl,m))); m_Mods[m].SetHelpID(g_pSkillsButeMgr->GetModifierDescriptionId(skl,m)); char szTmp[8]; float fBase = g_pSkillsButeMgr->GetModifier(skl,SKL_NOVICE,m); if (fBase <= 0.0f) { ASSERT(!"MenuPlayer::Bad skill mod"); fBase = 1.0f; } float fCur = g_pSkillsButeMgr->GetModifier(skl,lvl,m); if (fCur <= 0.0f) { ASSERT(!"MenuPlayer::Bad skill mod"); fCur = 1.0f; } if (fCur >= fBase) { sprintf(szTmp,"%3.0f%%",100.0f*fCur/fBase); } else { sprintf(szTmp,"%3.0f%%",100.0f*fBase/fCur); } m_Mods[m].GetColumn(1)->SetString(szTmp); if ( nxt < kNumSkillLevels) { float fNxt = g_pSkillsButeMgr->GetModifier(skl,nxt,m); if (fNxt <= 0.0f) { ASSERT(!"MenuPlayer::Bad skill mod"); fNxt = 1.0f; } if (fNxt >= fBase) { sprintf(szTmp,"%3.0f%%",100.0f*fNxt/fBase); } else { sprintf(szTmp,"%3.0f%%",100.0f*fBase/fNxt); } } else { sprintf(szTmp," - "); } m_Mods[m].GetColumn(2)->SetString(szTmp); m_Mods[m].GetColumn(2)->Show(!IsMultiplayerGame()); m_Mods[m].Show(true); } else { m_Mods[m].Show(false); } } if (IsMultiplayerGame()) { m_Upgrade.Show(LTFALSE); m_Upgrade.Enable(LTFALSE); m_Upgrade.Select(LTFALSE); m_Popup.ClearSelection(); m_Popup.NextSelection(); } else if ( nxt < kNumSkillLevels) { uint32 nCost = g_pPlayerStats->GetCostToUpgrade(skl); char szNext[32]; SAFE_STRCPY(szNext,GetSkillLevelName(nxt)); m_Upgrade.SetString(FormatTempString(IDS_SKILL_UPGRADE,szNext,nCost)); m_Upgrade.SetColors(m_SelectedColor,m_NonSelectedColor,m_DisabledColor); LTBOOL bCanAfford = (nCost <= g_pPlayerStats->GetAvailSkillPoints() ); m_Upgrade.Show(LTTRUE); m_Upgrade.Enable(bCanAfford); m_Upgrade.Select(bCanAfford); if (!bCanAfford) { m_Popup.ClearSelection(); m_Popup.NextSelection(); } } else { m_Upgrade.Show(LTTRUE); m_Upgrade.SetString(FormatTempString(IDS_SKILL_MAX)); m_Upgrade.SetColors(m_NonSelectedColor,m_NonSelectedColor,m_NonSelectedColor); m_Upgrade.Enable(LTFALSE); m_Upgrade.Select(LTFALSE); m_Popup.ClearSelection(); m_Popup.NextSelection(); } m_Points.SetString(FormatTempString(IDS_SKILL_AVAIL,g_pPlayerStats->GetAvailSkillPoints())); m_Points.Show(!IsMultiplayerGame()); }
void CreateClientWeaponFX(CLIENTWEAPONFX & theStruct) { if (!g_pLTServer) return; // make sure the impact FX in valid ASSERT( ( 0 <= theStruct.eImpactType ) || ( IMPACT_TYPE_COUNT > theStruct.eImpactType ) ); // If this is a moveable object, set the flags of fx to ignore // marks and smoke... if (IsMoveable(theStruct.hObj)) { theStruct.wIgnoreFX |= WFX_MARK; // Create a server-side mark if applicable... if (CanMarkObject(theStruct.hObj)) { AMMO const *pAmmo = g_pWeaponMgr->GetAmmo(theStruct.nAmmoId); if (pAmmo) { if (pAmmo->pImpactFX) { if (WFX_MARK & pAmmo->pImpactFX->nFlags) { CreateServerMark((CLIENTWEAPONFX)theStruct); } } // Create an exit mark if applicable... if (pAmmo->pFireFX) { if (WFX_EXITMARK & pAmmo->pFireFX->nFlags) { CreateServerExitMark((const CLIENTWEAPONFX)theStruct); } } } } } // Do impact dings if applicable... if (!(IsMultiplayerGame() && IsCharacter(theStruct.hObj))) { theStruct.wIgnoreFX |= WFX_IMPACTDING; } // [KLS 2/28/02] - If the object hit is a character, re-evaluate the surface type. // We do this here because the process of applying damage to the character may have // changed the character's surface type (e.g., from Armor to Flesh). if (IsCharacter(theStruct.hObj)) { theStruct.nSurfaceType = GetSurfaceType(theStruct.hObj); } // Tell all the clients who can see this fx about the fx... CAutoMessage cMsg; cMsg.Writeuint8(SFX_WEAPON_ID); cMsg.WriteObject(theStruct.hObj); cMsg.WriteObject(theStruct.hFiredFrom); cMsg.Writeuint8(theStruct.nWeaponId); cMsg.Writeuint8(theStruct.nAmmoId); cMsg.Writeuint8(theStruct.nSurfaceType); cMsg.Writeuint16(theStruct.wIgnoreFX); cMsg.Writeuint8(theStruct.nShooterId); cMsg.WriteLTVector(theStruct.vFirePos); cMsg.WriteLTVector(theStruct.vPos); cMsg.WriteLTVector(theStruct.vSurfaceNormal); cMsg.Writeuint8(theStruct.eImpactType); g_pLTServer->SendSFXMessage(cMsg.Read(), theStruct.vPos, 0); }
void CreateClientWeaponFX(CLIENTWEAPONFX & theStruct) { if (!g_pLTServer) return; // If this is a moveable object, set the flags of fx to ignore // marks and smoke... if (IsMoveable(theStruct.hObj)) { theStruct.wIgnoreFX |= WFX_MARK; // Create a server-side mark if applicable... if (CanMarkObject(theStruct.hObj)) { AMMO* pAmmo = g_pWeaponMgr->GetAmmo(theStruct.nAmmoId); if (pAmmo) { if (pAmmo->pImpactFX) { if (WFX_MARK & pAmmo->pImpactFX->nFlags) { CreateServerMark((CLIENTWEAPONFX)theStruct); } } // Create an exit mark if applicable... if (pAmmo->pFireFX) { if (WFX_EXITMARK & pAmmo->pFireFX->nFlags) { CreateServerExitMark((const CLIENTWEAPONFX)theStruct); } } } } } // Do impact dings if applicable... if (!(IsMultiplayerGame() && IsCharacter(theStruct.hObj))) { theStruct.wIgnoreFX |= WFX_IMPACTDING; } // Tell all the clients who can see this fx about the fx... HMESSAGEWRITE hMessage = g_pLTServer->StartInstantSpecialEffectMessage(&(theStruct.vPos)); g_pLTServer->WriteToMessageByte(hMessage, SFX_WEAPON_ID); g_pLTServer->WriteToMessageObject(hMessage, theStruct.hFiredFrom); g_pLTServer->WriteToMessageByte(hMessage, theStruct.nWeaponId); g_pLTServer->WriteToMessageByte(hMessage, theStruct.nAmmoId); g_pLTServer->WriteToMessageByte(hMessage, theStruct.nSurfaceType); g_pLTServer->WriteToMessageWord(hMessage, theStruct.wIgnoreFX); g_pLTServer->WriteToMessageByte(hMessage, theStruct.nShooterId); g_pLTServer->WriteToMessageVector(hMessage, &(theStruct.vFirePos)); g_pLTServer->WriteToMessageVector(hMessage, &(theStruct.vPos)); g_pLTServer->WriteToMessageVector(hMessage, &(theStruct.vSurfaceNormal)); // This doesn't always work correctly... //g_pLTServer->WriteToMessageCompPosition(hMessage, &(theStruct.vFirePos)); //g_pLTServer->WriteToMessageCompPosition(hMessage, &(theStruct.vPos)); //g_pLTServer->WriteToMessageCompPosition(hMessage, &(theStruct.vSurfaceNormal)); g_pLTServer->EndMessage2(hMessage, MESSAGE_NAGGLEFAST); }
void CProjectile::HandleTouch(HOBJECT hObj) { if (m_bObjectRemoved) return; // Don't process any touches until this has been cleared... if (m_bProcessInvImpact) return; // Let it get out of our bounding box... if (hObj == m_hFiredFrom) return; CCharacterHitBox* pHitBox = LTNULL; // If we've hit a character (or body), let its hit box take control... if (IsCharacter(hObj)) { CCharacter* pChar = (CCharacter*)g_pLTServer->HandleToObject(hObj); if (pChar) { hObj = pChar->GetHitBox(); } } else if (IsBody(hObj)) { Body* pBody = (Body*)g_pLTServer->HandleToObject(hObj); if (pBody) { hObj = pBody->GetHitBox(); } } if (IsCharacterHitBox(hObj)) { pHitBox = (CCharacterHitBox*)g_pLTServer->HandleToObject(hObj); if (!pHitBox) return; if (pHitBox->GetModelObject() == m_hFiredFrom) return; } // Don't hit our own type of projectiles (for multi-projectile weapons // and projectiles that stick to objects)... if (IsKindOf(hObj, m_hObject)) { CProjectile* pObj = (CProjectile*)g_pLTServer->HandleToObject(hObj); if (pObj) { if (pObj->GetFiredFrom() == m_hFiredFrom) { return; } } } // See if we want to impact on this object... uint32 dwUsrFlags = g_pLTServer->GetObjectUserFlags(hObj); if (dwUsrFlags & USRFLG_IGNORE_PROJECTILES) return; LTBOOL bIsWorld = IsMainWorld(hObj); // Don't impact on non-solid objects...unless it is a CharacterHitBox // object... uint32 dwFlags = g_pLTServer->GetObjectFlags(hObj); if (!bIsWorld && !(dwFlags & FLAG_SOLID)) { if (pHitBox) { // See if we really impacted on the box... if (pHitBox->DidProjectileImpact(this)) { // This is the object that we really hit... hObj = pHitBox->GetModelObject(); } else { return; } } else if (!(dwFlags & FLAG_RAYHIT)) { // If we have ray hit set to true, projectiles should // impact on us too... return; } } // See if we hit the sky... if (bIsWorld || (OT_WORLDMODEL == g_pLTServer->GetObjectType(hObj))) { CollisionInfo info; g_pLTServer->GetLastCollision(&info); SurfaceType eType = GetSurfaceType(info); if (eType == ST_SKY) { RemoveObject(); return; } else if (eType == ST_INVISIBLE) { // Update 1.002 [KLS] - If multiplayer and we hit an invisible // surface, just treat it like a normal surface... if (!IsMultiplayerGame()) { m_bProcessInvImpact = LTTRUE; g_pLTServer->GetObjectPos(m_hObject, &m_vInvisNewPos); g_pLTServer->GetVelocity(m_hObject, &m_vInvisVel); m_vInvisNewPos += (m_vInvisVel * g_pLTServer->GetFrameTime()); // Make sure this new position is inside the world...else // just blow up... if (LT_INSIDE == g_pLTServer->Common()->GetPointStatus(&m_vInvisNewPos)) { return; } } } } HandleImpact(hObj); }
LTBOOL CWeaponFX::CreateObject(ILTClient* pClientDE) { if (!CSpecialFX::CreateObject(pClientDE) || !g_pWeaponMgr) return LTFALSE; CGameSettings* pSettings = g_pInterfaceMgr->GetSettings(); if (!pSettings) return LTFALSE; // Set up our data members... // Set the local client id... uint32 dwId; g_pLTClient->GetLocalClientID(&dwId); m_nLocalId = (uint8)dwId; m_nDetailLevel = pSettings->SpecialFXSetting(); // Fire pos may get tweaked a little... m_vFirePos = CalcFirePos(m_vFirePos); m_vDir = m_vPos - m_vFirePos; m_fFireDistance = m_vDir.Mag(); m_vDir.Norm(); g_pLTClient->AlignRotation(&m_rSurfaceRot, &m_vSurfaceNormal, LTNULL); g_pLTClient->AlignRotation(&m_rDirRot, &m_vDir, LTNULL); SetupExitInfo(); // Calculate if the camera can see the fire position and the impact // position... g_bCanSeeImpactPos = LTTRUE; g_bCanSeeFirePos = LTTRUE; g_bDistantImpactPos = LTFALSE; g_bDistantFirePos = LTFALSE; if (g_vtWeaponFXUseFOVPerformance.GetFloat()) { HOBJECT hCamera = g_pGameClientShell->GetCamera(); LTVector vCameraPos, vU, vR, vF, vDir; LTRotation rCameraRot; g_pLTClient->GetObjectPos(hCamera, &vCameraPos); g_pLTClient->GetObjectRotation(hCamera, &rCameraRot); g_pLTClient->GetRotationVectors(&rCameraRot, &vU, &vR, &vF); vDir = m_vPos - vCameraPos; LTFLOAT fImpactDist = vDir.Mag(); if (fImpactDist > g_vtWeaponFXMaxImpactDist.GetFloat()) { g_bDistantImpactPos = LTTRUE; } vDir.Norm(); LTFLOAT fMul = VEC_DOT(vDir, vF); g_bCanSeeImpactPos = (fMul < g_vtWeaponFXMinImpactDot.GetFloat() ? LTFALSE : LTTRUE); // In multiplayer we need to account for impacts that occur around // our camera that we didn't cause (this is also an issue in single // player, but due to the singler player gameplay dynamics it isn't // as noticeable)... if (!g_bCanSeeImpactPos && IsMultiplayerGame()) { // Somebody else shot this...if the impact is close enough, we // "saw" it... if (m_nLocalId != m_nShooterId && fImpactDist <= g_vtWeaponFXMaxMultiImpactDist.GetFloat()) { g_bCanSeeImpactPos = LTTRUE; } } vDir = m_vFirePos - vCameraPos; if (vDir.Mag() > g_vtWeaponFXMaxFireDist.GetFloat()) { g_bDistantFirePos = LTTRUE; } vDir.Norm(); fMul = VEC_DOT(vDir, vF); g_bCanSeeFirePos = (fMul < g_vtWeaponFXMinFireDot.GetFloat() ? LTFALSE : LTTRUE); } // Determine what container the sfx is in... HLOCALOBJ objList[1]; LTVector vTestPos = m_vPos + m_vSurfaceNormal; // Test a little closer... uint32 dwNum = g_pLTClient->GetPointContainers(&vTestPos, objList, 1); if (dwNum > 0 && objList[0]) { uint32 dwUserFlags; g_pLTClient->GetObjectUserFlags(objList[0], &dwUserFlags); if (dwUserFlags & USRFLG_VISIBLE) { uint16 dwCode; if (g_pLTClient->GetContainerCode(objList[0], &dwCode)) { m_eCode = (ContainerCode)dwCode; } } } // Determine if the fire point is in liquid vTestPos = m_vFirePos + m_vDir; // Test a little further in... dwNum = g_pLTClient->GetPointContainers(&vTestPos, objList, 1); if (dwNum > 0 && objList[0]) { uint32 dwUserFlags; g_pLTClient->GetObjectUserFlags(objList[0], &dwUserFlags); if (dwUserFlags & USRFLG_VISIBLE) { uint16 dwCode; if (g_pLTClient->GetContainerCode(objList[0], &dwCode)) { m_eFirePosCode = (ContainerCode)dwCode; } } } if (IsLiquid(m_eCode)) { m_wImpactFX = m_pAmmo->pUWImpactFX ? m_pAmmo->pUWImpactFX->nFlags : 0; } else { m_wImpactFX = m_pAmmo->pImpactFX ? m_pAmmo->pImpactFX->nFlags : 0; } m_wFireFX = m_pAmmo->pFireFX ? m_pAmmo->pFireFX->nFlags : 0; // Assume alt-fire, silenced, and tracer...these will be cleared by // IgnoreFX if not used... m_wFireFX |= WFX_ALTFIRESND | WFX_SILENCED | WFX_TRACER; // Assume impact ding, it will be cleared if not used... m_wImpactFX |= WFX_IMPACTDING; // Clear all the fire fx we want to ignore... m_wFireFX &= ~m_wIgnoreFX; m_wImpactFX &= ~m_wIgnoreFX; // See if this is a redundant weapon fx (i.e., this client shot the // weapon so they've already seen this fx)... if (g_pGameClientShell->IsMultiplayerGame()) { if (m_pAmmo->eType != PROJECTILE) { if (!m_bLocal && m_nLocalId >= 0 && m_nLocalId == m_nShooterId) { if (m_wImpactFX & WFX_IMPACTDING) { if (g_vtMultiDing.GetFloat()) { PlayImpactDing(); } } return LTFALSE; } } } // Show the fire path...(debugging...) if (g_cvarShowFirePath.GetFloat() > 0) { PLFXCREATESTRUCT pls; pls.vStartPos = m_vFirePos; pls.vEndPos = m_vPos; pls.vInnerColorStart = LTVector(GetRandom(127.0f, 255.0f), GetRandom(127.0f, 255.0f), GetRandom(127.0f, 255.0f)); pls.vInnerColorEnd = pls.vInnerColorStart; pls.vOuterColorStart = LTVector(0, 0, 0); pls.vOuterColorEnd = LTVector(0, 0, 0); pls.fAlphaStart = 1.0f; pls.fAlphaEnd = 1.0f; pls.fMinWidth = 0; pls.fMaxWidth = 10; pls.fMinDistMult = 1.0f; pls.fMaxDistMult = 1.0f; pls.fLifeTime = 10.0f; pls.fAlphaLifeTime = 10.0f; pls.fPerturb = 0.0f; pls.bAdditive = LTFALSE; pls.nWidthStyle = PLWS_CONSTANT; pls.nNumSegments = 2; CSpecialFX* pFX = g_pGameClientShell->GetSFXMgr()->CreateSFX(SFX_POLYLINE_ID, &pls); if (pFX) pFX->Update(); } // If the surface is the sky, don't create any impact related fx... if (m_eSurfaceType != ST_SKY || (m_wImpactFX & WFX_IMPACTONSKY)) { CreateWeaponSpecificFX(); if (g_bCanSeeImpactPos) { if ((m_wImpactFX & WFX_MARK) && ShowsMark(m_eSurfaceType) && (LTBOOL)GetConsoleInt("MarkShow", 1)) { LTBOOL bCreateMark = LTTRUE; if (g_bDistantImpactPos && m_nLocalId == m_nShooterId) { // Assume we'll see the mark if we're zoomed in ;) bCreateMark = g_pGameClientShell->IsZoomed(); } if (bCreateMark) { CreateMark(m_vPos, m_vSurfaceNormal, m_rSurfaceRot, m_eSurfaceType); } } CreateSurfaceSpecificFX(); } PlayImpactSound(); } if (IsBulletTrailWeapon()) { if (IsLiquid(m_eFirePosCode)) { if (m_nDetailLevel != RS_LOW) { CreateBulletTrail(&m_vFirePos); } } } // No tracers under water... if ((LTBOOL)GetConsoleInt("Tracers", 1) && (m_wFireFX & WFX_TRACER) && !IsLiquid(m_eCode)) { CreateTracer(); } if (g_bCanSeeFirePos) { // Only do muzzle fx for the client (not for AIs)... if ((m_wFireFX & WFX_MUZZLE) && (m_nLocalId == m_nShooterId)) { CreateMuzzleFX(); } if (!g_bDistantFirePos && (LTBOOL)GetConsoleInt("ShellCasings", 1) && (m_wFireFX & WFX_SHELL)) { CreateShell(); } if ((m_wFireFX & WFX_LIGHT)) { CreateMuzzleLight(); } } if ((m_wFireFX & WFX_FIRESOUND) || (m_wFireFX & WFX_ALTFIRESND) || (m_wFireFX & WFX_SILENCED)) { PlayFireSound(); } // Only do fly-by sounds for weapons that leave bullet trails... if (IsBulletTrailWeapon()) { PlayBulletFlyBySound(); } return LTFALSE; // Just delete me, I'm done :) }
bool CCheatMgr::Process( CheatCode nCheatCode, CParsedMsg &cMsg ) { if ( nCheatCode <= CHEAT_NONE || nCheatCode >= CHEAT_MAX ) return false; #ifdef _FINAL // Don't do cheats in multiplayer... if (IsMultiplayerGame()) { // Well, okay, let them toggle between 1st and 3rd person ;) // and, well, blood is pretty cool... switch ( nCheatCode ) { case CHEAT_CHASETOGGLE: ChaseToggle(); break; case CHEAT_EXITLEVEL: // exit the current level SetExitLevel(); break; case CHEAT_NEXTMISSION: // exit the current mission NextMission(); break; case CHEAT_BOOT: // boot players BootPlayer(cMsg); break; default : return false; break; } m_bPlayerCheated = LTTRUE; return true; } #endif // _FINAL // process cheat codes switch ( nCheatCode ) { case CHEAT_GOD: // god mode toggle SetGodMode(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_SKILLZ: // give em skill points GetSkills(); break; case CHEAT_ARMOR: // full armor SetArmor(); break; case CHEAT_HEALTH: // full health SetHealth(); break; case CHEAT_EXITLEVEL: // exit the current level SetExitLevel(); break; case CHEAT_VERSION: // display version info Version(); break; case CHEAT_BUILDGUID: // display build guid BuildGuid(); break; case CHEAT_INVISIBLE: // time to mess with the AI SetInvisible(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_BODYGOLFING: // bodies fly far BodyGolfing(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_POS: // show/hide player position SetPos(!s_CheatInfo[nCheatCode].bActive); break; #ifndef _TO2DEMO case CHEAT_KFA: // give em everything SetKFA(); break; case CHEAT_AMMO: // full ammo SetAmmo(); break; case CHEAT_MODSQUAD: // give all mods for current weapons ModSquad(); break; case CHEAT_CONSOLE: SetConsole(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_NEXTMISSION: // exit the current mission NextMission(); break; case CHEAT_BOOT: // exit the current mission BootPlayer(cMsg); break; case CHEAT_FULL_WEAPONS: // give all weapons SetFullWeapons(); break; case CHEAT_SNOWMOBILE: // spawn in snowmobile Snowmobile(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_FULL_GEAR: // give all gear FullGear(); break; case CHEAT_TEARS: // toggle tears cheat Tears(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_GIMMEGUN: GimmeGun( cMsg ); break; case CHEAT_GIMMEMOD: GimmeMod( cMsg ); break; case CHEAT_GIMMEGEAR: GimmeGear( cMsg ); break; case CHEAT_GIMMEAMMO: GimmeAmmo( cMsg ); break; case CHEAT_ENDGAME: ToggleEndgameFlag(); break; #ifndef _FINAL case CHEAT_CHASETOGGLE: // toggle 3rd person view ChaseToggle(); break; case CHEAT_CLIP: // toggle clipping mode SetClipMode(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_TELEPORT: // teleport to beginning Teleport(); break; case CHEAT_CAM_POSROT: // show/hide camera position/rotation SetCamPosRot(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_POSWEAPON: // toggle adjust of weapon pos PosWeapon(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_POSWEAPON_MUZZLE: // toggle adjust of weapon muzzle pos PosWeaponMuzzle(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_WEAPON_BREACHOFFSET: // toggle adjust of weapon breach offset pos WeaponBreachOffset(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_LIGHTSCALE: // toggle client light scale offset LightScale(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_LIGHTADD: // toggle client light add offset LightAdd(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_FOV: // toggle fov cheat FOV(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_REMOVEAI: // remove all ai RemoveAI(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_TRIGGERBOX: // toggle trigger boxes on/off TriggerBox(!s_CheatInfo[nCheatCode].bActive); break; case CHEAT_POS1STCAM: // toggle 1st person camera adjust on/off Pos1stCam(!s_CheatInfo[nCheatCode].bActive); break; #endif // _FINAL #endif // _TO2DEMO default: return false; // skip setting global cheat indicator for unhandled cheats } m_bPlayerCheated = LTTRUE; return true; }
LTBOOL PickupItem::ReadProp(ObjectCreateStruct *pInfo) { GenericProp genProp; if (!pInfo) return LTFALSE; if (g_pLTServer->GetPropGeneric("PickupCommand", &genProp) == LT_OK) { if(genProp.m_String[0]) { m_hstrPickupCommand = g_pLTServer->CreateString(genProp.m_String); } } if (g_pLTServer->GetPropGeneric("PickupSound", &genProp) == LT_OK) { if(genProp.m_String[0]) { m_hstrSoundFile = g_pLTServer->CreateString(genProp.m_String); } } if (g_pLTServer->GetPropGeneric("RespawnSound", &genProp) == LT_OK) { if(genProp.m_String[0]) { m_hstrRespawnSoundFile = g_pLTServer->CreateString(genProp.m_String); } } // Only get the value of the ModelOverride attribute if we're using // it... if (g_pLTServer->GetPropGeneric("UseModelOverride", &genProp) == LT_OK) { if (genProp.m_Bool) { if (g_pLTServer->GetPropGeneric("ModelOverride", &genProp) == LT_OK) { if(genProp.m_String[0]) { m_hstrModelOverride = g_pLTServer->CreateString(genProp.m_String); } } } } if (g_pLTServer->GetPropGeneric("Rotate", &genProp) == LT_OK) { m_bRotate = genProp.m_Bool; } if (g_pLTServer->GetPropGeneric("Bounce", &genProp) == LT_OK) { m_bBounce = genProp.m_Bool; } if (g_pLTServer->GetPropGeneric("MoveToFloor", &genProp) == LT_OK) { m_bMoveToFloor = genProp.m_Bool; } if( g_pLTServer->GetPropGeneric( "TouchPickup", &genProp ) == LT_OK ) { if( IsCoopMultiplayerGameType() ) { m_bTouchPickup = genProp.m_Bool; } } if( g_pLTServer->GetPropGeneric( "DMTouchPickup", &genProp ) == LT_OK ) { if( !IsCoopMultiplayerGameType() ) { m_bTouchPickup = genProp.m_Bool; } } if( g_pLTServer->GetPropGeneric( "ActivatePickup", &genProp ) == LT_OK ) { m_bActivatePickup = genProp.m_Bool; } if( !IsMultiplayerGame( )) { if( g_pLTServer->GetPropGeneric( "SPRespawn", &genProp ) == LT_OK ) { m_bRespawn = genProp.m_Bool; } } else { if( g_pLTServer->GetPropGeneric( "MPRespawn", &genProp ) == LT_OK ) { m_bRespawn = genProp.m_Bool; } } if (g_pLTServer->GetPropGeneric("RespawnTime", &genProp) == LT_OK) { m_fRespawnDelay = genProp.m_Float; } if (g_pLTServer->GetPropGeneric("Scale", &genProp) == LT_OK) { m_vScale = genProp.m_Vec; } if( g_pLTServer->GetPropGeneric( "WorldAnimation", &genProp ) == LT_OK ) { if( genProp.m_String[0] ) { m_sWorldAniName = genProp.m_String; } } // Get the team this object belongs to. if( IsTeamGameType() ) { if( g_pLTServer->GetPropGeneric( "Team", &genProp ) == LT_OK ) { m_nTeamId = TeamStringToTeamId( genProp.m_String ); } } else { m_nTeamId = INVALID_TEAM; } return LTTRUE; }
// Change in focus void CScreenTeam::OnFocus(LTBOOL bFocus) { CUserProfile *pProfile = g_pProfileMgr->GetCurrentProfile(); LTBOOL bInMPGame = (IsMultiplayerGame() && g_pGameClientShell->IsWorldLoaded()); if (bFocus) { int n = 0; for (n = 0; n < g_pModelButeMgr->GetNumTeamModels(); n++) { ModelId id = g_pModelButeMgr->GetTeamModel(n); HMODELDB dummy = NULL; g_pILTModelClient->CacheModelDB(g_pModelButeMgr->GetModelFilename(id),dummy); } switch (g_pGameClientShell->GetGameType()) { case eGameTypeTeamDeathmatch: m_nCurrentModel = pProfile->m_ServerGameOptions.GetTeamDeathmatch().m_nTeamModel[g_nCurTeam]; m_nSkipModel = pProfile->m_ServerGameOptions.GetTeamDeathmatch().m_nTeamModel[1-g_nCurTeam]; m_sTeamName = pProfile->m_ServerGameOptions.GetTeamDeathmatch().m_sTeamName[g_nCurTeam].c_str(); break; case eGameTypeDoomsDay: m_nCurrentModel = pProfile->m_ServerGameOptions.GetDoomsday().m_nTeamModel[g_nCurTeam]; m_nSkipModel = pProfile->m_ServerGameOptions.GetDoomsday().m_nTeamModel[1-g_nCurTeam]; m_sTeamName = pProfile->m_ServerGameOptions.GetDoomsday().m_sTeamName[g_nCurTeam].c_str(); break; }; m_pName->SetString(1,m_sTeamName.c_str()); m_pName->Enable(!bInMPGame); m_pModel->Enable(!bInMPGame); m_pLeft->Enable(!bInMPGame); m_pRight->Enable(!bInMPGame); UpdateData(LTFALSE); } else { UpdateData(); int n = 0; for (n = 0; n < g_pModelButeMgr->GetNumTeamModels(); n++) { ModelId id = g_pModelButeMgr->GetTeamModel(n); g_pILTModelClient->UncacheModelDB(g_pModelButeMgr->GetModelFilename(id)); } switch (g_pGameClientShell->GetGameType()) { case eGameTypeTeamDeathmatch: pProfile->m_ServerGameOptions.GetTeamDeathmatch().m_nTeamModel[g_nCurTeam] = m_nCurrentModel; pProfile->m_ServerGameOptions.GetTeamDeathmatch().m_sTeamName[g_nCurTeam] = m_sTeamName; break; case eGameTypeDoomsDay: pProfile->m_ServerGameOptions.GetDoomsday().m_nTeamModel[g_nCurTeam] = m_nCurrentModel; pProfile->m_ServerGameOptions.GetDoomsday().m_sTeamName[g_nCurTeam] = m_sTeamName; break; }; pProfile->Save(); } CBaseScreen::OnFocus(bFocus); if (bFocus) UpdateChar(); }
void CTargetMgr::Update() { // Do any necessary initialization... if (m_bFirstUpdate) { FirstUpdate(); m_bFirstUpdate = false; } if (m_hLockedTarget && m_hTarget == m_hLockedTarget) { //are we disabling a GadgetTarget? if (g_pPlayerMgr->IsDisabling()) { SetGadgetTarget( true ); return; } //are we searching something? if (g_pPlayerMgr->IsSearching()) { m_bSearchTarget = true; SetTargetStringID(IDS_TARGET_SEARCHING); float fDistAway = 10000.0f; CheckForIntersect(fDistAway); return; } } g_pPlayerStats->UpdateMaxProgress( 0 ); g_pPlayerStats->UpdateProgress( 0 ); g_pHUDMgr->QueueUpdate( kHUDProgressBar ); // If we currently have a target, see if it is a body and if so remove the // glow flag (it may be set again below)... if (m_hTarget) { CBodyFX* pBody = g_pGameClientShell->GetSFXMgr()->GetBodyFX(m_hTarget); if (pBody) { g_pCommonLT->SetObjectFlags(m_hTarget, OFT_User, 0, USRFLG_GLOW); } } // Start fresh ClearTargetInfo(); //see what we've looking at float fDistAway = 10000.0f; CheckForIntersect(fDistAway); if (!m_hTarget) { //nothing to see here return; } m_fTargetRange = fDistAway; //if its a body's hitbox, check the body instead CBodyFX* pBody = g_pGameClientShell->GetSFXMgr()->GetBodyFromHitBox(m_hTarget); if (pBody) { m_hTarget = pBody->GetServerObj(); m_ActivationData.m_hTarget = m_hTarget; if (!m_hTarget) return; } //if its a Character's hitbox and it is searchable, check the Character instead CCharacterFX* pCharacter = g_pGameClientShell->GetSFXMgr()->GetCharacterFromHitBox(m_hTarget); if (pCharacter) { m_hTarget = pCharacter->GetServerObj(); m_ActivationData.m_hTarget = m_hTarget; if (!m_hTarget) return; } uint32 dwUserFlags = 0; g_pCommonLT->GetObjectFlags(m_hTarget, OFT_User, dwUserFlags); // If we're on a vehicle (or if we are dead) all we care about is other players in a multiplayer game... // Some vehicles (like the PlayerLure) let you activate, so we'll just check if the // vehicle will let us show a crosshair to see if we're on a "true" vehicle or not... // It would be great if we didn't have to do all these checks, but such is life... bool bPlayersOnly = g_pPlayerMgr->IsPlayerDead() || (g_pPlayerMgr->GetMoveMgr()->GetVehicleMgr()->CanShowCrosshair() ? false : true); if (!bPlayersOnly) { //special case handling for bodies if (pBody || pCharacter) { bool bCanSearch = !!(dwUserFlags & USRFLG_CAN_SEARCH); if (pBody) { if (fDistAway <= g_vtActivationDistance.GetFloat()) { // Make target glow, so it stands out more... g_pCommonLT->SetObjectFlags(m_hTarget, OFT_User, USRFLG_GLOW, USRFLG_GLOW); } if (pBody->CanBeRevived() && fDistAway <= g_vtReviveDistance.GetFloat() && IsRevivePlayerGameType( )) { // Get the client information of the body and us. uint32 nId = pBody->GetClientId(); CClientInfoMgr* pCIMgr = g_pInterfaceMgr->GetClientInfoMgr(); CLIENT_INFO* pCI = pCIMgr->GetClientByID(nId); CLIENT_INFO *pLocalCI = g_pInterfaceMgr->GetClientInfoMgr()->GetLocalClient(); // Only allow us to revive people on the same team. For non-team games, // the teamid will be set to the same invalid value anyway. if( pCI && pLocalCI ) { if (pCI->nTeamID == pLocalCI->nTeamID) { m_nString = 0; FormatString(IDS_TARGET_REVIVE, m_szString, ARRAY_LEN(m_szString), pCI->sName.c_str()); LTVector vObjPos, vDims; g_pLTClient->GetObjectPos(pBody->GetServerObj(), &vObjPos); g_pPhysicsLT->GetObjectDims(pBody->GetServerObj(), &vDims); // Players are non-solid to each other so you can revive right on top of them. m_bCanActivate = true; //!CheckForCharacters(vObjPos, vDims, pBody->GetClientId()); m_bMoveTarget = true; m_ActivationData.m_nType = MID_ACTIVATE_REVIVE; } else { m_nString = 0; m_bCanActivate = false; m_bMoveTarget = false; LTStrCpy(m_szString, pCI->sName.c_str(), ARRAY_LEN(m_szString)); } return; } } else { m_bMoveTarget = (pBody->CanBeCarried() && g_pPlayerMgr->CanDropCarriedObject()); } } else if (pCharacter) { if( (pCharacter->m_cs.eCrosshairCharacterClass != BAD) && (pCharacter->CanWake()) && (pCharacter->IsUnconscious() || (pCharacter->Slipped() && !pCharacter->m_cs.bIsPlayer)) ) { SetTargetStringID( IDS_TARGET_WAKEUP ); m_bCanActivate = true; m_bMoveTarget = g_pPlayerMgr->CanDropCarriedObject() && pCharacter->CanBeCarried(); m_ActivationData.m_nType = MID_ACTIVATE_WAKEUP; return; } m_bMoveTarget = g_pPlayerMgr->CanDropCarriedObject() && pCharacter->CanBeCarried(); } else { m_bMoveTarget = false; } if (bCanSearch && fDistAway <= g_vtActivationDistance.GetFloat()) { // we can search this body m_bSearchTarget = true; m_ActivationData.m_nType = MID_ACTIVATE_SEARCH; SetTargetStringID(IDS_TARGET_SEARCH); uint8 nProgress = g_pPlayerMgr->GetSearcher()->GetMaxProgress(); g_pPlayerStats->UpdateMaxProgress( nProgress ); g_pPlayerStats->UpdateProgress( nProgress ); g_pHUDMgr->QueueUpdate( kHUDProgressBar ); return; } else if (pBody) { return; } } else { float fGadgetDistance = g_vtActivationDistance.GetFloat(); if( dwUserFlags & USRFLG_GADGET_CAMERA ) { fGadgetDistance = g_vtCamZoom1MaxDist.GetFloat(); } // is this a gadget target if (IsGadgetActivatable(m_hTarget) && (fDistAway <= fGadgetDistance)) { // looks like we can use a gadget on it... SetGadgetTarget( false ); return; } } } //are we aiming at a person? if (dwUserFlags & USRFLG_CHARACTER) { CCharacterFX* const pFX = (CCharacterFX*)g_pGameClientShell->GetSFXMgr()->FindSpecialFX(SFX_CHARACTER_ID, m_hTarget); // All we care about if we're on a vehicle (or if we are dead) is the Multiplayer check below... if (!bPlayersOnly) { //display debug info if we have any if( pFX && pFX->GetInfoString() && *pFX->GetInfoString() ) { SAFE_STRCPY(m_szDebugString,pFX->GetInfoString()); } else { m_szDebugString[0] = NULL; } // is this a person we can talk to? if (dwUserFlags & USRFLG_CAN_ACTIVATE) { if (fDistAway <= g_vtActivationDistance.GetFloat()) { SetTargetStringID(IDS_TARGET_TALK); return; } } } // This is the only thing we care about if we're dead or on a vehicle...(we care // if we're off a vehicle too) if (IsMultiplayerGame() && pFX && pFX->m_cs.bIsPlayer ) { uint32 nId = pFX->m_cs.nClientID; CClientInfoMgr* pCIMgr = g_pInterfaceMgr->GetClientInfoMgr(); CLIENT_INFO* pCI = pCIMgr->GetClientByID(nId); if (pCI) { m_nString = 0; SAFE_STRCPY(m_szString,pCI->sName.c_str()); if (IsTeamGameType()) { m_nTargetTeam = pCI->nTeamID; } } return; } // All we care about if we're dead or on a vehicle is the Multiplayer check above... if (!bPlayersOnly) { if( (fDistAway <= g_vtTargetDistance.GetFloat()) && pFX ) { // If a nameid was specified for the model display the name... uint16 nNameId = g_pModelButeMgr->GetModelNameId( pFX->m_cs.eModelId ); if( nNameId != (uint16)-1 ) { if( nNameId > 0 ) { SetTargetStringID( nNameId ); return; } // warn the player if we are pointing at a friend... if( pFX->m_cs.eCrosshairCharacterClass != BAD ) { SetTargetStringID( IDS_TARGET_INNOCENT ); return; } } } } } // All we care about if we're dead or on a vehicle is the above Multiplayer check... if (bPlayersOnly) { // Didn't see another player in Multiplayer, so we have no target... ClearTargetInfo(); return; } //is this a searchable object? if (dwUserFlags & USRFLG_CAN_SEARCH && (fDistAway <= g_vtActivationDistance.GetFloat())) { m_bSearchTarget = true; m_ActivationData.m_nType = MID_ACTIVATE_SEARCH; SetTargetStringID(IDS_TARGET_SEARCH); uint8 nProgress = g_pPlayerMgr->GetSearcher()->GetMaxProgress(); g_pPlayerStats->UpdateMaxProgress( nProgress ); g_pPlayerStats->UpdateProgress( nProgress ); g_pHUDMgr->QueueUpdate( kHUDProgressBar ); return; } // See if this object is part of the activate object list with it's own string ID's... if( fDistAway <= g_vtActivationDistance.GetFloat() ) { CActivateObjectHandler *pActivateObj = LTNULL; CActivateObjectHandler::ActivateObjList::const_iterator iter = CActivateObjectHandler::GetActivateObjectList().begin(); while( iter != CActivateObjectHandler::GetActivateObjectList().end() ) { pActivateObj = *iter; if( pActivateObj->GetHOBJECT() == m_hTarget ) { ACTIVATETYPE *pType = g_pActivateTypeMgr->GetActivateType( pActivateObj->m_nId ); if( pType ) { // Set whether or not it's disabled and set the string based on the state... m_bCanActivate = !pActivateObj->m_bDisabled; uint32 dwStringID = pType->dwStateID[pActivateObj->m_eState]; if( dwStringID != (uint32)-1 ) { SetTargetStringID( dwStringID ); } return; } } ++iter; } } //can we pick up or activate it? if (dwUserFlags & USRFLG_CAN_ACTIVATE && (fDistAway <= g_vtActivationDistance.GetFloat())) { //special case for bombs to defuse CGadgetTargetFX* const pGTFX = (CGadgetTargetFX*)g_pGameClientShell->GetSFXMgr()->FindSpecialFX(SFX_GADGETTARGET_ID, m_hTarget); if (pGTFX) { GadgetTargetType eGadgetType = pGTFX->GetType(); if (eBombable == eGadgetType) { // Can only defuse a bomb that doesn't belong to your team... if( IsTeamGameType() ) { CLIENT_INFO *pLocalCI = g_pInterfaceMgr->GetClientInfoMgr()->GetLocalClient(); if( !pLocalCI ) return; if( pGTFX->GetTeamID() != INVALID_TEAM ) { if( pLocalCI->nTeamID == pGTFX->GetTeamID() ) { m_bCanActivate = false; } } } SetTargetStringID(IDS_TARGET_DEFUSE); return; } } CPickupItemFX* const pFX = (CPickupItemFX*)g_pGameClientShell->GetSFXMgr()->FindSpecialFX(SFX_PICKUPITEM_ID, m_hTarget); // If this is a pickupitem, then display any team association it has. if( IsTeamGameType() && pFX ) { m_nTargetTeam = pFX->GetTeamId( ); } // If we're looking at a pickup, use the take string, otherwise it's just something to interact with. SetTargetStringID(pFX ? IDS_TARGET_TAKE : IDS_TARGET_USE); return; } // Are we looking at a doomsday piece... CDoomsdayPieceFX *pDDPiece = dynamic_cast<CDoomsdayPieceFX*>(g_pGameClientShell->GetSFXMgr()->FindSpecialFX( SFX_DOOMSDAYPIECE_ID, m_hTarget )); if( pDDPiece && (fDistAway <= g_vtActivationDistance.GetFloat()) ) { m_bCanActivate = false; m_bMoveTarget = true; } }
uint32 CMenuSystem::OnCommand(uint32 nCommand, uint32 nParam1, uint32 nParam2) { switch (nCommand) { case MC_LOAD: g_pInterfaceMgr->SwitchToScreen(SCREEN_ID_LOAD); break; case MC_SAVE: g_pInterfaceMgr->SwitchToScreen(SCREEN_ID_SAVE); break; case MC_OPTIONS: g_pInterfaceMgr->SwitchToScreen(SCREEN_ID_OPTIONS); break; case MC_HOST_OPTIONS: switch (g_pGameClientShell->GetGameType()) { case eGameTypeCooperative: g_pInterfaceMgr->SwitchToScreen(SCREEN_ID_HOST_OPTIONS); break; case eGameTypeDeathmatch: g_pInterfaceMgr->SwitchToScreen(SCREEN_ID_HOST_DM_OPTIONS); break; case eGameTypeTeamDeathmatch: g_pInterfaceMgr->SwitchToScreen(SCREEN_ID_HOST_TDM_OPTIONS); break; case eGameTypeDoomsDay: g_pInterfaceMgr->SwitchToScreen(SCREEN_ID_HOST_DD_OPTIONS); break; }; break; case MC_PLAYER: g_pInterfaceMgr->SwitchToScreen(SCREEN_ID_PLAYER); break; case MC_TEAM: g_pInterfaceMgr->SwitchToScreen(SCREEN_ID_PLAYER_TEAM); break; case MC_MAIN: { // Make sure we're disconnected from server. if(g_pLTClient->IsConnected()) { g_pInterfaceMgr->SetIntentionalDisconnect( true ); g_pClientMultiplayerMgr->ForceDisconnect(); } g_pInterfaceMgr->SwitchToScreen(SCREEN_ID_MAIN); } break; case MC_QUIT: { MBCreate mb; mb.eType = LTMB_YESNO; mb.pFn = QuitCallBack; mb.pData = this; g_pInterfaceMgr->ShowMessageBox(IDS_SUREWANTQUIT,&mb); break; } case MC_ABORT: { MBCreate mb; mb.eType = LTMB_YESNO; mb.pFn = AbortCallBack; mb.pData = this; int nMsgID = IDS_SUREWANTABORT; if (IsMultiplayerGame()) { // Since we know we're starting a new server, ignore any disconnect messages. bool bIsLocalClient = false; g_pLTClient->IsLocalToServer(&bIsLocalClient); if( bIsLocalClient) nMsgID = IDS_SHUTDOWNSERVER; } g_pInterfaceMgr->ShowMessageBox(nMsgID,&mb); break; } case MC_EXIT: { g_pLTClient->Shutdown(); break; } #ifdef _TRON_E3_DEMO case MC_RESUME: { g_pInterfaceMgr->ChangeState(GS_PLAYING); break; } #endif default: return CBaseMenu::OnCommand(nCommand,nParam1,nParam2); } return 1; }