-
-
Notifications
You must be signed in to change notification settings - Fork 460
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a9d8eef
commit 81b1477
Showing
4,520 changed files
with
894,776 additions
and
0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/////////////////////////////////////////////////////////////// | ||
// AI_PhraseDialogManager.cpp | ||
// Êëàññ, îò êîòîðîãî íàñëåäóþòñÿ NPC ïåðñîíàæè, âåäóùèå äèàëîã | ||
// ñ àêòåðîì | ||
// | ||
/////////////////////////////////////////////////////////////// | ||
|
||
#include "stdafx.h" | ||
#include "AI_PhraseDialogManager.h" | ||
#include "PhraseDialog.h" | ||
#include "inventoryowner.h" | ||
#include "character_info.h" | ||
#include "gameobject.h" | ||
#include "relation_registry.h" | ||
|
||
CAI_PhraseDialogManager::CAI_PhraseDialogManager (void) | ||
{ | ||
m_sStartDialog = m_sDefaultStartDialog = NULL; | ||
} | ||
|
||
CAI_PhraseDialogManager::~CAI_PhraseDialogManager (void) | ||
{} | ||
|
||
//PhraseDialogManager | ||
void CAI_PhraseDialogManager::ReceivePhrase (DIALOG_SHARED_PTR& phrase_dialog) | ||
{ | ||
AnswerPhrase(phrase_dialog); | ||
CPhraseDialogManager::ReceivePhrase(phrase_dialog); | ||
} | ||
#include "uigamesp.h" | ||
#include "level.h" | ||
#include "ui/UItalkWnd.h" | ||
|
||
void CAI_PhraseDialogManager::AnswerPhrase (DIALOG_SHARED_PTR& phrase_dialog) | ||
{ | ||
CInventoryOwner* pInvOwner = smart_cast<CInventoryOwner*>(this); | ||
THROW (pInvOwner); | ||
CGameObject* pOthersGO = smart_cast<CGameObject*>(phrase_dialog->OurPartner(this)); | ||
THROW (pOthersGO); | ||
CInventoryOwner* pOthersIO = smart_cast<CInventoryOwner*>(pOthersGO); | ||
THROW (pOthersIO); | ||
|
||
if(!phrase_dialog->IsFinished()) | ||
{ | ||
CHARACTER_GOODWILL attitude = RELATION_REGISTRY().GetAttitude(pOthersIO, pInvOwner); | ||
|
||
xr_vector<int> phrases; | ||
CHARACTER_GOODWILL phrase_goodwill = NO_GOODWILL; | ||
//åñëè íå íàéäåì áîëåå ïîäõîäÿåùåé âûâîäèì ôðàçó | ||
//ïîñëåäíþþ èç ñïèñêà (ñàìóþ ãðóáóþ) | ||
int phrase_num = phrase_dialog->PhraseList().size()-1; | ||
for(u32 i=0; i<phrase_dialog->PhraseList().size(); ++i) | ||
{ | ||
phrase_goodwill = phrase_dialog->PhraseList()[phrase_num]->GoodwillLevel(); | ||
if(attitude >= phrase_goodwill) | ||
{ | ||
phrase_num = i; | ||
break; | ||
} | ||
} | ||
|
||
for(i=0; i<phrase_dialog->PhraseList().size(); i++) | ||
{ | ||
if(phrase_goodwill == phrase_dialog->PhraseList()[phrase_num]->GoodwillLevel()) | ||
phrases.push_back(i); | ||
} | ||
|
||
phrase_num = phrases[Random.randI(0, phrases.size())]; | ||
|
||
shared_str phrase_id = phrase_dialog->PhraseList()[phrase_num]->GetID(); | ||
|
||
CUIGameSP* pGameSP = smart_cast<CUIGameSP*>(CurrentGameUI()); | ||
pGameSP->TalkMenu->AddAnswer (phrase_dialog->GetPhraseText(phrase_id), pInvOwner->Name()); | ||
|
||
CPhraseDialogManager::SayPhrase(phrase_dialog, phrase_id); | ||
} | ||
} | ||
|
||
|
||
|
||
void CAI_PhraseDialogManager::SetStartDialog(shared_str phrase_dialog) | ||
{ | ||
m_sStartDialog = phrase_dialog; | ||
} | ||
|
||
void CAI_PhraseDialogManager::SetDefaultStartDialog(shared_str phrase_dialog) | ||
{ | ||
m_sDefaultStartDialog = phrase_dialog; | ||
} | ||
|
||
void CAI_PhraseDialogManager::RestoreDefaultStartDialog() | ||
{ | ||
m_sStartDialog = m_sDefaultStartDialog; | ||
} | ||
|
||
|
||
void CAI_PhraseDialogManager::UpdateAvailableDialogs (CPhraseDialogManager* partner) | ||
{ | ||
m_AvailableDialogs.clear(); | ||
m_CheckedDialogs.clear(); | ||
|
||
if(*m_sStartDialog) | ||
inherited::AddAvailableDialog(*m_sStartDialog, partner); | ||
inherited::AddAvailableDialog("hello_dialog", partner); | ||
|
||
inherited::UpdateAvailableDialogs(partner); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/////////////////////////////////////////////////////////////// | ||
// AI_PhraseDialogManager.h | ||
// Êëàññ, îò êîòîðîãî íàñëåäóþòñÿ NPC ïåðñîíàæè, âåäóùèå äèàëîã | ||
// ñ àêòåðîì | ||
// | ||
/////////////////////////////////////////////////////////////// | ||
|
||
#pragma once | ||
|
||
#include "PhraseDialogManager.h" | ||
|
||
|
||
class CAI_PhraseDialogManager: public CPhraseDialogManager | ||
{ | ||
private: | ||
typedef CPhraseDialogManager inherited; | ||
public: | ||
CAI_PhraseDialogManager (); | ||
virtual ~CAI_PhraseDialogManager (); | ||
|
||
virtual void ReceivePhrase (DIALOG_SHARED_PTR& phrase_dialog); | ||
virtual void UpdateAvailableDialogs (CPhraseDialogManager* partner); | ||
virtual void AnswerPhrase (DIALOG_SHARED_PTR& phrase_dialog); | ||
|
||
|
||
virtual void SetStartDialog (shared_str phrase_dialog); | ||
virtual void SetDefaultStartDialog (shared_str phrase_dialog); | ||
virtual shared_str GetStartDialog () {return m_sStartDialog;} | ||
virtual void RestoreDefaultStartDialog (); | ||
protected: | ||
//äèàëîã, åñëè íå NULL, òî åãî ïåðñîíàæ çàïóñòèò | ||
//ïðè âñòðå÷å ñ àêòåðîì | ||
shared_str m_sStartDialog; | ||
shared_str m_sDefaultStartDialog; | ||
|
||
DEFINE_VECTOR(DIALOG_SHARED_PTR, DIALOG_SHARED_VECTOR, DIALOG_SHARED_IT); | ||
//ñïèñîê äèàëîãîâ, íà êîòîðûå íóæíî îòâåòèòü | ||
DIALOG_SHARED_VECTOR m_PendingDialogs; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#include "stdafx.h" | ||
|
||
#include "activatingcharcollisiondelay.h" | ||
#include "characterphysicssupport.h" | ||
#include "phmovementcontrol.h" | ||
#ifdef DEBUG | ||
#include "phdebug.h" | ||
#endif | ||
activating_character_delay::activating_character_delay(CCharacterPhysicsSupport *char_support_): | ||
char_support(*char_support_), | ||
activate_time(Device.dwTimeGlobal + delay ) | ||
{ | ||
VERIFY(char_support_); | ||
VERIFY(char_support.movement()); | ||
VERIFY( !char_support.movement()->CharacterExist() ); | ||
} | ||
bool activating_character_delay::active() | ||
{ | ||
VERIFY(char_support.movement()); | ||
return !char_support.movement()->CharacterExist(); | ||
} | ||
void activating_character_delay::update() | ||
{ | ||
if(!active()) | ||
return; | ||
|
||
if( Device.dwTimeGlobal < activate_time ) | ||
return; | ||
|
||
if( do_position_correct() ) | ||
char_support.CreateCharacter(); | ||
|
||
activate_time = Device.dwTimeGlobal + delay; | ||
} | ||
|
||
|
||
bool activating_character_delay::do_position_correct() | ||
{ | ||
CPHMovementControl *m = char_support.movement(); | ||
VERIFY( m ); | ||
|
||
CObject *obj = m->ParentObject(); | ||
#ifdef DEBUG | ||
CEntityAlive* e_alife =smart_cast<CEntityAlive*>(obj); | ||
VERIFY(e_alife); | ||
VERIFY(!e_alife->PPhysicsShell()); | ||
VERIFY(e_alife->g_Alive()); | ||
#endif | ||
VERIFY( obj ); | ||
Fvector sv_pos = obj->Position(); | ||
bool ret = char_support.CollisionCorrectObjPos(); | ||
if(!ret) | ||
obj->Position().set(sv_pos); | ||
#if 0 | ||
else | ||
{ | ||
DBG_OpenCashedDraw(); | ||
DBG_DrawMatrix( obj->XFORM(), 1.f ); | ||
Fmatrix m = obj->XFORM(); | ||
m.c = sv_pos; | ||
DBG_DrawMatrix( m, 0.5f ); | ||
DBG_DrawLine( obj->Position(), m.c, D3DCOLOR_XRGB( 255, 255, 255 ) ); | ||
DBG_ClosedCashedDraw(50000); | ||
} | ||
#endif | ||
return ret; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#pragma once | ||
|
||
#include <boost/noncopyable.hpp> | ||
|
||
class CCharacterPhysicsSupport; | ||
class activating_character_delay: | ||
private boost::noncopyable | ||
{ | ||
CCharacterPhysicsSupport &char_support; | ||
u32 activate_time; | ||
static const u32 delay = 3000; | ||
public: | ||
activating_character_delay(CCharacterPhysicsSupport *char_support_); | ||
void update(); | ||
bool active(); | ||
private: | ||
bool do_position_correct(); | ||
}; |
Oops, something went wrong.