5
5
//
6
6
// /////////////////////////////////////////////////////////////
7
7
8
- #include " stdafx.h"
9
8
#include " AI_PhraseDialogManager.h"
10
9
#include " PhraseDialog.h"
11
- #include " inventoryowner.h"
12
10
#include " character_info.h"
13
11
#include " gameobject.h"
12
+ #include " inventoryowner.h"
14
13
#include " relation_registry.h"
14
+ #include " stdafx.h"
15
15
16
- CAI_PhraseDialogManager::CAI_PhraseDialogManager (void )
16
+ CAI_PhraseDialogManager::CAI_PhraseDialogManager (void )
17
17
{
18
- m_sStartDialog = m_sDefaultStartDialog = NULL ;
18
+ m_sStartDialog = m_sDefaultStartDialog = NULL ;
19
19
}
20
20
21
- CAI_PhraseDialogManager::~CAI_PhraseDialogManager (void )
22
- {}
21
+ CAI_PhraseDialogManager::~CAI_PhraseDialogManager (void )
22
+ {
23
+ }
23
24
24
- // PhraseDialogManager
25
- void CAI_PhraseDialogManager::ReceivePhrase (DIALOG_SHARED_PTR& phrase_dialog)
25
+ // PhraseDialogManager
26
+ void CAI_PhraseDialogManager::ReceivePhrase (DIALOG_SHARED_PTR& phrase_dialog)
26
27
{
27
- AnswerPhrase (phrase_dialog);
28
- CPhraseDialogManager::ReceivePhrase (phrase_dialog);
28
+ AnswerPhrase (phrase_dialog);
29
+ CPhraseDialogManager::ReceivePhrase (phrase_dialog);
29
30
}
30
- #include " uigamesp.h"
31
31
#include " Level.h"
32
32
#include " ui/UItalkWnd.h"
33
+ #include " uigamesp.h"
33
34
34
- void CAI_PhraseDialogManager::AnswerPhrase (DIALOG_SHARED_PTR& phrase_dialog)
35
+ void CAI_PhraseDialogManager::AnswerPhrase (DIALOG_SHARED_PTR& phrase_dialog)
35
36
{
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
+ }
77
75
}
78
76
79
-
80
-
81
77
void CAI_PhraseDialogManager::SetStartDialog (shared_str phrase_dialog)
82
78
{
83
- m_sStartDialog = phrase_dialog;
79
+ m_sStartDialog = phrase_dialog;
84
80
}
85
81
86
82
void CAI_PhraseDialogManager::SetDefaultStartDialog (shared_str phrase_dialog)
87
83
{
88
- m_sDefaultStartDialog = phrase_dialog;
84
+ m_sDefaultStartDialog = phrase_dialog;
89
85
}
90
86
91
87
void CAI_PhraseDialogManager::RestoreDefaultStartDialog ()
92
88
{
93
- m_sStartDialog = m_sDefaultStartDialog;
89
+ m_sStartDialog = m_sDefaultStartDialog;
94
90
}
95
91
92
+ void CAI_PhraseDialogManager::UpdateAvailableDialogs (CPhraseDialogManager* partner)
93
+ {
94
+ m_AvailableDialogs.clear ();
95
+ m_CheckedDialogs.clear ();
96
96
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);
105
99
106
- inherited::UpdateAvailableDialogs (partner);
100
+ inherited::UpdateAvailableDialogs (partner);
107
101
}
0 commit comments