1634 lines
39 KiB
C++
Raw Normal View History

/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
/*
* This code is based on original Mortville Manor DOS source code
* Copyright (c) 1987-1989 Lankhor
*/
2013-07-19 11:51:10 +02:00
#include "mortevielle/mortevielle.h"
#include "mortevielle/dialogs.h"
2011-12-31 21:29:41 +11:00
#include "mortevielle/menu.h"
#include "mortevielle/mouse.h"
#include "mortevielle/outtext.h"
2012-03-10 09:46:51 +01:00
#include "mortevielle/speech.h"
2013-07-19 11:51:10 +02:00
#include "common/scummsys.h"
2011-12-26 22:08:18 +01:00
namespace Mortevielle {
/**
* Engine function - Move
* @remarks Originally called 'taller'
*/
void MortevielleEngine::fctMove() {
2013-07-22 23:59:43 +02:00
if ((_coreVar._currPlace == ROOM26) && (_currAction == _menu._moveMenu[6])) {
2012-03-22 08:36:59 +01:00
_coreVar._currPlace = LANDING;
_caff = _coreVar._currPlace;
2012-10-11 00:45:46 +02:00
drawPictureWithText();
handleDescriptionText(2, _coreVar._currPlace);
}
2013-07-22 23:59:43 +02:00
if ((_coreVar._currPlace == LANDING) && (_currAction == _menu._moveMenu[6])) {
2012-03-14 18:25:17 +01:00
if (!_syn)
2012-10-14 21:59:27 +02:00
displayTextInVerbBar(getEngineString(S_GO_TO));
displayStatusArrow();
2012-03-14 18:25:17 +01:00
if (_keyPressedEsc)
2012-10-12 07:31:30 +02:00
_destinationOk = false;
2012-03-14 18:25:17 +01:00
if ((_anyone) || (_keyPressedEsc))
return;
2012-03-14 23:06:23 +01:00
2012-03-24 15:19:54 +01:00
setCoordinates(1);
2012-03-14 18:25:17 +01:00
if (_num == 0)
return;
2012-03-14 18:25:17 +01:00
if (_num == 1) {
2012-03-22 08:36:59 +01:00
_coreVar._currPlace = OWN_ROOM;
2012-03-24 15:19:54 +01:00
_menu.setDestinationText(OWN_ROOM);
} else if (_num == 7) {
2012-03-22 08:36:59 +01:00
_coreVar._currPlace = ATTIC;
2012-03-24 15:19:54 +01:00
_menu.setDestinationText(ATTIC);
} else if (_num != 6)
2012-03-22 08:36:59 +01:00
_coreVar._currPlace = ROOM26;
2012-03-27 22:54:50 +02:00
if ((_num > 1) && (_num < 6))
2012-10-10 08:19:54 +02:00
_roomDoorId = _num - 1;
else if (_num > 7)
2012-10-10 08:19:54 +02:00
_roomDoorId = _num - 3;
2012-03-14 18:25:17 +01:00
if (_num != 6)
prepareDisplayText();
else
2012-03-20 22:52:59 +01:00
showMoveMenuAlert();
return;
}
2012-03-24 15:19:54 +01:00
exitRoom();
2012-03-14 23:06:23 +01:00
int menuChoice = 1;
2012-03-14 18:25:17 +01:00
2013-07-22 23:59:43 +02:00
while (_menu._moveMenu[menuChoice] != _currAction)
2012-03-14 23:06:23 +01:00
++menuChoice;
2012-03-22 08:36:59 +01:00
if (_coreVar._currPlace == MOUNTAIN) {
2012-03-14 23:06:23 +01:00
if (menuChoice == 1)
2012-03-14 18:25:17 +01:00
gotoManorFront();
2012-03-14 23:06:23 +01:00
else if (menuChoice == 2)
2012-03-14 18:25:17 +01:00
checkManorDistance();
2012-03-24 15:19:54 +01:00
_menu.setDestinationText(_coreVar._currPlace);
return;
2012-03-22 08:36:59 +01:00
} else if (_coreVar._currPlace == INSIDE_WELL) {
2012-03-14 23:06:23 +01:00
if (menuChoice == 1)
floodedInWell();
else if (menuChoice == 2)
2012-03-14 18:25:17 +01:00
gotoManorBack();
2012-03-24 15:19:54 +01:00
_menu.setDestinationText(_coreVar._currPlace);
return;
2012-03-22 08:36:59 +01:00
} else if ((_coreVar._currPlace == BUREAU) && (menuChoice == 1))
2012-03-14 23:06:23 +01:00
menuChoice = 6;
2012-03-22 08:36:59 +01:00
else if (_coreVar._currPlace == KITCHEN) {
2012-03-14 23:06:23 +01:00
if (menuChoice == 2)
menuChoice = 6;
else if (menuChoice == 5)
menuChoice = 16;
2012-03-22 08:36:59 +01:00
} else if ((_coreVar._currPlace == CELLAR) && (menuChoice == 3))
2012-03-14 23:06:23 +01:00
menuChoice = 6;
2012-03-22 08:36:59 +01:00
else if (((_coreVar._currPlace == LANDING) || (_coreVar._currPlace == ROOM26)) && (menuChoice == 4))
2012-03-14 23:06:23 +01:00
menuChoice = 6;
2012-03-27 22:54:50 +02:00
2012-03-22 08:36:59 +01:00
if ((_coreVar._currPlace > MOUNTAIN) && (_coreVar._currPlace != ROOM26))
2012-03-14 23:06:23 +01:00
menuChoice += 10;
2012-03-27 22:54:50 +02:00
2012-03-22 08:36:59 +01:00
if ((_coreVar._currPlace == CHAPEL) && (menuChoice == 13))
2012-03-14 23:06:23 +01:00
menuChoice = 16;
2012-03-22 08:36:59 +01:00
else if (_coreVar._currPlace == MANOR_FRONT) {
2012-03-14 23:06:23 +01:00
if (menuChoice == 12)
menuChoice = 16;
else if (menuChoice > 13)
menuChoice = 15;
2012-03-22 08:36:59 +01:00
} else if ((_coreVar._currPlace == MANOR_BACK) && (menuChoice > 14))
2012-03-14 23:06:23 +01:00
menuChoice = 15;
2012-03-22 08:36:59 +01:00
else if ((_coreVar._currPlace == WELL) && (menuChoice > 13) && (menuChoice != 17))
2012-03-14 23:06:23 +01:00
menuChoice = 15;
if (menuChoice == 1)
2012-03-22 08:36:59 +01:00
_coreVar._currPlace = BUREAU;
2012-03-14 23:06:23 +01:00
else if (menuChoice == 2)
2012-03-22 08:36:59 +01:00
_coreVar._currPlace = KITCHEN;
2012-03-14 23:06:23 +01:00
else if (menuChoice == 3)
2012-03-22 08:36:59 +01:00
_coreVar._currPlace = CELLAR;
2012-03-14 23:06:23 +01:00
else if (menuChoice == 4)
2012-03-22 08:36:59 +01:00
_coreVar._currPlace = LANDING;
2012-03-14 23:06:23 +01:00
else if (menuChoice == 5)
menuChoice = 12;
else if (menuChoice == 6)
menuChoice = 11;
2012-03-14 18:25:17 +01:00
2012-03-14 23:06:23 +01:00
if (menuChoice == 11)
2012-03-14 18:25:17 +01:00
gotoDiningRoom();
2012-03-14 23:06:23 +01:00
else if (menuChoice == 12)
2012-03-14 18:25:17 +01:00
gotoManorFront();
2012-03-14 23:06:23 +01:00
else if (menuChoice == 13)
2012-03-22 08:36:59 +01:00
_coreVar._currPlace = CHAPEL;
2012-03-14 23:06:23 +01:00
else if (menuChoice == 14)
2012-03-22 08:36:59 +01:00
_coreVar._currPlace = WELL;
2012-03-14 23:06:23 +01:00
else if (menuChoice == 15)
2012-03-14 18:25:17 +01:00
checkManorDistance();
2012-03-14 23:06:23 +01:00
else if (menuChoice == 16)
2012-03-14 18:25:17 +01:00
gotoManorBack();
2012-03-14 23:06:23 +01:00
else if (menuChoice == 17) {
2012-03-22 08:36:59 +01:00
if ((_coreVar._wellObjectId != 120) && (_coreVar._wellObjectId != 140))
_crep = 997;
2012-03-22 08:36:59 +01:00
else if (_coreVar._wellObjectId == 120)
_crep = 181;
2012-03-22 08:36:59 +01:00
else if (_coreVar._faithScore > 80) {
_crep = 1505;
2012-03-14 18:25:17 +01:00
loseGame();
} else {
2012-03-22 08:36:59 +01:00
_coreVar._currPlace = INSIDE_WELL;
prepareDisplayText();
}
}
2012-03-14 23:06:23 +01:00
if ((menuChoice < 5) || (menuChoice == 13) || (menuChoice == 14))
prepareDisplayText();
resetRoomVariables(_coreVar._currPlace);
2012-03-24 15:19:54 +01:00
_menu.setDestinationText(_coreVar._currPlace);
2011-12-23 19:02:50 +00:00
}
/**
* Engine function - Take
* @remarks Originally called 'tprendre'
*/
void MortevielleEngine::fctTake() {
if (_caff > 99) {
int cx = _caff;
2012-10-12 07:31:30 +02:00
putInHand(cx);
if (_crep != 139) {
2012-03-14 23:06:23 +01:00
if (_currBitIndex > 0)
2012-03-22 08:36:59 +01:00
_coreVar._faithScore += 3;
2012-03-14 18:25:17 +01:00
if (_obpart) {
2012-03-22 08:36:59 +01:00
if (_coreVar._currPlace == PURPLE_ROOM)
_coreVar._purpleRoomObjectId = 0;
if (_coreVar._currPlace == ATTIC) {
if (_coreVar._atticBallHoleObjectId == _caff)
2012-03-22 08:36:59 +01:00
_coreVar._atticBallHoleObjectId = 0;
if (_coreVar._atticRodHoleObjectId == _caff)
2012-03-22 08:36:59 +01:00
_coreVar._atticRodHoleObjectId = 0;
}
2012-03-22 08:36:59 +01:00
if (_coreVar._currPlace == CELLAR)
_coreVar._cellarObjectId = 0;
if (_coreVar._currPlace == CRYPT)
_coreVar._cryptObjectId = 0;
if (_coreVar._currPlace == SECRET_PASSAGE)
_coreVar._secretPassageObjectId = 0;
if (_coreVar._currPlace == WELL)
_coreVar._wellObjectId = 0;
2012-03-14 18:25:17 +01:00
_menu.unsetSearchMenu();
_obpart = false;
prepareDisplayText();
} else {
2012-10-13 12:10:48 +02:00
_tabdon[kAcha + ((_mchai - 1) * 10) + _searchCount - 1] = 0;
tsuiv();
2012-10-10 08:19:54 +02:00
++_takeObjCount;
if (_takeObjCount > 6) {
2012-03-22 08:36:59 +01:00
_coreVar._faithScore += 2;
2012-10-10 08:19:54 +02:00
_takeObjCount = 0;
}
}
}
return;
}
2012-03-14 18:25:17 +01:00
if (!_syn)
2012-10-14 21:59:27 +02:00
displayTextInVerbBar(getEngineString(S_TAKE));
displayStatusArrow();
2012-03-14 18:25:17 +01:00
if ((_anyone) || (_keyPressedEsc))
return;
if (_caff == 3) {
2012-03-24 15:19:54 +01:00
setCoordinates(2);
if (_num == 1) {
_crep = 152;
return;
}
}
2012-03-24 15:19:54 +01:00
setCoordinates(5);
if ((_num == 0) || ((_num == 1) && (_coreVar._currPlace == CRYPT))) {
2012-03-24 15:19:54 +01:00
setCoordinates(8);
if (_num != 0) {
2012-03-14 23:06:23 +01:00
if (_currBitIndex > 0)
2012-03-22 08:36:59 +01:00
_coreVar._faithScore += 3;
_crep = 997;
2012-03-22 08:36:59 +01:00
if ((_coreVar._currPlace == PURPLE_ROOM) && (_coreVar._purpleRoomObjectId != 0))
2012-10-12 07:31:30 +02:00
putInHand(_coreVar._purpleRoomObjectId);
if ((_coreVar._currPlace == ATTIC) && (_num == 1) && (_coreVar._atticBallHoleObjectId != 0)) {
2012-10-12 07:31:30 +02:00
putInHand(_coreVar._atticBallHoleObjectId);
if ((_crep != 997) && (_crep != 139))
aniof(2, 7);
}
if ((_coreVar._currPlace == ATTIC) && (_num == 2) && (_coreVar._atticRodHoleObjectId != 0)) {
2012-10-12 07:31:30 +02:00
putInHand(_coreVar._atticRodHoleObjectId);
if ((_crep != 997) && (_crep != 139))
aniof(2, 6);
}
2012-03-22 08:36:59 +01:00
if ((_coreVar._currPlace == CELLAR) && (_coreVar._cellarObjectId != 0)) {
2012-10-12 07:31:30 +02:00
putInHand(_coreVar._cellarObjectId);
if ((_crep != 997) && (_crep != 139))
aniof(2, 2);
}
2012-03-22 08:36:59 +01:00
if ((_coreVar._currPlace == CRYPT) && (_coreVar._cryptObjectId != 0))
2012-10-12 07:31:30 +02:00
putInHand(_coreVar._cryptObjectId);
2012-03-05 00:00:48 +01:00
2012-03-22 08:36:59 +01:00
if ((_coreVar._currPlace == SECRET_PASSAGE) && (_coreVar._secretPassageObjectId != 0)) {
2012-10-12 07:31:30 +02:00
putInHand(_coreVar._secretPassageObjectId);
if ((_crep != 997) && (_crep != 139)) {
_crep = 182;
aniof(2, 1);
}
}
2012-03-22 08:36:59 +01:00
if ((_coreVar._currPlace == WELL) && (_coreVar._wellObjectId != 0)) {
2012-10-12 07:31:30 +02:00
putInHand(_coreVar._wellObjectId);
if ((_crep != 997) && (_crep != 139))
aniof(2, 1);
}
if ((_crep != 997) && (_crep != 182) && (_crep != 139))
_crep = 999;
}
} else {
if ( ((_coreVar._currPlace == OWN_ROOM) && (_num == 3))
|| ((_coreVar._currPlace == GREEN_ROOM) && (_num == 4))
|| ((_coreVar._currPlace == PURPLE_ROOM) && (_num == 1))
|| ((_coreVar._currPlace == DARKBLUE_ROOM) && (_num == 3))
|| ((_coreVar._currPlace == BLUE_ROOM) && (_num == 6))
|| ((_coreVar._currPlace == RED_ROOM) && (_num == 2))
|| ((_coreVar._currPlace == BATHROOM) && (_num == 6))
|| ((_coreVar._currPlace == GREEN_ROOM2) && (_num == 4))
|| ((_coreVar._currPlace == ROOM9) && (_num == 4))
|| ((_coreVar._currPlace == DINING_ROOM) && (_num > 2))
|| ((_coreVar._currPlace == BUREAU) && (_num == 7))
|| ((_coreVar._currPlace == KITCHEN) && (_num == 6))
|| ((_coreVar._currPlace == ATTIC) && (_num > 4))
2012-03-22 08:36:59 +01:00
|| ((_coreVar._currPlace > ATTIC) && (_coreVar._currPlace != INSIDE_WELL)) )
_crep = 997;
2012-03-22 08:36:59 +01:00
else if (_coreVar._currPlace == INSIDE_WELL) {
_crep = 1504;
2012-03-14 18:25:17 +01:00
loseGame();
} else
_crep = 120;
}
2011-12-23 19:02:50 +00:00
}
/**
* Engine function - Inventory / Take
* @remarks Originally called 'tsprendre'
*/
void MortevielleEngine::fctInventoryTake() {
2012-10-14 10:28:03 +02:00
int inventIndex = 0;
do {
2012-10-14 10:28:03 +02:00
++inventIndex;
2013-07-22 23:59:43 +02:00
} while (_menu._inventoryMenu[inventIndex] != _currAction);
2012-03-24 15:19:54 +01:00
int cz = 0;
int cy = 0;
do {
++cy;
2012-10-14 10:28:03 +02:00
if (_coreVar._inventory[cy] != 0)
++cz;
2012-10-14 10:28:03 +02:00
} while (cz != inventIndex);
cz = _coreVar._inventory[cy];
_coreVar._inventory[cy] = 0;
2012-03-24 15:19:54 +01:00
_menu.setInventoryText();
2012-10-12 07:31:30 +02:00
putInHand(cz);
_crep = 998;
2012-10-11 00:45:46 +02:00
clearDescriptionBar();
2011-12-23 19:02:50 +00:00
}
/**
* Engine function - Lift
* @remarks Originally called 'tsoulever'
*/
void MortevielleEngine::fctLift() {
2012-03-14 18:25:17 +01:00
if (!_syn)
2012-10-14 21:59:27 +02:00
displayTextInVerbBar(getEngineString(S_LIFT));
displayStatusArrow();
2012-03-14 18:25:17 +01:00
if ((_anyone) || (_keyPressedEsc))
return;
2012-03-24 15:19:54 +01:00
setCoordinates(3);
if (_num == 0) {
2012-03-24 15:19:54 +01:00
setCoordinates(8);
if (_num != 0) {
2012-03-14 23:06:23 +01:00
if (_currBitIndex > 0)
2012-03-22 08:36:59 +01:00
++_coreVar._faithScore;
_crep = 997;
2012-03-22 08:36:59 +01:00
if ((_coreVar._currPlace == PURPLE_ROOM) && (_coreVar._purpleRoomObjectId != 0))
treg(_coreVar._purpleRoomObjectId);
}
return;
}
2012-03-14 23:06:23 +01:00
if (_currBitIndex > 0)
2012-03-22 08:36:59 +01:00
++_coreVar._faithScore;
int tmpPlace = _coreVar._currPlace;
if (_coreVar._currPlace == CRYPT)
2012-03-05 00:00:48 +01:00
tmpPlace = 14;
2012-03-22 08:36:59 +01:00
else if (_coreVar._currPlace == MOUNTAIN)
2012-03-05 00:00:48 +01:00
tmpPlace = 15;
2012-03-24 22:48:47 +01:00
_crep = _tabdon[kAsoul + (tmpPlace << 3) + (_num - 1)];
if (_crep == 255)
_crep = 997;
2011-12-23 19:02:50 +00:00
}
/**
* Engine function - Read
* @remarks Originally called 'tlire'
*/
void MortevielleEngine::fctRead() {
if (_caff > 99)
2012-03-24 15:19:54 +01:00
getReadDescription(_caff);
else {
2012-03-14 18:25:17 +01:00
if (!_syn)
2012-10-14 21:59:27 +02:00
displayTextInVerbBar(getEngineString(S_READ));
displayStatusArrow();
2012-03-14 18:25:17 +01:00
if (!(_anyone) && !(_keyPressedEsc)) {
2012-03-24 15:19:54 +01:00
setCoordinates(4);
if (_num != 0)
_crep = 107;
}
}
2011-12-23 19:02:50 +00:00
}
/**
* Engine function - Self / Read
* @remarks Originally called 'tslire'
*/
void MortevielleEngine::fctSelfRead() {
2012-03-22 08:36:59 +01:00
if (_coreVar._selectedObjectId == 0)
_crep = 186;
else
2012-03-24 15:19:54 +01:00
getReadDescription(_coreVar._selectedObjectId);
2011-12-23 19:02:50 +00:00
}
/**
* Engine function - Look
* @remarks Originally called 'tregarder'
*/
void MortevielleEngine::fctLook() {
if (_caff > 99) {
_crep = 103;
return;
}
2012-03-14 18:25:17 +01:00
if (!_syn)
2012-10-14 21:59:27 +02:00
displayTextInVerbBar(getEngineString(S_LOOK));
displayStatusArrow();
2012-03-14 18:25:17 +01:00
if ((_anyone) || (_keyPressedEsc))
return;
2012-03-24 15:19:54 +01:00
setCoordinates(5);
if (_num == 0) {
2012-03-24 15:19:54 +01:00
setCoordinates(8);
_crep = 131;
if (_num != 0) {
2012-03-22 08:36:59 +01:00
if (_coreVar._currPlace == ATTIC) {
if (_num == 1) {
_crep = 164;
2012-03-22 08:36:59 +01:00
if (_coreVar._atticRodHoleObjectId != 0)
treg(_coreVar._atticRodHoleObjectId);
else if (_coreVar._atticBallHoleObjectId != 0)
treg(_coreVar._atticBallHoleObjectId);
} else {
_crep = 193;
2012-03-22 08:36:59 +01:00
if (_coreVar._atticRodHoleObjectId != 0)
treg(_coreVar._atticRodHoleObjectId);
}
}
2012-03-22 08:36:59 +01:00
if (_coreVar._currPlace == CELLAR) {
_crep = 164;
2012-03-22 08:36:59 +01:00
if (_coreVar._cellarObjectId != 0)
treg(_coreVar._cellarObjectId);
}
2012-03-22 08:36:59 +01:00
if (_coreVar._currPlace == SECRET_PASSAGE) {
_crep = 174;
2012-03-22 08:36:59 +01:00
if (_coreVar._secretPassageObjectId != 0)
treg(_coreVar._secretPassageObjectId);
}
2012-03-22 08:36:59 +01:00
if (_coreVar._currPlace == WELL) {
_crep = 131;
2012-03-22 08:36:59 +01:00
if (_coreVar._wellObjectId != 0)
treg(_coreVar._wellObjectId);
}
}
return;
}
int cx = _coreVar._currPlace;
2012-03-22 08:36:59 +01:00
if (_coreVar._currPlace == CHAPEL)
cx = 17;
2012-03-22 08:36:59 +01:00
if ((_coreVar._currPlace > MANOR_FRONT) && (_coreVar._currPlace < DOOR))
cx -= 4;
2012-03-22 08:36:59 +01:00
if (_coreVar._currPlace == ROOM26)
cx = 21;
2012-03-24 22:48:47 +01:00
_crep = _tabdon[kArega + (cx * 7) + _num - 1];
if ((_coreVar._currPlace == ATTIC) && (_num == 8))
_crep = 126;
2012-03-22 08:36:59 +01:00
if (_coreVar._currPlace == MOUNTAIN)
_crep = 103;
if (_crep == 255)
_crep = 131;
if ((_coreVar._currPlace == GREEN_ROOM) && (_num == 1))
treg(144);
if ((_coreVar._currPlace == BLUE_ROOM) && (_num == 3))
treg(147);
if ((_coreVar._currPlace == GREEN_ROOM2) && (_num == 3))
treg(149);
if ((_coreVar._currPlace == ROOM9) && (_num == 2))
treg(30);
if ((_coreVar._currPlace == DINING_ROOM) && (_num == 3))
treg(31);
2011-12-23 19:02:50 +00:00
}
/**
* Engine function - Self / Look
* @remarks Originally called 'tsregarder'
*/
void MortevielleEngine::fctSelftLook() {
2012-03-22 08:36:59 +01:00
if (_coreVar._selectedObjectId != 0)
treg(_coreVar._selectedObjectId);
else
_crep = 186;
2011-12-23 19:02:50 +00:00
}
/**
* Engine function - Search
* @remarks Originally called 'tfouiller'
*/
void MortevielleEngine::fctSearch() {
2013-07-23 10:18:08 +02:00
static const byte answerArr[14] = {123, 104, 123, 131, 131, 123, 104, 131, 123, 123, 106, 123, 123, 107};
2011-12-23 19:02:50 +00:00
if (_caff > 99) {
2012-03-24 15:19:54 +01:00
getSearchDescription(_caff);
return;
}
2012-03-14 18:25:17 +01:00
if (!_syn)
2012-10-14 21:59:27 +02:00
displayTextInVerbBar(getEngineString(S_SEARCH));
displayStatusArrow();
2012-03-14 18:25:17 +01:00
if (_anyone || _keyPressedEsc)
return;
2012-03-22 08:36:59 +01:00
if (_coreVar._currPlace == INSIDE_WELL) {
_crep = 1504;
2012-03-14 18:25:17 +01:00
loseGame();
return;
}
2012-03-24 15:19:54 +01:00
setCoordinates(6);
if (_num == 0) {
2012-03-24 15:19:54 +01:00
setCoordinates(7);
if (_num != 0) {
int cx = 0;
do {
++cx;
} while ((cx <= 6) && (_num != _openObjects[cx]));
if (_num != _openObjects[cx])
_crep = 187;
else {
2012-03-14 23:06:23 +01:00
if (_currBitIndex > 0)
2012-03-22 08:36:59 +01:00
_coreVar._faithScore += 3;
2013-06-29 10:30:42 +02:00
_mchai = rechai();
2012-03-23 07:44:04 +01:00
if (_mchai != 0) {
2012-10-13 12:10:48 +02:00
_searchCount = 0;
2012-03-14 18:25:17 +01:00
_heroSearching = true;
_menu.setSearchMenu();
tsuiv();
} else
_crep = 997;
}
} else {
2012-03-24 15:19:54 +01:00
setCoordinates(8);
_crep = 997;
if (_num != 0) {
2012-03-14 23:06:23 +01:00
if (_currBitIndex > 0)
2012-03-22 08:36:59 +01:00
_coreVar._faithScore += 3;
if ((_coreVar._currPlace != WELL) && (_coreVar._currPlace != SECRET_PASSAGE) && (_coreVar._currPlace != ATTIC)) {
if (_coreVar._currPlace == PURPLE_ROOM) {
_crep = 123;
2012-03-22 08:36:59 +01:00
if (_coreVar._purpleRoomObjectId != 0)
treg(_coreVar._purpleRoomObjectId);
}
2012-03-22 08:36:59 +01:00
if (_coreVar._currPlace == CRYPT) {
_crep = 123;
2012-03-22 08:36:59 +01:00
if (_coreVar._cryptObjectId != 0)
treg(_coreVar._cryptObjectId);
}
}
}
}
} else {
2012-03-14 23:06:23 +01:00
if (_currBitIndex > 0)
2012-03-22 08:36:59 +01:00
_coreVar._faithScore += 3;
_crep = 997;
2012-03-22 08:36:59 +01:00
if (_coreVar._currPlace < CELLAR)
2013-07-23 10:18:08 +02:00
_crep = answerArr[_coreVar._currPlace];
if ((_coreVar._currPlace == TOILETS) && (_num == 2))
_crep = 162;
2012-03-22 08:36:59 +01:00
if (_coreVar._currPlace == KITCHEN) {
if ((_num == 3) || (_num == 4))
_crep = 162;
else if (_num == 5)
_crep = 159;
}
2012-03-22 08:36:59 +01:00
if (_coreVar._currPlace == MOUNTAIN)
_crep = 104;
2012-03-22 08:36:59 +01:00
else if (_coreVar._currPlace == CRYPT)
_crep = 155;
}
2011-12-23 19:02:50 +00:00
}
/**
* Engine function - Self / Search
* @remarks Originally called 'tsfouiller'
*/
void MortevielleEngine::fctSelfSearch() {
2012-03-22 08:36:59 +01:00
if (_coreVar._selectedObjectId != 0)
2012-03-24 15:19:54 +01:00
getSearchDescription(_coreVar._selectedObjectId);
else
_crep = 186;
2011-12-23 19:02:50 +00:00
}
/**
* Engine function - Open
* @remarks Originally called 'touvrir'
*/
void MortevielleEngine::fctOpen() {
2012-03-14 18:25:17 +01:00
if (!_syn)
2012-10-14 21:59:27 +02:00
displayTextInVerbBar(getEngineString(S_OPEN));
if (_caff == ROOM26) {
2012-10-10 08:19:54 +02:00
if (_roomDoorId != OWN_ROOM) {
2013-07-22 23:59:43 +02:00
_currAction = OPCODE_ENTER;
2012-03-14 18:25:17 +01:00
_syn = true;
} else
_crep = 997;
return;
}
2012-10-13 12:10:48 +02:00
if (_caff == LANDING) {
2012-03-20 22:52:59 +01:00
showMoveMenuAlert();
return;
}
displayStatusArrow();
2012-03-14 18:25:17 +01:00
if ((_anyone) || (_keyPressedEsc))
return;
2012-03-24 15:19:54 +01:00
setCoordinates(7);
if (_num != 0) {
2012-03-14 23:06:23 +01:00
if (_currBitIndex > 0)
2012-03-22 08:36:59 +01:00
_coreVar._faithScore += 2;
2012-10-10 08:19:54 +02:00
++_openObjCount;
2012-03-05 00:00:48 +01:00
int tmpPlace = 0;
do {
2012-03-05 00:00:48 +01:00
++tmpPlace;
} while (!((tmpPlace > 6) || (_openObjects[tmpPlace] == 0) || (_openObjects[tmpPlace] == _num)));
if (_openObjects[tmpPlace] != _num) {
2012-10-13 12:10:48 +02:00
if (!( ((_num == 3) && ((_coreVar._currPlace == OWN_ROOM)
|| (_coreVar._currPlace == ROOM9)
|| (_coreVar._currPlace == BLUE_ROOM)
2012-10-13 12:10:48 +02:00
|| (_coreVar._currPlace == BATHROOM)))
|| ((_num == 4) && ((_coreVar._currPlace == GREEN_ROOM)
2012-10-13 12:10:48 +02:00
|| (_coreVar._currPlace == PURPLE_ROOM)
|| (_coreVar._currPlace == RED_ROOM)))
|| ((_coreVar._currPlace == DARKBLUE_ROOM) && (_num == 5))
2012-10-13 12:10:48 +02:00
|| ((_num == 6) && ((_coreVar._currPlace == BATHROOM)
|| (_coreVar._currPlace == DINING_ROOM)
|| (_coreVar._currPlace == GREEN_ROOM2)
|| (_coreVar._currPlace == ATTIC)))
|| ((_coreVar._currPlace == GREEN_ROOM2) && (_num == 2))
|| ((_coreVar._currPlace == KITCHEN) && (_num == 7))) ) {
2012-03-22 08:36:59 +01:00
if ( ((_coreVar._currPlace > DINING_ROOM) && (_coreVar._currPlace < CELLAR))
|| ((_coreVar._currPlace > RED_ROOM) && (_coreVar._currPlace < DINING_ROOM))
2012-10-13 12:10:48 +02:00
|| (_coreVar._currPlace == OWN_ROOM)
|| (_coreVar._currPlace == PURPLE_ROOM)
|| (_coreVar._currPlace == BLUE_ROOM)) {
if (getRandomNumber(1, 4) == 3)
2012-03-14 18:25:17 +01:00
_speechManager.startSpeech(7, 9, 1);
}
_openObjects[tmpPlace] = _num;
aniof(1, _num);
}
2012-03-22 08:36:59 +01:00
tmpPlace = _coreVar._currPlace;
if (_coreVar._currPlace == CRYPT)
2012-03-05 00:00:48 +01:00
tmpPlace = CELLAR;
2012-03-24 22:48:47 +01:00
_crep = _tabdon[kAouvr + (tmpPlace * 7) + _num - 1];
if (_crep == 254)
_crep = 999;
} else
2012-10-13 12:10:48 +02:00
// display "Already Opened"
_crep = 18;
}
2011-12-23 19:02:50 +00:00
}
/**
* Engine function - Place
* @remarks Originally called 'tmettre'
*/
void MortevielleEngine::fctPlace() {
2012-03-22 08:36:59 +01:00
if (_coreVar._selectedObjectId == 0) {
_crep = 186;
return;
}
2012-03-14 18:25:17 +01:00
if (!_syn)
2012-10-14 21:59:27 +02:00
displayTextInVerbBar(getEngineString(S_PUT));
displayStatusArrow();
2012-03-14 18:25:17 +01:00
if (_keyPressedEsc)
_crep = 998;
2012-03-14 18:25:17 +01:00
if ((_anyone) || (_keyPressedEsc))
return;
2012-03-24 15:19:54 +01:00
setCoordinates(8);
if (_num != 0) {
_crep = 999;
2012-10-14 21:59:27 +02:00
if (_caff == ATTIC) {
if (_num == 1) {
2012-03-22 08:36:59 +01:00
if (_coreVar._atticBallHoleObjectId != 0) {
_crep = 188;
} else {
2012-03-22 08:36:59 +01:00
_coreVar._atticBallHoleObjectId = _coreVar._selectedObjectId;
if (_coreVar._selectedObjectId == 141)
aniof(1, 7);
}
2012-03-22 08:36:59 +01:00
} else if (_coreVar._atticRodHoleObjectId != 0) {
_crep = 188;
} else {
2012-03-22 08:36:59 +01:00
_coreVar._atticRodHoleObjectId = _coreVar._selectedObjectId;
if (_coreVar._selectedObjectId == 159)
aniof(1, 6);
}
}
2012-10-14 21:59:27 +02:00
if (_caff == CELLAR) {
2012-03-22 08:36:59 +01:00
if (_coreVar._cellarObjectId != 0) {
_crep = 188;
} else {
2012-03-22 08:36:59 +01:00
_coreVar._cellarObjectId = _coreVar._selectedObjectId;
if (_coreVar._selectedObjectId == 151) {
// Open hidden passage
aniof(1, 2);
aniof(1, 1);
2012-10-11 00:45:46 +02:00
handleDescriptionText(2, 165);
displayEmptyHand();
2012-03-14 18:25:17 +01:00
_speechManager.startSpeech(6, -9, 1);
// Do you want to enter the hidden passage?
int answer = _dialogManager.show(getEngineString(S_YES_NO), 1);
if (answer == 1) {
2012-03-23 00:35:19 +01:00
Common::String alertTxt = getString(582);
_dialogManager.show(alertTxt, 1);
bool enterPassageFl = _dialogManager.showKnowledgeCheck();
_mouse.hideMouse();
hirs();
drawRightFrame();
2012-10-11 00:45:46 +02:00
clearDescriptionBar();
clearVerbBar();
_mouse.showMouse();
2012-03-22 08:36:59 +01:00
prepareRoom();
drawClock();
2012-03-14 23:06:23 +01:00
if (_currBitIndex != 0)
showPeoplePresent(_currBitIndex);
2012-03-27 22:54:50 +02:00
else
2012-03-05 23:59:21 +01:00
displayAloneText();
2012-03-14 18:25:17 +01:00
_menu.displayMenu();
if (enterPassageFl) {
2012-03-22 08:36:59 +01:00
_coreVar._currPlace = SECRET_PASSAGE;
2012-03-24 15:19:54 +01:00
_menu.setDestinationText(SECRET_PASSAGE);
} else {
2012-03-24 15:19:54 +01:00
_menu.setDestinationText(_coreVar._currPlace);
2012-03-21 08:32:36 +01:00
setPal(14);
2012-10-11 00:45:46 +02:00
drawPicture();
aniof(1, 2);
aniof(1, 1);
2012-03-23 00:35:19 +01:00
alertTxt = getString(577);
_dialogManager.show(alertTxt, 1);
aniof(2, 1);
_crep = 166;
}
prepareDisplayText();
} else {
aniof(2, 1);
_crep = 166;
}
return;
}
}
}
2012-10-14 21:59:27 +02:00
if (_caff == CRYPT) {
2012-03-22 08:36:59 +01:00
if (_coreVar._cryptObjectId == 0)
_coreVar._cryptObjectId = _coreVar._selectedObjectId;
else
_crep = 188;
}
2012-10-14 21:59:27 +02:00
if (_caff == SECRET_PASSAGE) {
2012-03-22 08:36:59 +01:00
if (_coreVar._secretPassageObjectId != 0) {
_crep = 188;
2012-03-22 08:36:59 +01:00
} else if (_coreVar._selectedObjectId == 143) {
_coreVar._secretPassageObjectId = 143;
aniof(1, 1);
} else {
_crep = 1512;
2012-03-14 18:25:17 +01:00
loseGame();
}
}
2012-10-14 21:59:27 +02:00
if (_caff == WELL) {
2012-03-22 08:36:59 +01:00
if (_coreVar._wellObjectId != 0) {
_crep = 188;
2012-03-22 08:36:59 +01:00
} else if ((_coreVar._selectedObjectId == 140) || (_coreVar._selectedObjectId == 120)) {
_coreVar._wellObjectId = _coreVar._selectedObjectId;
aniof(1, 1);
} else {
_crep = 185;
}
}
if (_crep != 188)
displayEmptyHand();
}
2011-12-23 19:02:50 +00:00
}
/**
* Engine function - Turn
* @remarks Originally called 'ttourner'
*/
void MortevielleEngine::fctTurn() {
if (_caff > 99) {
_crep = 149;
return;
}
2012-03-14 18:25:17 +01:00
if (!_syn)
2012-10-14 21:59:27 +02:00
displayTextInVerbBar(getEngineString(S_TURN));
displayStatusArrow();
2012-03-14 18:25:17 +01:00
if ((_anyone) || (_keyPressedEsc))
return;
2012-03-24 15:19:54 +01:00
setCoordinates(9);
if (_num != 0) {
_crep = 997;
2012-03-22 08:36:59 +01:00
if ((_coreVar._currPlace == ATTIC) && (_coreVar._atticRodHoleObjectId == 159) && (_coreVar._atticBallHoleObjectId == 141)) {
2012-10-11 00:45:46 +02:00
handleDescriptionText(2, 167);
2012-03-14 18:25:17 +01:00
_speechManager.startSpeech(7, 9, 1);
int answer = _dialogManager.show(getEngineString(S_YES_NO), 1);
if (answer == 1)
2012-03-14 18:25:17 +01:00
_endGame = true;
else
_crep = 168;
}
2012-03-22 08:36:59 +01:00
if ((_coreVar._currPlace == SECRET_PASSAGE) && (_coreVar._secretPassageObjectId == 143)) {
2012-10-11 00:45:46 +02:00
handleDescriptionText(2, 175);
clearVerbBar();
2012-03-14 18:25:17 +01:00
_speechManager.startSpeech(6, -9, 1);
int answer = _dialogManager.show(getEngineString(S_YES_NO), 1);
if (answer == 1) {
2012-03-22 08:36:59 +01:00
_coreVar._currPlace = CRYPT;
prepareDisplayText();
} else
_crep = 176;
}
}
2011-12-23 19:02:50 +00:00
}
/**
* Engine function - Hide Self
* @remarks Originally called 'tcacher'
*/
void MortevielleEngine::fctSelfHide() {
2012-03-14 18:25:17 +01:00
if (!_syn)
2012-10-14 21:59:27 +02:00
displayTextInVerbBar(getEngineString(S_HIDE_SELF));
displayStatusArrow();
2012-03-14 18:25:17 +01:00
if (!(_anyone) && !(_keyPressedEsc)) {
2012-03-24 15:19:54 +01:00
setCoordinates(10);
if (_num == 0)
2012-03-14 18:25:17 +01:00
_hiddenHero = false;
else {
2012-03-14 18:25:17 +01:00
_hiddenHero = true;
_crep = 999;
}
}
2011-12-23 19:02:50 +00:00
}
/**
* Engine function - Attach
* @remarks Originally called 'tattacher'
*/
void MortevielleEngine::fctAttach() {
2012-03-22 08:36:59 +01:00
if (_coreVar._selectedObjectId == 0)
_crep = 186;
else {
2012-03-14 18:25:17 +01:00
if (!_syn)
2012-10-14 21:59:27 +02:00
displayTextInVerbBar(getEngineString(S_TIE));
displayStatusArrow();
2012-03-14 18:25:17 +01:00
if (!(_anyone) && !(_keyPressedEsc)) {
2012-03-24 15:19:54 +01:00
setCoordinates(8);
_crep = 997;
if ((_num != 0) && (_coreVar._currPlace == WELL)) {
_crep = 999;
2012-03-22 08:36:59 +01:00
if ((_coreVar._selectedObjectId == 120) || (_coreVar._selectedObjectId == 140)) {
_coreVar._wellObjectId = _coreVar._selectedObjectId;
aniof(1, 1);
} else
_crep = 185;
displayEmptyHand();
}
}
}
2011-12-23 19:02:50 +00:00
}
/**
* Engine function - Close
* @remarks Originally called 'tfermer'
*/
void MortevielleEngine::fctClose() {
2012-03-14 18:25:17 +01:00
if (!_syn)
2012-10-14 21:59:27 +02:00
displayTextInVerbBar(getEngineString(S_CLOSE));
if (_caff < ROOM26) {
displayStatusArrow();
2012-03-14 18:25:17 +01:00
if (_keyPressedEsc)
_crep = 998;
2012-03-14 18:25:17 +01:00
if ((_anyone) || (_keyPressedEsc))
return;
2012-03-24 15:19:54 +01:00
setCoordinates(7);
if (_num != 0) {
int cx = 0;
do {
++cx;
} while ((cx <= 6) && (_num != _openObjects[cx]));
if (_num == _openObjects[cx]) {
aniof(2, _num);
_crep = 998;
_openObjects[cx] = 0;
2012-10-10 08:19:54 +02:00
--_openObjCount;
if (_openObjCount < 0)
_openObjCount = 0;
2013-06-29 10:30:42 +02:00
int chai = rechai();
2012-03-23 07:44:04 +01:00
if (_mchai == chai)
_mchai = 0;
2012-03-02 08:38:41 +01:00
} else {
_crep = 187;
2012-03-02 08:38:41 +01:00
}
}
}
if (_caff == ROOM26)
_crep = 999;
2011-12-23 19:02:50 +00:00
}
/**
* Engine function - Knock
* @remarks Originally called 'tfrapper'
*/
void MortevielleEngine::fctKnock() {
2012-03-14 18:25:17 +01:00
if (!_syn)
2012-10-14 21:59:27 +02:00
displayTextInVerbBar(getEngineString(S_HIT));
2012-03-22 08:36:59 +01:00
if (_coreVar._currPlace == LANDING) {
_dialogManager.show(getEngineString(S_BEFORE_USE_DEP_MENU), 1);
return;
}
2012-03-22 08:36:59 +01:00
if (_coreVar._currPlace < DOOR) {
displayStatusArrow();
2012-03-14 18:25:17 +01:00
if (!(_anyone) && !(_keyPressedEsc)) {
2012-03-22 08:36:59 +01:00
if ((_coreVar._currPlace < MOUNTAIN) && (_coreVar._currPlace != LANDING))
_crep = 133;
else
_crep = 997;
}
return;
}
2012-03-22 08:36:59 +01:00
if (_coreVar._currPlace == ROOM26) {
int rand = (getRandomNumber(0, 8)) - 4;
2012-03-14 18:25:17 +01:00
_speechManager.startSpeech(11, rand, 1);
2012-10-10 08:19:54 +02:00
int p = getPresenceStats(rand, _coreVar._faithScore, _roomDoorId);
int l = _roomDoorId;
if (l != OWN_ROOM) {
if (p != -500) {
if (rand > p)
_crep = 190;
else {
setPresenceFlags(l);
getKnockAnswer();
}
} else
getKnockAnswer();
}
2012-10-10 08:19:54 +02:00
if (_roomDoorId == GREEN_ROOM2)
_crep = 190;
}
2011-12-23 19:02:50 +00:00
}
/**
* Engine function - Self / Put
* @remarks Originally called 'tposer'
*/
void MortevielleEngine::fctSelfPut() {
2012-03-14 18:25:17 +01:00
if (!_syn)
2012-10-14 21:59:27 +02:00
displayTextInVerbBar(getEngineString(S_POSE));
2012-03-22 08:36:59 +01:00
if (_coreVar._selectedObjectId == 0)
_crep = 186;
else {
if (_caff > 99) {
_crep = 999;
ajchai();
if (_crep != 192)
displayEmptyHand();
return;
}
displayStatusArrow();
2012-03-14 18:25:17 +01:00
if ((_anyone) || (_keyPressedEsc))
return;
2012-03-24 15:19:54 +01:00
setCoordinates(7);
_crep = 124;
if (_num != 0) {
2013-06-29 10:30:42 +02:00
int chai = rechai();
if (chai == 0)
_crep = 997;
else {
int cx = 0;
do {
++cx;
} while ((cx <= 6) && (_num != _openObjects[cx]));
if (_num != _openObjects[cx])
_crep = 187;
else {
2012-03-23 07:44:04 +01:00
_mchai = chai;
_crep = 999;
}
}
} else {
2012-03-24 15:19:54 +01:00
setCoordinates(8);
if (_num != 0) {
_crep = 998;
if (_caff == PURPLE_ROOM) {
2012-03-22 08:36:59 +01:00
if (_coreVar._purpleRoomObjectId != 0)
_crep = 188;
else
2012-03-22 08:36:59 +01:00
_coreVar._purpleRoomObjectId = _coreVar._selectedObjectId;
}
if (_caff == ATTIC) {
if (_num == 1) {
2012-03-22 08:36:59 +01:00
if (_coreVar._atticBallHoleObjectId != 0)
_crep = 188;
else
2012-03-22 08:36:59 +01:00
_coreVar._atticBallHoleObjectId = _coreVar._selectedObjectId;
} else if (_coreVar._atticRodHoleObjectId != 0) {
_crep = 188;
} else {
2012-03-22 08:36:59 +01:00
_coreVar._atticRodHoleObjectId = _coreVar._selectedObjectId;
}
}
if (_caff == CRYPT) {
2012-03-22 08:36:59 +01:00
if (_coreVar._cryptObjectId != 0)
_crep = 188;
else
2012-03-22 08:36:59 +01:00
_coreVar._cryptObjectId = _coreVar._selectedObjectId;
}
if (_caff == WELL)
_crep = 185;
if ((_caff == CELLAR) || (_caff == SECRET_PASSAGE))
_crep = 124;
} else {
_crep = 124;
if (_caff == WELL) {
2012-03-24 15:19:54 +01:00
setCoordinates(5);
if (_num != 0)
_crep = 185;
}
}
}
if (_caff == INSIDE_WELL)
_crep = 185;
if ((_crep == 999) || (_crep == 185) || (_crep == 998)) {
if (_crep == 999)
ajchai();
if (_crep != 192)
displayEmptyHand();
}
}
2011-12-23 19:02:50 +00:00
}
/**
* Engine function - Listen
* @remarks Originally called 'tecouter'
*/
void MortevielleEngine::fctListen() {
2012-03-22 08:36:59 +01:00
if (_coreVar._currPlace != ROOM26)
_crep = 101;
else {
2012-03-14 23:06:23 +01:00
if (_currBitIndex != 0)
2012-03-22 08:36:59 +01:00
++_coreVar._faithScore;
int rand;
2012-10-10 08:19:54 +02:00
int p = getPresenceStats(rand, _coreVar._faithScore, _roomDoorId);
int l = _roomDoorId;
if (l != OWN_ROOM) {
if (p != -500) {
if (rand > p)
_crep = 101;
else {
setPresenceFlags(l);
int j, h, m;
2012-03-05 23:59:21 +01:00
updateHour(j, h, m);
rand = getRandomNumber(1, 100);
if ((h >= 0) && (h < 8)) {
if (rand > 30)
_crep = 101;
else
_crep = 178;
} else if (rand > 70)
_crep = 101;
else
_crep = 178;
}
} else
_crep = 178;
}
}
2011-12-23 19:02:50 +00:00
}
/**
* Engine function - Eat
* @remarks Originally called 'tmanger'
*/
void MortevielleEngine::fctEat() {
2012-03-22 08:36:59 +01:00
if ((_coreVar._currPlace > LANDING) && (_coreVar._currPlace < ROOM26)) {
_crep = 148;
} else {
2012-03-24 15:19:54 +01:00
exitRoom();
2012-03-22 08:36:59 +01:00
_coreVar._currPlace = DINING_ROOM;
2012-10-14 21:59:27 +02:00
_caff = DINING_ROOM;
resetRoomVariables(_coreVar._currPlace);
2012-03-24 15:19:54 +01:00
_menu.setDestinationText(_coreVar._currPlace);
int j, h, m;
2012-03-05 23:59:21 +01:00
updateHour(j, h, m);
if ((h == 12) || (h == 13) || (h == 19)) {
2012-03-22 08:36:59 +01:00
_coreVar._faithScore -= (_coreVar._faithScore / 7);
if (h == 12) {
if (m == 0)
h = 4;
else
h = 3;
}
if ((h == 13) || (h == 19)) {
if (m == 0)
h = 2;
else
h = 1;
}
2012-03-27 22:54:50 +02:00
2012-10-13 12:10:48 +02:00
_currentHourCount += h;
_crep = 135;
2012-03-22 08:36:59 +01:00
prepareRoom();
} else {
_crep = 134;
}
}
2011-12-23 19:02:50 +00:00
}
/**
* Engine function - Enter
* @remarks Originally called 'tentrer'
*/
void MortevielleEngine::fctEnter() {
2012-03-22 08:36:59 +01:00
if ((_coreVar._currPlace == MANOR_FRONT) || (_coreVar._currPlace == MANOR_BACK)) {
2012-03-14 18:25:17 +01:00
gotoDiningRoom();
2012-03-24 15:19:54 +01:00
_menu.setDestinationText(_coreVar._currPlace);
2012-03-22 08:36:59 +01:00
} else if (_coreVar._currPlace == LANDING)
2012-03-20 22:52:59 +01:00
showMoveMenuAlert();
2012-10-10 08:19:54 +02:00
else if (_roomDoorId == OWN_ROOM)
_crep = 997;
2012-10-10 08:19:54 +02:00
else if ((_roomDoorId == ROOM9) && (_coreVar._selectedObjectId != 136)) {
_crep = 189;
2012-10-14 21:59:27 +02:00
_coreVar._availableQuestion[8] = '*';
} else {
int z = 0;
2012-03-14 18:25:17 +01:00
if (!_blo)
2012-10-10 08:19:54 +02:00
z = getPresence(_roomDoorId);
if (z != 0) {
2012-10-10 08:19:54 +02:00
if ((_roomDoorId == TOILETS) || (_roomDoorId == BATHROOM))
_crep = 179;
else {
2012-10-13 12:10:48 +02:00
int randVal = (getRandomNumber(0, 10)) - 5;
_speechManager.startSpeech(7, randVal, 1);
aniof(1, 1);
2012-03-27 22:54:50 +02:00
2012-10-13 12:10:48 +02:00
int charIndex = convertBitIndexToCharacterIndex(z);
2012-03-22 08:36:59 +01:00
++_coreVar._faithScore;
_coreVar._currPlace = LANDING;
2013-07-22 23:59:43 +02:00
_currMenu = MENU_DISCUSS;
_currAction = _menu._discussMenu[charIndex];
2012-03-14 18:25:17 +01:00
_syn = true;
2012-10-10 08:19:54 +02:00
if (_roomDoorId == ROOM9) {
2012-03-14 18:25:17 +01:00
_col = true;
_caff = 70;
2012-10-11 00:45:46 +02:00
drawPictureWithText();
handleDescriptionText(2, _caff);
} else
2012-03-14 18:25:17 +01:00
_col = false;
2012-10-10 08:19:54 +02:00
resetRoomVariables(_roomDoorId);
_roomDoorId = OWN_ROOM;
}
} else {
2012-10-13 12:10:48 +02:00
int randVal = (getRandomNumber(0, 10)) - 5;
_speechManager.startSpeech(7, randVal, 1);
aniof(1, 1);
2012-03-27 22:54:50 +02:00
2012-10-10 08:19:54 +02:00
_coreVar._currPlace = _roomDoorId;
prepareDisplayText();
resetRoomVariables(_coreVar._currPlace);
2012-03-24 15:19:54 +01:00
_menu.setDestinationText(_coreVar._currPlace);
2012-10-10 08:19:54 +02:00
_roomDoorId = OWN_ROOM;
_savedBitIndex = 0;
2012-03-14 23:06:23 +01:00
_currBitIndex = 0;
}
}
2011-12-23 19:02:50 +00:00
}
/**
* Engine function - Sleep
* @remarks Originally called 'tdormir'
*/
void MortevielleEngine::fctSleep() {
int j, h, m;
2011-12-23 19:02:50 +00:00
2012-03-22 08:36:59 +01:00
if ((_coreVar._currPlace > LANDING) && (_coreVar._currPlace < ROOM26)) {
_crep = 148;
return;
}
2012-03-22 08:36:59 +01:00
if (_coreVar._currPlace != OWN_ROOM) {
2012-03-24 15:19:54 +01:00
exitRoom();
2012-03-22 08:36:59 +01:00
_coreVar._currPlace = OWN_ROOM;
prepareDisplayText();
2012-10-11 00:45:46 +02:00
drawPictureWithText();
resetRoomVariables(_coreVar._currPlace);
2012-03-24 15:19:54 +01:00
_menu.setDestinationText(_coreVar._currPlace);
}
2012-10-11 00:45:46 +02:00
clearVerbBar();
clearDescriptionBar();
2012-03-16 07:32:43 +01:00
prepareScreenType2();
2012-03-14 18:25:17 +01:00
ecr2(getEngineString(S_WANT_TO_WAKE_UP));
2012-03-05 23:59:21 +01:00
updateHour(j, h, m);
int answer;
do {
if (h < 8) {
2012-03-22 08:36:59 +01:00
_coreVar._faithScore -= (_coreVar._faithScore / 20);
int z = (7 - h) * 2;
if (m == 30)
--z;
2012-10-13 12:10:48 +02:00
_currentHourCount += z;
h = 7;
}
2012-10-13 12:10:48 +02:00
_currentHourCount += 2;
++h;
if (h > 23)
h = 0;
2012-03-22 08:36:59 +01:00
prepareRoom();
answer = _dialogManager.show(getEngineString(S_YES_NO), 1);
2012-03-14 18:25:17 +01:00
_anyone = false;
} while (answer != 1);
_crep = 998;
_num = 0;
2011-12-23 19:02:50 +00:00
}
/**
* Engine function - Force
* @remarks Originally called 'tdefoncer'
*/
void MortevielleEngine::fctForce() {
2012-03-14 18:25:17 +01:00
if (!_syn)
2012-10-14 21:59:27 +02:00
displayTextInVerbBar(getEngineString(S_SMASH));
if (_caff < DOOR)
displayStatusArrow();
2012-03-14 18:25:17 +01:00
if ((!_anyone) && (!_keyPressedEsc)) {
2012-03-22 08:36:59 +01:00
if (_coreVar._currPlace != ROOM26)
_crep = 997;
else {
_crep = 143;
2012-03-22 08:36:59 +01:00
_coreVar._faithScore += 2;
}
}
2011-12-23 19:02:50 +00:00
}
/**
* Engine function - Leave
* @remarks Originally called 'tsortir'
*/
void MortevielleEngine::fctLeave() {
2012-03-24 15:19:54 +01:00
exitRoom();
_crep = 0;
2012-03-22 08:36:59 +01:00
if ((_coreVar._currPlace == MOUNTAIN) || (_coreVar._currPlace == MANOR_FRONT) || (_coreVar._currPlace == MANOR_BACK) || (_coreVar._currPlace == WELL))
_crep = 997;
else {
2012-03-14 18:25:17 +01:00
int nextPlace = OWN_ROOM;
2012-03-22 08:36:59 +01:00
if ((_coreVar._currPlace < CRYPT) || (_coreVar._currPlace == ROOM26))
2012-03-14 18:25:17 +01:00
nextPlace = DINING_ROOM;
2012-03-22 08:36:59 +01:00
else if ((_coreVar._currPlace == DINING_ROOM) || (_coreVar._currPlace == CHAPEL))
2012-03-14 18:25:17 +01:00
nextPlace = MANOR_FRONT;
2012-03-22 08:36:59 +01:00
else if ((_coreVar._currPlace < DINING_ROOM) || (_coreVar._currPlace == ATTIC))
2012-03-14 18:25:17 +01:00
nextPlace = LANDING;
2012-03-22 08:36:59 +01:00
else if (_coreVar._currPlace == CRYPT) {
2012-03-14 18:25:17 +01:00
nextPlace = SECRET_PASSAGE;
_crep = 176;
2012-03-22 08:36:59 +01:00
} else if (_coreVar._currPlace == SECRET_PASSAGE)
2012-03-24 15:19:54 +01:00
nextPlace = checkLeaveSecretPassage();
2012-03-22 08:36:59 +01:00
else if (_coreVar._currPlace == INSIDE_WELL)
2012-03-14 18:25:17 +01:00
nextPlace = WELL;
if (_crep != 997)
2012-03-22 08:36:59 +01:00
_coreVar._currPlace = nextPlace;
2012-03-14 18:25:17 +01:00
_caff = nextPlace;
if (_crep == 0)
_crep = nextPlace;
resetRoomVariables(nextPlace);
2012-03-24 15:19:54 +01:00
_menu.setDestinationText(nextPlace);
}
2011-12-23 19:02:50 +00:00
}
/**
* Engine function - Wait
* @remarks Originally called 'tattendre'
*/
void MortevielleEngine::fctWait() {
_savedBitIndex = 0;
2012-10-11 00:45:46 +02:00
clearVerbBar();
int answer;
do {
2012-10-13 12:10:48 +02:00
++_currentHourCount;
2012-03-22 08:36:59 +01:00
prepareRoom();
2012-03-14 18:25:17 +01:00
if (!_blo)
2012-03-24 15:19:54 +01:00
getPresence(_coreVar._currPlace);
if ((_currBitIndex != 0) && (_savedBitIndex == 0)) {
_crep = 998;
2012-03-22 08:36:59 +01:00
if ((_coreVar._currPlace == ATTIC) || (_coreVar._currPlace == CELLAR))
initCaveOrCellar();
2012-03-22 08:36:59 +01:00
if ((_coreVar._currPlace > OWN_ROOM) && (_coreVar._currPlace < DINING_ROOM))
2012-03-14 18:25:17 +01:00
_anyone = true;
_savedBitIndex = _currBitIndex;
2012-03-14 18:25:17 +01:00
if (!_anyone)
2012-03-22 08:36:59 +01:00
prepareRoom();
return;
}
2012-10-11 00:45:46 +02:00
handleDescriptionText(2, 102);
answer = _dialogManager.show(getEngineString(S_YES_NO), 1);
} while (answer != 2);
_crep = 998;
2012-03-14 18:25:17 +01:00
if (!_anyone)
2012-03-22 08:36:59 +01:00
prepareRoom();
2011-12-23 19:02:50 +00:00
}
/**
* Engine function - Sound
* @remarks Originally called 'tsonder'
*/
void MortevielleEngine::fctSound() {
2012-03-14 18:25:17 +01:00
if (!_syn)
2012-10-14 21:59:27 +02:00
displayTextInVerbBar(getEngineString(S_PROBE2));
if (_caff < 27) {
displayStatusArrow();
2012-03-14 18:25:17 +01:00
if (!(_anyone) && (!_keyPressedEsc))
_crep = 145;
_num = 0;
}
2011-12-23 19:02:50 +00:00
}
/**
* Engine function - Discuss
* @remarks Originally called 'tparler'
*/
void MortevielleEngine::fctDiscuss() {
2012-10-14 10:28:03 +02:00
bool questionAsked[47];
int cy, cx;
int x, y;
Common::String lib[47];
2012-10-14 10:28:03 +02:00
int choice;
2012-10-14 10:28:03 +02:00
int displId;
2011-12-23 19:02:50 +00:00
endSearch();
2012-03-14 18:25:17 +01:00
if (_col)
2012-10-14 10:28:03 +02:00
displId = 128;
else {
cx = 0;
do {
++cx;
2013-07-22 23:59:43 +02:00
} while (_menu._discussMenu[cx] != _currAction);
_caff = 69 + cx;
2012-10-11 00:45:46 +02:00
drawPictureWithText();
handleDescriptionText(2, _caff);
2012-10-14 10:28:03 +02:00
displId = _caff + 60;
}
2012-03-24 15:19:54 +01:00
testKey(false);
mennor();
_mouse.hideMouse();
hirs();
premtet();
2012-10-14 10:28:03 +02:00
startDialog(displId);
hirs();
for (int ix = 1; ix <= 46; ++ix)
2012-10-14 10:28:03 +02:00
questionAsked[ix] = false;
for (int ix = 1; ix <= 45; ++ix) {
2012-03-23 00:35:19 +01:00
lib[ix] = getString(ix + kQuestionStringIndex);
2012-10-14 10:28:03 +02:00
for (int i = lib[ix].size(); i <= 40; ++i)
lib[ix] = lib[ix] + ' ';
}
lib[46] = lib[45];
lib[45] = ' ';
_mouse.showMouse();
do {
2012-10-14 10:28:03 +02:00
choice = 0;
int posX = 0;
int posY = 0;
for (int icm = 1; icm < 43; icm++) {
_screenSurface.putxy(posX, posY);
2012-10-14 21:59:27 +02:00
if (_coreVar._availableQuestion[icm] == '*') {
2012-10-14 10:28:03 +02:00
// If question already asked, write it in reverse video
if (questionAsked[icm])
2013-07-20 10:47:32 +02:00
displayQuestionText(lib[icm], 1);
else
2013-07-20 10:47:32 +02:00
displayQuestionText(lib[icm], 0);
}
if (icm == 23) {
2012-10-14 10:28:03 +02:00
posY = 0;
posX = 320;
} else
2012-10-14 10:28:03 +02:00
posY += 8;
}
2012-03-14 18:25:17 +01:00
_screenSurface.putxy(320, 176);
2013-07-20 10:47:32 +02:00
displayQuestionText(lib[46], 0);
2012-10-14 10:28:03 +02:00
char retKey = '\0';
bool click;
do {
2012-10-14 10:28:03 +02:00
bool dummyFl;
_mouse.moveMouse(dummyFl, retKey);
2013-06-26 07:51:11 +02:00
if (shouldQuit())
2013-06-24 23:48:00 +02:00
return;
2012-10-14 10:28:03 +02:00
_mouse.getMousePosition(x, y, click);
2012-10-14 21:59:27 +02:00
x *= (3 - _resolutionScaler);
if (x > 319)
cx = 41;
else
cx = 1;
2012-02-21 23:09:29 +01:00
cy = ((uint)y >> 3) + 1; // 0-199 => 1-25
if ((cy > 23) || ((cx == 41) && ((cy >= 20) && (cy <= 22)))) {
2012-10-14 10:28:03 +02:00
if (choice != 0) {
posY = ((choice - 1) % 23) << 3;
if (choice > 23)
posX = 320;
else
2012-10-14 10:28:03 +02:00
posX = 0;
_screenSurface.putxy(posX, posY);
if (questionAsked[choice])
2013-07-20 10:47:32 +02:00
displayQuestionText(lib[choice], 0);
else
2013-07-20 10:47:32 +02:00
displayQuestionText(lib[choice], 1);
2012-10-14 10:28:03 +02:00
questionAsked[choice] = !questionAsked[choice];
choice = 0;
}
} else {
int ix = cy;
if (cx == 41)
2012-03-13 08:14:19 +01:00
ix += 23;
2012-10-14 10:28:03 +02:00
if (ix != choice) {
if (choice != 0) {
posY = ((choice - 1) % 23) << 3;
if (choice > 23)
posX = 320;
else
2012-10-14 10:28:03 +02:00
posX = 0;
_screenSurface.putxy(posX, posY);
if (questionAsked[choice])
2013-07-20 10:47:32 +02:00
displayQuestionText(lib[choice], 0);
else
2013-07-20 10:47:32 +02:00
displayQuestionText(lib[choice], 1);
2012-10-14 10:28:03 +02:00
questionAsked[choice] = ! questionAsked[choice];
}
2012-10-14 21:59:27 +02:00
if ((_coreVar._availableQuestion[ix] == '*') || (ix == 46)) {
2012-10-14 10:28:03 +02:00
posY = ((ix - 1) % 23) << 3;
if (ix > 23)
2012-10-14 10:28:03 +02:00
posX = 320;
else
2012-10-14 10:28:03 +02:00
posX = 0;
_screenSurface.putxy(posX, posY);
if (questionAsked[ix])
2013-07-20 10:47:32 +02:00
displayQuestionText(lib[ix], 0);
else
2013-07-20 10:47:32 +02:00
displayQuestionText(lib[ix], 1);
2012-10-14 10:28:03 +02:00
questionAsked[ix] = ! questionAsked[ix];
choice = ix;
} else
2012-10-14 10:28:03 +02:00
choice = 0;
}
}
2012-10-14 10:28:03 +02:00
} while (!((retKey == '\15') || (((click != 0) || getMouseClick()) && (choice != 0))));
2012-03-14 18:25:17 +01:00
setMouseClick(false);
2012-10-14 10:28:03 +02:00
// If choice is not "End of Conversation"
if (choice != 46) {
int ix = choice - 1;
2012-03-14 18:25:17 +01:00
if (_col) {
_col = false;
2012-03-22 08:36:59 +01:00
_coreVar._currPlace = 15;
2012-10-14 10:28:03 +02:00
int maxRandVal;
2012-10-10 08:19:54 +02:00
if (_openObjCount > 0)
2012-10-14 10:28:03 +02:00
maxRandVal = 8;
else
2012-10-14 10:28:03 +02:00
maxRandVal = 4;
if (getRandomNumber(1, maxRandVal) == 2)
displId = 129;
else {
2012-10-14 10:28:03 +02:00
displId = 138;
2012-03-22 08:36:59 +01:00
_coreVar._faithScore += (3 * (_coreVar._faithScore / 10));
}
} else if (_nbrep[_caff - 69] < _nbrepm[_caff - 69]) {
2012-10-14 10:28:03 +02:00
displId = _tabdon[kArep + (ix << 3) + (_caff - 70)];
2012-03-24 22:48:47 +01:00
_coreVar._faithScore += _tabdon[kArcf + ix];
++_nbrep[_caff - 69];
} else {
2012-03-22 08:36:59 +01:00
_coreVar._faithScore += 3;
2012-10-14 10:28:03 +02:00
displId = 139;
}
_mouse.hideMouse();
hirs();
premtet();
2012-10-14 10:28:03 +02:00
startDialog(displId);
_mouse.showMouse();
2012-10-14 10:28:03 +02:00
if ((displId == 84) || (displId == 86)) {
2012-10-14 21:59:27 +02:00
_coreVar._pctHintFound[5] = '*';
_coreVar._availableQuestion[7] = '*';
}
2012-10-14 10:28:03 +02:00
if ((displId == 106) || (displId == 108) || (displId == 94)) {
for (int indx = 29; indx <= 31; ++indx)
2012-10-14 21:59:27 +02:00
_coreVar._availableQuestion[indx] = '*';
_coreVar._pctHintFound[7] = '*';
}
2012-10-14 10:28:03 +02:00
if (displId == 70) {
2012-10-14 21:59:27 +02:00
_coreVar._pctHintFound[8] = '*';
_coreVar._availableQuestion[32] = '*';
}
_mouse.hideMouse();
hirs();
_mouse.showMouse();
}
2012-10-14 10:28:03 +02:00
} while ((choice != 46) && (displId != 138));
2012-03-14 18:25:17 +01:00
if (_col) {
2012-03-22 08:36:59 +01:00
_coreVar._faithScore += (3 * (_coreVar._faithScore / 10));
_mouse.hideMouse();
hirs();
premtet();
startDialog(138);
_mouse.showMouse();
2012-03-14 18:25:17 +01:00
_col = false;
2012-03-22 08:36:59 +01:00
_coreVar._currPlace = LANDING;
}
_controlMenu = 0;
_mouse.hideMouse();
hirs();
drawRightFrame();
_mouse.showMouse();
2012-03-14 23:06:23 +01:00
showPeoplePresent(_currBitIndex);
2012-03-22 08:36:59 +01:00
prepareRoom();
drawClock();
prepareDisplayText();
/* chech;*/
2012-03-24 15:19:54 +01:00
_menu.setDestinationText(_coreVar._currPlace);
2012-10-11 00:45:46 +02:00
clearVerbBar();
2011-12-23 19:02:50 +00:00
}
/**
* Engine function - Smell
* @remarks Originally called 'tsentir'
*/
void MortevielleEngine::fctSmell() {
_crep = 119;
if (_caff < ROOM26) {
2012-03-14 18:25:17 +01:00
if (!_syn)
2012-10-14 21:59:27 +02:00
displayTextInVerbBar(getEngineString(S_SMELL));
displayStatusArrow();
2012-03-14 18:25:17 +01:00
if (!(_anyone) && !(_keyPressedEsc))
2012-10-14 21:59:27 +02:00
if (_caff == CRYPT)
_crep = 153;
} else if (_caff == 123)
_crep = 110;
_num = 0;
2011-12-23 19:02:50 +00:00
}
/**
* Engine function - Scratch
* @remarks Originally called 'tgratter'
*/
void MortevielleEngine::fctScratch() {
_crep = 155;
if (_caff < 27) {
2012-03-14 18:25:17 +01:00
if (!_syn)
2012-10-14 21:59:27 +02:00
displayTextInVerbBar(getEngineString(S_SCRATCH));
displayStatusArrow();
}
_num = 0;
2011-12-23 19:02:50 +00:00
}
/**
* The game is over
* @remarks Originally called 'tmaj1'
*/
void MortevielleEngine::endGame() {
_quitGame = true;
tlu(13, 152);
displayEmptyHand();
2012-10-11 00:45:46 +02:00
clearUpperLeftPart();
clearDescriptionBar();
clearVerbBar();
handleDescriptionText(9, 1509);
2012-03-24 15:19:54 +01:00
testKey(false);
_mouse.hideMouse();
_caff = 70;
_text.taffich();
hirs();
premtet();
startDialog(141);
_mouse.showMouse();
2012-10-11 00:45:46 +02:00
clearUpperLeftPart();
handleDescriptionText(9, 1509);
handleDescriptionText(2, 142);
2012-03-24 15:19:54 +01:00
testKey(false);
_caff = 32;
2012-10-11 00:45:46 +02:00
drawPictureWithText();
handleDescriptionText(6, 34);
handleDescriptionText(2, 35);
2012-03-16 07:32:43 +01:00
startMusicOrSpeech(0);
2012-03-24 15:19:54 +01:00
testKey(false);
2012-03-27 22:54:50 +02:00
// A wait message was displayed.
2012-03-24 15:19:54 +01:00
// testKey (aka tkey1) was called before and after.
// This double call is useless, thus removed
resetVariables();
2011-12-23 19:02:50 +00:00
}
/**
* You lost!
* @remarks Originally called 'tencore'
*/
2012-03-14 18:25:17 +01:00
void MortevielleEngine::askRestart() {
2012-10-11 00:45:46 +02:00
clearDescriptionBar();
2012-03-16 07:32:43 +01:00
startMusicOrSpeech(0);
2012-03-24 15:19:54 +01:00
testKey(false);
displayEmptyHand();
resetVariables();
2012-03-13 00:06:15 +01:00
initGame();
2012-03-16 07:32:43 +01:00
_currHour = 10;
_currHalfHour = 0;
_currDay = 0;
_minute = 0;
_hour = 10;
_day = 0;
2012-10-11 00:45:46 +02:00
handleDescriptionText(2, 180);
int answer = _dialogManager.show(getEngineString(S_YES_NO), 1);
_quitGame = (answer != 1);
2011-12-23 19:02:50 +00:00
}
2011-12-26 22:08:18 +01:00
} // End of namespace Mortevielle