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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
|
/* 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.
*
*/
#include "neverhood/modules/module1100_sprites.h"
namespace Neverhood {
static const uint32 kSsScene1105SymbolDieFileHashes[] = {
0,
0x90898414,
0x91098414,
0x92098414,
0x94098414,
0x98098414,
0x80098414,
0xB0098414,
0xD0098414,
0x10098414
};
SsScene1105Button::SsScene1105Button(NeverhoodEngine *vm, Scene *parentScene, uint32 fileHash, NRect &collisionBounds)
: StaticSprite(vm, fileHash, 200), _parentScene(parentScene), _countdown(0) {
_collisionBounds = collisionBounds;
SetMessageHandler(&SsScene1105Button::handleMessage);
SetUpdateHandler(&SsScene1105Button::update);
setVisible(false);
}
void SsScene1105Button::update() {
if (_countdown != 0 && (--_countdown == 0)) {
sendMessage(_parentScene, 0x4807, 0);
setVisible(false);
}
}
uint32 SsScene1105Button::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) {
uint32 messageResult = Sprite::handleMessage(messageNum, param, sender);
switch (messageNum) {
case 0x1011:
if (_countdown == 0) {
sendMessage(_parentScene, 0x4826, 0);
messageResult = 1;
}
break;
case 0x480B:
_countdown = 8;
setVisible(true);
playSound(0, 0x44141000);
break;
}
return messageResult;
}
SsScene1105Symbol::SsScene1105Symbol(NeverhoodEngine *vm, uint32 fileHash, int16 x, int16 y)
: StaticSprite(vm, 0) {
loadSprite(fileHash, kSLFCenteredDrawOffset | kSLFSetPosition, 200, x, y);
}
void SsScene1105Symbol::hide() {
setVisible(false);
_needRefresh = true;
updatePosition();
}
SsScene1105SymbolDie::SsScene1105SymbolDie(NeverhoodEngine *vm, uint dieIndex, int16 x, int16 y)
: StaticSprite(vm, 1100), _dieIndex(dieIndex) {
_x = x;
_y = y;
createSurface(200, 50, 50);
loadSymbolSprite();
SetMessageHandler(&SsScene1105SymbolDie::handleMessage);
}
uint32 SsScene1105SymbolDie::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) {
uint32 messageResult = Sprite::handleMessage(messageNum, param, sender);
switch (messageNum) {
case 0x2000:
loadSymbolSprite();
break;
}
return messageResult;
}
void SsScene1105SymbolDie::loadSymbolSprite() {
loadSprite(kSsScene1105SymbolDieFileHashes[getSubVar(VA_CURR_DICE_NUMBERS, _dieIndex)], kSLFCenteredDrawOffset);
}
void SsScene1105SymbolDie::hide() {
setVisible(false);
_needRefresh = true;
updatePosition();
}
AsScene1105TeddyBear::AsScene1105TeddyBear(NeverhoodEngine *vm, Scene *parentScene)
: AnimatedSprite(vm, 1100), _parentScene(parentScene) {
createSurface(100, 556, 328);
_x = 320;
_y = 240;
SetUpdateHandler(&AnimatedSprite::update);
SetMessageHandler(&AsScene1105TeddyBear::handleMessage);
startAnimation(0x65084002, 0, -1);
_newStickFrameIndex = 0;
setVisible(false);
_needRefresh = true;
updatePosition();
loadSound(0, 0xCE840261);
loadSound(1, 0xCCA41A62);
}
uint32 AsScene1105TeddyBear::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) {
uint32 messageResult = Sprite::handleMessage(messageNum, param, sender);
switch (messageNum) {
case 0x2002:
if (getGlobalVar(V_ROBOT_TARGET)) {
startAnimation(0x6B0C0432, 0, -1);
playSound(0);
} else {
startAnimation(0x65084002, 0, -1);
playSound(1);
}
break;
case 0x3002:
sendMessage(_parentScene, 0x2003, 0);
stopAnimation();
break;
}
return messageResult;
}
void AsScene1105TeddyBear::show() {
setVisible(true);
_needRefresh = true;
updatePosition();
}
void AsScene1105TeddyBear::hide() {
setVisible(false);
_needRefresh = true;
updatePosition();
}
SsScene1105OpenButton::SsScene1105OpenButton(NeverhoodEngine *vm, Scene *parentScene)
: StaticSprite(vm, 900), _parentScene(parentScene), _countdown(0), _isClicked(false) {
loadSprite(0x8228A46C, kSLFDefDrawOffset | kSLFDefPosition | kSLFDefCollisionBoundsOffset, 400);
setVisible(false);
loadSound(0, 0x44045140);
SetUpdateHandler(&SsScene1105OpenButton::update);
SetMessageHandler(&SsScene1105OpenButton::handleMessage);
}
void SsScene1105OpenButton::update() {
updatePosition();
if (_countdown != 0 && (--_countdown == 0)) {
setVisible(false);
sendMessage(_parentScene, 0x2001, 0);
}
}
uint32 SsScene1105OpenButton::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) {
uint32 messageResult = 0;
Sprite::handleMessage(messageNum, param, sender);
switch (messageNum) {
case 0x1011:
if (_countdown == 0 && !_isClicked) {
playSound(0);
setVisible(true);
_isClicked = true;
_countdown = 4;
}
messageResult = 1;
break;
}
return messageResult;
}
KmScene1109::KmScene1109(NeverhoodEngine *vm, Scene *parentScene, int16 x, int16 y)
: Klaymen(vm, parentScene, x, y) {
// Empty
}
uint32 KmScene1109::xHandleMessage(int messageNum, const MessageParam ¶m) {
uint32 messageResult = 0;
switch (messageNum) {
case 0x2000:
_isSittingInTeleporter = param.asInteger() != 0;
messageResult = 1;
break;
case 0x4001:
case 0x4800:
startWalkToX(param.asPoint().x, false);
break;
case 0x4004:
if (_isSittingInTeleporter)
GotoState(&Klaymen::stSitIdleTeleporter);
else
GotoState(&Klaymen::stTryStandIdle);
break;
case 0x4804:
if (param.asInteger() != 0) {
_destX = param.asInteger();
GotoState(&Klaymen::stWalkingFirst);
} else
GotoState(&Klaymen::stPeekWall);
break;
case 0x4817:
setDoDeltaX(param.asInteger());
gotoNextStateExt();
break;
case 0x481D:
if (_isSittingInTeleporter)
GotoState(&Klaymen::stTurnToUseInTeleporter);
break;
case 0x481E:
if (_isSittingInTeleporter)
GotoState(&Klaymen::stReturnFromUseInTeleporter);
break;
case 0x4834:
GotoState(&Klaymen::stStepOver);
break;
case 0x4835:
sendMessage(_parentScene, 0x2000, 1);
_isSittingInTeleporter = true;
GotoState(&Klaymen::stSitInTeleporter);
break;
case 0x4836:
sendMessage(_parentScene, 0x2000, 0);
_isSittingInTeleporter = false;
GotoState(&Klaymen::stGetUpFromTeleporter);
break;
case 0x483D:
teleporterAppear(0x2C2A4A1C);
break;
case 0x483E:
teleporterDisappear(0x3C2E4245);
break;
}
return messageResult;
}
} // End of namespace Neverhood
|