/*void map_add_object_spot_complex(u16 id, LPCSTR spot_name, LPCSTR hint, LPCSTR left_icon, LPCSTR right_icon, LPCSTR top_icon, int time_end ) { CMapLocation* ml = Level().MapManager().AddMapLocation(spot_name,id); R_ASSERT2( ml, spot_name ); R_ASSERT2( ml->complex_spot(), spot_name ); ml->complex_spot()->SetTTL( time_end ); if ( hint && xr_strlen(hint) ) { ml->SetHint(hint); } if ( left_icon && xr_strlen(left_icon) ) { ml->complex_spot()->SetLeftTexture(left_icon); } if ( right_icon && xr_strlen(right_icon) ) { ml->complex_spot()->SetRightTexture(right_icon); } if ( top_icon && xr_strlen(top_icon) ) { ml->complex_spot()->SetTopTexture(top_icon); } } */ void map_add_object_spot_ser(u16 id, LPCSTR spot_type, LPCSTR text) { CMapLocation* ml = Level().MapManager().AddMapLocation(spot_type,id); if( xr_strlen(text) ) ml->SetHint(text); ml->SetSerializable(true); }
void CGameTaskManager::UpdateActiveTask () { GameTasks_it it = GameTasks().begin(); GameTasks_it it_e = GameTasks().end(); bool bHasSpotPointer = false; for( ;it!=it_e; ++it ) { CGameTask* t = (*it).game_task; if( t->Objective(0).TaskState() != eTaskStateInProgress ) continue; for(u32 i=0; i<t->m_Objectives.size() ;++i) { SGameTaskObjective& obj = t->Objective(i); //1-st enable hidden locations if( (!obj.def_location_enabled) && (obj.TaskState()==eTaskStateInProgress) && (t->Objective(i-1).TaskState()==eTaskStateCompleted) ) { if(obj.object_id!=u16(-1) && *obj.map_location) { CMapLocation* ml = Level().MapManager().AddMapLocation(obj.map_location, obj.object_id); if(obj.map_hint.size()) ml->SetHint(obj.map_hint); ml->DisablePointer (); ml->SetSerializable (true); } } bHasSpotPointer = bHasSpotPointer || (ActiveObjective()==&t->Objective(i)); } } // highlight new spot pointer if( !bHasSpotPointer ) { bool bDone =false; GameTasks::iterator it = GameTasks().begin(); GameTasks::iterator it_e = GameTasks().end(); for( ;(it!=it_e)&&(!bDone); ++it ) { CGameTask* t = (*it).game_task; if(t->Objective(0).TaskState()!=eTaskStateInProgress) continue; for(u16 i=0; (i<t->m_Objectives.size())&&(!bDone) ;++i) { if( (i==0) || (t->Objective(i).TaskState() != eTaskStateInProgress) ) continue; SetActiveTask (t->m_ID, i); bDone = true; } } } m_flags.set (eChanged, FALSE); }
CGameTask* CGameTaskManager::GiveGameTaskToActor(CGameTask* t, u32 timeToComplete, bool bCheckExisting) { if(bCheckExisting && HasGameTask(t->m_ID)) return NULL; m_flags.set (eChanged, TRUE); GameTasks().push_back (SGameTaskKey(t->m_ID) ); GameTasks().back().game_task = t; t->m_ReceiveTime = Level().GetGameTime(); t->m_TimeToComplete = t->m_ReceiveTime + timeToComplete; std::sort (GameTasks().begin(), GameTasks().end(), task_prio_pred); ARTICLE_VECTOR& article_vector = Actor()->encyclopedia_registry->registry().objects(); SGameTaskObjective *obj = NULL; for (u32 i = 0; i < t->m_Objectives.size(); ++i){ obj = &t->m_Objectives[i]; if(obj->article_id.size()){ FindArticleByIDPred pred(obj->article_id); if( std::find_if(article_vector.begin(), article_vector.end(), pred) == article_vector.end() ){ CEncyclopediaArticle article; article.Load(obj->article_id); article_vector.push_back(ARTICLE_DATA(obj->article_id, Level().GetGameTime(), article.data()->articleType)); } } if(obj->object_id!=u16(-1) && obj->map_location.size() && obj->def_location_enabled){ CMapLocation* ml = Level().MapManager().AddMapLocation(obj->map_location, obj->object_id); if(obj->map_hint.size()) ml->SetHint(obj->map_hint); ml->DisablePointer (); ml->SetSerializable (true); } } CGameTask* _at = ActiveTask(); if ( (NULL==_at) || (_at->m_priority > t->m_priority) ) { SetActiveTask(t->m_ID, 1); } //установить флажок необходимости прочтения тасков в PDA if(HUD().GetUI()){ CUIGameSP* pGameSP = smart_cast<CUIGameSP*>(HUD().GetUI()->UIGame()); if(pGameSP) pGameSP->PdaMenu->PdaContentsChanged (pda_section::quests); } if(true /*t->m_ID!="user_task"*/) t->Objective(0).ChangeStateCallback(); return t; }