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
|
/* 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 "hdb/hdb.h"
namespace HDB {
bool AI::init() {
warning("STUB: AI::init required");
return true;
}
static const char *cineTypeStr[] = {
"C_NO_COMMAND",
"C_STOPCINE",
"C_LOCKPLAYER",
"C_UNLOCKPLAYER",
"C_SETCAMERA",
"C_MOVECAMERA",
"C_WAIT",
"C_WAITUNTILDONE",
"C_MOVEENTITY",
"C_DIALOG",
"C_ANIMENTITY",
"C_RESETCAMERA",
"C_SETENTITY",
"C_STARTMAP",
"C_MOVEPIC",
"C_MOVEMASKEDPIC",
"C_DRAWPIC",
"C_DRAWMASKEDPIC",
"C_FADEIN",
"C_FADEOUT",
"C_SPAWNENTITY",
"C_PLAYSOUND",
"C_CLEAR_FG",
"C_SET_FG",
"C_SET_BG",
"C_FUNCTION",
"C_ENTITYFACE",
"C_USEENTITY",
"C_REMOVEENTITY",
"C_SETANIMFRAME",
"C_TEXTOUT",
"C_CENTERTEXTOUT",
"C_PLAYVOICE",
"C_ENDLIST"
};
void AI::processCines() {
bool complete, bailOut;
if (!_cineActive) {
return;
}
bailOut = complete = false;
// TODO: Make sure Dialogs are timing out
// TODO: Make sure Cine Pics are drawing
// TODO: Check for Game Pause
for (uint i = 0; i < _cine.size();i++) {
debug(3, "processCines: [%d] %s now: %d start: %d delay: %d", i, cineTypeStr[_cine[i]->cmdType],
g_system->getMillis(), _cine[i]->start, _cine[i]->delay);
switch (_cine[i]->cmdType) {
case C_SETCAMERA:
_cameraX = _cine[i]->x;
_cameraY = _cine[i]->y;
g_hdb->_map->centerMapXY((int)_cameraX + 16, (int)_cameraY + 16);
_cameraLock = true;
complete = true;
break;
case C_RESETCAMERA:
int px, py;
_cameraLock = false;
warning("STUB: AI::GetPlayerXY required");
warning("STUB: MAP::CenterMapXY required");
complete = true;
break;
case C_MOVECAMERA:
_cameraLock = true;
if (!(_cine[i]->start)) {
debug(3, "C_MOVECAMERA: [%d] now: x: %d, y: %d, speed: %d", i, _cine[i]->x, i, _cine[i]->y, _cine[i]->speed);
_cine[i]->xv = (((double)_cine[i]->x) - _cameraX) / (double)_cine[i]->speed;
_cine[i]->yv = (((double)_cine[i]->y) - _cameraY) / (double)_cine[i]->speed;
_cine[i]->start = 1;
}
_cameraX += _cine[i]->xv;
_cameraY += _cine[i]->yv;
debug(3, "C_MOVECAMERA: _cine[%d]->xv: %d, _cine[%d]->yv: %d", i, _cine[i]->xv, i, _cine[i]->yv);
debug(3, "C_MOVECAMERA: abs(_cameraX - _cine[i]->x): %d, abs(_cameraY - _cine[i]->y): %d", abs(_cameraX - _cine[i]->x), abs(_cameraY - _cine[i]->y));
if (abs(_cameraX - _cine[i]->x) <= 1 && abs(_cameraY - _cine[i]->y) <= 1) {
_cameraX = _cine[i]->x;
_cameraY = _cine[i]->y;
complete = true;
}
g_hdb->_map->centerMapXY((int)_cameraX + 16, (int)_cameraY + 16);
break;
case C_WAIT:
if (!(_cine[i]->start)) {
_cine[i]->start = 1;
_cine[i]->delay = g_system->getMillis() + _cine[i]->delay * 1000;
} else {
if (_cine[i]->delay < g_system->getMillis()) {
complete = true;
} else {
bailOut = true;
}
}
break;
case C_WAITUNTILDONE:
if (!i) {
complete = true;
} else {
bailOut = true;
}
break;
case C_FADEIN:
if (!_cine[i]->start) {
g_hdb->_drawMan->setFade(true, (bool)_cine[i]->end, _cine[i]->speed);
_cine[i]->start = 1;
} else if (!g_hdb->_drawMan->isFadeActive()) {
complete = true;
}
break;
case C_FADEOUT:
if (!_cine[i]->start) {
g_hdb->_drawMan->setFade(false, (bool)_cine[i]->end, _cine[i]->speed);
_cine[i]->start = 1;
} else if (!g_hdb->_drawMan->isFadeActive()) {
complete = true;
}
break;
default:
warning("STUB: AI::PROCESSCINES incomplete for %d", _cine[i]->cmdType);
break;
}
if (bailOut) {
return;
}
if (complete) {
if (_cine.size()) {
_cine.remove_at(i);
i--;
complete = false;
}
}
}
}
void AI::cineStart(bool abortable, const char *abortFunc) {
_cineAbortable = abortable;
_cineAborted = false;
_cineAbortFunc = abortFunc;
_cineActive = true;
_playerLock = false;
_cameraLock = false;
}
void AI::cineSetCamera(int x, int y) {
CineCommand *cmd = new CineCommand;
cmd->x = x * kTileWidth;
cmd->y = y * kTileHeight;
cmd->cmdType = C_SETCAMERA;
_cine.push_back(cmd);
}
void AI::cineResetCamera() {
CineCommand *cmd = new CineCommand;
cmd->cmdType = C_RESETCAMERA;
_cine.push_back(cmd);
}
void AI::cineMoveCamera(int x, int y, int speed) {
CineCommand *cmd = new CineCommand;
cmd->start = 0;
cmd->x = x * kTileWidth;
cmd->y = y * kTileHeight;
debug("Setting up C_MOVECAMERA: x: %d, y: %d", cmd->x, cmd->y);
cmd->cmdType = C_MOVECAMERA;
_cine.push_back(cmd);
}
void AI::cineWait(int seconds) {
CineCommand *cmd = new CineCommand;
cmd->start = 0;
cmd->cmdType = C_WAIT;
cmd->delay = seconds;
_cine.push_back(cmd);
}
void AI::cineWaitUntilDone() {
CineCommand *cmd = new CineCommand;
cmd->cmdType = C_WAITUNTILDONE;
_cine.push_back(cmd);
}
void AI::cineFadeIn(bool isBlack, int steps) {
CineCommand *cmd = new CineCommand;
cmd->speed = steps;
cmd->end = (int) isBlack;
cmd->start = 0;
cmd->cmdType = C_FADEIN;
_cine.push_back(cmd);
}
void AI::cineFadeOut(bool isBlack, int steps) {
CineCommand *cmd = new CineCommand;
cmd->speed = steps;
cmd->end = (int) isBlack;
cmd->start = 0;
cmd->cmdType = C_FADEOUT;
_cine.push_back(cmd);
}
} // End of Namespace
|