forked from Wavestation/oq-zik
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathactors.scc
executable file
·402 lines (356 loc) · 13.8 KB
/
actors.scc
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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
/* ScummC
* Copyright (C) 2007 Alban Bedel, Gerrit Karius
*
* 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 <scummVars6.s>
#include "common.sch"
#include "actors.sch"
#include "dialog.sch"
#include "inventoryitems.sch"
#include "officeroom.sch"
#include "secretroom.sch"
#include "zif_anim.sch"
// 2-dim array used like a struct array
nibble *roaming;
#define RM_STATE 0
#define RM_MIN_X 1
#define RM_MAX_X 2
#define RM_MIN_Y 3
#define RM_MAX_Y 4
#define RM_NUM_FIELD 5
// Roaming state
#define RM_STOPPED 0
#define RM_PAUSED 1
#define RM_RUNNING 2
room Actors {
// the costumes for our actors
cost ensignZobCost = "zob.cost";
cost commanderZifCost = "zif.cost";
cost carolCost = "carol.cost";
cost bluecupCost = "bluecup.cost";
cost cubeCost = "cube.cost";
object commanderZifObj;
object ensignZobObj;
script setZifOnThePhone() {
setCurrentActor(commanderZif);
setActorStandFrame( zif_anim_standWithPhone );
setActorInitFrame( zif_anim_standWithPhone );
setActorTalkFrame( zif_anim_talkToPhoneStart,
zif_anim_standWithPhone );
setActorStanding();
setCurrentActor(VAR_EGO);
}
script setZifOffThePhone() {
setCurrentActor(commanderZif);
setActorStandFrame( zif_anim_stand );
setActorInitFrame( zif_anim_init );
setActorTalkFrame( zif_anim_talkStart, zif_anim_talkStop );
setActorStanding();
setCurrentActor(VAR_EGO);
}
script roam(int a) {
int event, dstX, dstY, paused;
dbgPrint("Roaming script for %n{a} started");
while(roaming[a,RM_STATE] > RM_STOPPED) {
// Debug stuff
paused = 0;
until(VAR_EGO != a && roaming[a,RM_STATE] > RM_PAUSED) {
unless(paused) {
paused = 1;
dbgPrint("Roaming script for %n{a} paused");
}
breakScript();
}
if(paused) dbgPrint("Roaming script for %n{a} resumed");
// Select a new state
event = getRandomNumber(1);
switch(event) {
case 1: // go somewhere else
do {
breakScript();
dstX = getRandomNumberRange(roaming[a,RM_MIN_X],
roaming[a,RM_MAX_X]);
dstY = getRandomNumberRange(roaming[a,RM_MIN_Y],
roaming[a,RM_MAX_Y]);
} while(getActorRoom(a) == VAR_ROOM && getActorAt(dstX,dstY));
dbgPrint("%n{a} roam to %i{dstX}x%i{dstY}");
walkActorTo(a,dstX,dstY);
break;
// TODO: add more stuff. For that we probably want
// to call the actor object to know how many extra
// event the actor support, and to execute them.
}
delay(getRandomNumberRange(50,200));
}
dbgPrint("Roaming script for %n{a} finished");
}
script startRoaming(int a, int x_min, int x_max, int y_min, int y_max) {
unless(a < 0xF) {
dbgPrint("Invalid actor id (%i{a}), can't make it roam.");
return;
}
dbgPrint("Starting roam script for %n{a}");
unless(roaming) dimInt2(roaming,0xF,RM_NUM_FIELD);
roaming[a,RM_MIN_X] = x_min; roaming[a,RM_MAX_X] = x_max;
roaming[a,RM_MIN_Y] = y_min; roaming[a,RM_MAX_Y] = y_max;
if(roaming[a,RM_STATE] > RM_STOPPED)
roaming[a,RM_STATE] = RM_RUNNING;
else {
roaming[a,RM_STATE] = RM_RUNNING;
startScript(1,roam,[a]);
}
}
script pauseRoaming(int a) {
unless(a < 0xF && roaming) return;
unless(roaming[a,RM_STATE] > RM_STOPPED) return;
dbgPrint("Pausing roam script for %n{a}");
setCurrentActor(a);
setActorStanding();
roaming[a,RM_STATE] = RM_PAUSED;
}
script resumeRoaming(int a) {
unless(a < 0xF && roaming) return;
unless(roaming[a,RM_STATE] > RM_STOPPED) return;
dbgPrint("Resuming roam script for %n{a}");
roaming[a,RM_STATE] = RM_RUNNING;
}
script stopRoaming(int a) {
unless(a < 0xF && roaming) return;
unless(roaming[a,RM_STATE] > RM_STOPPED) return;
dbgPrint("Stoping roam script for %n{a}");
setCurrentActor(a);
setActorStanding();
roaming[a,RM_STATE] = RM_STOPPED;
}
// set the actor costume, etc
script setupActors() {
dbgPrint("setupActors()");
// initialize ensignZob
setCurrentActor(ensignZob);
initActor();
setActorCostume(ensignZobCost);
setActorName("Ensign Zob");
setActorWalkSpeed(2,1);
setActorTalkColor(ZOB_COLOR);
setActorWidth(20);
setActorAnimSpeed(4);
setObjectClass(ensignZob, [ 0x80 + Person ]);
actorObject[ensignZob] = ensignZobObj;
// set VAR_EGO so we can use the *Ego* functions
VAR_EGO = ensignZob;
// initialize commanderZif
setCurrentActor(commanderZif);
initActor();
setActorCostume(commanderZifCost);
setActorName("Commander Zif");
setActorWalkSpeed(2,1);
setActorTalkColor(ZIF_COLOR);
setActorWidth(20);
setActorAnimSpeed(4);
setObjectClass(commanderZif, [ 0x80 + Person ]);
actorObject[commanderZif] = commanderZifObj;
setCurrentActor(carol);
initActor();
setActorCostume(carolCost);
setActorName("indigenous lifeform");
setActorWidth(20);
setActorIgnoreBoxes();
setActorAnimSpeed( 7 );
setActorTalkColor(CAROL_COLOR);
setObjectClass(carol, [ 0x80 + Person ]);
actorObject[carol] = OfficeRoom::carolObj;
setCurrentActor(bluecupActor);
initActor();
setActorCostume(bluecupCost);
setActorName("blue cup");
setActorAnimSpeed(2);
actorObject[bluecupActor] = SecretRoom::blueCup;
putActorAt(bluecupActor,159,97,SecretRoom);
setActorElevation( 55 );
setActorWidth(0);
setCurrentActor(cubeActor);
initActor();
setActorCostume(cubeCost);
// TODO: make the cube irresponsive to mouseover
setActorName("blue cup");
setActorAnimSpeed(2);
setObjectClass(cubeActor, [ 0x80 + ClassUntouchable ]);
actorObject[cubeActor] = SecretRoom::blueCup;
putActorAt(cubeActor,160,98,SecretRoom);
setActorElevation( 55 );
setActorWidth(0);
pickupObject( InventoryItems::scanner, InventoryItems );
//pickupObject( InventoryItems::card, InventoryItems );
//pickupObject( InventoryItems::gun, InventoryItems );
//pickupObject( InventoryItems::bullets, InventoryItems );
invOffset = 0;
setCurrentActor(VAR_EGO);
}
// This script is called on pre-entry to load the actor
// objects from this room
script loadObjects() {
loadFlObject(commanderZifObj,Actors);
loadFlObject(ensignZobObj,Actors);
}
script zobTalkToZif() {
char* sentence;
cutscene(1) {
actorFace( commanderZif, VAR_EGO );
actorSay(commanderZif,"Yes, ensign?");
waitForMessage();
}
dialogLoop: while(1) {
sentence[0] = "What are your orders?";
Dialog::dialogAdd(sentence);
sentence = 0;
if( OfficeRoom::hasPressedPlate &&
! OfficeRoom::hasTalkedAboutPlate )
sentence[0] = "I require your assistance with this opening mechanism.";
Dialog::dialogAdd(sentence);
sentence = 0;
sentence[0] = "I'll continue my search.";
Dialog::dialogAdd(sentence);
sentence = 0;
Dialog::dialogStart(ZOB_DIM_COLOR,ZOB_COLOR);
do breakScript() while(selectedSentence < 0);
Dialog::dialogHide();
cutscene() {
sentence = dialogList[selectedSentence];
egoSay("%s{sentence}");
waitForMessage();
switch(selectedSentence) {
case 0:
try {
actorSay(commanderZif,"Locate the stolen artifact.");
waitForMessage();
egoSay("Any ideas where?");
waitForMessage();
actorSay(commanderZif,"Study your surroundings.");
waitForMessage();
actorSay(commanderZif,"Use all the cunning and guile at your disposal.");
waitForMessage();
actorSay(commanderZif,"Should you do this, you shall surely be successful.");
waitForMessage();
egoSay("Guile, right, aye sir.");
waitForMessage();
actorSay(commanderZif,"Also get a gun with which to shoot things.");
waitForMessage();
}
override {
if(VAR_OVERRIDE) {
actorSay(0xFF, ""); //stopTalking();
}
}
break;
case 2:
actorSay(commanderZif,"Very good.");
break;
case 1:
actorSay(commanderZif,"Have you deciphered its secrets?");
waitForMessage();
egoSay("Yes, I believe two persons are required.");
waitForMessage();
actorSay(commanderZif,"In which case I shall follow you, ensign.");
OfficeRoom::hasTalkedAboutPlate = 1;
break;
}
waitForMessage();
}
Dialog::dialogClear(1);
if(selectedSentence == 2) break dialogLoop;
}
Dialog::dialogEnd();
}
script zobTalkToZifInSecretRoom() {
char* sentence;
cutscene(1) {
actorFace( commanderZif, VAR_EGO );
actorSay(commanderZif,"Yes, ensign?");
waitForMessage();
}
dialogLoop: while(1) {
sentence[0] = "What now, Sir?";
Dialog::dialogAdd(sentence);
sentence = 0;
sentence[0] = "I'll continue my search.";
Dialog::dialogAdd(sentence);
Dialog::dialogStart(ZOB_DIM_COLOR,ZOB_COLOR);
do breakScript() while(selectedSentence < 0);
Dialog::dialogHide();
cutscene() {
sentence = dialogList[selectedSentence];
egoSay("%s{sentence}");
waitForMessage();
switch(selectedSentence) {
case 0:
try {
actorSay(commanderZif,"Get artifact.");
waitForMessage();
actorSay(commanderZif,"We need to leave orbit quickly.");
waitForMessage();
egoSay("I'll see what I can do.");
waitForMessage();
}
override {
if(VAR_OVERRIDE) {
stopTalking();
}
}
break;
case 1:
actorSay(commanderZif,"Very good.");
break;
}
waitForMessage();
}
Dialog::dialogClear(1);
if(selectedSentence == 1) break dialogLoop;
}
Dialog::dialogEnd();
}
object commanderZifObj {
name = "Commander Zif";
verb(int vrb,int objA,int objB) {
char* sentence;
int asked;
case TalkTo:
pauseRoaming(commanderZif);
if(SecretRoom::cubeDisappeared) {
zobTalkToZifInSecretRoom();
while(isScriptRunning(zobTalkToZifInSecretRoom)) breakScript();
} else {
zobTalkToZif();
while(isScriptRunning(zobTalkToZif)) breakScript();
}
resumeRoaming(commanderZif);
return;
case LookAt:
egoSay("My commanding officer, Commander Zif.");
return;
case Smell:
pauseRoaming(commanderZif);
egoSay("Is that a new cologne, Sir?");
waitForMessage();
actorSay(commanderZif,"I thought we got past these... feelings.");
waitForMessage();
egoSay("Sorry, Sir.");
resumeRoaming(commanderZif);
return;
}
}
object ensignZobObj {
name = "Ensign Zob";
}
}