File: room202.cpp

package info (click to toggle)
scummvm 2.9.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 450,268 kB
  • sloc: cpp: 4,297,604; asm: 28,322; python: 12,901; sh: 11,219; java: 8,477; xml: 7,843; perl: 2,633; ansic: 2,465; yacc: 1,670; javascript: 1,020; makefile: 933; lex: 578; awk: 275; objc: 82; sed: 11; php: 1
file content (151 lines) | stat: -rw-r--r-- 4,595 bytes parent folder | download | duplicates (2)
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
/* 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 3 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, see <http://www.gnu.org/licenses/ },.
 *
 */

#include "m4/riddle/rooms/section2/room202.h"
#include "m4/graphics/gr_series.h"
#include "m4/riddle/vars.h"

namespace M4 {
namespace Riddle {
namespace Rooms {

static const char *SAID[][2] = {
	{ "rope and hook", "202r10" },
	{ "lantern",       "202r11" },
	{ "shovel",        "202r12" },
	{ "bunch of keys", "202r13" },
	{ "map",           "202r14" },
	{ "axe",           "202r15" },
	{ "gong",          "202r20" },
	{ "note",          "202r24" },
	{ "wooden box",    "202r22" },
	{ nullptr, nullptr }
};


void Room202::preload() {
	_G(player).walker_in_this_scene = false;
}

void Room202::init() {
	_G(player).disable_hyperwalk = true;
	_G(player).walker_in_this_scene = false;

	if (_G(flags)[V068] == 1 && _G(flags)[V065] <= 5) {
		_G(flags)[V068] = 0;
		_G(flags)[V065]++;
	}

	digi_preload("950_s02");
	digi_preload("950_s03");
	digi_preload("950_s04");
	player_set_commands_allowed(true);
	digi_play("950_s02", 2, 30);
	kernel_timing_trigger(1500, 105);

	if (_G(flags)[V065] >= 1)
		series_show_sprite("202 FIRST NASTY SIGN", 0, 0x400);
	if (_G(flags)[V065] >= 2)
		series_show_sprite("202 SECOND NASTY SIGN", 0, 0x400);
	if (_G(flags)[V065] >= 3)
		series_show_sprite("202 THIRD NASTY SIGN", 0, 0x400);
	if (_G(flags)[V065] >= 4)
		series_show_sprite("202 FORTH NASTY SIGN", 0, 0x400);
	if (_G(flags)[V065] >= 5)
		series_show_sprite("202 FIFTH NASTY SIGN", 0, 0x400);
}

void Room202::daemon() {
	if (_G(kernel).trigger == 105) {
		switch (imath_ranged_rand(1, 3)) {
		case 1:
			digi_play("950_s02", 2, 30);
			kernel_timing_trigger(1500, 105);
			break;
		case 2:
			digi_play("950_s03", 2, 30);
			kernel_timing_trigger(1020, 105);
			break;
		case 3:
			digi_play("950_s04", 2, 30);
			kernel_timing_trigger(540, 105);
			break;
		default:
			break;
		}
	}
}

void Room202::pre_parser() {
	_G(player).resetWalk();
}

void Room202::parser() {
	bool lookFlag = player_said_any("look", "look at");
	bool takeFlag = player_said("take");
	bool useFlag = player_said_any("push", "pull", "gear", "open", "close");

	if (lookFlag && player_said("TRADER'S STALL") && _G(flags)[V065] == 1) {
		digi_play("202r01", 1);
	} else if (lookFlag && player_said("TRADER'S STALL") && _G(flags)[V065] == 2) {
		digi_play("202r02", 1);
	} else if (lookFlag && player_said("TRADER'S STALL") && _G(flags)[V065] == 3) {
		digi_play("202r03", 1);
	} else if (lookFlag && player_said("TRADER'S STALL") && _G(flags)[V065] == 4) {
		digi_play("202r04", 1);
	} else if (lookFlag && player_said("TRADER'S STALL") && _G(flags)[V065] == 5) {
		digi_play("202r05", 1);
	} else if (useFlag && player_said("WOODEN BOX")) {
		digi_play("202r23", 1);
	} else if (takeFlag && player_said_any("WOODEN BOX", "GONG")) {
		digi_play("202r21", 1);
	} else if (takeFlag && player_said("NOTE")) {
		digi_play("202r27", 1);
	} else if (player_said("GONG") && inv_player_has(_G(player).verb) &&
			player_said_any("SEVEN SPOKES", "SOLDIER'S HELMET", "BUCKET", "LEAD PIPE")) {
		digi_play("202_S01", 1);
	} else if (player_said("GEAR", "GONG")) {
		digi_play("202_S01", 1);
	} else if (takeFlag) {
		digi_play("202r09", 1);
	} else if (player_said("GEAR")) {
		digi_play("202r09", 1);
	} else if (player_said("exit") && _G(kernel).trigger == -1) {
		player_set_commands_allowed(false);
		disable_player_commands_and_fade_init(1);
	} else if (player_said("exit") && _G(kernel).trigger == 1) {
		digi_stop(2);
		interface_show();
		_G(game).setRoom(203);
	} else if (lookFlag && _G(walker).ripley_said(SAID)) {
		// No implementation
	} else if (player_said("journal") && !takeFlag && !lookFlag) {
		digi_play("202r16", 1);
	} else {
		return;
	}

	_G(player).command_ready = false;
}

} // namespace Rooms
} // namespace Riddle
} // namespace M4