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
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
|
/* 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 "bladerunner/script/ai_script.h"
namespace BladeRunner {
AIScriptTransient::AIScriptTransient(BladeRunnerEngine *vm) : AIScriptBase(vm) {
}
void AIScriptTransient::Initialize() {
_animationFrame = 0;
_animationState = 0;
_animationStateNext = 0;
_animationNext = 0;
Actor_Put_In_Set(kActorTransient, kSetCT03_CT04);
Actor_Set_At_XYZ(kActorTransient, -171.41f, -621.3f, 736.52f, 580);
Actor_Set_Goal_Number(kActorTransient, kGoalTransientDefault);
Actor_Set_Targetable(kActorTransient, true);
}
bool AIScriptTransient::Update() {
if (Global_Variable_Query(kVariableChapter) == 5
&& Actor_Query_Which_Set_In(kActorTransient) != kSetFreeSlotG
) {
Actor_Put_In_Set(kActorTransient, kSetFreeSlotG);
Actor_Set_At_Waypoint(kActorTransient, 39, false);
}
if (Global_Variable_Query(kVariableChapter) == 2
&& (Actor_Query_Goal_Number(kActorTransient) == kGoalTransientDefault
|| Actor_Query_Goal_Number(kActorTransient) == 10
)
) {
Actor_Set_Goal_Number(kActorTransient, 200);
}
if ( Global_Variable_Query(kVariableChapter) == 3
&& Game_Flag_Query(kFlagCT04HomelessKilledByMcCoy)
&& Game_Flag_Query(kFlagCT04HomelessBodyInDumpster)
&& !Game_Flag_Query(kFlagCT04HomelessBodyFound)
&& !Game_Flag_Query(kFlagCT04HomelessBodyThrownAway)
) {
Game_Flag_Set(kFlagCT04HomelessBodyThrownAway);
}
if (Global_Variable_Query(kVariableChapter) < 4
&& Game_Flag_Query(kFlagCT04HomelessBodyFound)
&& Actor_Query_Goal_Number(kActorTransient) != 6
&& Actor_Query_Goal_Number(kActorTransient) != 599
) {
Actor_Set_Goal_Number(kActorTransient, 6);
}
if ( Player_Query_Current_Scene() == kSceneCT04
&& !Game_Flag_Query(kFlagCT04HomelessTrashFinish)
) {
Game_Flag_Set(kFlagCT04HomelessTrashFinish);
AI_Countdown_Timer_Reset(kActorTransient, 1);
AI_Countdown_Timer_Start(kActorTransient, 1, 12);
}
return false;
}
void AIScriptTransient::TimerExpired(int timer) {
if (timer == 0) {
if (Actor_Query_Goal_Number(kActorTransient) == 395 && Actor_Query_Which_Set_In(kActorMcCoy) == kSetUG13) {
AI_Countdown_Timer_Start(kActorTransient, 0, Random_Query(20, 10));
switch (Random_Query(1, 3)) {
case 1:
Sound_Play(356, 50, 0, 0, 50);
break;
case 2:
Sound_Play(357, 50, 0, 0, 50);
break;
case 3:
Sound_Play(358, 50, 0, 0, 50);
break;
}
} else if (Actor_Query_Goal_Number(kActorTransient) != 599) {
Actor_Set_Goal_Number(kActorTransient, 391);
AI_Countdown_Timer_Reset(kActorTransient, 0);
}
}
if (timer == 1) {
if (Actor_Query_Goal_Number(kActorTransient) == kGoalTransientDefault) { // stop diggin the trash
Actor_Set_Goal_Number(kActorTransient, 10);
Actor_Change_Animation_Mode(kActorTransient, kAnimationModeIdle);
}
Actor_Set_Goal_Number(kActorTransient, 10);
Actor_Set_Targetable(kActorTransient, false);
AI_Countdown_Timer_Reset(kActorTransient, 1);
}
}
void AIScriptTransient::CompletedMovementTrack() {
//return false;
}
void AIScriptTransient::ReceivedClue(int clueId, int fromActorId) {
//return false;
}
void AIScriptTransient::ClickedByPlayer() {
//return false;
}
void AIScriptTransient::EnteredScene(int sceneId) {
// return false;
}
void AIScriptTransient::OtherAgentEnteredThisScene(int otherActorId) {
// return false;
}
void AIScriptTransient::OtherAgentExitedThisScene(int otherActorId) {
// return false;
}
void AIScriptTransient::OtherAgentEnteredCombatMode(int otherActorId, int combatMode) {
// return false;
}
void AIScriptTransient::ShotAtAndMissed() {
// return false;
}
bool AIScriptTransient::ShotAtAndHit() {
Actor_Set_Frame_Rate_FPS(kActorTransient, 8);
if (Game_Flag_Query(kFlagUG13HomelessLayingdown)) {
_animationState = 11;
} else {
_animationState = 14;
}
_animationFrame = 0;
Actor_Set_Targetable(kActorTransient, false);
if (Global_Variable_Query(kVariableChapter) < 4) {
Actor_Set_Goal_Number(kActorTransient, 3);
} else {
Actor_Set_Goal_Number(kActorTransient, 599);
}
Game_Flag_Set(kFlagCT04HomelessKilledByMcCoy);
return false;
}
void AIScriptTransient::Retired(int byActorId) {
Actor_Set_Goal_Number(kActorTransient, 599);
if (Global_Variable_Query(kVariableChapter) == 4) {
Game_Flag_Set(kFlagMcCoyRetiredHuman);
}
}
int AIScriptTransient::GetFriendlinessModifierIfGetsClue(int otherActorId, int clueId) {
return 0;
}
bool AIScriptTransient::GoalChanged(int currentGoalNumber, int newGoalNumber) {
switch (newGoalNumber) {
case kGoalTransientCT04Leave:
AI_Movement_Track_Flush(kActorTransient);
AI_Movement_Track_Append(kActorTransient, 51, 0);
AI_Movement_Track_Append(kActorTransient, 105, 0);
AI_Movement_Track_Append(kActorTransient, 42, 1);
AI_Movement_Track_Repeat(kActorTransient);
return true;
case 6:
AI_Movement_Track_Flush(kActorTransient);
AI_Movement_Track_Append(kActorTransient, 41, 10);
AI_Movement_Track_Repeat(kActorTransient);
return true;
case 200:
Actor_Put_In_Set(kActorTransient, kSetFreeSlotH);
Actor_Set_At_Waypoint(kActorTransient, 40, 0);
return true;
case 390:
Actor_Put_In_Set(kActorTransient, kSetUG13);
Actor_Set_At_XYZ(kActorTransient, -310.0, 55.0, -350.0, 400);
Actor_Change_Animation_Mode(kActorTransient, 53);
Actor_Set_Targetable(kActorTransient, true);
Game_Flag_Set(kFlagUG13HomelessLayingdown);
return true;
case 391:
Actor_Change_Animation_Mode(kActorTransient, 53);
return true;
case 395:
Actor_Change_Animation_Mode(kActorTransient, 55);
AI_Countdown_Timer_Start(kActorTransient, 0, Random_Query(30, 40));
return true;
case 599:
AI_Countdown_Timer_Reset(kActorTransient, 0);
return true;
}
return false;
}
bool AIScriptTransient::UpdateAnimation(int *animation, int *frame) {
switch (_animationState) {
case 0:
*animation = 499;
_animationFrame++;
if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(499)) {
_animationFrame = 0;
} else {
*animation = 497;
if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(497)) {
_animationFrame = 0;
}
}
break;
case 1:
*animation = 487;
_animationFrame++;
if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(487)) {
_animationFrame = 0;
}
break;
case 2:
*animation = 500;
_animationFrame++;
if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(500)) {
_animationFrame = 0;
}
break;
case 3:
*animation = 501;
_animationFrame++;
if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(501)) {
*animation = 500;
_animationState = 2;
_animationFrame = 0;
}
break;
case 4:
*animation = 502;
_animationFrame++;
if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(502)) {
*animation = 500;
_animationState = 2;
_animationFrame = 0;
}
break;
case 5:
*animation = 503;
_animationFrame++;
if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(503)) {
*animation = 500;
_animationState = 2;
_animationFrame = 0;
}
break;
case 6:
*animation = 491;
_animationFrame++;
if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(491)) {
_animationFrame = 0;
}
break;
case 7:
*animation = 492;
_animationFrame++;
if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(492)) {
_animationState = 6;
_animationFrame = 0;
}
break;
case 8:
*animation = 493;
_animationFrame++;
if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(493)) {
_animationState = 6;
_animationFrame = 0;
}
break;
case 9:
*animation = 494;
_animationFrame++;
if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(494)) {
_animationState = 6;
_animationFrame = 0;
}
break;
case 10:
*animation = 496;
_animationFrame++;
if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(496)) {
_animationState = 6;
_animationFrame = 0;
}
break;
case 11:
*animation = 495;
_animationFrame++;
if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(495)) {
Actor_Set_Frame_Rate_FPS(kActorTransient, 8);
_animationState = 12;
_animationFrame = Slice_Animation_Query_Number_Of_Frames(495) - 1;
}
break;
case 12:
*animation = 495;
_animationFrame = Slice_Animation_Query_Number_Of_Frames(495) - 1;
break;
case 14:
*animation = 489;
_animationFrame++;
if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(489)) {
Actor_Set_Goal_Number(kActorTransient, 3);
_animationState = 15;
_animationFrame = Slice_Animation_Query_Number_Of_Frames(489) - 1;
Actor_Set_Targetable(kActorTransient, false);
Actor_Retired_Here(kActorTransient, 120, 24, 1, -1);
}
break;
case 15:
*animation = 489;
_animationFrame = Slice_Animation_Query_Number_Of_Frames(489) - 1;
break;
case 16:
*animation = 504;
_animationFrame++;
if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(504) - 1) {
_animationFrame = 0;
}
break;
case 17:
*animation = 505;
_animationFrame++;
if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(505) - 1) {
*animation = 497;
_animationFrame = 0;
_animationState = 0;
Actor_Change_Animation_Mode(kActorTransient, kAnimationModeIdle);
if (Actor_Query_Goal_Number(kActorTransient) == 10 && Player_Query_Current_Scene() == kSceneCT04) {
Actor_Set_At_XYZ(kActorTransient, -171.41f, -621.30f, 728.52f, 530);
Actor_Face_Actor(kActorTransient, kActorMcCoy, true);
}
}
break;
case 18:
*animation = 491;
_animationFrame++;
if (_animationFrame - 1 == 4) {
_animationState = 19;
}
break;
case 19:
*animation = 491;
_animationFrame--;
if (_animationFrame + 1 == 4) {
_animationState = 18;
}
break;
default:
*animation = 399;
break;
}
*frame = _animationFrame;
return true;
}
bool AIScriptTransient::ChangeAnimationMode(int mode) {
if (mode != 55) {
Actor_Set_Frame_Rate_FPS(kActorTransient, 8);
}
switch (mode) {
case 0:
switch (_animationState) {
case 0:
break;
case 6:
case 7:
case 8:
case 9:
case 10:
case 18:
case 19:
_animationState = 6;
_animationFrame = 0;
break;
case 16:
_animationState = 17;
_animationFrame = 0;
break;
default:
_animationState = 0;
_animationFrame = 0;
break;
}
break;
case 1:
if (_animationState != 1) {
_animationState = 1;
_animationFrame = 0;
}
break;
case 3:
case 30:
if (_animationState - 6 > 4) {
_animationState = 2;
} else {
_animationState = 7;
}
_animationFrame = 0;
break;
case 12:
case 31:
if (_animationState == 6) {
_animationState = 8;
} else {
_animationState = 3;
}
_animationFrame = 0;
break;
case 13:
case 32:
if (_animationState == 6) {
_animationState = 9;
} else {
_animationState = 4;
}
_animationFrame = 0;
break;
case 14:
case 33:
case 34:
case 35:
case 36:
case 37:
if (_animationState == 6) {
_animationState = 10;
} else {
_animationState = 5;
}
_animationFrame = 0;
break;
case 21:
if (Game_Flag_Query(kFlagUG13HomelessLayingdown)) {
_animationState = 11;
} else {
_animationState = 14;
}
_animationFrame = 0;
break;
case 38:
_animationState = 16;
_animationFrame = 0;
break;
case 53:
case 54:
_animationState = 6;
_animationFrame = 0;
break;
case 55:
if (_animationState == 6) {
Actor_Set_Frame_Rate_FPS(kActorTransient, 4);
_animationState = 18;
_animationFrame = 3;
}
break;
case 89:
_animationState = 12;
_animationFrame = Slice_Animation_Query_Number_Of_Frames(495) - 1;
break;
}
return true;
}
void AIScriptTransient::QueryAnimationState(int *animationState, int *animationFrame, int *animationStateNext, int *animationNext) {
*animationState = _animationState;
*animationFrame = _animationFrame;
*animationStateNext = _animationStateNext;
*animationNext = _animationNext;
}
void AIScriptTransient::SetAnimationState(int animationState, int animationFrame, int animationStateNext, int animationNext) {
_animationState = animationState;
_animationFrame = animationFrame;
_animationStateNext = animationStateNext;
_animationNext = animationNext;
}
bool AIScriptTransient::ReachedMovementTrackWaypoint(int waypointId) {
return true;
}
void AIScriptTransient::FledCombat() {
// return false;
}
} // End of namespace BladeRunner
|