aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic/game/transport
diff options
context:
space:
mode:
authorPaul Gilbert2016-08-23 07:40:14 -0400
committerPaul Gilbert2016-08-23 07:40:14 -0400
commita26a3d433877175cb1a48224c797d3172555fd8f (patch)
treeef4b7fbb7fd0b8f46bd5157bb4ccd773312b19c3 /engines/titanic/game/transport
parent14f163bad19927093bdcf2eeeaf36dd9129833ac (diff)
downloadscummvm-rg350-a26a3d433877175cb1a48224c797d3172555fd8f.tar.gz
scummvm-rg350-a26a3d433877175cb1a48224c797d3172555fd8f.tar.bz2
scummvm-rg350-a26a3d433877175cb1a48224c797d3172555fd8f.zip
TITANIC: Implemented CLift class
Diffstat (limited to 'engines/titanic/game/transport')
-rw-r--r--engines/titanic/game/transport/lift.cpp275
-rw-r--r--engines/titanic/game/transport/lift.h13
2 files changed, 271 insertions, 17 deletions
diff --git a/engines/titanic/game/transport/lift.cpp b/engines/titanic/game/transport/lift.cpp
index 72f832bf76..ef8d9028d9 100644
--- a/engines/titanic/game/transport/lift.cpp
+++ b/engines/titanic/game/transport/lift.cpp
@@ -21,27 +21,34 @@
*/
#include "titanic/game/transport/lift.h"
+#include "titanic/pet_control/pet_control.h"
+#include "titanic/titanic.h"
namespace Titanic {
BEGIN_MESSAGE_MAP(CLift, CTransport)
+ ON_MESSAGE(StatusChangeMsg)
+ ON_MESSAGE(MovieEndMsg)
+ ON_MESSAGE(EnterViewMsg)
ON_MESSAGE(EnterRoomMsg)
+ ON_MESSAGE(LeaveRoomMsg)
+ ON_MESSAGE(ActMsg)
END_MESSAGE_MAP()
int CLift::_v1;
-int CLift::_v2;
-int CLift::_v3;
-int CLift::_v4;
-int CLift::_v5;
+int CLift::_elevator1Floor;
+int CLift::_elevator2Floor;
+int CLift::_elevator3Floor;
+int CLift::_elevator4Floor;
int CLift::_v6;
void CLift::save(SimpleFile *file, int indent) {
file->writeNumberLine(1, indent);
file->writeNumberLine(_v1, indent);
- file->writeNumberLine(_v2, indent);
- file->writeNumberLine(_v3, indent);
- file->writeNumberLine(_v4, indent);
- file->writeNumberLine(_v5, indent);
+ file->writeNumberLine(_elevator1Floor, indent);
+ file->writeNumberLine(_elevator2Floor, indent);
+ file->writeNumberLine(_elevator3Floor, indent);
+ file->writeNumberLine(_elevator4Floor, indent);
file->writeNumberLine(_fieldF8, indent);
file->writeNumberLine(_v6, indent);
@@ -51,18 +58,260 @@ void CLift::save(SimpleFile *file, int indent) {
void CLift::load(SimpleFile *file) {
file->readNumber();
_v1 = file->readNumber();
- _v2 = file->readNumber();
- _v3 = file->readNumber();
- _v4 = file->readNumber();
- _v5 = file->readNumber();
+ _elevator1Floor = file->readNumber();
+ _elevator2Floor = file->readNumber();
+ _elevator3Floor = file->readNumber();
+ _elevator4Floor = file->readNumber();
_fieldF8 = file->readNumber();
_v6 = file->readNumber();
CTransport::load(file);
}
+bool CLift::StatusChangeMsg(CStatusChangeMsg *msg) {
+ CPetControl *pet = getPetControl();
+ if ((!_v1 && pet->getRoomsElevatorNum() == 4) ||
+ (!_v6 && pet->getRoomsElevatorNum() == 4))
+ return true;
+
+ int oldFloorNum = msg->_oldStatus;
+ int floorNum = msg->_newStatus;
+ int oldClass = 0, newClass = 0;
+ if (oldFloorNum == 19)
+ oldClass = 2;
+ if (oldFloorNum == 27)
+ oldClass = 3;
+ if (floorNum == 19)
+ newClass = 2;
+ if (floorNum == 27)
+ newClass = 3;
+
+ static const int UP_FRAME_NUMBERS[40] = {
+ 0, 8, 13, 18, 23, 28, 33, 38, 43, 48, 53, 58,
+ 63, 68, 73, 78, 83, 88, 93, 118, 123, 128, 133,
+ 138, 143, 148, 153, 228, 233, 238, 243, 248, 253,
+ 258, 263, 268, 273, 278, 298, 299
+ };
+ static const int DOWN_FRAME_NUMBERS[39] = {
+ 598, 589, 584, 579, 574, 569, 564, 559, 554, 549,
+ 544, 539, 534, 529, 524, 519, 514, 509, 504, 479,
+ 474, 469, 464, 459, 454, 449, 444, 369, 364, 359,
+ 354, 349, 344, 339, 334, 329, 324, 319
+ };
+
+ if (pet)
+ pet->setRoomsFloorNum(floorNum);
+ if (pet->getRoomsElevatorNum() == 2 || pet->getRoomsElevatorNum() == 4) {
+ if (floorNum > 27)
+ floorNum = 27;
+ if (oldFloorNum > 27)
+ oldFloorNum = 27;
+ }
+
+ changeView("Lift.Node 1.N");
+ CTurnOn onMsg;
+ onMsg.execute("LiftHood");
+
+ CString debugStr;
+ if (floorNum > oldFloorNum) {
+ // Animate lift going up
+ _startFrame = UP_FRAME_NUMBERS[oldFloorNum - 1];
+ _endFrame = UP_FRAME_NUMBERS[floorNum - 1];
+
+ if (oldClass == newClass) {
+ debugStr = CString::format("Same (%d-%d)", _startFrame, _endFrame);
+ playMovie(_startFrame, _endFrame, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE);
+ } else if (oldClass == 1 && newClass == 2) {
+ debugStr = CString::format("1 to 2 (%d-108, 108-%d)", _startFrame, _endFrame);
+ playMovie(_startFrame, 108, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE);
+ playMovie(108, _endFrame, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE);
+ } else if (oldClass == 1 && newClass == 3) {
+ debugStr = CString::format("1 to 3 (%d-108, 108-190, 190-%d)", _startFrame, _endFrame);
+ playMovie(_startFrame, 108, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE);
+ playMovie(108, 190, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE);
+ playMovie(190, _endFrame, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE);
+ } else {
+ debugStr = CString::format("2 to 3 (%d-190, 190-%d)", _startFrame, _endFrame);
+ playMovie(_startFrame, 190, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE);
+ playMovie(190, _endFrame, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE);
+ }
+ }
+
+ if (floorNum < oldFloorNum) {
+ // Animate lift going down
+ _startFrame = DOWN_FRAME_NUMBERS[floorNum - 1];
+ _endFrame = DOWN_FRAME_NUMBERS[oldFloorNum - 1];
+
+ if (oldClass == newClass) {
+ debugStr = CString::format("Same (%d-%d)", _startFrame, _endFrame);
+ playMovie(_startFrame, _endFrame, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE);
+ } else if (oldClass == 3 && newClass == 2) {
+ debugStr = CString::format("3 to 2 (%d-407, 407-%d)", _startFrame, _endFrame);
+ playMovie(_startFrame, 407, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE);
+ playMovie(407, _endFrame, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE);
+ } else if (oldClass == 3 && newClass == 1) {
+ debugStr = CString::format("3 to 1 (%d-407, 407-489, 489-%d)", _startFrame, _endFrame);
+ playMovie(_startFrame, 407, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE);
+ playMovie(407, 489, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE);
+ playMovie(489, _endFrame, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE);
+ } else {
+ debugStr = CString::format("2 to 1 (%d-489, 489-%d)", _startFrame, _endFrame);
+ playMovie(_startFrame, 489, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE);
+ playMovie(489, _endFrame, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE);
+ }
+ }
+
+ CShipSettingMsg settingMsg;
+ switch (pet->getRoomsElevatorNum()) {
+ case 1:
+ _elevator1Floor = floorNum;
+ break;
+ case 2:
+ _elevator2Floor = floorNum;
+ _elevator4Floor = oldFloorNum;
+ settingMsg._value = oldFloorNum;
+ settingMsg.execute("SGTStateroomTV");
+ break;
+ case 3:
+ _elevator3Floor = floorNum;
+ break;
+ case 4:
+ _elevator4Floor = floorNum;
+ break;
+ default:
+ break;
+ }
+
+ debugC(1, kDebugScripts, "%s", debugStr.c_str());
+ return true;
+}
+
+bool CLift::MovieEndMsg(CMovieEndMsg *msg) {
+ switch (msg->_endFrame) {
+ case 108:
+ setGlobalSoundVolume(-4, 1, 2);
+ setGlobalSoundVolume(-2, 1, 1);
+ break;
+
+ case 190:
+ setGlobalSoundVolume(-4, 1, 1);
+ setGlobalSoundVolume(-2, 1, 2);
+ break;
+
+ case 407:
+ setGlobalSoundVolume(-4, 1, 0);
+ setGlobalSoundVolume(-2, 1, 1);
+ break;
+
+ case 489:
+ setGlobalSoundVolume(-4, 1, 1);
+ setGlobalSoundVolume(-2, 1, 0);
+ break;
+
+ default: {
+ CActMsg actMsg("LiftArrive");
+ actMsg.execute("Liftbot");
+ sleep(500);
+ playSound("352 gp button 1.wav");
+
+ CTurnOff offMsg;
+ offMsg.execute("LiftHood");
+ changeView("Lift.Node 1.W");
+ break;
+ }
+ }
+
+ return true;
+}
+
+bool CLift::EnterViewMsg(CEnterViewMsg *msg) {
+ static const int FRAME_NUMBERS[40] = {
+ 0, 8, 13, 18, 23, 28, 33, 38, 43, 48, 53, 58, 63, 68, 73,
+ 78, 83, 88, 93, 118, 123, 128, 133, 138, 143, 148, 153,
+ 228, 233, 238, 243, 248, 253, 258, 263, 268, 273, 278, 298
+ };
+
+ CPetControl *pet = getPetControl();
+ loadFrame(FRAME_NUMBERS[pet->getRoomsFloorNum() - 1]);
+ return true;
+}
+
bool CLift::EnterRoomMsg(CEnterRoomMsg *msg) {
- warning("CLift::handleEvent");
+ if (isEquals("Well")) {
+ CPetControl *pet = getPetControl();
+ int floorNum = pet->getRoomsFloorNum();
+ int elevNum = pet->getRoomsElevatorNum();
+ loadSound("z#520.wav");
+ loadSound("z#519.wav");
+ loadSound("z#518.wav");
+
+ if (elevNum == 4 && _v1 == 1 && !_v6) {
+ CVisibleMsg visibleMsg;
+ visibleMsg.execute("GetLiftEye");
+ }
+
+ if (floorNum < 20) {
+ playGlobalSound("z#520.wav", -2, true, true, 0);
+ playGlobalSound("z#519.wav", -4, false, true, 1);
+ playGlobalSound("z#518.wav", -4, false, true, 2);
+ } else if (floorNum < 28) {
+ playGlobalSound("z#520.wav", -4, false, true, 0);
+ playGlobalSound("z#519.wav", -2, true, true, 1);
+ playGlobalSound("z#518.wav", -4, false, true, 2);
+ } else {
+ playGlobalSound("z#520.wav", -4, false, true, 0);
+ playGlobalSound("z#519.wav", -4, false, true, 1);
+ playGlobalSound("z#518.wav", -2, true, true, 2);
+ }
+ }
+
+ return true;
+}
+
+bool CLift::LeaveRoomMsg(CLeaveRoomMsg *msg) {
+ stopGlobalSound(true, -1);
+
+ CPetControl *pet = getPetControl();
+ if (pet->getRoomsElevatorNum() == 4 && _v1 == 1 && !_v6) {
+ CVisibleMsg visibleMsg;
+ visibleMsg.execute("Eye2");
+ }
+
+ return true;
+}
+
+bool CLift::ActMsg(CActMsg *msg) {
+ if (msg->_action == "LoseHead") {
+ _v1 = 0;
+ _v6 = 0;
+
+ CActMsg actMsg1("Lift.Node 2.N");
+ actMsg1.execute("RPanInLiftW");
+ CActMsg actMsg2("Lift.Node 2.S");
+ actMsg2.execute("LPanInLiftW");
+ } else if (msg->_action == "AddWrongHead") {
+ _v1 = 1;
+ _v6 = 0;
+
+ CActMsg actMsg1("Lift.Node 1.N");
+ actMsg1.execute("RPanInLiftW");
+ CActMsg actMsg2("Lift.Node 1.S");
+ actMsg2.execute("LPanInLiftW");
+ } else if (msg->_action == "AddRightHead") {
+ _v1 = 1;
+ _v6 = 1;
+ petSetRooms1D4(0);
+
+ CActMsg actMsg1("Lift.Node 1.N");
+ actMsg1.execute("RPanInLiftW");
+ CActMsg actMsg2("Lift.Node 1.S");
+ actMsg2.execute("LPanInLiftW");
+ CActMsg actMsg3("ActivateLift");
+ actMsg3.execute("Liftbot");
+ }
+
+ CVisibleMsg visibleMsg;
+ visibleMsg.execute("LiftbotWithoutHead");
return true;
}
diff --git a/engines/titanic/game/transport/lift.h b/engines/titanic/game/transport/lift.h
index 763e545c31..38af00a1ce 100644
--- a/engines/titanic/game/transport/lift.h
+++ b/engines/titanic/game/transport/lift.h
@@ -30,13 +30,18 @@ namespace Titanic {
class CLift : public CTransport {
DECLARE_MESSAGE_MAP;
+ bool StatusChangeMsg(CStatusChangeMsg *msg);
+ bool MovieEndMsg(CMovieEndMsg *msg);
+ bool EnterViewMsg(CEnterViewMsg *msg);
bool EnterRoomMsg(CEnterRoomMsg *msg);
+ bool LeaveRoomMsg(CLeaveRoomMsg *msg);
+ bool ActMsg(CActMsg *msg);
public:
static int _v1;
- static int _v2;
- static int _v3;
- static int _v4;
- static int _v5;
+ static int _elevator1Floor;
+ static int _elevator2Floor;
+ static int _elevator3Floor;
+ static int _elevator4Floor;
static int _v6;
int _fieldF8;