55//
66// /////////////////////////////////////////////////////////////
77
8- #include " stdafx.h"
98#include " AI_PhraseDialogManager.h"
109#include " PhraseDialog.h"
11- #include " inventoryowner.h"
1210#include " character_info.h"
1311#include " gameobject.h"
12+ #include " inventoryowner.h"
1413#include " relation_registry.h"
14+ #include " stdafx.h"
1515
16- CAI_PhraseDialogManager::CAI_PhraseDialogManager (void )
16+ CAI_PhraseDialogManager::CAI_PhraseDialogManager (void )
1717{
18- m_sStartDialog = m_sDefaultStartDialog = NULL ;
18+ m_sStartDialog = m_sDefaultStartDialog = NULL ;
1919}
2020
21- CAI_PhraseDialogManager::~CAI_PhraseDialogManager (void )
22- {}
21+ CAI_PhraseDialogManager::~CAI_PhraseDialogManager (void )
22+ {
23+ }
2324
24- // PhraseDialogManager
25- void CAI_PhraseDialogManager::ReceivePhrase (DIALOG_SHARED_PTR& phrase_dialog)
25+ // PhraseDialogManager
26+ void CAI_PhraseDialogManager::ReceivePhrase (DIALOG_SHARED_PTR& phrase_dialog)
2627{
27- AnswerPhrase (phrase_dialog);
28- CPhraseDialogManager::ReceivePhrase (phrase_dialog);
28+ AnswerPhrase (phrase_dialog);
29+ CPhraseDialogManager::ReceivePhrase (phrase_dialog);
2930}
30- #include " uigamesp.h"
3131#include " Level.h"
3232#include " ui/UItalkWnd.h"
33+ #include " uigamesp.h"
3334
34- void CAI_PhraseDialogManager::AnswerPhrase (DIALOG_SHARED_PTR& phrase_dialog)
35+ void CAI_PhraseDialogManager::AnswerPhrase (DIALOG_SHARED_PTR& phrase_dialog)
3536{
36- CInventoryOwner* pInvOwner = smart_cast<CInventoryOwner*>(this );
37- THROW (pInvOwner);
38- CGameObject* pOthersGO = smart_cast<CGameObject*>(phrase_dialog->OurPartner (this ));
39- THROW (pOthersGO);
40- CInventoryOwner* pOthersIO = smart_cast<CInventoryOwner*>(pOthersGO);
41- THROW (pOthersIO);
42-
43- if (!phrase_dialog->IsFinished ())
44- {
45- CHARACTER_GOODWILL attitude = RELATION_REGISTRY ().GetAttitude (pOthersIO, pInvOwner);
46-
47- xr_vector<int > phrases;
48- CHARACTER_GOODWILL phrase_goodwill = NO_GOODWILL;
49- // åñëè íå íàéäåì áîëåå ïîäõîäÿåùåé âûâîäèì ôðàçó
50- // ïîñëåäíþþ èç ñïèñêà (ñàìóþ ãðóáóþ)
51- int phrase_num = phrase_dialog->PhraseList ().size ()-1 ;
52- for (u32 i=0 ; i<phrase_dialog->PhraseList ().size (); ++i)
53- {
54- phrase_goodwill = phrase_dialog->PhraseList ()[phrase_num]->GoodwillLevel ();
55- if (attitude >= phrase_goodwill)
56- {
57- phrase_num = i;
58- break ;
59- }
60- }
61-
62- for (u32 i=0 ; i<phrase_dialog->PhraseList ().size (); i++)
63- {
64- if (phrase_goodwill == phrase_dialog->PhraseList ()[phrase_num]->GoodwillLevel ())
65- phrases.push_back (i);
66- }
67-
68- phrase_num = phrases[Random.randI (0 , phrases.size ())];
69-
70- shared_str phrase_id = phrase_dialog->PhraseList ()[phrase_num]->GetID ();
71-
72- CUIGameSP* pGameSP = smart_cast<CUIGameSP*>(CurrentGameUI ());
73- pGameSP->TalkMenu ->AddAnswer (phrase_dialog->GetPhraseText (phrase_id), pInvOwner->Name ());
74-
75- CPhraseDialogManager::SayPhrase (phrase_dialog, phrase_id);
76- }
37+ CInventoryOwner* pInvOwner = smart_cast<CInventoryOwner*>(this );
38+ THROW (pInvOwner);
39+ CGameObject* pOthersGO = smart_cast<CGameObject*>(phrase_dialog->OurPartner (this ));
40+ THROW (pOthersGO);
41+ CInventoryOwner* pOthersIO = smart_cast<CInventoryOwner*>(pOthersGO);
42+ THROW (pOthersIO);
43+
44+ if (!phrase_dialog->IsFinished ()) {
45+ CHARACTER_GOODWILL attitude = RELATION_REGISTRY ().GetAttitude (pOthersIO, pInvOwner);
46+
47+ xr_vector<int > phrases;
48+ CHARACTER_GOODWILL phrase_goodwill = NO_GOODWILL;
49+ // åñëè íå íàéäåì áîëåå ïîäõîäÿåùåé âûâîäèì ôðàçó
50+ // ïîñëåäíþþ èç ñïèñêà (ñàìóþ ãðóáóþ)
51+ int phrase_num = phrase_dialog->PhraseList ().size () - 1 ;
52+ for (u32 i = 0 ; i < phrase_dialog->PhraseList ().size (); ++i)
53+ {
54+ phrase_goodwill = phrase_dialog->PhraseList ()[phrase_num]->GoodwillLevel ();
55+ if (attitude >= phrase_goodwill) {
56+ phrase_num = i;
57+ break ;
58+ }
59+ }
60+
61+ for (u32 i = 0 ; i < phrase_dialog->PhraseList ().size (); i++)
62+ {
63+ if (phrase_goodwill == phrase_dialog->PhraseList ()[phrase_num]->GoodwillLevel ()) phrases.push_back (i);
64+ }
65+
66+ phrase_num = phrases[Random.randI (0 , phrases.size ())];
67+
68+ shared_str phrase_id = phrase_dialog->PhraseList ()[phrase_num]->GetID ();
69+
70+ CUIGameSP* pGameSP = smart_cast<CUIGameSP*>(CurrentGameUI ());
71+ pGameSP->TalkMenu ->AddAnswer (phrase_dialog->GetPhraseText (phrase_id), pInvOwner->Name ());
72+
73+ CPhraseDialogManager::SayPhrase (phrase_dialog, phrase_id);
74+ }
7775}
7876
79-
80-
8177void CAI_PhraseDialogManager::SetStartDialog (shared_str phrase_dialog)
8278{
83- m_sStartDialog = phrase_dialog;
79+ m_sStartDialog = phrase_dialog;
8480}
8581
8682void CAI_PhraseDialogManager::SetDefaultStartDialog (shared_str phrase_dialog)
8783{
88- m_sDefaultStartDialog = phrase_dialog;
84+ m_sDefaultStartDialog = phrase_dialog;
8985}
9086
9187void CAI_PhraseDialogManager::RestoreDefaultStartDialog ()
9288{
93- m_sStartDialog = m_sDefaultStartDialog;
89+ m_sStartDialog = m_sDefaultStartDialog;
9490}
9591
92+ void CAI_PhraseDialogManager::UpdateAvailableDialogs (CPhraseDialogManager* partner)
93+ {
94+ m_AvailableDialogs.clear ();
95+ m_CheckedDialogs.clear ();
9696
97- void CAI_PhraseDialogManager::UpdateAvailableDialogs (CPhraseDialogManager* partner)
98- {
99- m_AvailableDialogs.clear ();
100- m_CheckedDialogs.clear ();
101-
102- if (*m_sStartDialog)
103- inherited::AddAvailableDialog (*m_sStartDialog, partner);
104- inherited::AddAvailableDialog (" hello_dialog" , partner);
97+ if (*m_sStartDialog) inherited::AddAvailableDialog (*m_sStartDialog, partner);
98+ inherited::AddAvailableDialog (" hello_dialog" , partner);
10599
106- inherited::UpdateAvailableDialogs (partner);
100+ inherited::UpdateAvailableDialogs (partner);
107101}
0 commit comments