This commit is contained in:
parent
2c54c59bdd
commit
2ca7da9ba7
5 changed files with 69 additions and 2 deletions
|
@ -26,15 +26,24 @@ CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] =
|
||||||
{
|
{
|
||||||
NPC_INIT_DEFAULT,
|
NPC_INIT_DEFAULT,
|
||||||
NPC_SENSOR_NONE,
|
NPC_SENSOR_NONE,
|
||||||
NPC_MOVEMENT_VERTICAL,
|
NPC_MOVEMENT_STATIC,
|
||||||
NPC_MOVEMENT_MODIFIER_NONE,
|
NPC_MOVEMENT_MODIFIER_NONE,
|
||||||
|
false,
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
NPC_INIT_DEFAULT,
|
||||||
|
NPC_SENSOR_NONE,
|
||||||
|
NPC_MOVEMENT_STATIC,
|
||||||
|
NPC_MOVEMENT_MODIFIER_NONE,
|
||||||
|
true,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void CNpc::init()
|
void CNpc::init()
|
||||||
{
|
{
|
||||||
m_type = NPC_TEST_TYPE;
|
m_type = NPC_SANDY_CHEEKS;
|
||||||
|
|
||||||
switch ( m_data[this->m_type].initFunc )
|
switch ( m_data[this->m_type].initFunc )
|
||||||
{
|
{
|
||||||
|
@ -173,3 +182,32 @@ void CNpc::processTimer()
|
||||||
void CNpc::render()
|
void CNpc::render()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CNpc::processEvent( GAME_EVENT evt, CThing *sourceThing )
|
||||||
|
{
|
||||||
|
CConversation *currentConversation = GameScene.getConversation();
|
||||||
|
|
||||||
|
if ( m_data[this->m_type].canTalk )
|
||||||
|
{
|
||||||
|
DVECTOR sourcePos;
|
||||||
|
int xDiffSqr, yDiffSqr;
|
||||||
|
|
||||||
|
// check talk distance
|
||||||
|
|
||||||
|
sourcePos = sourceThing->getPos();
|
||||||
|
|
||||||
|
xDiffSqr = this->Pos.vx - sourcePos.vx;
|
||||||
|
xDiffSqr *= xDiffSqr;
|
||||||
|
|
||||||
|
yDiffSqr = this->Pos.vy - sourcePos.vy;
|
||||||
|
yDiffSqr *= yDiffSqr;
|
||||||
|
|
||||||
|
if ( xDiffSqr + yDiffSqr < 250 )
|
||||||
|
{
|
||||||
|
if( !currentConversation->isActive() )
|
||||||
|
{
|
||||||
|
currentConversation->trigger( SCRIPTS_SPEECHTEST_DAT );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ public:
|
||||||
void shutdown();
|
void shutdown();
|
||||||
void think(int _frames);
|
void think(int _frames);
|
||||||
virtual void render();
|
virtual void render();
|
||||||
|
void processEvent( GAME_EVENT evt, CThing *sourceThing );
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -24,6 +25,7 @@ protected:
|
||||||
enum NPC_UNIT_TYPE
|
enum NPC_UNIT_TYPE
|
||||||
{
|
{
|
||||||
NPC_TEST_TYPE = 0,
|
NPC_TEST_TYPE = 0,
|
||||||
|
NPC_SANDY_CHEEKS = 1,
|
||||||
NPC_UNIT_TYPE_MAX,
|
NPC_UNIT_TYPE_MAX,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -69,6 +71,7 @@ protected:
|
||||||
NPC_SENSOR_FUNC sensorFunc;
|
NPC_SENSOR_FUNC sensorFunc;
|
||||||
NPC_MOVEMENT_FUNC movementFunc;
|
NPC_MOVEMENT_FUNC movementFunc;
|
||||||
NPC_MOVEMENT_MODIFIER_FUNC movementModifierFunc;
|
NPC_MOVEMENT_MODIFIER_FUNC movementModifierFunc;
|
||||||
|
bool canTalk;
|
||||||
}
|
}
|
||||||
NPC_DATA;
|
NPC_DATA;
|
||||||
|
|
||||||
|
|
|
@ -129,3 +129,15 @@ CPlayer * CGameScene::getPlayer()
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
void CGameScene::sendEvent( GAME_EVENT evt, CThing *sourceThing )
|
||||||
|
{
|
||||||
|
CThing::processEventAllThings(evt, sourceThing);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
CConversation * CGameScene::getConversation ()
|
||||||
|
{
|
||||||
|
return( &m_conversation );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
|
@ -12,6 +12,14 @@
|
||||||
#include "game\convo.h"
|
#include "game\convo.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef __GAME_EVENT_H__
|
||||||
|
#include "game\event.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __GAME_THING_H__
|
||||||
|
#include "game\thing.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
class FontBank;
|
class FontBank;
|
||||||
|
|
||||||
|
@ -31,6 +39,8 @@ virtual ~CGameScene() {;}
|
||||||
|
|
||||||
static MATRIX *GetCamMtx() {return(&CamMtx);}
|
static MATRIX *GetCamMtx() {return(&CamMtx);}
|
||||||
class CPlayer *getPlayer();
|
class CPlayer *getPlayer();
|
||||||
|
CConversation *getConversation();
|
||||||
|
void sendEvent( GAME_EVENT evt, CThing *sourceThing );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
|
@ -241,6 +241,10 @@ SOURCE=..\..\..\source\game\convo.h
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=..\..\..\source\game\event.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=..\..\..\source\game\game.cpp
|
SOURCE=..\..\..\source\game\game.cpp
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
Loading…
Add table
Reference in a new issue