MCPcopy Create free account
hub / github.com/OGSR/OGSR-Engine / AnswerPhrase

Method AnswerPhrase

ogsr_engine/xrGame/AI_PhraseDialogManager.cpp:31–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29#include "ui/UItalkWnd.h"
30
31void 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
76void CAI_PhraseDialogManager::SetStartDialog(shared_str phrase_dialog) { m_sStartDialog = phrase_dialog; }
77

Callers

nothing calls this directly

Calls 14

RELATION_REGISTRYClass · 0.85
OurPartnerMethod · 0.80
IsFinishedMethod · 0.80
GoodwillLevelMethod · 0.80
randIMethod · 0.80
UIGameMethod · 0.80
GetUIMethod · 0.80
GetPhraseTextMethod · 0.80
GetAttitudeMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45
GetIDMethod · 0.45

Tested by

no test coverage detected