From 2ca7da9ba7b2fcafbe6a069b37516a07176b4ec4 Mon Sep 17 00:00:00 2001 From: Charles Date: Tue, 16 Jan 2001 20:55:44 +0000 Subject: [PATCH] --- source/enemy/npc.cpp | 42 ++++++++++++++++++- source/enemy/npc.h | 3 ++ source/game/game.cpp | 12 ++++++ source/game/game.h | 10 +++++ .../spongebob project/spongebob project.dsp | 4 ++ 5 files changed, 69 insertions(+), 2 deletions(-) diff --git a/source/enemy/npc.cpp b/source/enemy/npc.cpp index a904ae330..2158d9c50 100644 --- a/source/enemy/npc.cpp +++ b/source/enemy/npc.cpp @@ -26,15 +26,24 @@ CNpc::NPC_DATA CNpc::m_data[NPC_UNIT_TYPE_MAX] = { NPC_INIT_DEFAULT, NPC_SENSOR_NONE, - NPC_MOVEMENT_VERTICAL, + NPC_MOVEMENT_STATIC, NPC_MOVEMENT_MODIFIER_NONE, + false, + }, + + { + NPC_INIT_DEFAULT, + NPC_SENSOR_NONE, + NPC_MOVEMENT_STATIC, + NPC_MOVEMENT_MODIFIER_NONE, + true, }, }; void CNpc::init() { - m_type = NPC_TEST_TYPE; + m_type = NPC_SANDY_CHEEKS; switch ( m_data[this->m_type].initFunc ) { @@ -173,3 +182,32 @@ void CNpc::processTimer() 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 ); + } + } + } +} diff --git a/source/enemy/npc.h b/source/enemy/npc.h index 4b7d1097b..0eef84b62 100644 --- a/source/enemy/npc.h +++ b/source/enemy/npc.h @@ -16,6 +16,7 @@ public: void shutdown(); void think(int _frames); virtual void render(); + void processEvent( GAME_EVENT evt, CThing *sourceThing ); protected: @@ -24,6 +25,7 @@ protected: enum NPC_UNIT_TYPE { NPC_TEST_TYPE = 0, + NPC_SANDY_CHEEKS = 1, NPC_UNIT_TYPE_MAX, }; @@ -69,6 +71,7 @@ protected: NPC_SENSOR_FUNC sensorFunc; NPC_MOVEMENT_FUNC movementFunc; NPC_MOVEMENT_MODIFIER_FUNC movementModifierFunc; + bool canTalk; } NPC_DATA; diff --git a/source/game/game.cpp b/source/game/game.cpp index 61c42f410..124f5ef65 100644 --- a/source/game/game.cpp +++ b/source/game/game.cpp @@ -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 ); +} + +/*****************************************************************************/ diff --git a/source/game/game.h b/source/game/game.h index c8f1e0940..1a9fb8e5b 100644 --- a/source/game/game.h +++ b/source/game/game.h @@ -12,6 +12,14 @@ #include "game\convo.h" #endif +#ifndef __GAME_EVENT_H__ +#include "game\event.h" +#endif + +#ifndef __GAME_THING_H__ +#include "game\thing.h" +#endif + /*****************************************************************************/ class FontBank; @@ -31,6 +39,8 @@ virtual ~CGameScene() {;} static MATRIX *GetCamMtx() {return(&CamMtx);} class CPlayer *getPlayer(); + CConversation *getConversation(); + void sendEvent( GAME_EVENT evt, CThing *sourceThing ); private: diff --git a/users/paul/spongebob project/spongebob project.dsp b/users/paul/spongebob project/spongebob project.dsp index 55c4df36b..8aa2c2cb0 100644 --- a/users/paul/spongebob project/spongebob project.dsp +++ b/users/paul/spongebob project/spongebob project.dsp @@ -241,6 +241,10 @@ SOURCE=..\..\..\source\game\convo.h # End Source File # Begin Source File +SOURCE=..\..\..\source\game\event.h +# End Source File +# Begin Source File + SOURCE=..\..\..\source\game\game.cpp # End Source File # Begin Source File