Skip to content

Commit 81b1477

Browse files
committed
VS2008 Part 2
1 parent a9d8eef commit 81b1477

File tree

4,520 files changed

+894776
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

4,520 files changed

+894776
-0
lines changed

xrGame/AI_PhraseDialogManager.cpp

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
///////////////////////////////////////////////////////////////
2+
// AI_PhraseDialogManager.cpp
3+
// Êëàññ, îò êîòîðîãî íàñëåäóþòñÿ NPC ïåðñîíàæè, âåäóùèå äèàëîã
4+
// ñ àêòåðîì
5+
//
6+
///////////////////////////////////////////////////////////////
7+
8+
#include "stdafx.h"
9+
#include "AI_PhraseDialogManager.h"
10+
#include "PhraseDialog.h"
11+
#include "inventoryowner.h"
12+
#include "character_info.h"
13+
#include "gameobject.h"
14+
#include "relation_registry.h"
15+
16+
CAI_PhraseDialogManager::CAI_PhraseDialogManager (void)
17+
{
18+
m_sStartDialog = m_sDefaultStartDialog = NULL;
19+
}
20+
21+
CAI_PhraseDialogManager::~CAI_PhraseDialogManager (void)
22+
{}
23+
24+
//PhraseDialogManager
25+
void CAI_PhraseDialogManager::ReceivePhrase (DIALOG_SHARED_PTR& phrase_dialog)
26+
{
27+
AnswerPhrase(phrase_dialog);
28+
CPhraseDialogManager::ReceivePhrase(phrase_dialog);
29+
}
30+
#include "uigamesp.h"
31+
#include "level.h"
32+
#include "ui/UItalkWnd.h"
33+
34+
void CAI_PhraseDialogManager::AnswerPhrase (DIALOG_SHARED_PTR& phrase_dialog)
35+
{
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(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+
}
77+
}
78+
79+
80+
81+
void CAI_PhraseDialogManager::SetStartDialog(shared_str phrase_dialog)
82+
{
83+
m_sStartDialog = phrase_dialog;
84+
}
85+
86+
void CAI_PhraseDialogManager::SetDefaultStartDialog(shared_str phrase_dialog)
87+
{
88+
m_sDefaultStartDialog = phrase_dialog;
89+
}
90+
91+
void CAI_PhraseDialogManager::RestoreDefaultStartDialog()
92+
{
93+
m_sStartDialog = m_sDefaultStartDialog;
94+
}
95+
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);
105+
106+
inherited::UpdateAvailableDialogs(partner);
107+
}

xrGame/AI_PhraseDialogManager.h

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
///////////////////////////////////////////////////////////////
2+
// AI_PhraseDialogManager.h
3+
// Êëàññ, îò êîòîðîãî íàñëåäóþòñÿ NPC ïåðñîíàæè, âåäóùèå äèàëîã
4+
// ñ àêòåðîì
5+
//
6+
///////////////////////////////////////////////////////////////
7+
8+
#pragma once
9+
10+
#include "PhraseDialogManager.h"
11+
12+
13+
class CAI_PhraseDialogManager: public CPhraseDialogManager
14+
{
15+
private:
16+
typedef CPhraseDialogManager inherited;
17+
public:
18+
CAI_PhraseDialogManager ();
19+
virtual ~CAI_PhraseDialogManager ();
20+
21+
virtual void ReceivePhrase (DIALOG_SHARED_PTR& phrase_dialog);
22+
virtual void UpdateAvailableDialogs (CPhraseDialogManager* partner);
23+
virtual void AnswerPhrase (DIALOG_SHARED_PTR& phrase_dialog);
24+
25+
26+
virtual void SetStartDialog (shared_str phrase_dialog);
27+
virtual void SetDefaultStartDialog (shared_str phrase_dialog);
28+
virtual shared_str GetStartDialog () {return m_sStartDialog;}
29+
virtual void RestoreDefaultStartDialog ();
30+
protected:
31+
//äèàëîã, åñëè íå NULL, òî åãî ïåðñîíàæ çàïóñòèò
32+
//ïðè âñòðå÷å ñ àêòåðîì
33+
shared_str m_sStartDialog;
34+
shared_str m_sDefaultStartDialog;
35+
36+
DEFINE_VECTOR(DIALOG_SHARED_PTR, DIALOG_SHARED_VECTOR, DIALOG_SHARED_IT);
37+
//ñïèñîê äèàëîãîâ, íà êîòîðûå íóæíî îòâåòèòü
38+
DIALOG_SHARED_VECTOR m_PendingDialogs;
39+
};
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#include "stdafx.h"
2+
3+
#include "activatingcharcollisiondelay.h"
4+
#include "characterphysicssupport.h"
5+
#include "phmovementcontrol.h"
6+
#ifdef DEBUG
7+
#include "phdebug.h"
8+
#endif
9+
activating_character_delay::activating_character_delay(CCharacterPhysicsSupport *char_support_):
10+
char_support(*char_support_),
11+
activate_time(Device.dwTimeGlobal + delay )
12+
{
13+
VERIFY(char_support_);
14+
VERIFY(char_support.movement());
15+
VERIFY( !char_support.movement()->CharacterExist() );
16+
}
17+
bool activating_character_delay::active()
18+
{
19+
VERIFY(char_support.movement());
20+
return !char_support.movement()->CharacterExist();
21+
}
22+
void activating_character_delay::update()
23+
{
24+
if(!active())
25+
return;
26+
27+
if( Device.dwTimeGlobal < activate_time )
28+
return;
29+
30+
if( do_position_correct() )
31+
char_support.CreateCharacter();
32+
33+
activate_time = Device.dwTimeGlobal + delay;
34+
}
35+
36+
37+
bool activating_character_delay::do_position_correct()
38+
{
39+
CPHMovementControl *m = char_support.movement();
40+
VERIFY( m );
41+
42+
CObject *obj = m->ParentObject();
43+
#ifdef DEBUG
44+
CEntityAlive* e_alife =smart_cast<CEntityAlive*>(obj);
45+
VERIFY(e_alife);
46+
VERIFY(!e_alife->PPhysicsShell());
47+
VERIFY(e_alife->g_Alive());
48+
#endif
49+
VERIFY( obj );
50+
Fvector sv_pos = obj->Position();
51+
bool ret = char_support.CollisionCorrectObjPos();
52+
if(!ret)
53+
obj->Position().set(sv_pos);
54+
#if 0
55+
else
56+
{
57+
DBG_OpenCashedDraw();
58+
DBG_DrawMatrix( obj->XFORM(), 1.f );
59+
Fmatrix m = obj->XFORM();
60+
m.c = sv_pos;
61+
DBG_DrawMatrix( m, 0.5f );
62+
DBG_DrawLine( obj->Position(), m.c, D3DCOLOR_XRGB( 255, 255, 255 ) );
63+
DBG_ClosedCashedDraw(50000);
64+
}
65+
#endif
66+
return ret;
67+
68+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#pragma once
2+
3+
#include <boost/noncopyable.hpp>
4+
5+
class CCharacterPhysicsSupport;
6+
class activating_character_delay:
7+
private boost::noncopyable
8+
{
9+
CCharacterPhysicsSupport &char_support;
10+
u32 activate_time;
11+
static const u32 delay = 3000;
12+
public:
13+
activating_character_delay(CCharacterPhysicsSupport *char_support_);
14+
void update();
15+
bool active();
16+
private:
17+
bool do_position_correct();
18+
};

0 commit comments

Comments
 (0)