void SpecialMove::ReadProp(const GenericPropList *pProps) { if (!pProps) return; const char* pszAnimation = pProps->GetString("Animation", NULL); if (!LTStrEmpty(pszAnimation)) { m_eAnimation = AnimPropUtils::Enum(pszAnimation); } m_fActivateDist = pProps->GetReal("ActivateDist", m_fActivateDist); const char* pszActivateType = pProps->GetString("ActivationType", NULL); if (!LTStrEmpty(pszActivateType)) { m_ActivateTypeHandler.SetActivateType(pszActivateType); } m_bOn = pProps->GetBool("On", true); m_bRadial = pProps->GetBool("Radial", false); m_sActivateCommand = pProps->GetCommand("ActivateCommand", ""); m_sReleaseCommand = pProps->GetCommand("ReleaseCommand", ""); m_sLookedAtCommand = pProps->GetCommand("LookedAtCommand", ""); }
static bool ValidateTargetProperty( ILTPreInterface *pInterface, ConParse &cpMsgParams ) { char *pObj = CCommandMgrPlugin::GetCurrentObjectName(); const char* pszCommand = cpMsgParams.m_Args[0]; // Failed to find a target property. This shouldn't happen unless // we change the property set for this object. GenericProp gTargetNameProp; if( pInterface->GetPropGeneric( pObj, "Target", &gTargetNameProp ) != LT_OK ) { WORLDEDIT_ERROR_MSG( pInterface, cpMsgParams, "No 'Target' property." ); return false; } const char* pszTargetObjectName = gTargetNameProp.GetString(); // Fail if the target property string is empty. if ( LTStrEmpty( pszTargetObjectName ) ) { WORLDEDIT_ERROR_MSG( pInterface, cpMsgParams, "No object specified in the Target property" ); return false; } // Fail if the class does not exist. const char *pClassName = pInterface->GetObjectClass( pszTargetObjectName ); if ( LTStrEmpty( pClassName ) ) { WORLDEDIT_ERROR_MSG1( pInterface, cpMsgParams, "Target object '%s' does not exist!", pszTargetObjectName ); return false; } // Fail if the target object does not have a template property. GenericProp gTargetTemplateProp; if( pInterface->GetPropGeneric( pszTargetObjectName, "Template", &gTargetTemplateProp ) != LT_OK ) { WORLDEDIT_ERROR_MSG1( pInterface, cpMsgParams, "Target object '%s' is not a template object!", pszTargetObjectName ); } // Fail if the target object is not a template. if ( LT_PT_BOOL != gTargetTemplateProp.GetType() || false == gTargetTemplateProp.GetBool() ) { WORLDEDIT_ERROR_MSG1( pInterface, cpMsgParams, "Target object '%s' is not a template object!", pszTargetObjectName ); } return true; }
char* GetSound(CCharacter* pCharacter, EnumAISoundType eSound) { /* if (g_pVersionMgr->IsLowViolence()) { if ( (eSound == kAIS_Death) || (eSound == kAIS_DeathQuiet) || (eSound == kAIS_Pain) ) { return BUILD_NOPAIN_WAV; } } */ if (!pCharacter || !g_pServerSoundMgr) return NULL; if (eSound == kAIS_InvalidType ) return NULL; ModelsDB::HMODEL hModel = pCharacter->GetModel(); HRECORD hSoundTemplate = g_pModelsDB->GetModelSoundTemplate(hModel); if( !hSoundTemplate ) return NULL; // Look for sounds in a heirarchical manner: First look for the sound in the sound // template, if it isn't found there look in the parent sound template, and so on... char szStr[128] = ""; g_pAISoundDB->GetRandomSoundFilename(hSoundTemplate, AISoundUtils::String( eSound ), szStr, sizeof(szStr)); if (!LTStrEmpty(szStr)) { LTStrCpy(s_FileBuffer, szStr, LTARRAYSIZE(s_FileBuffer)); return s_FileBuffer; } return NULL; }
// Launches the end splash screen. bool LaunchApplication::LaunchEndSplashScreen( ) { #if defined(PLATFORM_WIN32) if( !g_pLTIStringEdit->DoesIDExist(g_pLTDBStringEdit, "EndSplashURL" )) return false; char szEndSplashURL[MAX_PATH*2] = ""; LTStrCpy( szEndSplashURL, MPW2A( LoadString( "EndSplashURL" )).c_str(), LTARRAYSIZE( szEndSplashURL )); if( LTStrEmpty( szEndSplashURL )) return false; char szExe[MAX_PATH] = ""; uint32 nExeSize = LTARRAYSIZE( szExe ); AssocQueryString(ASSOCF_NOTRUNCATE, ASSOCSTR_EXECUTABLE, ".htm", "open", szExe, ( DWORD* )&nExeSize); return LaunchFromString( szExe, szEndSplashURL, true, true ); #else return false; #endif }
bool CLoadingScreen::NeedsPostLoadScreen() const { // Always go to postload screen if in mp. We may need to wait there for other players. if( IsMultiplayerGameClient( )) return true; // Only go to postload if we had a briefing for sp. return ( !LTStrEmpty(m_Briefing.GetString())); }
void Turret::GetPrefetchResourceList(const char* pszObjectName, IObjectResourceGatherer* pInterface, ResourceList& Resources ) { // get the turret record char szTurretType[MAX_PATH]; pInterface->GetPropString(pszObjectName, "TurretType", szTurretType, LTARRAYSIZE(szTurretType), NULL); if (!LTStrEmpty(szTurretType)) { HRECORD hTurretRecord = g_pWeaponDB->GetTurretRecord(szTurretType); // get the base model and material HATTRIBUTE hBaseModelAttribute = g_pLTDatabase->GetAttribute(hTurretRecord, WDB_TURRET_sBaseModel); const char* pszBaseModel = g_pLTDatabase->GetString(hBaseModelAttribute, 0, NULL); if (pszBaseModel) { Resources.push_back(pszBaseModel); } HATTRIBUTE hBaseMaterialAttribute = g_pLTDatabase->GetAttribute(hTurretRecord, WDB_TURRET_sBaseMaterial); const char* pszBaseMaterial = g_pLTDatabase->GetString(hBaseMaterialAttribute, 0, NULL); if (pszBaseMaterial) { Resources.push_back(pszBaseMaterial); } // get the client FX resources GetClientFXResources(Resources, hTurretRecord, WDB_TURRET_sLoopFX); GetClientFXResources(Resources, hTurretRecord, WDB_TURRET_sDamageFX); HATTRIBUTE hDamageStateStruct = g_pLTDatabase->GetAttribute(hTurretRecord, WDB_TURRET_DamageState); uint32 nNumberOfDamageStates = g_pLTDatabase->GetNumValues(hDamageStateStruct); for (uint32 nDamageStateIndex = 0; nDamageStateIndex < nNumberOfDamageStates; ++nDamageStateIndex) { HATTRIBUTE hClientFX = CGameDatabaseReader::GetStructAttribute(hDamageStateStruct, nDamageStateIndex, WDB_TURRET_fxClientFX); const char* pszClientFX = g_pLTDatabase->GetString(hClientFX, 0, NULL); GetClientFXResources(Resources, pszClientFX); } // get the weapon record HATTRIBUTE hTurretWeaponLink = g_pLTDatabase->GetAttribute(hTurretRecord, WDB_TURRET_rWeapon); HRECORD hTurretWeapon = g_pLTDatabase->GetRecordLink(hTurretWeaponLink, 0, NULL); if (hTurretWeapon) { // get the default attribute HATTRIBUTE hDefaultAttribute = g_pLTDatabase->GetAttribute(hTurretWeapon, "Default"); HRECORD hDefaultRecord = g_pLTDatabase->GetRecordLink(hDefaultAttribute, 0, NULL); // get everything under here GetRecordResources(Resources, hDefaultRecord, true); } } }
void CDestructibleModel::InitialUpdate( const GenericPropList *pProps ) { // Set the collisionproperty override. char const* pszCollisionProperty = pProps->GetString( "CollisionProperty", "" ); if( !LTStrEmpty( pszCollisionProperty )) { HRECORD hRecord = g_pLTDatabase->GetRecord( DATABASE_CATEGORY( CollisionProperty ).GetCategory(), pszCollisionProperty ); if( hRecord ) { uint32 nUserFlags = CollisionPropertyRecordToUserFlag( hRecord ); g_pLTServer->Common( )->SetObjectFlags( m_hObject, OFT_User, nUserFlags, USRFLG_COLLISIONPROPMASK ); } } char const* pszSurfaceOverride = pProps->GetString( SURFACE_FLAGS_OVERRIDE_STR, "" ); if( !LTStrEmpty( pszSurfaceOverride )) { HSURFACE hSurf = g_pSurfaceDB->GetSurface( pszSurfaceOverride ); SetSurfaceType( hSurf ); } }
bool CDestructibleModel::ReadProp(const GenericPropList *pProps) { char szString[1024] = ""; LTStrCpy( szString, pProps->GetString( "DestroyedFX", m_pszDestroyedFXName ? m_pszDestroyedFXName : "" ), LTARRAYSIZE( szString )); if( m_pszDestroyedFXName ) { delete[] m_pszDestroyedFXName; m_pszDestroyedFXName = NULL; } if( !LTStrEmpty( szString )) m_pszDestroyedFXName = LTStrDup( szString ); return true; }
void LTFileOperations::GetUserDirectory(char const* pszGameName, char* pDirectoryBuffer, uint32 nDirectoryBufferSize) { if (LTStrEmpty(g_szUserDirectory)) { // set to the current working directory GetCurrentWorkingDirectory(pDirectoryBuffer, nDirectoryBufferSize); } else { // use the specified user directory LTStrCpy(pDirectoryBuffer, g_szUserDirectory, nDirectoryBufferSize); } // add a trailing slash LTStrCat(pDirectoryBuffer, "/", nDirectoryBufferSize); }
void CLoadingScreen::UpdateSessionName( ) { // If connecting to a remote server, set our mission descriptor to // the ip we're connecting to. if( g_pClientConnectionMgr->IsConnectedToRemoteServer( )) { // Make a loading string using the IP to be joined. wchar_t szLoadingString[256]; // LTSNPrintF( szSession, LTARRAYSIZE(szSession), L"%s", g_pClientConnectionMgr->GetStartGameRequest().m_pNetSession->m_sName ); if ( !LTStrEmpty(g_pClientConnectionMgr->GetServerName())) { LTSNPrintF( szLoadingString, LTARRAYSIZE(szLoadingString), L"%s: %s", LoadString("IDS_CONNECTING_TO_SERVER"), g_pClientConnectionMgr->GetServerName() ); } else { LTSNPrintF( szLoadingString, LTARRAYSIZE(szLoadingString), L"%s", LoadString("IDS_CONNECTING_TO_SERVER")); } m_MissionName.SetFont(g_CurrentLayout.m_sLevelFont); m_MissionName.SetString(szLoadingString); LTSNPrintF( szLoadingString, LTARRAYSIZE(szLoadingString), L" (%S)", g_pClientConnectionMgr->GetStartGameRequest( ).m_TCPAddress ); m_LevelName.SetString(szLoadingString); } // Local game, set the mission descriptor to the level name. else { m_MissionName.SetFont(g_CurrentLayout.m_sTitleFont); if (g_pGameClientShell->IsRunningPerformanceTest()) { m_MissionName.SetString(LoadString( "IDS_TITLE_PERFORMANCE_TEST" )); m_LevelName.SetString(L""); } else { m_MissionName.SetString(LoadString( "IDS_CUSTOM_LEVEL" )); // Split the worldname up into parts so we can get the load string. wchar_t szWorldTitle[MAX_PATH] = L""; _wsplitpath( MPA2W(g_pMissionMgr->GetCurrentWorldName( )).c_str(), NULL, NULL, szWorldTitle, NULL ); m_LevelName.SetString(szWorldTitle); } } }
bool SoundNonPoint::AllObjectsCreated() { // resolve the object links. Basically, get the sound zone volumes // and collect their info into the non-point sound object that // gets created on the client. ObjArray <HOBJECT, 1> objArray; int32 i; m_SCS.m_nNumZones = 0; for (i=0; i < MAX_SOUND_VOLUMES; i++) { SoundZoneVolume* pSZV; if(!LTStrEmpty(m_sSoundZone[i].c_str())) { g_pLTServer->FindNamedObjects(m_sSoundZone[i].c_str(), objArray); if(objArray.NumObjects() > 0) { if (IsKindOf(objArray.GetObject(0), "SoundZoneVolume")) { HOBJECT hObj; hObj = objArray.GetObject(0); pSZV = (SoundZoneVolume*) g_pLTServer->HandleToObject(hObj); // do a type check before casting... if (pSZV) { g_pLTServer->GetObjectPos(hObj, &m_SCS.m_SoundZone[m_SCS.m_nNumZones].m_vPos); g_pLTServer->GetObjectRotation(hObj, &m_SCS.m_SoundZone[m_SCS.m_nNumZones].m_rRotation); m_SCS.m_SoundZone[m_SCS.m_nNumZones].m_vHalfDims = pSZV->GetHalfDims(); m_SCS.m_nNumZones++; } } } } } return true; }
void CDestructibleModel::CreateDestroyedFX(const DamageStruct& DamageInfo) { // If no destroyed fx is specifed, return... if ( LTStrEmpty( m_pszDestroyedFXName ) || !LTStrICmp(m_pszDestroyedFXName, FX_NONE)) return; // Use the position/rotation of the object for the fx... LTRigidTransform tObjTrans; g_pLTServer->GetObjectTransform(m_hObject, &tObjTrans); CAutoMessage cMsg; cMsg.Writeuint8(SFX_CLIENTFXGROUPINSTANT); cMsg.WriteString(m_pszDestroyedFXName); cMsg.Writebool( false ); // loop cMsg.Writebool( false ); // smooth shutdown cMsg.Writebool( false ); // No special parent cMsg.WriteLTVector(tObjTrans.m_vPos); cMsg.WriteCompLTRotation(tObjTrans.m_rRot); cMsg.Writebool( false ); // No target info g_pLTServer->SendSFXMessage(cMsg.Read(), 0); }
void CClientWeaponMgr::InitCustomWeapons() { for ( int i = 0; i < m_nMaxWeapons; ++i ) { CClientWeapon* pWeapon = m_apClientWeapon[ i ]; if ( pWeapon ) { // check to see if this is a custom weapon by check for a custom select stimulus // which is used to bring the custom weapon up. HWEAPON hWeapon = pWeapon->GetWeaponRecord(); HWEAPONDATA hWpnData = g_pWeaponDB->GetWeaponData(hWeapon, !USE_AI_DATA); const char* pszCustomSelect = g_pWeaponDB->GetString(hWpnData, WDB_WEAPON_CustomSelectStimulus); bool bCustomWeapon = !LTStrEmpty(pszCustomSelect) && LTStrCmp(pszCustomSelect, "None")!=0; if (bCustomWeapon) { pWeapon->Activate(); pWeapon->SetDisable(false); pWeapon->SetVisible(false); } } } }
// ----------------------------------------------------------------------- // // // ROUTINE: TeamClientFX::ReadProp // // PURPOSE: Read in the properties of the object... // // ----------------------------------------------------------------------- // bool TeamClientFX::ReadProp( const GenericPropList *pProps ) { char const* pszTeamClientFX = pProps->GetString( "TeamClientFX", "" ); if( LTStrEmpty( pszTeamClientFX )) return false; m_hTeamClientFXRec = DATABASE_CATEGORY( TeamClientFX ).GetRecordByName( pszTeamClientFX ); if( !m_hTeamClientFXRec ) return false; if( GameModeMgr::Instance( ).m_grbUseTeams ) { const char *pszTeam = pProps->GetString( "Team", "" ); m_nTeamId = TeamStringToTeamId( pszTeam ); } else { // Not useful without a team mode. return false; } return true; }
// create strings const wchar_t* CreateHelpString(const char *pszStringID) { static std::wstring wsTmp; wsTmp = LoadString(pszStringID); uint32 nFirst = wsTmp.find_first_of(L"|"); while (nFirst != std::wstring::npos) { uint32 nNext = wsTmp.find_first_of(L"|", nFirst+1); if (nNext != std::wstring::npos && nNext) { uint32 nLen = nNext-nFirst; std::wstring wsAction; if (nLen >= 2) { wsAction = wsTmp.substr(nFirst+1,nLen-1); } wsTmp.erase(nFirst,nLen+1); CUserProfile *pProfile = g_pProfileMgr->GetCurrentProfile(); int nCommand = GetCommandID( MPW2A(wsAction.c_str()).c_str() ); wchar_t szTriggerName[32] = L""; LTStrCpy(szTriggerName,pProfile->GetTriggerNameFromCommandID(nCommand),LTARRAYSIZE(szTriggerName)); if (LTStrEmpty(szTriggerName)) { LTStrCpy(szTriggerName,LoadString("Control_Unassigned"),LTARRAYSIZE(szTriggerName)); } wsTmp.insert(nFirst,szTriggerName); } nFirst = wsTmp.find_first_of(L"|"); } return wsTmp.c_str(); }
// Add a character to the end void CLTGUIEditCtrl::AddCharacter(wchar_t c) { //add 1 for trailing 0 uint32 len = LTStrLen(m_Text.GetText()) + 1; // Check to see are at our buffer limit if (len >= m_nMaxLength) return; // strip out leading whitespace which confuses things if (LTStrEmpty(m_Text.GetText( )) && c == ' ') return; LTStrCpy(szString, m_Text.GetText(), LTARRAYSIZE(szString)); uint32 nIndex = LTStrLen(szString); while (nIndex > m_nCaretPos) { szString[nIndex] = szString[nIndex-1]; nIndex--; } szString[nIndex] = c; m_nCaretPos++; m_Text.SetText(szString); LTRect2n rExt; LTRESULT res = m_Text.GetExtents(rExt); if (res == LT_OK) { if (rExt.GetWidth() > int32(GetWidth()) ) { m_nCaretPos--; RemoveCharacter(); } } }
void CNamedObjectList::ReadProp(const GenericPropList *pProps, const char* pszObjectType) { // Read list of objects. This list may start at either 0 or 1, so ignore a // blank first string. uint32 iObject = 0; char szBuffer[128]; LTSNPrintF( szBuffer, LTARRAYSIZE( szBuffer ), "%s%d", pszObjectType, iObject ); const char* pszPropString = pProps->GetString( szBuffer, "" ); while( pszPropString[0] || iObject == 0 ) { if ( !LTStrEmpty(pszPropString) ) { std::string sTmp; sTmp = pszPropString; m_lstObjectNames.push_back( sTmp ); } ++iObject; LTSNPrintF( szBuffer, LTARRAYSIZE( szBuffer ), "%s%d", pszObjectType, iObject ); pszPropString = pProps->GetString( szBuffer, "" ); } }
void CScreenHostLevels::LoadMissionList() { // Sanity checks... if (!m_pSelMissions) return; char szMissionName[256]; uint8 numMissions = 0; for( ;; ) { if( !GameModeMgr::Instance( ).GetMissionByIndex( g_pProfileMgr->GetCurrentProfile( )->m_sServerOptionsFile.c_str( ), numMissions, szMissionName, LTARRAYSIZE( szMissionName ))) break; // Stop as soon as the mission entries end. if( LTStrEmpty( szMissionName )) break; HRECORD hMissionRec = g_pLTDatabase->GetRecord( g_pMissionDB->GetMissionCat( ), szMissionName ); int nMissionId = g_pLTDatabase->GetRecordIndex( hMissionRec ); AddMissionToList(nMissionId,false,true); numMissions++; } }
// --------------------------------------------------------------------------- // // // ROUTINE: LaunchApplication::LaunchFromString // // PURPOSE: Runs a start command. // // --------------------------------------------------------------------------- // bool LaunchApplication::LaunchFromString( char const* pszFile, char const* pszParameters, bool bMaximize, bool bShutdownCurrentApp ) { #if defined(PLATFORM_WIN32) RMode rMode; // Check inputs. if( LTStrEmpty( pszFile )) return false; // Check if the input is a file. char szFileName[MAX_PATH] = ""; LTFileOperations::SplitPath( pszFile, NULL, szFileName, NULL ); if( !LTStrEmpty( szFileName )) { // Make sure the file exists. if( !LTFileOperations::FileExists( pszFile )) return false; } // Save the current render mode. We'll need to restore it if the serverapp // launching fails. g_pLTClient->GetRenderMode( &rMode ); // Shutdown the renderer, minimize it, and hide it... if( bShutdownCurrentApp ) { g_pLTClient->ShutdownRender( RSHUTDOWN_MINIMIZEWINDOW | RSHUTDOWN_HIDEWINDOW ); } // Not shutting down, but we'll need to make sure to minimize. Just executing the new app // doesn't always make it foreground. else { extern HWND g_hMainWnd; ShowWindow(g_hMainWnd, SW_MINIMIZE); } SHELLEXECUTEINFO ShExecInfo = {0}; ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO); ShExecInfo.fMask = 0; ShExecInfo.hwnd = NULL; ShExecInfo.lpVerb = "open"; ShExecInfo.lpFile = pszFile; ShExecInfo.lpParameters = pszParameters; ShExecInfo.lpDirectory = NULL; ShExecInfo.nShow = bMaximize ? SW_SHOWMAXIMIZED : SW_SHOWNORMAL; ShExecInfo.hInstApp = NULL; if( !ShellExecuteEx(&ShExecInfo)) { // Serverapp failed. Restore the render mode. if( bShutdownCurrentApp ) g_pLTClient->SetRenderMode( &rMode ); return false; } if( bShutdownCurrentApp ) { // We're done with this process. g_pLTClient->Shutdown(); } return true; #elif defined(PLATFORM_XENON) // XENON: Not yet implemented return false; #else // New platforms must re-implement this function #error Undefined platform encountered in LaunchFromString return false; #endif }
bool CHUDSubtitles::Show(const char* szStringId, LTVector vSpeakerPos, float fRadius, float fDuration, bool bSubtitlePriority) { // Only show subtitles if conversations in range... LTVector vListenerPos; bool bListenerInClient; LTRotation rRot; g_pLTClient->GetListener(&bListenerInClient, &vListenerPos, &rRot); LTVector vPos = vSpeakerPos - vListenerPos; float fAdjustedRadius = fRadius * g_vtAdjustedRadius.GetFloat(); float fDist = vPos.Mag(); if (vSpeakerPos == LTVector(0, 0, 0)) fDist = 0.0f; //should we override what ever is already playing? if (m_bVisible) { //if the old one has priority, and the new doesn't, don't play the new if (m_bSubtitlePriority && !bSubtitlePriority) { return false; } //if they have the same priority, check distances if (m_bSubtitlePriority == bSubtitlePriority) { LTVector vOldPos = m_vSpeakerPos - vListenerPos; float fOldDist = vOldPos.Mag(); if (m_vSpeakerPos == LTVector(0, 0, 0)) fOldDist = 0.0f; if (fOldDist < fDist) { return false; } } } const wchar_t *pStr = LoadString(szStringId); if (LTStrEmpty(pStr)) { DebugCPrint(2,"CHUDSubtitles::Show(%s) : No Text",szStringId); return false; } m_Text.SetText(pStr); m_bVisible = true; m_bSubtitlePriority = bSubtitlePriority; m_vSpeakerPos = vSpeakerPos; m_fRadius = fRadius; m_fDuration = fDuration; if (m_fDuration < 0.0f) m_fDuration = 0.04f * (float)LTStrLen(m_Text.GetText()); LTVector2n pos = m_vBasePos; uint32 width = m_nWidth; /* if( g_pPlayerMgr->GetPlayerCamera()->GetCameraMode() == CPlayerCamera::kCM_Cinematic ) { pos = m_CinematicPos; width = m_nCinematicWidth; } */ LTVector2 vfScale = g_pInterfaceResMgr->GetScreenScale(); uint32 x = (uint32)((float)pos.x * vfScale.x); uint32 y = (uint32)((float)pos.y * vfScale.y); width = (uint32 )((float)width * vfScale.x); uint32 height = (2 + m_nMaxLines * m_sTextFont.m_nHeight) ; float fFontHeight = (float)m_sTextFont.m_nHeight; m_Rect.Init(x,y,x+width,y+height); m_Text.WordWrap(m_Rect.GetWidth()); float textX = (float)m_Rect.Left(); float textY = (float)m_Rect.Top(); LTRect2n rExt; m_Text.CreateTexture(); m_Text.GetExtents(rExt); uint32 numLines = (uint32)(rExt.GetHeight() / fFontHeight); if (numLines > m_nMaxLines) { m_bOverflow = true; float fTimePerLine = m_fDuration / ((float)numLines + 1.0f); float fDelay = (float)m_nMaxLines * fTimePerLine; m_fScrollStartTime = fDelay; m_fScrollSpeed = fFontHeight / fTimePerLine; m_fMaxOffset = (float)(rExt.GetHeight() - m_Rect.GetHeight()); } else { m_bOverflow = false; textX += (float)(m_Rect.GetWidth() - width) / 2.0f; m_fOffset = (float)(m_Rect.GetHeight() - height); textY += m_fOffset; m_fScrollSpeed = 0.0f; } m_fEndTime = m_fDuration; //reset our time to the beginning m_fElapsedTime = 0.0f; m_Text.SetPos(LTVector2(textX,textY)); return true; }
void CTargetMgr::Update() { // Do any necessary initialization... if (m_bFirstUpdate) { FirstUpdate(); m_bFirstUpdate = false; } g_pPlayerStats->UpdateMaxProgress( 0 ); g_pPlayerStats->UpdateProgress( 0 ); // Start fresh ClearTargetInfo(); //see what we've looking at float fDistAway = kMaxDistance; CheckForIntersect(fDistAway); m_fTargetRange = fDistAway; if (!m_hTarget) { //nothing to see here SpecialMoveMgr::Instance().HandleLookedAt(NULL); return; } // If its a Character's hitbox, 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; } CLadderFX *pLadder = g_pGameClientShell->GetSFXMgr()->GetLadderFX(m_hTarget); if (pLadder && LadderMgr::Instance().CanReachLadder(pLadder)) { m_ActivationData.m_hTarget = m_hTarget; m_ActivationData.m_nType = MID_ACTIVATE_LADDER; return; } CTurretFX *pTurret = g_pGameClientShell->GetSFXMgr( )->GetTurretFX( m_hTarget ); if( pTurret && pTurret->CanActivate( )) { m_ActivationData.m_hTarget = m_hTarget; m_ActivationData.m_nType = MID_ACTIVATE_TURRET; return; } CSpecialMoveFX *pSpecialMove = g_pGameClientShell->GetSFXMgr()->GetSpecialMoveFX(m_hTarget); if (pSpecialMove) { SpecialMoveMgr::Instance().HandleLookedAt(pSpecialMove); if (SpecialMoveMgr::Instance().CanReach(pSpecialMove)) { m_ActivationData.m_hTarget = m_hTarget; m_ActivationData.m_nType = MID_ACTIVATE_SPECIALMOVE; return; } } else { SpecialMoveMgr::Instance().HandleLookedAt(NULL); } if( m_ActivationData.m_hActivateSnd ) { m_ActivationData.m_nType = MID_ACTIVATE_SURFACESND; } CClientWeapon* pCurrentWeapon = g_pPlayerMgr->GetClientWeaponMgr()->GetCurrentClientWeapon(); uint32 dwUserFlags = 0; g_pCommonLT->GetObjectFlags(m_hTarget, OFT_User, dwUserFlags); // is this a person we can talk to? if(( !(dwUserFlags & USRFLG_CAN_ACTIVATE) && m_ActivationData.m_nType != MID_ACTIVATE_SURFACESND ) || (fDistAway > g_vtActivationDistance.GetFloat()) ) { m_ActivationData.m_hTarget = NULL; } // 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->IsPlayerAlive() || (g_pPlayerMgr->GetMoveMgr()->GetVehicleMgr()->CanShowCrosshair() ? false : true); //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() ) { g_pHUDDebug->SetTargetDebugString(pFX->GetInfoString()); } else { g_pHUDDebug->SetTargetDebugString(L""); } // 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 (IsMultiplayerGameClient() && 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_szStringID = NULL; LTStrCpy(m_wszString, pCI->sName.c_str(), LTARRAYSIZE(m_wszString)); if (GameModeMgr::Instance( ).m_grbUseTeams) { 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(pFX) { if (fDistAway <= g_vtTargetDistance.GetFloat()) { // If a nameid was specified for the model display the name... const char* szNameId = g_pModelsDB->GetModelNameId( pFX->m_cs.hModel ); if( szNameId && (szNameId[0] != '\0') ) { //SetTargetStringID( nNameId ); return; } } } } } // See if this object is part of the activate object list with it's own string ID's... if( fDistAway <= g_vtActivationDistance.GetFloat() ) { const CActivateObjectHandler *pActivateObj = CActivateObjectHandler::FindActivateObject( m_hTarget ); if( pActivateObj ) { // See whether or not it's disabled m_bCanActivate = !pActivateObj->m_bDisabled; // Fetch the proper string from the database depending on the state... HRECORD hRecord = DATABASE_CATEGORY( Activate ).GetRecordByIndex( pActivateObj->m_nId ); HATTRIBUTE hStates = DATABASE_CATEGORY( Activate ).GETRECORDSTRUCT( hRecord, States ); const char* pszStringID = DATABASE_CATEGORY( Activate ).GETSTRUCTATTRIB( States, hStates, pActivateObj->m_eState, HudText ); if( !LTStrEmpty( pszStringID ) ) { SetTargetStringID( pszStringID ); } 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; } }
// Utility function to do work. bool LaunchApplication::LaunchMainExe( char const* pszExeName, SwitchToScreen eSwitchToScreen ) { #if defined(PLATFORM_WIN32) // Rebuild the commandline args without the current process. char szCommandLineArgs[MAX_PATH]; szCommandLineArgs[0] = '\0'; for( int32 nIndex = 1; nIndex < __argc; nIndex++ ) { // Skip any screen arguments that the current process was launched with. if( LTStrIEquals( __argv[nIndex], "+screen" )) { // Skip the screen name parameter. nIndex++; continue; } if( !LTStrEmpty( szCommandLineArgs )) { LTStrCat( szCommandLineArgs, " ", LTARRAYSIZE( szCommandLineArgs )); } LTStrCat( szCommandLineArgs, __argv[nIndex], LTARRAYSIZE( szCommandLineArgs )); } // Check if we are switching to a specific screen. char const* pszSwitchToScreenName = NULL; switch( eSwitchToScreen ) { default: case kSwitchToScreen_None: break; case kSwitchToScreen_Single: pszSwitchToScreenName = "single"; break; case kSwitchToScreen_Multi: pszSwitchToScreenName = "multi"; break; case kSwitchToScreen_Performance: pszSwitchToScreenName = "performance"; break; } // Add the screen to the commandline. if( !LTStrEmpty( pszSwitchToScreenName )) { if( !LTStrEmpty( szCommandLineArgs )) { LTStrCat( szCommandLineArgs, " +screen ", LTARRAYSIZE( szCommandLineArgs )); } else { LTStrCat( szCommandLineArgs, "+screen ", LTARRAYSIZE( szCommandLineArgs )); } // Add any additional commandline. LTStrCat( szCommandLineArgs, pszSwitchToScreenName, LTARRAYSIZE( szCommandLineArgs )); } // Launch the exe. return LaunchFromString( pszExeName, szCommandLineArgs, true, true ); #else return false; #endif }
//called to emit a batch of particles given the properties void CParticleSystemGroup::EmitParticleBatch(float fUnitLifetime, float fUpdateTime, const LTRigidTransform& tObjTrans) { LTASSERT(m_pProps, "Error: Called EmitParticleBatch on an uninitialized particle group"); //determine the number of particles that we are going to emit (and bail if we aren't going to emit any) uint32 nParticlesToEmit = m_pProps->m_nfcParticlesPerEmission.GetValue(fUnitLifetime); if(nParticlesToEmit == 0) return; LTMatrix3x4 mMat; tObjTrans.ToMatrix(mMat); float fPercentToBounce = m_pProps->m_ffcPercentToBounce.GetValue(fUnitLifetime); float fPercentToSplat = m_pProps->m_ffcPercentToSplat.GetValue(fUnitLifetime); float fMinLifetime = m_pProps->m_ffcMinLifetime.GetValue(fUnitLifetime); float fMaxLifetime = m_pProps->m_ffcMinLifetime.GetValue(fUnitLifetime); float fMinRadius = m_pProps->m_ffcMinRadius.GetValue(fUnitLifetime); float fMaxRadius = m_pProps->m_ffcMaxRadius.GetValue(fUnitLifetime); LTVector vEmissionOffset = m_pProps->m_vfcEmissionOffset.GetValue(fUnitLifetime); LTVector vEmissionDims = m_pProps->m_vfcEmissionDims.GetValue(fUnitLifetime); LTVector vMinVelocity = m_pProps->m_vfcMinVelocity.GetValue(fUnitLifetime); LTVector vMaxVelocity = m_pProps->m_vfcMaxVelocity.GetValue(fUnitLifetime); //apply the global particle scale if appropriate if(m_pProps->m_bEnableBounceScale) { fPercentToBounce *= g_vtParticleBounceScale.GetFloat(1.0f); fPercentToSplat *= g_vtParticleBounceScale.GetFloat(1.0f); } //determine if we will be bouncing or splatting (avoids some expensive fcmps) bool bBounceParticles = (fPercentToBounce > 0.001f); bool bSplatParticles = (fPercentToSplat > 0.001f) && !LTStrEmpty(m_pProps->m_pszSplatEffect); //run through and add all of the particles for( uint32 nCurrParticle = 0; nCurrParticle < nParticlesToEmit; nCurrParticle++ ) { SParticle* pParticle = (SParticle*)m_Particles.AllocateParticle(); if(!pParticle) { //we are out of memory break; } LTVector vPos = GenerateObjectSpaceParticlePos(vEmissionOffset, vEmissionDims, fMinRadius, fMaxRadius); LTVector vVel = GenerateObjectSpaceParticleVel(m_pProps->m_eVelocityType, vPos, vMinVelocity, vMaxVelocity); //convert velocity and position into world space if (!m_pProps->m_bObjectSpace) { vPos = mMat * vPos; vVel = mMat.Transform3x3(vVel); } float fParticleLifespan = GetRandom( fMinLifetime, fMaxLifetime ); // Try and add the new particle to the system pParticle->m_Pos = vPos; pParticle->m_Velocity = vVel; pParticle->m_fLifetime = fParticleLifespan; pParticle->m_fTotalLifetime = fParticleLifespan; pParticle->m_nUserData = rand() % m_pProps->m_nNumImages; // Randomize the angle information if needed if(m_pProps->m_bRotate) { pParticle->m_fAngle = GetRandom(0.0f, MATH_CIRCLE); pParticle->m_fAngularVelocity = GetRandom(m_pProps->m_fMinAngularVelocity, m_pProps->m_fMaxAngularVelocity); } else { pParticle->m_fAngle = 0.0f; pParticle->m_fAngularVelocity = 0.0f; } //determine if we want this particle to bounce if(bBounceParticles && (GetRandom(0.0f, 100.0f) < fPercentToBounce)) { //this particle should bounce pParticle->m_nUserData |= PARTICLE_BOUNCE; m_nNumRayTestParticles++; } //determine if we want this particle to splat if(bSplatParticles && (GetRandom(0.0f, 100.0f) < fPercentToSplat)) { //this particle should bounce pParticle->m_nUserData |= PARTICLE_SPLAT; m_nNumRayTestParticles++; } } //add a batch marker for this group AddParticleBatchMarker(fUpdateTime, false); }
void CHUDActivateObject::SetObject( LTObjRef iObjRef, uint32 nNewType ) { // Check to see if this is a valid activate object... if( nNewType == AOT_INVALID ) { if( m_iObjRef.GetData() ) { m_iObjRef = NULL; m_nUserFlags = 0; m_pActivateObject = NULL; // Reset the fade time... if( m_fEffectTime <= 0 ) m_fEffectTime = m_fFadeTime; else m_fEffectTime = m_fFadeTime - m_fEffectTime; } return; } m_Text.SetText(CreateHelpString("Training_Action")); if( m_iObjRef != iObjRef ) { // A new object is being targeted... m_iObjRef = iObjRef; m_fEffectTime = m_fFadeTime; // Cache the activate object, if it has one... m_pActivateObject = CActivateObjectHandler::FindActivateObject( iObjRef ); } // Assign the new activate object... m_iObjRef = iObjRef; g_pLTClient->Common()->GetObjectFlags( m_iObjRef.GetData(), OFT_User, m_nUserFlags ); m_nType = nNewType; // fetch any specific textures switch( nNewType ) { case AOT_GENERAL: { bool bUseFallbackIcon = true; if( m_pActivateObject ) { HRECORD hRecord; HATTRIBUTE hStates; const char* pszHUDTexture = NULL; uint32 dwColor = m_cIconColor; // Fetch the proper string from the database depending on the state... hRecord = DATABASE_CATEGORY( Activate ).GetRecordByIndex( m_pActivateObject->m_nId ); if( hRecord ) { hStates = DATABASE_CATEGORY( Activate ).GETRECORDSTRUCT( hRecord, States ); if( hStates ) { pszHUDTexture = DATABASE_CATEGORY( Activate ).GETSTRUCTATTRIB( States, hStates, m_pActivateObject->m_eState, HudIcon ); } // If a separate disabled icon is listed use that instead of the state icon... if( m_pActivateObject->m_bDisabled ) { const char *pszDisabledIcon = DATABASE_CATEGORY( Activate ).GETRECORDATTRIB( hRecord, DisabledIcon ); if( !LTStrEmpty( pszDisabledIcon )) pszHUDTexture = pszDisabledIcon; // Use the disabled color of the icon... dwColor = DATABASE_CATEGORY( Activate ).GETRECORDATTRIB( hRecord, DisabledColor ); } } // Set the color, alpha will be changed by the fade effect... DrawPrimSetRGBA( m_ObjectRect, dwColor ); // Set the alpha value to fade into... m_dwEffectAlpha = GETA(dwColor); if( !LTStrEmpty( pszHUDTexture ) ) { bUseFallbackIcon = false; // Don't change to the same icon... if( !LTStrIEquals( m_sObjectsIcon.c_str( ), pszHUDTexture )) { // Reset the effect time and load the new icon... m_sObjectsIcon = pszHUDTexture; m_aObjects[ AOT_GENERAL ].Load( pszHUDTexture ); } } } else { // Use the default icon color... DrawPrimSetRGBA( m_ObjectRect, m_cIconColor ); m_dwEffectAlpha = GETA(m_cIconColor); } if( bUseFallbackIcon ) { // If no specific activate type was specified, use the fallback... m_aObjects[AOT_GENERAL] = m_aFallbacks[AOT_GENERAL]; m_sObjectsIcon.clear( ); } } break; case AOT_PICKUP: { // generic fallback texture m_aObjects[AOT_PICKUP] = m_aFallbacks[AOT_PICKUP]; // get the client side pickup item CPickupItemFX* pPickupItemFX = static_cast< CPickupItemFX* >( g_pGameClientShell->GetSFXMgr()->FindSpecialFX( SFX_PICKUPITEM_ID, iObjRef )); if (pPickupItemFX && pPickupItemFX->GetPickupItemType( ) == kPickupItemType_Weapon ) { // get pickup object record HRECORD hPickupType = pPickupItemFX->GetTypeRecord(); if( hPickupType ) { // get weapon data of pickup object HWEAPONDATA hWpnData = g_pWeaponDB->GetWeaponData( hPickupType, !USE_AI_DATA ); if( hWpnData ) { // get hud texture from weapon data const char* szTexture = g_pWeaponDB->GetString(hWpnData,WDB_WEAPON_sHUDTexture); if( !LTStrEmpty( szTexture )) { m_aObjects[ AOT_PICKUP ].Load( szTexture ); m_bObjectTextureValid = false; } } } } } break; default: break; } }