//--------------------------------------- void CMiscAnnouncer::Update(const float dt) { if(!ma_enabled || !AnnouncerRequired()) return; #if !defined(_RELEASE) switch(ma_debug) { case 2: // debug OnWeaponFiredMap for (TWeaponFiredMap::iterator it=m_weaponFiredMap.begin(); it != m_weaponFiredMap.end(); ++it) { SOnWeaponFired &onWeaponFired = it->second; CryWatch("weaponFired: weapon=%s; announce=%s; played: friend=%s; enemy=%s", onWeaponFired.m_weaponEntityClass->GetName(), onWeaponFired.m_announcementName.c_str(), onWeaponFired.m_havePlayedFriendly ? "true" : "false", onWeaponFired.m_havePlayedEnemy ? "true" : "false"); } break; case 3: // debug listeners { CGameRules *pGameRules = g_pGame->GetGameRules(); for (ActorWeaponListenerMap::iterator it=m_actorWeaponListener.begin(); it != m_actorWeaponListener.end(); ++it) { CryWatch("ActorWeaponListener: Actor=%s; Weapon=%s", pGameRules->GetEntityName(it->first), pGameRules->GetEntityName(it->second)); } } } #endif }
void CNetLerper::DebugDraw(const SPrediction& prediction, const Vec3& entityPos, bool hadNewData) { #if !defined(_RELEASE) if (m_debug == NULL) m_debug = new Debug; Vec3 desiredVelocity = m_desired.vel; Vec3 lerpVel = prediction.lerpVel; Vec3 desiredPosition = m_desired.worldPos; Vec3 predictedPosition = prediction.predictedPos; if(g_pGameCVars->pl_debugInterpolation > 1) { CryWatch("Cur: (%.2f, %.2f, %.2f) Des: (%.2f, %.2f, %.2f) Pred: (%.2f, %.2f, %.2f) ", entityPos.x, entityPos.y, entityPos.z, desiredPosition.x, desiredPosition.y, desiredPosition.z, predictedPosition.x, predictedPosition.y, predictedPosition.z); CryWatch("LerpErrorXY: (%.2f)", m_lerpedError.GetLength2D()); CryWatch("InputSpeed: (%.2f, %.2f, %.2f) lerpVel: (%.2f, %.2f, %.2f) lerpSpeed: %.2f", desiredVelocity.x, desiredVelocity.y, desiredVelocity.z, lerpVel.x, lerpVel.y, lerpVel.z, lerpVel.GetLength()); } if (hadNewData) { m_debug->AddDesired(m_desired.worldPos, m_desired.vel); } m_debug->AddCurrent(prediction.shouldSnap ? prediction.predictedPos : entityPos, prediction.lerpVel, m_lerpedError, prediction.shouldSnap); m_debug->Draw(); #endif }
//--------------------------------------- TAudioSignalID CAreaAnnouncer::GenerateAnnouncement(const int* actorCount, const int k_areaCount, const EntityId clientId) { int maxActorArea = -1; //busiest area int maxActorCount = 0; for(int i = 0; i < k_areaCount; i++) { #if !defined(_RELEASE) if(aa_debug) { CryWatch("%s - %d", m_areaList[i].m_name, actorCount[i]); } #endif if(actorCount[i] > maxActorCount) { maxActorArea = i; maxActorCount = actorCount[i]; } } if(maxActorCount >= aa_peopleNeeded) { return m_areaList[maxActorArea].m_signal[GetAreaAnnouncerTeamIndex(clientId)]; } return INVALID_AUDIOSIGNAL_ID; }
// PLAYERPREDICTION void CNetPlayerInput::GetDesiredVel(const Vec3 &pos, Vec3 &vel) const { bool doInterp = !m_passedPredictionPos; vel.Set(0.0f, 0.0f, 0.0f); if (doInterp) { Vec3 offset = m_predictedPosition - pos; offset.z = 0.0f; float dist = offset.GetLength2D(); if (dist > 0.0f) { vel = offset * (m_netLerpSpeed / dist); float parallelSpeed = m_initialDir.Dot(vel); Vec3 parallelVel = m_initialDir * parallelSpeed; Vec3 pathCorrection = vel - parallelVel; vel = parallelVel + (g_pGameCVars->pl_velocityInterpPathCorrection * pathCorrection); if (g_pGameCVars->pl_debugInterpolation) { CryWatch("Offset: (%f, %f, %f) InitDir: (%f, %f, %f) DesiredVel: (%f, %f, %f)", offset.x, offset.y, offset.z, m_initialDir.x, m_initialDir.y, m_initialDir.z, vel.x, vel.y, vel.z); } } } }
void CNetPlayerInput::InitialiseInterpolation(f32 netPosDist, const Vec3 &desPosOffset, const Vec3 &desiredVelocity, const CTimeValue &curTime) { m_newInterpolation = false; //--- Don't trigger a fresh interpolation for minor adjustments if the player is on the ground & stopping or //--- would be moving against the local player's velocity bool isStatic = (m_pPlayer->GetActorStats()->onGround > 0.1f) && ((m_netDesiredSpeed < k_staticSpeed) || (desPosOffset.Dot(desiredVelocity) < 0.0f)); const float minDist = isStatic ? k_minDistStatic : k_minDistMoving; if (g_pGameCVars->pl_debugInterpolation) { CryWatch("NewInterp NetPosDist: %f MinDist: %f)", netPosDist, minDist); } m_netLastUpdate = curTime; if (netPosDist > minDist) { if (m_netDesiredSpeed > k_staticSpeed) { m_initialDir = desiredVelocity / m_netDesiredSpeed; } else { m_initialDir = desPosOffset / netPosDist; } // Always set position when an update is first received. m_passedNetPos = false; m_passedPredictionPos = false; } }
void CMPTrackViewManager::Update() { #ifndef _RELEASE if (g_pGameCVars->g_mptrackview_debug) { IMovieSystem *pMovieSystem = gEnv->pMovieSystem; int numSequences=pMovieSystem->GetNumSequences(); CryWatch("num finished trackviews=%d", m_FinishedTrackViewCount); for (int i=0; i<m_FinishedTrackViewCount; i++) { const char *foundName="NOT FOUND"; // SLOW IAnimSequence *foundSequence = FindTrackviewSequence(m_FinishedTrackViews[i]); if (foundSequence) { foundName = foundSequence->GetName(); } CryWatch("finished[%d] hash=%x; time=%f; foundName=%s", i, m_FinishedTrackViews[i], m_FinishedTrackViewTimes[i], foundName); } int numPlaying=pMovieSystem->GetNumPlayingSequences(); for(int i = 0; i < numPlaying; ++i) { IAnimSequence* pSequence = pMovieSystem->GetPlayingSequence(i); if( pSequence ) { const char *name=pSequence->GetName(); if (!name) { name = "[NULL]"; } CryHashStringId hash_id(pSequence->GetName()); float timeValue = pMovieSystem->GetPlayingTime(pSequence); CryWatch("Seq[%d]: name=%s; time=%f; hash=%x", i, name, timeValue, hash_id.id); } } } #endif }
void CKillCamDataStreamer::DebugStreamData() const { CryWatch("Expected Stream Data:"); for(int i=0; i<kMaxSimultaneousStreams; i++) { if(m_streams[i].IsUnused()) { CryWatch(" Stream Slot [%d]: Empty", i); } else { const SKillCamExpectedData& exp = m_streams[i].m_expect; IEntity* pSender = gEnv->pEntitySystem->GetEntity(exp.m_sender); IEntity* pVictim = gEnv->pEntitySystem->GetEntity(exp.m_victim); CryWatch(" Stream Slot [%d]: Expecting Data. Sender[%s:%d] Victim[%s:%d] WinningKill[%s]", i, pSender?pSender->GetName():"", exp.m_sender, pVictim?pVictim->GetName():"", exp.m_victim, exp.m_winningKill?"True":"False"); } } }
void CAutoTester::Update() { if (m_started) { CryWatch("[AUTOTESTER] %s \"%s\" tests", m_finished ? "Finished" : "Running", m_includeThisInFileName); for (TTestSuites::const_iterator it=m_testSuites.begin(); it!=m_testSuites.end(); ++it) { const STestSuite &testSuiteStruct = it->second; CryWatch("[AUTOTESTER] Suite '%s' %spass=%d$o %sfail=%d$o", it->first.c_str(), testSuiteStruct.m_numTestCasesPassed ? "$3" : "$9", testSuiteStruct.m_numTestCasesPassed, testSuiteStruct.m_numTestCasesFailed ? "$4" : "$9", testSuiteStruct.m_numTestCasesFailed); } if (! m_finished) { switch (m_state) { case ATEST_STATE_TEST_NUM_CLIENTS: UpdateTestNumClients(); break; case ATEST_STATE_TEST_NUM_CLIENTS_LEVEL_ROTATE: UpdateTestNumClientsLevelRotate(); break; case ATEST_STATE_TEST_FEATURES: UpdateTestFeatureTests(); break; case ATEST_STATE_TEST_PERFORMANCE: UpdatePerformanceTest(); break; default: CRY_ASSERT_MESSAGE(0, string().Format("CAutoTester::Update() unrecognised state %d (%s)", m_state, s_autoTesterStateNames[m_state])); break; } } } else if (g_pGameCVars->autotest_enabled) { CryLogAlways("CAutoTester::Update() autotest_enabled"); gEnv->pConsole->ExecuteString("i_forcefeedback 0"); Start(g_pGameCVars->autotest_state_setup->GetString(), "../Xml-Reports/autotest_.xml", g_pGameCVars->autotest_quit_when_done != 0); // TODO add datestamp if needed } }
//--------------------------------------- void CAreaAnnouncer::Update(const float dt) { if(!aa_enabled) return; #if !defined(_RELEASE) if(aa_debug) { const EntityId clientId = gEnv->pGame->GetIGameFramework()->GetClientActorId(); TAudioSignalID signal = BuildAnnouncement(clientId); CryWatch("Signal %d", signal); } #endif }
void CDownloadableResource::DebugWatchContents() { const char *ss=CDownloadableResource::GetStateAsString(m_state).c_str(); float timeElapsed=0.0f; if (!(m_state&k_notStarted)) { if (m_state&k_dataAvailable) { timeElapsed=(m_downloadFinished-m_downloadStarted).GetSeconds(); } else { timeElapsed=(CTimeValue(gEnv->pTimer->GetAsyncCurTime())-m_downloadStarted).GetSeconds(); } } CryWatch("Resource %s : state %s : content %d B / %d B (%.2f bytes/sec) (elapsed %.2f sec)", m_descName.c_str(), ss, m_bufferUsed-m_contentOffset, m_contentLength, GetTransferRate(),timeElapsed); }
float CRapid::GetAmmoSoundParam() { float ammo = 1.0f; int clipSize = GetClipSize(); int ammoCount = GetAmmoCount(); if(clipSize > 0 && ammoCount >= 0) { ammo = (float) ammoCount / clipSize; } #if !defined(_RELEASE) if (g_pGameCVars->i_debug_sounds) { CryWatch("ammo_left param %.2f", ammo); } #endif return ammo; };
bool CFireModePlugin_AutoAim::Update( float frameTime, uint32 frameId ) { #ifdef DEBUG_DRAW if(g_pGameCVars->pl_debug_projectileAimHelper) { // Force update of auto aim helper code through regular flow so we can see debug visuals Vec3 hit(ZERO); Vec3 pos = m_pOwnerFiremode->GetFiringPos(hit); Vec3 dir = m_pOwnerFiremode->GetFiringDir(hit, pos); AlterFiringDirection(pos,dir); } #endif #if ALLOW_PROJECTILEHELPER_DEBUGGING if(g_pGameCVars->pl_watch_projectileAimHelper) { CryWatch("[Last Shot Auto Aimed]: %s", m_lastShotAutoAimedStatus.c_str()); } #endif // #if ALLOW_PROJECTILEHELPER_DEBUGGING return true; }
void CPlayerVisTable::UpdateIgnoreEntityDebug() { // Output array contents CryWatch("==== VISTABLE: Ignore Entities ===="); CryWatch(""); const int finalIndex = m_currentNumIgnoreEntities; for(int i = 0; i <= finalIndex; ++i) { const char* pEntName = "Unknown"; IEntity* pIgnoreEntity = gEnv->pEntitySystem->GetEntity(m_globalIgnoreEntities[i].id); if(pIgnoreEntity) { pEntName = pIgnoreEntity->GetName(); } CryWatch("Entity: Id < %d > , Name < %s >", m_globalIgnoreEntities[i].id, pEntName); CryWatch("RefCount %d", m_globalIgnoreEntities[i].refCount); if(m_globalIgnoreEntities[i].requesteeName.c_str()) { CryWatch("Caller %s", m_globalIgnoreEntities[i].requesteeName.c_str()); } CryWatch(""); } CryWatch("==== ==== ==== ==== ==== ==== ===="); // Test adding / removing specified ids if(g_pGameCVars->pl_debug_vistableAddEntityId) { AddGlobalIgnoreEntity(g_pGameCVars->pl_debug_vistableAddEntityId, "VisTable DEBUG"); g_pGameCVars->pl_debug_vistableAddEntityId = 0; } if(g_pGameCVars->pl_debug_vistableRemoveEntityId) { RemoveGlobalIgnoreEntity(g_pGameCVars->pl_debug_vistableRemoveEntityId); g_pGameCVars->pl_debug_vistableRemoveEntityId = 0; } }
bool CControllerInputRenderInfo::CreateForInput(const char * mapName, const char * inputName) { CRY_ASSERT(gEnv); CRY_ASSERT(gEnv->pGame); CRY_ASSERT(gEnv->pGame->GetIGameFramework()); CRY_ASSERT(gEnv->pGame->GetIGameFramework()->GetIActionMapManager()); IActionMap* pActionMap = gEnv->pGame->GetIGameFramework()->GetIActionMapManager()->GetActionMap(mapName); if (pActionMap) { const IActionMapAction* pAction = pActionMap->GetAction(ActionId(inputName)); if (!pAction) return false; int iNumActionInputs = pAction->GetNumActionInputs(); for (int i = 0; i < iNumActionInputs; i++) { const SActionInput* pActionInput = pAction->GetActionInput(i); CRY_ASSERT(pActionInput != NULL); // TODO: Make data driven! #if CRY_PLATFORM_ORBIS if (0 == strcmp(pActionInput->input, "pad_square")) { return SetIcon("controller_face_left"); } else if (0 == strcmp(pActionInput->input, "pad_cross")) { return SetIcon("controller_face_down"); } else if (0 == strcmp(pActionInput->input, "pad_circle")) { return SetIcon("controller_face_right"); } else if (0 == strcmp(pActionInput->input, "pad_triangle")) { return SetIcon("controller_face_up"); } else if (0 == strcmp(pActionInput->input, "pad_r2")) { return SetText("@ui_inputName_rightTrigger"); // TODO: An icon would be better... } else if (0 == strcmp(pActionInput->input, "pad_l2")) { return SetText("@ui_inputName_leftTrigger"); // TODO: An icon would be better... } else if (0 == strcmp(pActionInput->input, "pad_r3")) { return SetText("@ui_inputName_clickRightStick"); // TODO: An icon would be better... } else if (0 == strcmp(pActionInput->input, "pad_l3")) { return SetText("@ui_inputName_clickLeftStick"); // TODO: An icon would be better... } #else if (0 == strcmp(pActionInput->input, "xi_x")) { return SetIcon("controller_face_left"); } else if (0 == strcmp(pActionInput->input, "xi_a")) { return SetIcon("controller_face_down"); } else if (0 == strcmp(pActionInput->input, "xi_b")) { return SetIcon("controller_face_right"); } else if (0 == strcmp(pActionInput->input, "xi_y")) { return SetIcon("controller_face_up"); } else if (0 == strcmp(pActionInput->input, "xi_triggerr_btn")) { return SetText("@ui_inputName_rightTrigger"); // TODO: An icon would be better... } else if (0 == strcmp(pActionInput->input, "xi_triggerl_btn")) { return SetText("@ui_inputName_leftTrigger"); // TODO: An icon would be better... } else if (0 == strcmp(pActionInput->input, "xi_thumbr")) { return SetText("@ui_inputName_clickRightStick"); // TODO: An icon would be better... } else if (0 == strcmp(pActionInput->input, "xi_thumbl")) { return SetText("@ui_inputName_clickLeftStick"); // TODO: An icon would be better... } #endif } } #if WATCH_CONTROLLER_INPUT_ICON_FAILURES || ASSERT_ON_CONTROLLER_INPUT_ICON_FAILURES string error; if (pActionMap) { const IActionMapAction* pAction = pActionMap->GetAction(ActionId(inputName)); if (pAction) { int iNumActionInputs = pAction->GetNumActionInputs(); if (iNumActionInputs > 0) { error.Format("%d input(s) =", iNumActionInputs); } else { error = "no such input"; } for (int i = 0; i < iNumActionInputs; i++) { const SActionInput* pActionInput = pAction->GetActionInput(i); CRY_ASSERT(pActionInput != NULL); error = string(error + " '" + pActionInput->input.c_str() + "'"); } } else { error.Format("\"%s\" action not found", mapName); } } else { error.Format("\"%s\" action map not found", mapName); } #if WATCH_CONTROLLER_INPUT_ICON_FAILURES CryWatch("No HUD prompt icon/text for \"%s.%s\": %s", mapName, inputName, error.c_str()); #endif #if ASSERT_ON_CONTROLLER_INPUT_ICON_FAILURES CRY_ASSERT_MESSAGE(false, string().Format("No HUD prompt icon/text for \"%s.%s\": %s", mapName, inputName, error.c_str())); #endif #endif return false; }
//------------------------------------------------------------------------- void CGameRulesStandardState::Update( float frameTime ) { if (gEnv->bServer) { if(m_state == EGRS_Intro) { // We assume there is an intro, if we reach this point and an intro hasnt been registered, we know there isn't one. Onwards and upwards. if(!m_pGameRules->IsIntroSequenceRegistered()) { ChangeState(EGRS_PreGame); } } if (m_state == EGRS_PreGame) { if (m_isStarting) { const float remainingTime = m_pGameRules->GetRemainingStartTimer(); if (remainingTime <= 0.f) { CryLog("CGameRulesStandardState::Update(), starting game"); ChangeState(EGRS_InGame); } } else { bool bOk = true; CGameLobby* pGameLobby = g_pGame->GetGameLobby(); const int numPlayers = m_pGameRules->GetPlayerCount(true); if (pGameLobby) { if (m_isWaitingForOverrideTimer) { //-- test override timer m_startTimerOverrideWait -= frameTime; bOk = (m_startTimerOverrideWait <= 0.0f); if (!bOk) { bOk = true; //-- testing min player count doesn't apply to private games const bool publicGame = !pGameLobby->IsPrivateGame(); const bool onlineGame = pGameLobby->IsOnlineGame(); if (publicGame && onlineGame) { // Start only when we have enough players if (m_pGameRules->GetTeamCount() > 1) { //-- team game, insist at least 1 player per team const int numPlayersPerTeamMin = g_pGameCVars->g_gameRules_startTimerMinPlayersPerTeam; const int numPlayersTeam1 = m_pGameRules->GetTeamPlayerCount(1, true); const int numPlayersTeam2 = m_pGameRules->GetTeamPlayerCount(2, true); bOk = ((numPlayersTeam1 >= numPlayersPerTeamMin) && (numPlayersTeam2 >= numPlayersPerTeamMin)); } else { //-- not a team game, so just insist on minimum 2 players const int numPlayersMin = g_pGameCVars->g_gameRules_startTimerMinPlayers; bOk = (numPlayers >= numPlayersMin); } const int numPlayersInLobby = pGameLobby->GetSessionNames().Size(); bOk |= (numPlayersInLobby == numPlayers); } if (bOk) { //-- Enforce a percentage of lobby players in game before starting countdown bOk = (!gEnv->IsClient() || (g_pGame->GetClientActorId() != 0)) && CheckInitialChannelPlayers(); } } } else { bOk = false; if (numPlayers) { //-- Start the override timer. m_startTimerOverrideWait = g_pGameCVars->g_gameRules_startTimerOverrideWait; m_isWaitingForOverrideTimer = true; } } } if (bOk) { CryLog("CGameRulesStandardState::Update(), we have %i players, starting the game", numPlayers); float startTimeLength = #if !defined(_RELEASE) g_pGameCVars->g_gameRules_skipStartTimer ? 0.0f : #endif g_pGameCVars->g_gameRules_startTimerLength; #if USE_PC_PREMATCH bool bDoPCPrematch = false; CGameRules::EPrematchState prematchState = m_pGameRules->GetPrematchState(); if (prematchState==CGameRules::ePS_Prematch) { int numRequiredPlayers = g_pGameCVars->g_minPlayersForRankedGame - m_pGameRules->GetPlayerCount(true); if ((numRequiredPlayers > 0) || (pGameLobby && pGameLobby->UseLobbyTeamBalancing() && !pGameLobby->IsGameBalanced())) { bDoPCPrematch = true; CPlaylistManager *pPlaylistManager = g_pGame->GetPlaylistManager(); if (pGameLobby && pPlaylistManager) { if (!pGameLobby->IsRankedGame() || pPlaylistManager->IsUsingCustomVariant()) { // Private games don't do prematch bDoPCPrematch = false; } } if (bDoPCPrematch) { // If we are waiting for players on pc, spawn ingame and set a prematch state which waits for players. m_pGameRules->StartPrematch(); startTimeLength = 0.f; } } if (!bDoPCPrematch) { m_pGameRules->SkipPrematch(); } } #endif m_pGameRules->ResetGameStartTimer(startTimeLength); StartCountdown(true); } } } else if (m_state == EGRS_PostGame) { const float prevUpdateStamp = m_timeInPostGame; const float timeInPost = (prevUpdateStamp + frameTime); const float timeToShowHUDMessage = g_pGameCVars->g_gameRules_postGame_HUDMessageTime; const float timeToShowTop3 = g_pGameCVars->g_gameRules_postGame_Top3Time; const float timeToShowScoreboard = g_pGameCVars->g_gameRules_postGame_ScoreboardTime; float killcamLength = m_pGameRules->GameEndedByWinningKill() ? g_pGameCVars->kc_length : 0.f; if (g_pGameCVars->kc_showHighlightsAtEndOfGame) { CRecordingSystem* pRecordingSystem = g_pGame->GetRecordingSystem(); if(pRecordingSystem) { killcamLength += pRecordingSystem->GetHighlightsReelLength(); killcamLength = min(killcamLength, 20.f); } } const float totalPostGameTime = timeToShowHUDMessage + timeToShowTop3 + timeToShowScoreboard + killcamLength; if (timeInPost > totalPostGameTime) { CRecordingSystem* pRecordingSystem = g_pGame->GetRecordingSystem(); if (!pRecordingSystem || (!pRecordingSystem->IsPlaybackQueued() && !pRecordingSystem->IsPlayingBack())) { CGameLobby *pGameLobby = g_pGame->GetGameLobby(); if (pGameLobby) { CryLog("[GameRules] Server trying to return to lobby"); pGameLobby->SvFinishedGame(frameTime); } } else if(pRecordingSystem) { pRecordingSystem->StopHighlightReel(); } } m_timeInPostGame = timeInPost; } } CPlayer * pPlayer = static_cast<CPlayer*>(g_pGame->GetIGameFramework()->GetClientActor()); if((pPlayer && pPlayer->ShouldPlayIntro() || gEnv->bServer) && m_pGameRules->IsIntroSequenceRegistered() && !m_bHaveNotifiedIntroListeners) { // All flowgraph nodes that want to listen, should be created at this point OnIntroStart_NotifyListeners(); } #ifndef _RELEASE if(g_pGameCVars->g_hud_postgame_debug) { const char* stateName = ""; switch(m_state) { case EGRS_Reset: { stateName = "EGRS_Reset"; break;} case EGRS_Intro: { stateName = "EGRS_Intro"; break;} case EGRS_PreGame: { stateName = "EGRS_PreGame"; break;} case EGRS_InGame: { stateName = "EGRS_InGame"; break;} case EGRS_PostGame: { stateName = "EGRS_PostGame"; break;} case EGRS_MAX: { stateName = "EGRS_MAX"; break;} } CryWatch("GameRulesStandardState - State = %s", stateName); if(m_state == EGRS_PostGame) { const char* postGameStateName = ""; switch(m_postGameState) { case ePGS_Unknown: { postGameStateName = "ePGS_Unknown"; break; } case ePGS_Starting: { postGameStateName = "ePGS_Starting"; break; } case ePGS_HudMessage: { postGameStateName = "ePGS_HudMessage"; break; } case ePGS_FinalKillcam: { postGameStateName = "ePGS_FinalKillcam"; break; } case ePGS_HighlightReel: { postGameStateName = "ePGS_HighlightReel"; break; } case ePGS_Top3: { postGameStateName = "ePGS_Top3"; break; } case ePGS_Scoreboard: { postGameStateName = "ePGS_Scoreboard"; break; } } CryWatch("GameRulesStandardState -PostGameState = %s", postGameStateName); } } #endif if (gEnv->IsClient()) { if (m_state == EGRS_PreGame) { if( !gEnv->IsDedicated() ) { if (m_isStarting) { const float timeTillStartInSeconds = m_pGameRules->GetRemainingStartTimer(); SHUDEventWrapper::UpdateGameStartCountdown( ePreGameCountdown_MatchStarting, timeTillStartInSeconds ); } else { SHUDEventWrapper::UpdateGameStartCountdown( ePreGameCountdown_WaitingForPlayers, 0.0f ); } } } else if (m_state == EGRS_InGame && !gEnv->IsDedicated() ) { if (m_introMessageShown == false) // Show only once { CGameRules *pGameRules = g_pGame->GetGameRules(); if (pGameRules && pGameRules->HasGameActuallyStarted()) { if (EntityId localPlayerId = g_pGame->GetIGameFramework()->GetClientActorId()) { int teamId = g_pGame->GetGameRules()->GetTeam(localPlayerId); bool bTeamGame = (pGameRules->GetTeamCount() > 1); IActor *pActor = g_pGame->GetIGameFramework()->GetClientActor(); if (pActor->GetSpectatorMode()==CActor::eASM_None && !pActor->IsDead() && (!bTeamGame || teamId!=0)) { if (IGameRulesPlayerStatsModule *statsModule = pGameRules->GetPlayerStatsModule()) { const SGameRulesPlayerStat *stats = statsModule->GetPlayerStats(localPlayerId); if (stats->deaths <= 0) // Not died ever { if (m_startMatchString.empty() == false) { const char* gamemodeName = g_pGame->GetGameRules()->GetEntity()->GetClass()->GetName(); CryFixedStringT<32> strSignalName; strSignalName.Format("StartGame%s", gamemodeName); TAudioSignalID signalId = g_pGame->GetGameAudio()->GetSignalID(strSignalName); CryFixedStringT<64> localisedStartString = CHUDUtils::LocalizeString( m_startMatchString.c_str() ); if (bTeamGame) { CryFixedStringT<16> strTeamName; strTeamName.Format("@ui_hud_team_%d", teamId); SHUDEventWrapper::TeamMessage(strTeamName.c_str(), teamId, SHUDEventWrapper::SMsgAudio(signalId), false, true); SHUDEventWrapper::SimpleBannerMessage(localisedStartString.c_str(), SHUDEventWrapper::kMsgAudioNULL); } else { SHUDEventWrapper::RoundMessageNotify(localisedStartString.c_str(), SHUDEventWrapper::SMsgAudio(signalId)); } } } } m_introMessageShown = true; // Or not if has already died, but don't check again anyway. } } } } } else if(m_state == EGRS_PostGame && !gEnv->IsDedicated()) { if (!gEnv->bServer) { m_timeInPostGame += frameTime; } m_timeInCurrentPostGameState += frameTime; switch (m_postGameState) { case ePGS_Starting: { CRecordingSystem* pRecordingSystem = g_pGame->GetRecordingSystem(); if (pRecordingSystem != NULL && (pRecordingSystem->IsPlayingBack() || pRecordingSystem->IsPlaybackQueued())) { // Currently showing a killcam, skip to the killcam stage of the postgame flow EnterPostGameState(ePGS_FinalKillcam); } else { if (m_pGameRules->GetRoundsModule()) { EnterPostGameState(ePGS_Top3); } else { EnterPostGameState(ePGS_HudMessage); } } break; } case ePGS_HudMessage: { if (m_timeInCurrentPostGameState > g_pGameCVars->g_gameRules_postGame_HUDMessageTime) { EnterPostGameState(ePGS_FinalKillcam); } break; } case ePGS_FinalKillcam: { CRecordingSystem* pRecordingSystem = g_pGame->GetRecordingSystem(); if (!pRecordingSystem || !(pRecordingSystem->IsPlayingBack() || (pRecordingSystem->IsPlaybackQueued() && pRecordingSystem->HasWinningKillcam()))) { EnterPostGameState(ePGS_Top3); } #ifndef _RELEASE else if(g_pGameCVars->g_hud_postgame_debug && pRecordingSystem) { CryWatch("PostGameState - Waiting for final killcam to end:"); CryWatch("IsPlaybackQueued: %s, IsPlayingBack: %s", pRecordingSystem->IsPlaybackQueued() ? "True" : "False", pRecordingSystem->IsPlayingBack() ? "True" : "False"); } #endif break; } case ePGS_HighlightReel: { CRecordingSystem* pRecordingSystem = g_pGame->GetRecordingSystem(); if (!pRecordingSystem || (!pRecordingSystem->IsPlaybackQueued() && !pRecordingSystem->IsPlayingBack())) { CGameLobby *pGameLobby = g_pGame->GetGameLobby(); if (pGameLobby) { CryLog("[GameRules] Client trying to return to lobby"); pGameLobby->SvFinishedGame(frameTime); EnterPostGameState(ePGS_LeavingGame); } } #ifndef _RELEASE else if(g_pGameCVars->g_hud_postgame_debug && pRecordingSystem) { CryWatch("PostGameState - Waiting for highlight reel to end:"); CryWatch("IsPlaybackQueued: %s, IsPlayingBack: %s, IsPlayingHighlightsReel: %s", pRecordingSystem->IsPlaybackQueued() ? "True" : "False", pRecordingSystem->IsPlayingBack() ? "True" : "False", pRecordingSystem->IsPlayingHighlightsReel() ? "True" : "False"); } #endif break; } case ePGS_Top3: { if (m_timeInCurrentPostGameState > g_pGameCVars->g_gameRules_postGame_Top3Time) { EnterPostGameState(ePGS_Scoreboard); } break; } case ePGS_Scoreboard: { if(m_timeInCurrentPostGameState > g_pGameCVars->g_gameRules_postGame_ScoreboardTime) { if(!m_bHasShownHighlightReel && g_pGameCVars->kc_showHighlightsAtEndOfGame) { EnterPostGameState(ePGS_HighlightReel); } else { CGameLobby *pGameLobby = g_pGame->GetGameLobby(); if (pGameLobby) { CryLog("[GameRules] Client trying to return to lobby [No highlight reel]"); pGameLobby->SvFinishedGame(frameTime); } } } break; } } } } }
void CNetPlayerInput::UpdateInterpolation() { Vec3 desiredPosition = m_curInput.position; Vec3 entPos = m_pPlayer->GetEntity()->GetPos(); Vec3 displacement = desiredPosition - entPos; displacement.z = 0.0f; float dist = displacement.len(); CTimeValue curTime=gEnv->pTimer->GetFrameStartTime(); Vec3 desiredVelocity = m_curInput.deltaMovement * g_pGameCVars->pl_netSerialiseMaxSpeed; m_netDesiredSpeed = desiredVelocity.GetLength2D(); if (m_newInterpolation) { InitialiseInterpolation(dist, displacement, desiredVelocity, curTime); } float dt = curTime.GetDifferenceInSeconds(m_netLastUpdate) + k_lerpTargetTime; dt = min(dt, k_maxPredictTime); m_predictedPosition = desiredPosition + (desiredVelocity * dt); Vec3 predOffset = m_predictedPosition - entPos; float predDist = predOffset.GetLength2D(); float lerpSpeed = (predDist/k_lerpTargetTime); lerpSpeed=clamp(lerpSpeed, k_minInterpolateSpeed, k_maxInterpolateSpeed); m_netLerpSpeed = lerpSpeed; UpdateErrorSnap(entPos, desiredPosition, dist, displacement, curTime); if (!m_passedNetPos && (m_initialDir.Dot(displacement) < 0.0f)) { m_passedNetPos = true; } Vec3 maxPrediction = desiredPosition + (desiredVelocity * k_maxPredictTime); if (m_passedNetPos && !m_passedPredictionPos && (m_initialDir.Dot(maxPrediction - entPos) < 0.0f)) { m_passedPredictionPos = true; } #if !defined(_RELEASE) if (g_pGameCVars->pl_debugInterpolation) { CryWatch("Cur: (%f, %f, %f) Des: (%f, %f, %f) Pred: (%f, %f, %f) ", entPos.x, entPos.y, entPos.z, desiredPosition.x, desiredPosition.y, desiredPosition.z, m_predictedPosition.x, m_predictedPosition.y, m_predictedPosition.z); CryWatch("BlockTime: (%f) PredictTime (%f) LastNetTime (%f) CurTime (%f)", m_blockedTime, dt, m_netLastUpdate.GetSeconds(), curTime.GetSeconds()); CryWatch("Lerp Speed: (%f) Passed pred pos (%d) Passed net pos (%d)", m_netLerpSpeed, m_passedPredictionPos, m_passedNetPos); CryWatch("InputSpeed: (%f, %f, %f) ", desiredVelocity.x, desiredVelocity.y, desiredVelocity.z); IRenderAuxGeom* pRender = gEnv->pRenderer->GetIRenderAuxGeom(); SAuxGeomRenderFlags flags = pRender->GetRenderFlags(); SAuxGeomRenderFlags oldFlags = pRender->GetRenderFlags(); flags.SetDepthWriteFlag(e_DepthWriteOff); flags.SetDepthTestFlag(e_DepthTestOff); pRender->SetRenderFlags(flags); pRender->DrawSphere(desiredPosition + Vec3(0.0f, 0.0f, 0.035f), 0.07f, ColorB(255,0,0,255)); pRender->DrawSphere(m_predictedPosition + Vec3(0.0f, 0.0f, 0.025f), 0.05f, ColorB(255,255,255,255)); pRender->SetRenderFlags(oldFlags); ColorF ballCol = m_passedPredictionPos ? ColorF(1.0f,1.0f,0.0f,0.75f) : (m_passedNetPos ? ColorF(1.0f,1.0f,1.0f,0.75f) : ColorF(0.0f,1.0f,0.0f,0.75f)); g_pGame->GetIGameFramework()->GetIPersistantDebug()->Begin("INTERPOLATION TRAIL", false); g_pGame->GetIGameFramework()->GetIPersistantDebug()->AddSphere(desiredPosition + Vec3(0.0f, 0.0f, 0.1f), 0.04f, ColorF(1.0f,0.0f,0.0f,0.75f), 30.f); g_pGame->GetIGameFramework()->GetIPersistantDebug()->AddSphere(m_predictedPosition + Vec3(0.0f, 0.0f, 0.1f), 0.03f, ColorF(0.0f,0.0f,1.0f,0.8f), 30.f); ballCol.a = 1.0f; g_pGame->GetIGameFramework()->GetIPersistantDebug()->AddSphere(entPos + Vec3(0.0f, 0.0f, 0.1f), 0.02f, ballCol, 30.f); g_pGame->GetIGameFramework()->GetIPersistantDebug()->AddLine(entPos + Vec3(0.0f, 0.0f, 0.1f), m_predictedPosition + Vec3(0.0f, 0.0f, 0.1f), ballCol, 30.f); } #endif //!_RELEASE }
void CPlayerStateUtil::UpdateRemotePlayersInterpolation( CPlayer& player, const SActorFrameMovementParams& movement, SCharacterMoveRequest& frameRequest ) { if (!gEnv->bMultiplayer) return; ////////////////////////////////////////////////////////////////////////// /// Interpolation for remote players const bool isRemoteClient = player.IsRemote(); const bool doVelInterpolation = isRemoteClient && player.GetPlayerInput(); if (doVelInterpolation) { if (g_pGameCVars->pl_clientInertia >= 0.0f) { player.m_inertia = g_pGameCVars->pl_clientInertia; } player.m_inertiaAccel = player.m_inertia; const bool isNetJumping = g_pGameCVars->pl_velocityInterpSynchJump && movement.jump && isRemoteClient; if (isNetJumping) { #ifdef STATE_DEBUG if (g_pGameCVars->pl_debugInterpolation) { CryWatch("SetVel (%f, %f, %f)", player.m_jumpVel.x, player.m_jumpVel.y, player.m_jumpVel.z); } #endif //_RELEASE frameRequest.velocity = player.m_jumpVel; frameRequest.type = eCMT_JumpAccumulate; } else { CNetPlayerInput *playerInput = static_cast<CNetPlayerInput*>(player.GetPlayerInput()); Vec3 interVel, desiredVel; bool inAir; desiredVel = playerInput->GetDesiredVelocity(inAir); interVel = desiredVel; IPhysicalEntity* pPhysEnt = player.GetEntity()->GetPhysics(); CRY_ASSERT_MESSAGE(pPhysEnt, "Entity not physicalised! TomB would like to look at this."); const bool isPlayerInAir = player.IsInAir(); if (inAir && isPlayerInAir) { if (pPhysEnt && (g_pGameCVars->pl_velocityInterpAirDeltaFactor < 1.0f)) { pe_status_dynamics dynStat; pPhysEnt->GetStatus(&dynStat); Vec3 velDiff = interVel - dynStat.v; interVel = dynStat.v + (velDiff * g_pGameCVars->pl_velocityInterpAirDeltaFactor); frameRequest.velocity.z = interVel.z; frameRequest.velocity.z -= player.GetActorPhysics().gravity.z*gEnv->pTimer->GetFrameTime(); frameRequest.type = eCMT_Fly; } } frameRequest.velocity.x = interVel.x; frameRequest.velocity.y = interVel.y; #ifdef STATE_DEBUG if (pPhysEnt && g_pGameCVars->pl_debugInterpolation) { pe_status_dynamics dynStat; pPhysEnt->GetStatus(&dynStat); CryWatch("Cur: (%f %f %f) Des: (%f %f %f)", dynStat.v.x, dynStat.v.y, dynStat.v.z, desiredVel.x, desiredVel.y, desiredVel.z); CryWatch("Req: (%f %f %f) Type (%d)", frameRequest.velocity.x, frameRequest.velocity.y, frameRequest.velocity.z, frameRequest.type); } #endif //!_RELEASE } } }
/// Used to update any time dependent state (such as timeouts) void CFlowNode_FeatureTest::Update(float deltaTime) { if(m_running) { m_timeRunning += deltaTime; CryWatch("$7[FG FeatureTest]$o Running test '%s'", Name()); const string &description = GetPortString(&m_actInfo, eInputPorts_Description); if(!description.empty()) CryWatch("$7[FG FeatureTest]$o %s", description.c_str()); const float maxTime = GetPortFloat(&m_actInfo, eInputPorts_MaxTime); IEntity *pFollowEntity = NULL; // Firstly, attempt to get the camera entity (index: -1) bool bHasEntry = GetEntityAtIndex(-1, pFollowEntity); if(!bHasEntry && !pFollowEntity) { // If there's an entity being tested, force the view camera to follow it (if no camera entity defined) // This needs to be implemented in a cleaner way and allow other options for non-entity based tests. bHasEntry = GetEntityAtIndex(m_entitySeqIndex, pFollowEntity); // If no sequence entity defined if(!bHasEntry && !pFollowEntity) { // Look for another suitable (active) entity to follow for(int i = 0; i < SEQ_ENTITY_COUNT; ++i) { GetEntityAtIndex(i, pFollowEntity); if(pFollowEntity && pFollowEntity->IsActive()) { break; } } } } if(pFollowEntity) { CCamera &viewCamera = gEnv->pSystem->GetViewCamera(); Vec3 vPos(0,0,0); Vec3 vDir(0,0,0); AABB bounds; pFollowEntity->GetWorldBounds(bounds); Vec3 vTarget; vTarget = bounds.GetCenter(); vPos = vTarget + (pFollowEntity->GetForwardDir().GetNormalizedSafe() * -2.5f) + Vec3(0.0f, 0.0f, 1.0f); vDir = (vTarget - vPos).GetNormalizedSafe(); float fRoll(0.0f); viewCamera.SetMatrix(CCamera::CreateOrientationYPR(CCamera::CreateAnglesYPR(vDir, fRoll))); viewCamera.SetPosition(vPos); } // If a valid max time has been set if(maxTime > 0.0f) { // If test has exceeded max time if(m_timeRunning >= maxTime) { OnTestResult(false, string().Format("Test failed: Test exceeded maximum time (%f).", maxTime).c_str()); } } } }
void CLocalPlayerComponent::UpdateFPIKTorso(float fFrameTime, IItem * pCurrentItem, const Vec3& cameraPosition) { //Get const ref instead of doing a full copy SMovementState info; m_rPlayer.m_pMovementController->GetMovementState(info); const QuatT &cameraTran = m_rPlayer.GetCameraTran(); if (m_rPlayer.m_torsoAimIK.GetBlendFactor() > 0.9f) { m_lastSTAPCameraDelta = m_rPlayer.m_torsoAimIK.GetLastEffectorTransform().GetInverted() * cameraTran; } else { m_lastSTAPCameraDelta.SetIdentity(); } ICharacterInstance* pCharacter = m_rPlayer.GetEntity()->GetCharacter(0); ICharacterInstance* pCharacterShadow = m_rPlayer.GetShadowCharacter(); QuatT torsoOffset; GetFPTotalTorsoOffset(torsoOffset, pCurrentItem); if (pCharacter != 0) { Vec3 aimDir; if (m_rPlayer.m_params.mountedWeaponCameraTarget.IsZero() && (m_rPlayer.GetLinkedVehicle() == NULL)) { aimDir = !m_rPlayer.m_pPlayerRotation->GetBaseQuat() * info.aimDirection; } else { aimDir = !m_rPlayer.GetEntity()->GetWorldRotation() * info.aimDirection; } AdjustTorsoAimDir(fFrameTime, aimDir); const bool needsPositionAdjust = !m_rPlayer.IsSliding(); CIKTorsoAim_Helper::SIKTorsoParams IKParams(pCharacter, pCharacterShadow, aimDir, torsoOffset, cameraPosition, m_rPlayer.GetBoneID(BONE_CAMERA), m_rPlayer.GetBoneID(BONE_SPINE2), m_rPlayer.GetBoneID(BONE_SPINE), ShouldUpdateTranslationPinning(), needsPositionAdjust); m_rPlayer.m_torsoAimIK.Update(IKParams); } #ifndef _RELEASE if (g_pGameCVars->pl_debug_view != 0) { CryWatch("CPlayer:UpdateFPIKTorso: RawCamera Pos(%f, %f, %f) Rot(%f, %f, %f, %f)", cameraTran.t.x, cameraTran.t.x, cameraTran.t.x, cameraTran.q.v.x, cameraTran.q.v.y, cameraTran.q.v.z, cameraTran.q.w ); CryWatch("CPlayer:UpdateFPIKTorso: MountedTarget (%f, %f, %f)", m_rPlayer.m_params.mountedWeaponCameraTarget.x, m_rPlayer.m_params.mountedWeaponCameraTarget.y, m_rPlayer.m_params.mountedWeaponCameraTarget.z ); CryWatch("CPlayer:UpdateFPIKTorso: CamPos(%f, %f, %f) Dir(%f, %f, %f)", cameraPosition.x, cameraPosition.y, cameraPosition.z, info.aimDirection.x, info.aimDirection.y, info.aimDirection.z); CryWatch("CPlayer:UpdateFPIKTorso: Anim Pos(%f, %f, %f) Rot(%f, %f, %f, %f)", m_lastSTAPCameraDelta.t.x, m_lastSTAPCameraDelta.t.y, m_lastSTAPCameraDelta.t.z, m_lastSTAPCameraDelta.q.v.x, m_lastSTAPCameraDelta.q.v.y, m_lastSTAPCameraDelta.q.v.z, m_lastSTAPCameraDelta.q.w); if (g_pGameCVars->pl_debug_view >= 2) { CryLog("CPlayer:UpdateFPIKTorso: CamPos(%f, %f, %f) Dir(%f, %f, %f)", cameraPosition.x, cameraPosition.y, cameraPosition.z, info.aimDirection.x, info.aimDirection.y, info.aimDirection.z); CryLog("CPlayer:UpdateFPIKTorso: EyeOffset(%f, %f, %f)", m_rPlayer.m_eyeOffset.x, m_rPlayer.m_eyeOffset.y, m_rPlayer.m_eyeOffset.z); } const QuatT cameraWorld = QuatT(m_rPlayer.GetEntity()->GetWorldTM()) * cameraTran; gEnv->pRenderer->GetIRenderAuxGeom()->DrawSphere(cameraWorld.t, 0.1f, ColorB(0, 0, 255)); gEnv->pRenderer->GetIRenderAuxGeom()->DrawLine(cameraWorld.t, ColorB(255, 0, 0), cameraWorld.t + cameraWorld.q.GetColumn1(), ColorB(255, 0, 0), 3.0f); } if(g_pGameCVars->p_collclassdebug == 1) { const QuatT cameraQuatT = QuatT(m_rPlayer.GetEntity()->GetWorldTM()) * cameraTran; ray_hit hit; if(gEnv->pPhysicalWorld->RayWorldIntersection(cameraQuatT.t+(cameraQuatT.q.GetColumn1()*1.5f), cameraQuatT.q.GetColumn1()*200.f, ent_all, rwi_colltype_any(geom_collides)|rwi_force_pierceable_noncoll|rwi_stop_at_pierceable, &hit, 1 )) { if(hit.pCollider) { gEnv->pRenderer->GetIRenderAuxGeom()->DrawSphere(hit.pt, 0.1f, ColorB(0, 0, 255)); g_pGame->GetGamePhysicsSettings()->Debug(*hit.pCollider, true); } } } #endif }
//------------------------------------------------------------------------ void CGameRulesKingOfTheHillObjective::Update( float frameTime ) { BaseType::Update(frameTime); CGameRules *pGameRules = g_pGame->GetGameRules(); IGameRulesScoringModule *pScoringModule = pGameRules->GetScoringModule(); const int localTeamId = pGameRules->GetTeam(g_pGame->GetIGameFramework()->GetClientActorId()); for (int i = 0; i < HOLD_OBJECTIVE_MAX_ENTITIES; ++ i) { SHoldEntityDetails *pDetails = &m_entities[i]; if (!pDetails->m_id) { continue; } SKotHEntity *pKotHEntity = static_cast<SKotHEntity *>(pDetails->m_pAdditionalData); CRY_ASSERT(pKotHEntity); if (gEnv->bServer && pScoringModule) { #ifndef _RELEASE if (g_pGameCVars->g_KingOfTheHillObjective_watchLvl) { IEntity *pEntity = gEnv->pEntitySystem->GetEntity(pDetails->m_id); const char *pEntName = pEntity ? pEntity->GetName() : "<NULL>"; if (pDetails->m_controllingTeamId == CONTESTED_TEAM_ID) { CryWatch("KotH entity '%s' is contested", pEntName); } else if (pDetails->m_controllingTeamId == 0) { CryWatch("KotH entity '%s' has no players nearby", pEntName); } else { CryWatch("KotH entity '%s' controlled by team %i, scoreTimerLength='%.2f', timeSinceLastScore='%.2f'", pEntName, pDetails->m_controllingTeamId, pKotHEntity->m_scoreTimerLength, pKotHEntity->m_timeSinceLastScore); } } #endif if (pKotHEntity->m_scoringTeamId) { const int teamIndex = pKotHEntity->m_scoringTeamId - 1; CRY_ASSERT_MESSAGE(teamIndex >= 0 && teamIndex < NUM_TEAMS, "Update() scoringTeamId is out of range"); pKotHEntity->m_timeSinceLastScore += frameTime; if (pKotHEntity->m_timeSinceLastScore >= pKotHEntity->m_scoreTimerLength) { pScoringModule->OnTeamScoringEvent(teamIndex + 1, EGRST_KingOfTheHillObjectiveHeld); pKotHEntity->m_timeSinceLastScore = 0.f; AwardPlayerPoints(&pDetails->m_insideEntities[teamIndex], EGRST_KingOfTheHillObjectiveHeld); CCCPOINT_IF((pKotHEntity->m_scoringTeamId == 1), KingOfTheHillObjective_TeamMarinesScored); CCCPOINT_IF((pKotHEntity->m_scoringTeamId == 2), KingOfTheHillObjective_TeamCellScored); } } } if (gEnv->IsClient()) { if (m_useIcons && pKotHEntity->m_needsIconUpdate) { UpdateIcon(pDetails); } if (pGameRules->GetGameMode() == eGM_CrashSite) { if (pDetails->m_localPlayerIsWithinRange && pDetails->m_controllingTeamId != CONTESTED_TEAM_ID) { CPersistantStats::GetInstance()->IncrementClientStats(EFPS_CrashSiteHeldTime, frameTime); } } if (pKotHEntity->m_bPulseEnabled) { pKotHEntity->m_pulseTime -= frameTime; if (pKotHEntity->m_pulseTime < 0.f) { eRadiusPulseType pulseType = GetPulseType(pDetails); const float radiusEffectScale = pKotHEntity->m_radiusEffectScale * pDetails->m_controlRadius; RadiusEffectPulse(pDetails->m_id, pulseType, radiusEffectScale); pKotHEntity->m_pulseTime = m_pulseTimerLength; } } else { if (!m_shouldDoPulseEffectFunc.empty()) { IEntity *pEntity = gEnv->pEntitySystem->GetEntity(pDetails->m_id); if (pEntity) { IScriptTable *pEntityScript = pEntity->GetScriptTable(); HSCRIPTFUNCTION pulseCheckFunc; if (pEntityScript != NULL && pEntityScript->GetValue(m_shouldDoPulseEffectFunc.c_str(), pulseCheckFunc)) { IScriptSystem *pScriptSystem = gEnv->pScriptSystem; bool result = false; if (Script::CallReturn(pScriptSystem, pulseCheckFunc, pEntityScript, result)) { pKotHEntity->m_bPulseEnabled = result; } } } } } const float fOldScoringSFX = pKotHEntity->m_fScoringSFX; if(pKotHEntity->m_scoringTeamId) { pKotHEntity->m_fScoringSFX = min(pKotHEntity->m_fScoringSFX + (frameTime * 2.0f), 1.0f); } else { pKotHEntity->m_fScoringSFX = max(pKotHEntity->m_fScoringSFX - (frameTime * 1.0f), 0.0f); } if(pKotHEntity->m_fScoringSFX != fOldScoringSFX) UpdateEntityAudio(pDetails); } } }
void CPlayerStateJump::StartJump( CPlayer& player, const bool isHeavyWeapon, const float fVerticalSpeedModifier ) { const SActorPhysics& actorPhysics = player.GetActorPhysics(); const SPlayerStats& stats = *player.GetActorStats(); const float onGroundTime = 0.2f; float g = actorPhysics.gravity.len(); const float jumpHeightScale = 1.0f; const float jumpHeight = player.GetActorParams().jumpHeight * jumpHeightScale; float playerZ = player.GetEntity()->GetWorldPos().z; float expectedJumpEndHeight = playerZ + jumpHeight; pe_player_dimensions dimensions; IPhysicalEntity *pPhysics = player.GetEntity()->GetPhysics(); if (pPhysics && pPhysics->GetParams(&dimensions)) { float physicsBottom = dimensions.heightCollider - dimensions.sizeCollider.z; if (dimensions.bUseCapsule) { physicsBottom -= dimensions.sizeCollider.x; } expectedJumpEndHeight += physicsBottom; } float jumpSpeed = 0.0f; if (g > 0.0f) { jumpSpeed = sqrt_tpl(2.0f*jumpHeight*(1.0f/g)) * g; if( isHeavyWeapon ) { jumpSpeed *= g_pGameCVars->pl_movement.nonCombat_heavy_weapon_speed_scale; } } //this is used to easily find steep ground float slopeDelta = (Vec3Constants<float>::fVec3_OneZ - actorPhysics.groundNormal).len(); SetJumpState(player, JState_Jump); Vec3 jumpVec(ZERO); bool bNormalJump = true; player.PlaySound(CPlayer::ESound_Jump); OnSpecialMove(player, IPlayerEventListener::eSM_Jump); CCCPOINT_IF( player.IsClient(), PlayerMovement_LocalPlayerNormalJump); CCCPOINT_IF(!player.IsClient(), PlayerMovement_NonLocalPlayerNormalJump); { // This was causing the vertical jumping speed to be much slower. float verticalMult = max(1.0f - m_jumpLock, 0.3f); const Quat baseQuat = player.GetBaseQuat(); jumpVec += baseQuat.GetColumn2() * jumpSpeed * verticalMult; jumpVec.z += fVerticalSpeedModifier; #ifdef STATE_DEBUG if (g_pGameCVars->pl_debugInterpolation > 1) { CryWatch("Jumping: vec from player BaseQuat only = (%f, %f, %f)", jumpVec.x, jumpVec.y, jumpVec.z); } #endif if (g_pGameCVars->pl_adjustJumpAngleWithFloorNormal && actorPhysics.groundNormal.len2() > 0.0f) { float vertical = clamp_tpl((actorPhysics.groundNormal.z - 0.25f) / 0.5f, 0.0f, 1.0f); Vec3 modifiedJumpDirection = LERP(actorPhysics.groundNormal, Vec3(0,0,1), vertical); jumpVec = modifiedJumpDirection * jumpVec.len(); } #ifdef STATE_DEBUG if (g_pGameCVars->pl_debugInterpolation > 1) { CryWatch("Jumping (%f, %f, %f)", jumpVec.x, jumpVec.y, jumpVec.z); } #endif } NETINPUT_TRACE(player.GetEntityId(), jumpVec); FinalizeVelocity( player, jumpVec ); if (!player.IsRemote()) { player.HasJumped(player.GetMoveRequest().velocity); } IPhysicalEntity* pPhysEnt = player.GetEntity()->GetPhysics(); if (pPhysEnt != NULL) { SAnimatedCharacterParams params = player.m_pAnimatedCharacter->GetParams(); pe_player_dynamics pd; pd.kAirControl = player.GetAirControl()* g_pGameCVars->pl_jump_control.air_control_scale; pd.kAirResistance = player.GetAirResistance() * g_pGameCVars->pl_jump_control.air_resistance_scale; params.inertia = player.GetInertia() * g_pGameCVars->pl_jump_control.air_inertia_scale; if(player.IsRemote() && (g_pGameCVars->pl_velocityInterpAirControlScale > 0)) { pd.kAirControl = g_pGameCVars->pl_velocityInterpAirControlScale; } pPhysEnt->SetParams(&pd); // Let Animated character handle the inertia player.SetAnimatedCharacterParams(params); } #if 0 if (debugJumping) { Vec3 entityPos = m_player.GetEntity()->GetWorldPos(); gEnv->pRenderer->GetIRenderAuxGeom()->DrawLine(entityPos, ColorB(255,255,255,255), entityPos, ColorB(255,255,0,255), 2.0f); gEnv->pRenderer->GetIRenderAuxGeom()->DrawLine(entityPos+Vec3(0,0,2), ColorB(255,255,255,255), entityPos+Vec3(0,0,2) + desiredVel, ColorB(0,255,0,255), 2.0f); gEnv->pRenderer->GetIRenderAuxGeom()->DrawLine(entityPos, ColorB(255,255,255,255), entityPos + jumpVec, ColorB(0,255,255,255), 2.0f); gEnv->pRenderer->DrawLabel(entityPos - entityRight * 1.0f + Vec3(0,0,3.0f), 1.5f, "Velo[%2.3f = %2.3f, %2.3f, %2.3f]", m_request.velocity.len(), m_request.velocity.x, m_request.velocity.y, m_request.velocity.z); } #endif m_expectedJumpEndHeight = expectedJumpEndHeight; m_bSprintJump = player.IsSprinting(); }
bool CPlayerStateGround::CheckForVaultTrigger(CPlayer & player, float frameTime) { const int enableVaultFromStandingCVar = g_pGameCVars->pl_ledgeClamber.enableVaultFromStanding; const bool doCheck = (enableVaultFromStandingCVar == 3) || ((enableVaultFromStandingCVar > 0) && player.m_jumpButtonIsPressed); if (doCheck) { SLedgeTransitionData ledgeTransition(LedgeId::invalid_id); const float zPos = player.GetEntity()->GetWorldPos().z; const bool ignoreMovement = (enableVaultFromStandingCVar == 2); if (CPlayerStateLedge::TryLedgeGrab(player, zPos, zPos, true, &ledgeTransition, ignoreMovement) && ledgeTransition.m_ledgeTransition != SLedgeTransitionData::eOLT_None) { CRY_ASSERT( LedgeId(ledgeTransition.m_nearestGrabbableLedgeId).IsValid() ); const SLedgeInfo ledgeInfo = g_pGame->GetLedgeManager()->GetLedgeById( LedgeId(ledgeTransition.m_nearestGrabbableLedgeId) ); CRY_ASSERT( ledgeInfo.IsValid() ); if (ledgeInfo.AreAnyFlagsSet(kLedgeFlag_useVault|kLedgeFlag_useHighVault)) { #ifdef STATE_DEBUG if (g_pGameCVars->pl_ledgeClamber.debugDraw) { const char * transitionName = s_ledgeTransitionNames[ledgeTransition.m_ledgeTransition]; IEntity* pEntity = gEnv->pEntitySystem->GetEntity(ledgeInfo.GetEntityId()); CryWatch ("[LEDGEGRAB] $5%s nearest ledge: %s%s%s%s, transition=%s", player.GetEntity()->GetEntityTextDescription(), pEntity ? pEntity->GetEntityTextDescription() : "none", ledgeInfo.AreFlagsSet(kLedgeFlag_isThin) ? " THIN" : "", ledgeInfo.AreFlagsSet(kLedgeFlag_isWindow) ? " WINDOW" : "", ledgeInfo.AreFlagsSet(kLedgeFlag_endCrouched) ? " ENDCROUCHED" : "", transitionName); } #endif if (player.m_jumpButtonIsPressed || enableVaultFromStandingCVar == 3) { ledgeTransition.m_comingFromOnGround=true; ledgeTransition.m_comingFromSprint=player.IsSprinting(); SStateEventLedge ledgeEvent(ledgeTransition); player.StateMachineHandleEventMovement(ledgeEvent); return true; } else { #ifdef STATE_DEBUG if (g_pGameCVars->pl_ledgeClamber.debugDraw) { const char * message = NULL; switch (ledgeTransition.m_ledgeTransition) { case SLedgeTransitionData::eOLT_VaultOnto: message = "CLIMB"; break; case SLedgeTransitionData::eOLT_VaultOver: message = "VAULT"; break; default: CRY_ASSERT_TRACE(0, ("Unexpected ledge transition #%d when trying to display HUD prompt for vault-from-standing!", ledgeTransition.m_ledgeTransition)); break; } if (message) { const float textColor[4] = {1.f, 1.f, 1.f, 1.0f}; const float bracketColor[4] = {0.7f, 0.7f, 0.7f, 1.0f}; const float iconSize = 4.f; const float textSize = 2.f; const float iconColor[4] = {0.3f, 1.f, 0.3f, 1.0f}; const char * iconText = "A"; gEnv->pRenderer->Draw2dLabel((gEnv->pRenderer->GetWidth() * 0.5f), (gEnv->pRenderer->GetHeight() * 0.65f), iconSize, bracketColor, true, "( )"); gEnv->pRenderer->Draw2dLabel((gEnv->pRenderer->GetWidth() * 0.5f), (gEnv->pRenderer->GetHeight() * 0.65f), iconSize, iconColor, true, "%s", iconText); gEnv->pRenderer->Draw2dLabel((gEnv->pRenderer->GetWidth() * 0.5f), (gEnv->pRenderer->GetHeight() * 0.72f), textSize, textColor, true, "%s", message); } } #endif } } } } return false; }
void CAutoTester::UpdateTestNumClientsLevelRotate() { if(gEnv->bServer) { IGameFramework *pFramework = gEnv->pGame->GetIGameFramework(); int numChannels = 1; //local channel if(pFramework) { INetNub *pNub = pFramework->GetServerNetNub(); if(pNub) { numChannels = pNub->GetNumChannels(); } } if (numChannels > m_stateData.testNumClientsRotate.m_maxNumClientsConnected) { m_stateData.testNumClientsRotate.m_maxNumClientsConnected=numChannels; } float timeSeconds=gEnv->pTimer->GetFrameStartTime().GetSeconds(); CryWatch("time=%f; nextTimeOut=%f; numClients=%d; maxNumClients=%d; numClientsExpected=%d", timeSeconds, m_stateData.testNumClientsRotate.m_nextTimeOut, numChannels, m_stateData.testNumClientsRotate.m_maxNumClientsConnected, m_stateData.testNumClientsRotate.m_numClientsExpected); if (timeSeconds > m_stateData.testNumClientsRotate.m_debugTimer) { m_stateData.testNumClientsRotate.m_debugTimer = timeSeconds+2.0f; CryLogAlways("CAutoTester::UpdateTestNumClientsLevelRotate() updating time=%f; nextTimeOut=%f; numClients=%d; maxNumClients=%d; numClientsExpected=%d", timeSeconds, m_stateData.testNumClientsRotate.m_nextTimeOut, numChannels, m_stateData.testNumClientsRotate.m_maxNumClientsConnected, m_stateData.testNumClientsRotate.m_numClientsExpected); } if (timeSeconds > m_stateData.testNumClientsRotate.m_nextTimeOut) { CryLogAlways("CAutoTester::UpdateTestNumClientsLevelRotate() testing num clients and time has expired. numClients=%d; maxNumClients=%d; numClientsExpected=%d", numChannels, m_stateData.testNumClientsRotate.m_maxNumClientsConnected, m_stateData.testNumClientsRotate.m_numClientsExpected); bool passed=false; ILevelRotation *pLevelRotation = g_pGame->GetIGameFramework()->GetILevelSystem()->GetLevelRotation(); string mapName = g_pGame->GetIGameFramework()->GetILevelSystem()->GetCurrentLevel()->GetLevelInfo()->GetName(); string gameRulesName; gameRulesName = g_pGame->GetGameRules()->GetEntity()->GetClass()->GetName(); XmlNodeRef testCase = GetISystem()->CreateXmlNode(); string nameStr; if (m_stateData.testNumClientsRotate.m_levelIndex == 0) { nameStr.Format("%02d/%d) Level: %s; gameRules: %s; numClients=%d; timeTested=%.1f seconds", m_stateData.testNumClientsRotate.m_levelIndex+1, pLevelRotation->GetLength(), mapName.c_str(), gameRulesName.c_str(), numChannels, m_stateData.testNumClientsRotate.m_firstLevelTimeOut); } else { nameStr.Format("%02d/%d) Level: %s; gameRules: %s; numClients=%d; timeTested=%.1f seconds", m_stateData.testNumClientsRotate.m_levelIndex+1, pLevelRotation->GetLength(), mapName.c_str(), gameRulesName.c_str(), numChannels, m_stateData.testNumClientsRotate.m_levelTimeOut); } CryLogAlways("CAutoTester::UpdateTestNumClientsLevelRotate() outputting a test result with these details [%s]", nameStr.c_str()); testCase->setTag("testcase"); testCase->setAttr("name", nameStr.c_str()); testCase->setAttr("time", 0); testCase->setAttr("numClients", numChannels); testCase->setAttr("maxNumClientsConnected",m_stateData.testNumClientsRotate.m_maxNumClientsConnected); testCase->setAttr("numClientsExpected", m_stateData.testNumClientsRotate.m_numClientsExpected); if (numChannels == m_stateData.testNumClientsRotate.m_maxNumClientsConnected) { CryLogAlways("CAutoTester::UpdateTestNumClientsLevelRotate() testing num clients and time has expired. We have the same number of clients are our maxNumClients %d", numChannels); if (numChannels == m_stateData.testNumClientsRotate.m_numClientsExpected) // may want to remove this check as keeping the number that joined should be sufficient { CryLogAlways("CAutoTester::UpdateTestNumClientsLevelRotate() testing num clients and time has expired. We have the same number of clients as we expected to have %d", numChannels); testCase->setAttr("status", "run"); passed=true; } else { CryLogAlways("CAutoTester::UpdateTestNumClientsLevelRotate() testing num clients and time has expired. We DON'T have the same number of clients %d as we expected to have %d", numChannels, m_stateData.testNumClientsRotate.m_numClientsExpected); //testCase->setAttr("status", "failed"); XmlNodeRef failedCase = GetISystem()->CreateXmlNode(); failedCase->setTag("failure"); failedCase->setAttr("type", "NotEnoughClients"); failedCase->setAttr("message", string().Format("testing num clients and time has expired. We DON'T have the same number of clients %d as we expected to have %d", numChannels, m_stateData.testNumClientsRotate.m_numClientsExpected)); testCase->addChild(failedCase); } } else { //testCase->setAttr("status", "failed"); XmlNodeRef failedCase = GetISystem()->CreateXmlNode(); failedCase->setTag("failure"); failedCase->setAttr("type", "NotEnoughClients"); failedCase->setAttr("message", string().Format("testing num clients and time has expired. We DON'T have the same number of clients %d as we peaked at %d", numChannels, m_stateData.testNumClientsRotate.m_maxNumClientsConnected)); testCase->addChild(failedCase); } AddTestCaseResult("Test Clients In Level Rotation", testCase, passed); Stop(); if (pLevelRotation->GetNext() != 0) { CryLogAlways("CAutoTester::UpdateTestNumClientsLevelRotate() has found we're not at the end of the level rotation moving on to the next level - levelIndex=%d; rotation->GetNext()=%d\n", m_stateData.testNumClientsRotate.m_levelIndex+1, pLevelRotation->GetNext()); Restart(); gEnv->pConsole->ExecuteString("g_nextlevel"); // has to be a better way of doing this m_stateData.testNumClientsRotate.m_nextTimeOut = timeSeconds + m_stateData.testNumClientsRotate.m_levelTimeOut; m_stateData.testNumClientsRotate.m_levelIndex++; } else { CryLogAlways("CAutoTester::UpdateTestNumClientsLevelRotate() has found we ARE at the end of the level rotation. Not doing anymore tests\n"); } } } }
//--------------------------------------------------------------------------- IEntity* CFireModePlugin_AutoAim::CalculateBestProjectileAutoAimTarget(const Vec3& attackerPos, const Vec3& attackerDir, const bool bCurrentlyZoomed, const EntityId ownerId) const { #if ALLOW_PROJECTILEHELPER_DEBUGGING static const ColorB red(127,0,0); static const ColorB green(0,127,0); static const ColorB brightGreen(0,255,0); static const float s_sphereDebugRad = 0.15f; #endif IEntity* pBestTarget = NULL; float fBestScore = 0.0f; const TAutoaimTargets& players = g_pGame->GetAutoAimManager().GetAutoAimTargets(); // Cache commonly required constants for scoring const ConeParams& aimConeSettings = GetAimConeSettings(bCurrentlyZoomed); const float minAutoAimDistSqrd = cry_sqr(aimConeSettings.m_minDistance); const float maxAutoAimDistSqrd = cry_sqr(aimConeSettings.m_maxDistance); const float coneSizeRads = aimConeSettings.m_outerConeRads; IEntitySystem* pEntitySystem = gEnv->pEntitySystem; CPlayerVisTable* pVisTable = g_pGame->GetPlayerVisTable(); const float distanceConstant = __fres(max(aimConeSettings.m_maxDistance, FLT_EPSILON)); const float coneAngleConstant = __fres(max(coneSizeRads*0.5f, FLT_EPSILON)); // For each potential target we do a dist + cone check TAutoaimTargets::const_iterator endIter = players.end(); for(TAutoaimTargets::const_iterator iter = players.begin(); iter != endIter; ++iter) { // If entity exists and we are allowed to target them EntityId targetEntityId = iter->entityId; IEntity* pEntity = pEntitySystem->GetEntity(targetEntityId); if(pEntity && AllowedToTargetPlayer(ownerId,targetEntityId)) { // If further than allowed dist, discard Vec3 targetTestPos; // Test against primary Auto aim position const SAutoaimTarget* pAutoAimInfo = g_pGame->GetAutoAimManager().GetTargetInfo(targetEntityId); if(pAutoAimInfo) { targetTestPos = pAutoAimInfo->primaryAimPosition; } else { // Then ABBB centre as backup IEntityPhysicalProxy* pPhysProxy = static_cast<IEntityPhysicalProxy*>(pEntity->GetProxy(ENTITY_PROXY_PHYSICS)); if(pPhysProxy) { AABB aabb; pPhysProxy->GetWorldBounds(aabb); targetTestPos = aabb.GetCenter(); } else { targetTestPos = pEntity->GetWorldPos(); } } Vec3 toTarget = targetTestPos - attackerPos; float distSqrd = toTarget.GetLengthSquared(); if( distSqrd >= minAutoAimDistSqrd && distSqrd <= maxAutoAimDistSqrd ) { // If not within cone.. discard float theta = 0.0f; if(TargetPositionWithinFrontalCone(attackerPos,targetTestPos, attackerDir,coneSizeRads, theta)) { // If cant see them .. next if(!pVisTable->CanLocalPlayerSee(targetEntityId, 5)) { #if ALLOW_PROJECTILEHELPER_DEBUGGING m_lastTargetRejectionReason.append("VISION BLOCKED"); #endif // #if ALLOW_PROJECTILEHELPER_DEBUGGING continue; } // For each candidate, generate their Auto Aim score. // 1) [0.0f,1.0f] score comprised of DISTANCE based score (closer is better) float targetDistScore = 1.0f - ( sqrtf(distSqrd) * distanceConstant ); // Lets try squaring this to make candidates with only small gaps between them reflect distance scoring better and reduce the importance of distance at super long ranges targetDistScore *= targetDistScore; // 2) + [0.0f,1.0f] cone based score (central is better) const float targetConeScore = 1.0f - ( theta * coneAngleConstant ); // Factor in designer controlled multipliers const float finalScore = (targetDistScore * g_pGameCVars->pl_pickAndThrow.chargedThrowAutoAimDistanceHeuristicWeighting) + // TODO - move these weightings into params (targetConeScore * g_pGameCVars->pl_pickAndThrow.chargedThrowAutoAimAngleHeuristicWeighting); if(finalScore > fBestScore) { fBestScore = finalScore; pBestTarget = pEntity; } // Debug rendering! #if ALLOW_PROJECTILEHELPER_DEBUGGING if(g_pGameCVars->pl_debug_projectileAimHelper) { CryWatch("Entity [%s - %d] DistScore [%.2f] , ConeScore[%.2f], totalScore [%.3f]", pEntity->GetName(), pEntity->GetId(), targetDistScore, targetConeScore, finalScore); // Draw a green sphere to indicate valid gEnv->pRenderer->GetIRenderAuxGeom()->DrawSphere(targetTestPos, s_sphereDebugRad,green); } #endif //#if ALLOW_PROJECTILEHELPER_DEBUGGING } #if ALLOW_PROJECTILEHELPER_DEBUGGING else { m_lastTargetRejectionReason.Format("OUTSIDE CONE [%.3f]",RAD2DEG(theta)); if(g_pGameCVars->pl_debug_projectileAimHelper) { // Draw a red sphere to indicate not valid gEnv->pRenderer->GetIRenderAuxGeom()->DrawSphere(targetTestPos, s_sphereDebugRad, red); } } #endif //#if ALLOW_PROJECTILEHELPER_DEBUGGING } #if ALLOW_PROJECTILEHELPER_DEBUGGING else { if(distSqrd >= minAutoAimDistSqrd) { m_lastTargetRejectionReason.Format("TOO CLOSE [%.3f]", cry_sqrtf_fast(distSqrd)); } else { m_lastTargetRejectionReason.Format("TOO FAR [%.3f]",cry_sqrtf_fast(distSqrd)); } } #endif //#if ALLOW_PROJECTILEHELPER_DEBUGGING } } // Draw a Really bright sphere on BEST target #if ALLOW_PROJECTILEHELPER_DEBUGGING if(pBestTarget && g_pGameCVars->pl_debug_projectileAimHelper) { // If further than allowed dist, discard Vec3 targetTestPos = pBestTarget->GetPos(); // We use aabb centre to reduce error IEntityPhysicalProxy* pPhysProxy = static_cast<IEntityPhysicalProxy*>(pBestTarget->GetProxy(ENTITY_PROXY_PHYSICS)); if(pPhysProxy) { AABB aabb; pPhysProxy->GetWorldBounds(aabb); targetTestPos = aabb.GetCenter(); } // Draw a bright green sphere to indicate target chosen gEnv->pRenderer->GetIRenderAuxGeom()->DrawSphere(targetTestPos, s_sphereDebugRad*1.05f, brightGreen); } #endif //#if ALLOW_PROJECTILEHELPER_DEBUGGING return pBestTarget; }
bool CIntersectionAssistanceUnit::GetHighestScoringLastKnownGoodPosition( const QuatT& baseOrientation, QuatT& outQuat ) const { bool bFlippedIsBest = false; if(!m_lastKnownGoodPositions.empty()) { // Higher is better float fBestScore = 0.0f; int bestIndex = -1; Vec3 vBaseUpDir = baseOrientation.q.GetColumn2().GetNormalized(); for(uint8 i = 0; i < m_lastKnownGoodPositions.size(); ++i) { const QuatT& qLastKnownGood = m_lastKnownGoodPositions[i]; if(IsPositionWithinAcceptedLimits(qLastKnownGood.t, baseOrientation.t, kDistanceTolerance)) { // Generate [0.0f,1.0f] score for distance const Vec3 distVec = (qLastKnownGood.t - baseOrientation.t); const float length = max(distVec.GetLengthFast(),0.0001f); const float distanceScore = max(1.0f - (length * kInverseDistanceTolerance) * kDistanceWeight, 0.0f); Vec3 vUpDir = qLastKnownGood.q.GetColumn2(); const float regularOrientationScore = vBaseUpDir.Dot(vUpDir); const float flippedOrientationScore = vBaseUpDir.Dot(-vUpDir); float orientationScore = max(regularOrientationScore, flippedOrientationScore); orientationScore *= kOrientationWeight; const float fCandidateScore = distanceScore + orientationScore; #ifndef _RELEASE if(g_pGameCVars->pl_pickAndThrow.intersectionAssistDebugEnabled == 2) { CryWatch("[INDEX(%d)] : D[%.3f] O[%.3f] T[%.3f] (%s)", i, distanceScore, orientationScore, fCandidateScore, flippedOrientationScore > regularOrientationScore ? "*F*" : "R"); } #endif //#ifndef _RELEASE if(fCandidateScore > fBestScore) { bestIndex = i; fBestScore = fCandidateScore; bFlippedIsBest = (flippedOrientationScore > regularOrientationScore); } } } if(bestIndex >= 0) { outQuat = m_lastKnownGoodPositions[bestIndex]; if(bFlippedIsBest) { Matrix34 wMat(outQuat); Vec3 vFlippedUpDir = -outQuat.q.GetColumn2().GetNormalized(); Vec3 vForwardDir = outQuat.q.GetColumn1().GetNormalized(); Vec3 vSideDir = -outQuat.q.GetColumn0().GetNormalized(); Matrix34 wFlippedMat; wFlippedMat = Matrix34::CreateFromVectors(vSideDir, vForwardDir, vFlippedUpDir, wMat.GetTranslation()); outQuat = QuatT(wFlippedMat); // Adjust pos (rotating around OOBB centre effectively) const IEntity* pSubjectEntity = gEnv->pEntitySystem->GetEntity(m_subjectEntityId); if(pSubjectEntity) { AABB entAABB; OBB entOBB; pSubjectEntity->GetLocalBounds(entAABB); entOBB.SetOBBfromAABB(Quat(IDENTITY), entAABB); Vec3 Centre = wMat.TransformPoint(entOBB.c); Vec3 toCentre = Centre - outQuat.t; outQuat.t += (toCentre * 2.0f); } } #ifndef _RELEASE if(g_pGameCVars->pl_pickAndThrow.intersectionAssistDebugEnabled == 2) { m_currentBestIndex = bestIndex; CryWatch("[BEST INDEX] : %d", bestIndex); } #endif // ifndef _RELEASE return true; } } #ifndef _RELEASE m_currentBestIndex = -1; #endif // ifndef _RELEASE return false; }
//--------------------------------------------------------------------- void CCryWatchOutputHandler::DoOutput(const char * text) { CryWatch ("%s", text); }
// TODO parameterise and refactor this now its mainly duplicated between the two runs void CAutoTester::UpdateTestNumClients() { if(gEnv->bServer) { IGameFramework *pFramework = gEnv->pGame->GetIGameFramework(); int numChannels = 1; //local channel if(pFramework) { INetNub *pNub = pFramework->GetServerNetNub(); if(pNub) { numChannels = pNub->GetNumChannels(); } } if (numChannels > m_stateData.testNumClients.m_maxNumClientsConnected) { m_stateData.testNumClients.m_maxNumClientsConnected=numChannels; } float timeSeconds=gEnv->pTimer->GetFrameStartTime().GetSeconds(); CryWatch("time=%f; numClients=%d; maxNumClients=%d; numClientsExpected=%d", timeSeconds, numChannels, m_stateData.testNumClients.m_maxNumClientsConnected, m_stateData.testNumClients.m_numClientsExpected); if (timeSeconds > m_stateData.testNumClients.m_debugTimer) { m_stateData.testNumClients.m_debugTimer = timeSeconds+2.0f; CryLogAlways("CAutoTester::UpdateTestNumClients() updating time=%f; numClients=%d; maxNumClients=%d; numClientsExpected=%d", timeSeconds, numChannels, m_stateData.testNumClients.m_maxNumClientsConnected, m_stateData.testNumClients.m_numClientsExpected); } if (timeSeconds > m_stateData.testNumClients.m_timeOut) { CryLogAlways("CAutoTester::UpdateTestNumClients() testing num clients and time has expired. numClients=%d; maxNumClients=%d; numClientsExpected=%d", numChannels, m_stateData.testNumClients.m_maxNumClientsConnected, m_stateData.testNumClients.m_numClientsExpected); bool passed=false; string mapName = g_pGame->GetIGameFramework()->GetILevelSystem()->GetCurrentLevel()->GetLevelInfo()->GetName(); string gameRulesName; gameRulesName = g_pGame->GetGameRules()->GetEntity()->GetClass()->GetName(); XmlNodeRef testCase = GetISystem()->CreateXmlNode(); string nameStr; nameStr.Format("Level: %s; gameRules: %s; numClients=%d; timeTested=%.1f seconds", mapName.c_str(), gameRulesName.c_str(), numChannels, m_stateData.testNumClients.m_timeOut); testCase->setTag("testcase"); testCase->setAttr("name", nameStr.c_str()); testCase->setAttr("time", 0); testCase->setAttr("numClients", numChannels); testCase->setAttr("maxNumClientsConnected",m_stateData.testNumClients.m_maxNumClientsConnected); testCase->setAttr("numClientsExpected", m_stateData.testNumClients.m_numClientsExpected); if (numChannels == m_stateData.testNumClients.m_maxNumClientsConnected) { CryLogAlways("CAutoTester::UpdateTestNumClients() testing num clients and time has expired. We have the same number of clients are our maxNumClients %d", numChannels); if (numChannels == m_stateData.testNumClients.m_numClientsExpected) // may want to remove this check as keeping the number that joined should be sufficient { CryLogAlways("CAutoTester::UpdateTestNumClients() testing num clients and time has expired. We have the same number of clients as we expected to have %d", numChannels); testCase->setAttr("status", "run"); passed=true; } else { CryLogAlways("CAutoTester::UpdateTestNumClients() testing num clients and time has expired. We DON'T have the same number of clients %d as we expected to have %d", numChannels, m_stateData.testNumClients.m_numClientsExpected); //testCase->setAttr("status", "failed"); XmlNodeRef failedCase = GetISystem()->CreateXmlNode(); failedCase->setTag("failure"); failedCase->setAttr("type", "NotEnoughClients"); failedCase->setAttr("message", string().Format("testing num clients and time has expired. We DON'T have the same number of clients %d as we expected to have %d", numChannels, m_stateData.testNumClients.m_numClientsExpected)); testCase->addChild(failedCase); } } else { //testCase->setAttr("status", "failed"); XmlNodeRef failedCase = GetISystem()->CreateXmlNode(); failedCase->setTag("failure"); failedCase->setAttr("type", "NotEnoughClients"); failedCase->setAttr("message", string().Format("testing num clients and time has expired. We DON'T have the same number of clients %d as we peaked at %d", numChannels, m_stateData.testNumClients.m_maxNumClientsConnected)); testCase->addChild(failedCase); } AddTestCaseResult("Test Clients In Levels", testCase, passed); Stop(); } } }