[Scummvm-cvs-logs] scummvm master -> 14cdfa3f58455c818691eb94d3a3de5b0dda8696

dreammaster dreammaster at scummvm.org
Sun Aug 14 03:44:30 CEST 2016


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
14cdfa3f58 TITANIC: Implemented CMaitreD class


Commit: 14cdfa3f58455c818691eb94d3a3de5b0dda8696
    https://github.com/scummvm/scummvm/commit/14cdfa3f58455c818691eb94d3a3de5b0dda8696
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2016-08-13T21:44:22-04:00

Commit Message:
TITANIC: Implemented CMaitreD class

Changed paths:
    engines/titanic/npcs/maitre_d.cpp
    engines/titanic/npcs/maitre_d.h
    engines/titanic/sound/music_handler.cpp
    engines/titanic/sound/music_handler.h



diff --git a/engines/titanic/npcs/maitre_d.cpp b/engines/titanic/npcs/maitre_d.cpp
index 903f3a4..207a97c 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 af73f02..878c32c 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 037c340..07c3994 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 17ffea9..6792844 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






More information about the Scummvm-git-logs mailing list