aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/titanic/npcs/maitre_d.cpp158
-rw-r--r--engines/titanic/npcs/maitre_d.h14
-rw-r--r--engines/titanic/sound/music_handler.cpp5
-rw-r--r--engines/titanic/sound/music_handler.h2
4 files changed, 175 insertions, 4 deletions
diff --git a/engines/titanic/npcs/maitre_d.cpp b/engines/titanic/npcs/maitre_d.cpp
index 903f3a49c9..207a97ccc3 100644
--- a/engines/titanic/npcs/maitre_d.cpp
+++ b/engines/titanic/npcs/maitre_d.cpp
@@ -21,14 +21,31 @@
*/
#include "titanic/npcs/maitre_d.h"
+#include "titanic/core/room_item.h"
+#include "titanic/sound/music_room.h"
+#include "titanic/titanic.h"
namespace Titanic {
+BEGIN_MESSAGE_MAP(CMaitreD, CTrueTalkNPC)
+ ON_MESSAGE(RestaurantMusicChanged)
+ ON_MESSAGE(TrueTalkTriggerActionMsg)
+ ON_MESSAGE(EnterViewMsg)
+ ON_MESSAGE(LeaveViewMsg)
+ ON_MESSAGE(NPCPlayTalkingAnimationMsg)
+ ON_MESSAGE(TimerMsg)
+ ON_MESSAGE(TrueTalkNotifySpeechStartedMsg)
+ ON_MESSAGE(TrueTalkNotifySpeechEndedMsg)
+ ON_MESSAGE(LoadSuccessMsg)
+ ON_MESSAGE(TextInputMsg)
+ ON_MESSAGE(TriggerNPCEvent)
+END_MESSAGE_MAP()
+
int CMaitreD::_v1;
CMaitreD::CMaitreD() : CTrueTalkNPC(),
_string2("z#40.wav"), _string3("z#40.wav"), _field108(0), _field118(1),
- _field11C(0), _field12C(0), _field130(1), _field134(0), _field138(0) {
+ _field11C(0), _field12C(0), _field130(1), _field134(0), _timerId(0) {
}
void CMaitreD::save(SimpleFile *file, int indent) {
@@ -43,7 +60,7 @@ void CMaitreD::save(SimpleFile *file, int indent) {
file->writeNumberLine(_v1, indent);
file->writeNumberLine(_field134, indent);
- file->writeNumberLine(_field138, indent);
+ file->writeNumberLine(_timerId, indent);
CTrueTalkNPC::save(file, indent);
}
@@ -60,9 +77,144 @@ void CMaitreD::load(SimpleFile *file) {
_v1 = file->readNumber();
_field134 = file->readNumber();
- _field138 = file->readNumber();
+ _timerId = file->readNumber();
CTrueTalkNPC::load(file);
}
+bool CMaitreD::RestaurantMusicChanged(CRestaurantMusicChanged *msg) {
+ if (msg->_value.empty()) {
+ _field118 = 0;
+ } else {
+ _string3 = msg->_value;
+ _field118 = _field11C = 1;
+ }
+
+ return true;
+}
+
+bool CMaitreD::TrueTalkTriggerActionMsg(CTrueTalkTriggerActionMsg *msg) {
+ if (msg->_action == 8) {
+ _field12C = 1;
+ stopAnimTimer(_timerId);
+ _timerId = startAnimTimer("MD Fight", 3500, 0);
+ } else if (msg->_action == 9) {
+ stopAnimTimer(_timerId);
+ _timerId = 0;
+ } else if (msg->_action == 10) {
+ _field12C = 0;
+ _v1 = 1;
+ stopAnimTimer(_timerId);
+ _timerId = 0;
+
+ CMaitreDDefeatedMsg defeatedMsg;
+ defeatedMsg.execute(findRoom());
+ }
+
+ return true;
+}
+
+bool CMaitreD::EnterViewMsg(CEnterViewMsg *msg) {
+ endTalking(this, true, findView());
+ _field12C = _field134;
+
+ if (_string3 == "STMusic" && (!_field11C || _string2 == _string3))
+ return true;
+
+ if (_string3.contains("nasty ambient"))
+ startTalking(this, 111, findView());
+ else if (!CMusicRoom::_musicHandler->checkSound(1))
+ startTalking(this, 114, findView());
+ else if (!CMusicRoom::_musicHandler->checkSound(3))
+ startTalking(this, 113, findView());
+ else if (!CMusicRoom::_musicHandler->checkSound(2))
+ startTalking(this, 115, findView());
+ else {
+ startTalking(this, 110, findView());
+ CMaitreDHappyMsg happyMsg;
+ happyMsg.execute("MaitreD Left Arm");
+ happyMsg.execute("MaitreD Right Arm");
+ }
+
+ return true;
+}
+
+bool CMaitreD::LeaveViewMsg(CLeaveViewMsg *msg) {
+ _field134 = _field12C;
+ performAction(true);
+ stopAnimTimer(_timerId);
+ _timerId = 0;
+
+ _field12C = 0;
+ return true;
+}
+
+bool CMaitreD::NPCPlayTalkingAnimationMsg(CNPCPlayTalkingAnimationMsg *msg) {
+ static const char *const NAMES[] = {
+ "Talking0", "Talking1", "Talking2", "Talking3", "Talking4",
+ "Talking5", "Talking6", "Talking7", nullptr
+ };
+
+ if (msg->_value2 != 2) {
+ msg->_names = NAMES;
+
+ CAnimateMaitreDMsg animMsg;
+ if (_field12C)
+ animMsg._value = 0;
+ animMsg.execute(this);
+ }
+
+ return true;
+}
+
+bool CMaitreD::TimerMsg(CTimerMsg *msg) {
+ if (msg->_action == "MD Fight") {
+ if (_field12C && compareViewNameTo("1stClassRestaurant.MaitreD Node.N")) {
+ startTalking(this, 131, findView());
+ }
+ } else {
+ CTrueTalkNPC::TimerMsg(msg);
+ }
+
+ return true;
+}
+
+bool CMaitreD::TrueTalkNotifySpeechStartedMsg(CTrueTalkNotifySpeechStartedMsg *msg) {
+ if (_field12C) {
+ stopAnimTimer(_timerId);
+ _timerId = 0;
+ }
+
+ CTrueTalkNPC::TrueTalkNotifySpeechStartedMsg(msg);
+ return true;
+}
+
+bool CMaitreD::TrueTalkNotifySpeechEndedMsg(CTrueTalkNotifySpeechEndedMsg *msg) {
+ if (_field12C) {
+ stopAnimTimer(_timerId);
+ _timerId = startAnimTimer("MD Fight", 3000 + g_vm->getRandomNumber(3000));
+ }
+
+ CTrueTalkNPC::TrueTalkNotifySpeechEndedMsg(msg);
+ return true;
+}
+
+bool CMaitreD::LoadSuccessMsg(CLoadSuccessMsg *msg) {
+ if (_field12C) {
+ _timerId = startAnimTimer("MD Fight", 3000 + g_vm->getRandomNumber(3000));
+ }
+
+ return true;
+}
+
+bool CMaitreD::TextInputMsg(CTextInputMsg *msg) {
+ CTrueTalkNPC::processInput(msg, findView());
+ return true;
+}
+
+bool CMaitreD::TriggerNPCEvent(CTriggerNPCEvent *msg) {
+ startTalking(this, msg->_value, findView());
+ return true;
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/npcs/maitre_d.h b/engines/titanic/npcs/maitre_d.h
index af73f02a9a..878c32cc0b 100644
--- a/engines/titanic/npcs/maitre_d.h
+++ b/engines/titanic/npcs/maitre_d.h
@@ -28,6 +28,18 @@
namespace Titanic {
class CMaitreD : public CTrueTalkNPC {
+ DECLARE_MESSAGE_MAP;
+ bool RestaurantMusicChanged(CRestaurantMusicChanged *msg);
+ bool TrueTalkTriggerActionMsg(CTrueTalkTriggerActionMsg *msg);
+ bool EnterViewMsg(CEnterViewMsg *msg);
+ bool LeaveViewMsg(CLeaveViewMsg *msg);
+ bool NPCPlayTalkingAnimationMsg(CNPCPlayTalkingAnimationMsg *msg);
+ bool TimerMsg(CTimerMsg *msg);
+ bool TrueTalkNotifySpeechStartedMsg(CTrueTalkNotifySpeechStartedMsg *msg);
+ bool TrueTalkNotifySpeechEndedMsg(CTrueTalkNotifySpeechEndedMsg *msg);
+ bool LoadSuccessMsg(CLoadSuccessMsg *msg);
+ bool TextInputMsg(CTextInputMsg *msg);
+ bool TriggerNPCEvent(CTriggerNPCEvent *msg);
private:
static int _v1;
private:
@@ -39,7 +51,7 @@ private:
int _field12C;
int _field130;
int _field134;
- int _field138;
+ int _timerId;
public:
CLASSDEF;
CMaitreD();
diff --git a/engines/titanic/sound/music_handler.cpp b/engines/titanic/sound/music_handler.cpp
index 037c340f0b..07c3994334 100644
--- a/engines/titanic/sound/music_handler.cpp
+++ b/engines/titanic/sound/music_handler.cpp
@@ -77,4 +77,9 @@ void CMusicHandler::stop() {
}
}
+bool CMusicHandler::checkSound(int index) const {
+ // TODO
+ return false;
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/sound/music_handler.h b/engines/titanic/sound/music_handler.h
index 17ffea965a..6792844cb5 100644
--- a/engines/titanic/sound/music_handler.h
+++ b/engines/titanic/sound/music_handler.h
@@ -63,6 +63,8 @@ public:
* Stop playing the music
*/
void stop();
+
+ bool checkSound(int index) const;
};
} // End of namespace Titanic