| 29 | #include "ui/UItalkWnd.h" |
| 30 | |
| 31 | void CAI_PhraseDialogManager::AnswerPhrase(DIALOG_SHARED_PTR& phrase_dialog) |
| 32 | { |
| 33 | CInventoryOwner* pInvOwner = smart_cast<CInventoryOwner*>(this); |
| 34 | THROW(pInvOwner); |
| 35 | CGameObject* pOthersGO = smart_cast<CGameObject*>(phrase_dialog->OurPartner(this)); |
| 36 | THROW(pOthersGO); |
| 37 | CInventoryOwner* pOthersIO = smart_cast<CInventoryOwner*>(pOthersGO); |
| 38 | THROW(pOthersIO); |
| 39 | |
| 40 | if (!phrase_dialog->IsFinished()) |
| 41 | { |
| 42 | CHARACTER_GOODWILL attitude = RELATION_REGISTRY().GetAttitude(pOthersIO, pInvOwner); |
| 43 | |
| 44 | xr_vector<int> phrases; |
| 45 | CHARACTER_GOODWILL phrase_goodwill = NO_GOODWILL; |
| 46 | //если не найдем более подходяещей выводим фразу |
| 47 | //последнюю из списка (самую грубую) |
| 48 | int phrase_num = phrase_dialog->PhraseList().size() - 1; |
| 49 | for (u32 i = 0; i < phrase_dialog->PhraseList().size(); ++i) |
| 50 | { |
| 51 | phrase_goodwill = phrase_dialog->PhraseList()[i]->GoodwillLevel(); |
| 52 | if (attitude >= phrase_goodwill) |
| 53 | { |
| 54 | phrase_num = i; |
| 55 | break; |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | for (u32 i = 0; i < phrase_dialog->PhraseList().size(); i++) |
| 60 | { |
| 61 | if (phrase_goodwill == phrase_dialog->PhraseList()[i]->GoodwillLevel()) |
| 62 | phrases.push_back(i); |
| 63 | } |
| 64 | |
| 65 | phrase_num = phrases[Random.randI(0, phrases.size())]; |
| 66 | |
| 67 | shared_str phrase_id = phrase_dialog->PhraseList()[phrase_num]->GetID(); |
| 68 | |
| 69 | CUIGameSP* pGameSP = smart_cast<CUIGameSP*>(HUD().GetUI()->UIGame()); |
| 70 | pGameSP->TalkMenu->AddAnswer(phrase_dialog->GetPhraseText(phrase_id), pInvOwner->Name()); |
| 71 | |
| 72 | CPhraseDialogManager::SayPhrase(phrase_dialog, phrase_id); |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | void CAI_PhraseDialogManager::SetStartDialog(shared_str phrase_dialog) { m_sStartDialog = phrase_dialog; } |
| 77 |
nothing calls this directly
no test coverage detected