void CASW_Location_Group::LoadFromKeyValues( KeyValues *pKeys ) { m_iRequiredUnlocks = pKeys->GetInt( "RequiredUnlocks", 0 ); m_Color = pKeys->GetColor( "Color" ); m_szGroupName = TileGenCopyString( pKeys->GetString( "Name" ) ); m_szTitleText = TileGenCopyString( pKeys->GetString( "TitleText" ) ); m_szDescriptionText = TileGenCopyString( pKeys->GetString( "DescriptionText" ) ); m_szImageName = TileGenCopyString( pKeys->GetString( "ImageName" ) ); // check all keys for unlock IDs m_UnlockedBy.Purge(); m_Locations.PurgeAndDeleteElements(); for ( KeyValues *pSubKey = pKeys->GetFirstSubKey(); pSubKey; pSubKey = pSubKey->GetNextKey() ) { if ( !Q_stricmp( pSubKey->GetName(), "UnlockMissionID" ) ) { m_UnlockedBy.AddToTail( pSubKey->GetInt() ); } else if ( !Q_stricmp( pSubKey->GetName(), "Location" ) ) { CASW_Location *pLocation = new CASW_Location( m_pLocationGrid ); pLocation->LoadFromKeyValues( pSubKey, &m_Random ); pLocation->m_pGroup = this; m_Locations.AddToTail( pLocation ); } } }
bool CASW_Reward::LoadFromKeyValues( KeyValues *pKeys, int iMissionDifficulty ) { if ( !Q_stricmp( pKeys->GetName(), "MoneyReward") ) { m_RewardType = ASW_REWARD_MONEY; m_iRewardAmount = pKeys->GetInt(); return true; } else if ( !Q_stricmp( pKeys->GetName(), "XPReward") ) { m_RewardType = ASW_REWARD_XP; //TODO: this was the previous average of how much XP you got with the Tier system per objective. // we probably want a more robust system for determining the amount of XP we want to reward on the mission m_iRewardAmount = pKeys->GetInt( NULL, 400 * iMissionDifficulty ); if ( m_iRewardAmount == 0 ) { m_iRewardAmount = 400 * iMissionDifficulty; } return true; } else if ( !Q_stricmp( pKeys->GetName(), "ItemReward") ) { m_RewardType = ASW_REWARD_ITEM; m_iRewardAmount = 0; m_szRewardName = TileGenCopyString( pKeys->GetString( "ItemName" ) ); m_iRewardLevel = pKeys->GetInt( "ItemLevel" ); m_iRewardQuality = pKeys->GetInt( "ItemQuality" ); } return false; }
void VMFExporter::ExportError( const char *pMsg, ... ) { char msg[4096]; va_list marker; va_start( marker, pMsg ); Q_vsnprintf( msg, sizeof( msg ), pMsg, marker ); va_end( marker ); m_ExportErrors.AddToTail( TileGenCopyString( msg ) ); }
void CASW_Location::LoadFromKeyValues( KeyValues *pKeys, CUniformRandomStream* pStream) { m_iXPos = pKeys->GetInt( "x" ); m_iYPos = pKeys->GetInt( "y" ); Q_strcpy( m_szMapName, "random" ); m_iMinDifficulty = pKeys->GetInt( "MinDifficulty", 1 ); m_iMaxDifficulty = pKeys->GetInt( "MaxDifficulty", 100 ); m_iCompanyIndex = pKeys->GetInt( "Company", 0 ); m_bIsMissionOptional = !!pKeys->GetInt( "Optional", 1 ); m_iLocationID = pKeys->GetInt( "ID", -1 ); m_pszCustomMission = TileGenCopyString( pKeys->GetString( "CustomMission" ) ); m_szStoryScene = TileGenCopyString( pKeys->GetString( "StoryScene" ) ) ? TileGenCopyString( pKeys->GetString( "StoryScene" ) ) : "spaceport_crashsite"; m_szImageName = TileGenCopyString( pKeys->GetString( "ImageName" ) ) ? TileGenCopyString( pKeys->GetString( "ImageName" ) ) : "swarm/MissionPics/PlantMissionpic.vmt"; if ( m_pszCustomMission ) { Q_FixSlashes( m_pszCustomMission ); } // pick a difficulty between the bounds m_iDifficulty = pStream->RandomInt( m_iMinDifficulty, m_iMaxDifficulty ); if ( m_pszCustomMission && m_pszCustomMission[0] ) { m_pMissionKV = m_pLocationGrid->GetMissionData( m_pszCustomMission ); } if ( m_pMissionKV ) { // Make a copy so we can modify it m_pMissionKV = m_pMissionKV->MakeCopy(); // Fill out mission settings from the mission grid data so it gets into the .layout file if ( GetMissionSettings() ) { GetMissionSettings()->SetInt( "Difficulty", m_iDifficulty ); const char *pMissionName = m_pszCustomMission; if ( Q_strnicmp( m_pszCustomMission, "tilegen/new_missions/", Q_strlen( "tilegen/new_missions/" ) ) == 0 ) { pMissionName += Q_strlen( "tilegen/new_missions/" ); } GetMissionSettings()->SetString( "Filename", m_pszCustomMission + Q_strlen( "tilegen/new_missions/" ) ); GetMissionSettings()->SetInt( "GridLocationID", m_iLocationID ); } } // if mission doesn't have a valid ID then find one if ( m_iLocationID == -1 ) { m_iLocationID = LocationGrid()->GetFreeLocationID(); } KeyValues *pRewards = pKeys->FindKey( "Rewards" ); if ( pRewards ) { for ( KeyValues *pRewardKey = pRewards->GetFirstSubKey(); pRewardKey; pRewardKey = pRewardKey->GetNextKey() ) { CASW_Reward *pReward = new CASW_Reward(); if ( pReward->LoadFromKeyValues( pRewardKey, m_iDifficulty ) ) { m_Rewards.AddToTail( pReward ); } else { delete pReward; } } } else { // TODO: Create some default rewards? } }