aboutsummaryrefslogtreecommitdiff
path: root/engines/mohawk/cstime_cases.cpp
blob: 746196e1209a04d61a86c52c42d2d3fd50153f74 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
/* 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.
 *
 * $URL$
 * $Id$
 *
 */

#include "mohawk/cstime_cases.h"
#include "mohawk/cstime_ui.h"

namespace Mohawk {

CSTimeCase1::CSTimeCase1(MohawkEngine_CSTime *vm) : CSTimeCase(vm, 1) {
}

CSTimeCase1::~CSTimeCase1() {
}

bool CSTimeCase1::checkConvCondition(uint16 conditionId) {
	const Common::Array<CSTimeHotspot> &hotspots = getCurrScene()->getHotspots();

	bool gotTorch = _vm->_haveInvItem[1];

	// These are all for conversations in the first scene (with the boatman).
	switch (conditionId) {
	case 0:
		// Got the torch?
		return (gotTorch);
	case 1:
		// Is the bag still on land?
		return (hotspots[5].state == 1);
	case 2:
		// Is the bag on the boat, but player hasn't taken the torch?
		return (hotspots[5].state != 1 && !gotTorch);
	}

	return false;
}

bool CSTimeCase1::checkAmbientCondition(uint16 charId, uint16 ambientId) {
	return true;
}

bool CSTimeCase1::checkObjectCondition(uint16 objectId) {
	const Common::Array<CSTimeHotspot> &hotspots = getCurrScene()->getHotspots();

	switch (_currScene) {
	case 1:
		switch (objectId) {
		case 1:
			// Hide bag on boat if it's not there.
			return (hotspots[5].state == 1);
		case 2:
			// Hide bag on land if it's not there.
			return (hotspots[5].state != 1);
		case 3:
			// Hide torch if it's been picked up.
			return (hotspots[4].state == 1);
		}
		break;

	case 2:
		// The first note piece.
		return !_vm->getInterface()->getCarmenNote()->havePiece(0);

	case 3:
		// The features representing different stages in the body sequence.
		if (objectId == 6 && _vm->_caseVariable[3] != 0)
			return false;
		else if (objectId == 7 && _vm->_caseVariable[3] != 1)
			return false;
		else if (objectId == 8 && _vm->_caseVariable[3] != 2)
			return false;
		break;

	case 4:
		// The second note piece?
		if (objectId == 0)
			return (hotspots[0].state > 0);
		break;

	case 5:
		// The third note piece.
		if (objectId == 1)
			return !_vm->getInterface()->getCarmenNote()->havePiece(2);
	}

	return true;
}

void CSTimeCase1::selectHelpStrings() {
	if (_currScene == 1) {
		if (_vm->_haveInvItem[1]) {
			// Got the torch, ready to leave.
			// FIXME
		} else {
			// Still don't have the torch.
			// FIXME
		}
	} else {
		// FIXME
	}

	// FIXME
}

void CSTimeCase1::handleConditionalEvent(const CSTimeEvent &event) {
	CSTimeEvent newEvent;

	switch (event.param2) {
	case 0:
		// Trying to enter the first room of the tomb.
		if (!_conversations[1]->getAsked(2, 0)) {
			// We need a plan first.
			_vm->addEvent(CSTimeEvent(kCSTimeEventCharStartFlapping, getCurrScene()->getHelperId(), 12352));
		} else if (!_vm->getInterface()->getCarmenNote()->havePiece(0)) {
			// Shouldn't we take a look at that note?
			_vm->addEvent(CSTimeEvent(kCSTimeEventCharStartFlapping, getCurrScene()->getHelperId(), 10355));
		} else {
			// Onward!
			_vm->addEvent(CSTimeEvent(kCSTimeEventNewScene, event.param1, 3));
			_vm->addEvent(CSTimeEvent(kCSTimeEventCharStartFlapping, 1, 12551));
		}
		break;

	case 1:
		// Poking at the jars. The response depends on whether the hieroglyphs on the tomb wall
		// have been seen yet or not.
		_vm->addEvent(CSTimeEvent(kCSTimeEventCharStartFlapping, getCurrScene()->getHelperId(),
			_vm->_caseVariable[2] ? 14304 : 14303));
		break;

	case 2:
		// FIXME: Leaving the mummy-preparing room?
		error("cond event 2");
		break;

	case 3:
		// FIXME: Body sequence stuff.
		error("cond event 3");
		break;

	case 4:
		// Woven bag dragged.
		if (_conversations[0]->getAsked(2, 1)) {
			// We were asked to move it.
			if (event.param1 == 5) {
				// Yay, the player got it on the boat!
				// Congratulate the player and enable the torch.
				_vm->insertEventAtFront(CSTimeEvent(kCSTimeEventCharStartFlapping, 2, 10551));
				getCurrScene()->getHotspot(4).invObjId = 1;
				_vm->insertEventAtFront(CSTimeEvent(kCSTimeEventEnableHotspot, 2, 6));
				_vm->insertEventAtFront(CSTimeEvent(kCSTimeEventAddFeature, 2, 2));
			} else {
				assert(event.param1 < 7);
				// It didn't get dropped onto the boat, so we complain about it.
				newEvent.type = kCSTimeEventCharStartFlapping;
				// Does the Good Guide complain (if we gave it to her, or put it in the inventory)?
				newEvent.param1 = (event.param1 == 1 || event.param1 == 6) ? getCurrScene()->getHelperId() : 2;
				// Which string?
				static const uint16 strings[7] = { 30201, 30103, 30202, 30203, 30203, 0, 10352};
				newEvent.param2 = strings[event.param1];
				_vm->insertEventAtFront(newEvent);
			}
		} else {
			// We're just randomly moving the woven bag!
			_vm->addEvent(CSTimeEvent(kCSTimeEventCharStartFlapping, getCurrScene()->getHelperId(), 10351));

			if (event.param1 == 5) {
				// This went onto the boat hotspot, so the bag was removed; put it back.
				_vm->insertEventAtFront(CSTimeEvent(kCSTimeEventEnableHotspot, 0xffff, 5));
				_vm->insertEventAtFront(CSTimeEvent(kCSTimeEventAddFeature, 0xffff, 1));
			}
		}
		break;

	case 5:
		// We're ready to shove off!
		_vm->addEvent(CSTimeEvent(kCSTimeEventCharStartFlapping, getCurrScene()->getHelperId(), 10356));
		break;

	case 6:
		// Trying to leave the first scene by walking.
		if (_vm->_haveInvItem[1]) {
			// If you have the torch, the Good Guide prods you to use the boat.
			_vm->addEvent(CSTimeEvent(kCSTimeEventCharStartFlapping, getCurrScene()->getHelperId(), 10305));
		} else {
			// Otherwise, the boatman tells you that you can't leave yet.
			_vm->addEvent(CSTimeEvent(kCSTimeEventCharStartFlapping, 2, 10506));
		}
		break;

	case 7:
		// Clicking on the woven bag.
		if (_conversations[0]->getAsked(2, 0)) {
			// If we were asked to move it, the Good Guide prods us to try dragging.
			_vm->addEvent(CSTimeEvent(kCSTimeEventCharStartFlapping, getCurrScene()->getHelperId(), 10306));
		} else {
			// Otherwise, the boatman tells us what it is.
			_vm->addEvent(CSTimeEvent(kCSTimeEventCharStartFlapping, 2, 10502));
		}
		break;

	case 8:
		// One-time-only reminder that you can re-ask questions.
		if (_vm->_caseVariable[7])
			break;
		_vm->_caseVariable[7] = 1;
		_vm->addEvent(CSTimeEvent(kCSTimeEventCharStartFlapping, 0, 12359));
		break;

	case 9:
		// Trying to give the torch to the Good Guide; you get a different message
		// depending on whether it's already in your inventory or not.
		_vm->addEvent(CSTimeEvent(kCSTimeEventCharStartFlapping, 0, _vm->_haveInvItem[1] ? 9906 : 30119));
		break;

	default:
		error("unknown Conditional Event type %d for case 1", event.param2);
	}
}

} // End of namespace Mohawk