Skip to content

Commit

Permalink
VS2008 Part 2
Browse files Browse the repository at this point in the history
  • Loading branch information
CasualDev242 committed Sep 18, 2014
1 parent a9d8eef commit 81b1477
Show file tree
Hide file tree
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.
107 changes: 107 additions & 0 deletions xrGame/AI_PhraseDialogManager.cpp
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);
}
39 changes: 39 additions & 0 deletions xrGame/AI_PhraseDialogManager.h
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;
};
68 changes: 68 additions & 0 deletions xrGame/ActivatingCharCollisionDelay.cpp
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;

}
18 changes: 18 additions & 0 deletions xrGame/ActivatingCharCollisionDelay.h
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();
};
Loading

0 comments on commit 81b1477

Please sign in to comment.