ScummVM API documentation
ai_script.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef BLADERUNNER_SCRIPT_AI_H
23#define BLADERUNNER_SCRIPT_AI_H
24
25#include "bladerunner/script/script.h"
26
27namespace BladeRunner {
28
29class BladeRunnerEngine;
30
31class AIScriptBase : public ScriptBase {
32protected:
33 int _animationState;
34 int _animationFrame;
35 int _animationStateNext;
36 int _animationNext;
37
38public:
40 _animationState = 0;
41 _animationFrame = 0;
42 _animationStateNext = 0;
43 _animationNext = 0;
44 }
45
46 virtual void Initialize() = 0;
47 virtual bool Update() = 0;
48 virtual void TimerExpired(int timer) = 0;
49 virtual void CompletedMovementTrack() = 0;
50 virtual void ReceivedClue(int clueId, int fromActorId) = 0;
51 virtual void ClickedByPlayer() = 0;
52 virtual void EnteredSet(int setId) = 0;
53 virtual void OtherAgentEnteredThisSet(int otherActorId) = 0;
54 virtual void OtherAgentExitedThisSet(int otherActorId) = 0;
55 virtual void OtherAgentEnteredCombatMode(int otherActorId, int combatMode) = 0;
56 virtual void ShotAtAndMissed() = 0;
57 virtual bool ShotAtAndHit() = 0;
58 virtual void Retired(int byActorId) = 0;
59 virtual int GetFriendlinessModifierIfGetsClue(int otherActorId, int clueId) = 0;
60 virtual bool GoalChanged(int currentGoalNumber, int newGoalNumber) = 0;
61 virtual bool UpdateAnimation(int *animation, int *frame) = 0;
62 virtual bool ChangeAnimationMode(int mode) = 0;
63 virtual void QueryAnimationState(int *animationState, int *animationFrame, int *animationStateNext, int *animationNext) = 0;
64 virtual void SetAnimationState(int animationState, int animationFrame, int animationStateNext, int animationNext) = 0;
65 virtual bool ReachedMovementTrackWaypoint(int waypointId) = 0;
66 virtual void FledCombat() = 0;
67};
68
69#define DECLARE_SCRIPT(name) \
70class AIScript##name : public AIScriptBase { \
71public: \
72 AIScript##name(BladeRunnerEngine *vm); \
73 void Initialize(); \
74 bool Update(); \
75 void TimerExpired(int timer); \
76 void CompletedMovementTrack(); \
77 void ReceivedClue(int clueId, int fromActorId); \
78 void ClickedByPlayer(); \
79 void EnteredSet(int setId); \
80 void OtherAgentEnteredThisSet(int otherActorId); \
81 void OtherAgentExitedThisSet(int otherActorId); \
82 void OtherAgentEnteredCombatMode(int otherActorId, int combatMode); \
83 void ShotAtAndMissed(); \
84 bool ShotAtAndHit(); \
85 void Retired(int byActorId); \
86 int GetFriendlinessModifierIfGetsClue(int otherActorId, int clueId); \
87 bool GoalChanged(int currentGoalNumber, int newGoalNumber); \
88 bool UpdateAnimation(int *animation, int *frame); \
89 bool ChangeAnimationMode(int mode); \
90 void QueryAnimationState(int *animationState, int *animationFrame, int *animationStateNext, int *animationNext); \
91 void SetAnimationState(int animationState, int animationFrame, int animationStateNext, int animationNext); \
92 bool ReachedMovementTrackWaypoint(int waypointId); \
93 void FledCombat(); \
94private:
95#define END_SCRIPT };
96
97DECLARE_SCRIPT(McCoy)
98 int _animationLoopCounter;
99 int _animationLoopLength;
100 int _animationLoopDirection;
101 int _animationLoopFrameMin;
102 int _animationLoopFrameMax;
103 int _animationStateNextSpecial;
104 int _animationNextSpecial;
105 int _nextSoundId;
106 bool _NR10SteeleShooting;
107 float _fallSpeed;
108 float _fallHeightCurrent;
109 float _fallHeightTarget;
110
111 void fallDown();
112 void UG15fall();
113 void dodge();
114 void walkStairsLeft(float stepHeight);
115 void walkStairsRight(float stepHeight);
116END_SCRIPT
117
118DECLARE_SCRIPT(Steele)
119 bool _resumeIdleAfterFramesetCompletesFlag;
120 int _varChooseIdleAnimation;
121 int _varNumOfTimesToHoldCurrentFrame;
122
123 double comp_distance(int actorId, float a5, float a6, int a1, float a2, float a3, float a4);
124END_SCRIPT
125
126DECLARE_SCRIPT(Gordo)
127 bool _resumeIdleAfterFramesetCompletesFlag;
128 int _counter;
129 int _counterTarget;
130 int _frameMin;
131 int _frameDelta;
132 int _frameMax;
133 int _state;
134
135 void talkToMcCoyInCity();
136 void talkToMcCoyAtNR02();
137 void dialogue2();
138 void dialogue1();
139 void unknown();
140END_SCRIPT
141
142DECLARE_SCRIPT(Dektora)
143 bool _resumeIdleAfterFramesetCompletesFlag;
144 float _x, _y, _z;
145
146 double comp_distance(int actorId, float x1, float y1, float z1);
147 void checkCombat();
148END_SCRIPT
149
150DECLARE_SCRIPT(Guzza)
151 int _frameDelta;
152 int _counter;
153 int _state;
154 bool _resumeIdleAfterFramesetCompletesFlag;
155END_SCRIPT
156
157DECLARE_SCRIPT(Clovis)
158 int _varChooseIdleAnimation;
159 int _varNumOfTimesToHoldCurrentFrame;
160 int _var3;
161 int _var4;
162 int _var5;
163 bool _resumeIdleAfterFramesetCompletesFlag;
164
165 void shotAnim();
166 void someAnim();
167END_SCRIPT
168
169DECLARE_SCRIPT(Lucy)
170 bool _resumeIdleAfterFramesetCompletesFlag;
171
172 void voightKampffTest();
173 void checkCombat();
174END_SCRIPT
175
176DECLARE_SCRIPT(Izo)
177 int _var1;
178 int _var2;
179 int _varNumOfTimesToHoldCurrentFrame;
180 int _varChooseIdleAnimation;
181 bool _resumeIdleAfterFramesetCompletesFlag;
182
183 void dialogueWithIzo();
184 void modifyWaypoints();
185END_SCRIPT
186
187DECLARE_SCRIPT(Sadik)
188 int _nextSoundId;
189 int _varChooseIdleAnimation;
190 int _varNumOfTimesToHoldCurrentFrame;
191 int _var4;
192 bool _resumeIdleAfterFramesetCompletesFlag;
193END_SCRIPT
194
195DECLARE_SCRIPT(Crazylegs)
196 bool _resumeIdleAfterFramesetCompletesFlag;
197END_SCRIPT
198
199DECLARE_SCRIPT(Luther)
200 bool _resumeIdleAfterFramesetCompletesFlag;
201END_SCRIPT
202
203DECLARE_SCRIPT(Grigorian)
204 int _varChooseIdleAnimation;
205 int _varNumOfTimesToHoldCurrentFrame;
206END_SCRIPT
207
208DECLARE_SCRIPT(Transient)
209END_SCRIPT
210
211DECLARE_SCRIPT(Lance)
212END_SCRIPT
213
214DECLARE_SCRIPT(BulletBob)
215 int _varChooseIdleAnimation;
216 int _var2;
217 int _var3;
218 int _varNumOfTimesToHoldCurrentFrame;
219END_SCRIPT
220
221DECLARE_SCRIPT(Runciter)
222 int _varChooseIdleAnimation;
223 int var_45CD7C;
224 int var_45CD80;
225 int _varNumOfTimesToHoldCurrentFrame;
226 int var_45CD88;
227END_SCRIPT
228
229DECLARE_SCRIPT(InsectDealer)
230 bool _resumeIdleAfterFramesetCompletesFlag;
231 int _state;
232 int _frameDelta;
233 int _var2;
234 int _counter;
235END_SCRIPT
236
237DECLARE_SCRIPT(TyrellGuard)
238 int _frameDelta;
239 bool _resumeIdleAfterFramesetCompletesFlag;
240END_SCRIPT
241
242DECLARE_SCRIPT(EarlyQ)
243 int _varNumOfTimesToHoldCurrentFrame;
244 int _varChooseIdleAnimation;
245 int _var3;
246 bool _resumeIdleAfterFramesetCompletesFlag;
247END_SCRIPT
248
249DECLARE_SCRIPT(Zuben)
250 int _animationLoopCounter;
251 int _animationLoopLength;
252 int _animationLoopFrameMin;
253 int _animationLoopDirection;
254 int _animationLoopFrameMax;
255
256 void dialogue();
257END_SCRIPT
258
259DECLARE_SCRIPT(Hasan)
260 int _var1;
261 int _var2;
262 int _varNumOfTimesToHoldCurrentFrame;
263 int _var4;
264 int _var5;
265 int _varChooseIdleAnimation;
266END_SCRIPT
267
268DECLARE_SCRIPT(Marcus)
269END_SCRIPT
270
271DECLARE_SCRIPT(Mia)
272 bool _resumeIdleAfterFramesetCompletesFlag;
273END_SCRIPT
274
275DECLARE_SCRIPT(OfficerLeary)
276 int _varChooseIdleAnimation;
277 bool _idleModeRequestedWhileInTalkingState;
278END_SCRIPT
279
280DECLARE_SCRIPT(OfficerGrayford)
281 int _varChooseIdleAnimation;
282 bool _resumeIdleAfterFramesetCompletesFlag;
283 int _varNumOfTimesToHoldCurrentFrame;
284END_SCRIPT
285
286DECLARE_SCRIPT(Hanoi)
287 bool _resumeIdleAfterFramesetCompletesFlag;
288 int _varChooseIdleAnimation;
289 int _varNumOfTimesToHoldCurrentFrame;
290 int _var4;
291END_SCRIPT
292
293DECLARE_SCRIPT(Baker)
294END_SCRIPT
295
296DECLARE_SCRIPT(DeskClerk)
297 int _varChooseIdleAnimation;
298 bool _resumeIdleAfterFramesetCompletesFlag;
299 int _varNumOfTimesToHoldCurrentFrame;
300END_SCRIPT
301
302DECLARE_SCRIPT(HowieLee)
303 int _varIdleStatesToggle;
304END_SCRIPT
305
306DECLARE_SCRIPT(FishDealer)
307 bool _resumeIdleAfterFramesetCompletesFlag;
308END_SCRIPT
309
310DECLARE_SCRIPT(Klein)
311END_SCRIPT
312
313DECLARE_SCRIPT(Murray)
314 bool _resumeIdleAfterFramesetCompletesFlag;
315END_SCRIPT
316
317DECLARE_SCRIPT(HawkersBarkeep)
318 int _varChooseIdleAnimation;
319 int _varNumOfTimesToHoldCurrentFrame;
320 int _var3;
321 bool _resumeIdleAfterFramesetCompletesFlag;
322END_SCRIPT
323
324DECLARE_SCRIPT(Holloway)
325 bool _resumeIdleAfterFramesetCompletesFlag;
326END_SCRIPT
327
328DECLARE_SCRIPT(SergeantWalls)
329END_SCRIPT
330
331DECLARE_SCRIPT(Moraji)
332 int _var1;
333 int _varNumOfTimesToHoldCurrentFrame;
334END_SCRIPT
335
336DECLARE_SCRIPT(TheBard)
337END_SCRIPT
338
339DECLARE_SCRIPT(Photographer)
340 int _varNumOfTimesToHoldCurrentFrame;
341 int _var2;
342 bool _resumeIdleAfterFramesetCompletesFlag;
343END_SCRIPT
344
345DECLARE_SCRIPT(Dispatcher)
346END_SCRIPT
347
348DECLARE_SCRIPT(AnsweringMachine)
349END_SCRIPT
350
351DECLARE_SCRIPT(Rajif)
352END_SCRIPT
353
354DECLARE_SCRIPT(GovernorKolvig)
355END_SCRIPT
356
357DECLARE_SCRIPT(EarlyQBartender)
358 int _varChooseIdleAnimation;
359 int _var2;
360 bool _resumeIdleAfterFramesetCompletesFlag;
361END_SCRIPT
362
363DECLARE_SCRIPT(HawkersParrot)
364END_SCRIPT
365
366DECLARE_SCRIPT(TaffyPatron)
367END_SCRIPT
368
369DECLARE_SCRIPT(LockupGuard)
370END_SCRIPT
371
372DECLARE_SCRIPT(Teenager)
373END_SCRIPT
374
375DECLARE_SCRIPT(HysteriaPatron1)
376END_SCRIPT
377
378DECLARE_SCRIPT(HysteriaPatron2)
379END_SCRIPT
380
381DECLARE_SCRIPT(HysteriaPatron3)
382END_SCRIPT
383
384DECLARE_SCRIPT(ShoeshineMan)
385 bool _state;
386END_SCRIPT
387
388DECLARE_SCRIPT(Tyrell)
389 bool _resumeIdleAfterFramesetCompletesFlag;
390 int _varChooseIdleAnimation;
391END_SCRIPT
392
393DECLARE_SCRIPT(Chew)
394 int _varNumOfTimesToHoldCurrentFrame;
395 int _varChooseIdleAnimation;
396 int _var3;
397 bool _resumeIdleAfterFramesetCompletesFlag;
398END_SCRIPT
399
400DECLARE_SCRIPT(Gaff)
401END_SCRIPT
402
403DECLARE_SCRIPT(Bryant)
404END_SCRIPT
405
406DECLARE_SCRIPT(Taffy)
407END_SCRIPT
408
409DECLARE_SCRIPT(Sebastian)
410 bool _resumeIdleAfterFramesetCompletesFlag;
411
412 void dialogue();
413 void setMcCoyIsABladeRunner();
414END_SCRIPT
415
416DECLARE_SCRIPT(Rachael)
417 bool _resumeIdleAfterFramesetCompletesFlag;
418
419 void dialogue_start();
420 void dialogue_agenda1();
421 void dialogue_agenda2();
422 void dialogue_act4();
423END_SCRIPT
424
425DECLARE_SCRIPT(GeneralDoll)
426 bool _resumeIdleAfterFramesetCompletesFlag;
427END_SCRIPT
428
429DECLARE_SCRIPT(Isabella)
430 int _var1;
431 int _varNumOfTimesToHoldCurrentFrame;
432 int _varChooseIdleAnimation;
433 int _var4;
434END_SCRIPT
435
436DECLARE_SCRIPT(BlimpGuy)
437END_SCRIPT
438
439DECLARE_SCRIPT(Newscaster)
440END_SCRIPT
441
442DECLARE_SCRIPT(Leon)
443 bool _resumeIdleAfterFramesetCompletesFlag;
444 float _mcCoyPositionX;
445 float _mcCoyPositionY;
446 float _mcCoyPositionZ;
447
448 float distanceTo(int actorId, float x, float y, float z);
449END_SCRIPT
450
451DECLARE_SCRIPT(MaleAnnouncer)
452END_SCRIPT
453
454DECLARE_SCRIPT(FreeSlotA)
455 int _var1;
456 int _var2;
457 float _fallSpeed;
458 float _fallHeightCurrent;
459 float _fallHeightTarget;
460
461 void checkIfOnBridge();
462 void goToRandomUGxx();
463END_SCRIPT
464
465DECLARE_SCRIPT(FreeSlotB)
466 int _var1;
467 int _var2;
468
469 void goToRandomUGxx();
470END_SCRIPT
471
472DECLARE_SCRIPT(Maggie)
473 int _varTimesToLoopWhenHappyB;
474 int _varTimesToBarkWhenHappyA;
475 int _varMaggieSoundPan; // Repurposed - Original: unused, only set to 0 (var_45F400)
476 int _varMaggieClickResponse; // Repurposed - Original: unused, only set to 0 (var_45F404)
477 int var_45F408; // unused, only set to 0
478
479 int randomWaypointMA02();
480 float distanceToActor(int actorId, float x, float y, float z);
481END_SCRIPT
482
483DECLARE_SCRIPT(GenericWalkerA)
484 bool isInside;
485 float deltaX;
486 float deltaZ;
487
488 void movingStart();
489 void movingUpdate();
490 bool prepareWalker();
491 bool preparePath();
492END_SCRIPT
493
494DECLARE_SCRIPT(GenericWalkerB)
495 bool isInside;
496 float deltaX;
497 float deltaZ;
498
499 void movingStart();
500 void movingUpdate();
501 bool prepareWalker();
502 bool preparePath();
503END_SCRIPT
504
505DECLARE_SCRIPT(GenericWalkerC)
506 bool isInside;
507 float deltaX;
508 float deltaZ;
509
510 void movingStart();
511 void movingUpdate();
512 bool prepareWalker();
513 bool preparePath();
514END_SCRIPT
515
516DECLARE_SCRIPT(Mutant1)
517 bool _resumeIdleAfterFramesetCompletesFlag;
518END_SCRIPT
519
520DECLARE_SCRIPT(Mutant2)
521 int _var1;
522 bool _resumeIdleAfterFramesetCompletesFlag;
523END_SCRIPT
524
525DECLARE_SCRIPT(Mutant3)
526 int _var1;
527 bool _resumeIdleAfterFramesetCompletesFlag;
528END_SCRIPT
529
530#undef DECLARE_SCRIPT
531#undef END_SCRIPT
532
534private:
536 int _inScriptCounter;
537 int _actorCount;
538 AIScriptBase **_AIScripts;
539 bool *_actorUpdating;
540public:
541 AIScripts(BladeRunnerEngine *vm, int actorCount);
542 ~AIScripts();
543
544 void initialize(int actor);
545 void update(int actor);
546 void timerExpired(int actor, int timer);
547 void completedMovementTrack(int actor);
548 void receivedClue(int actor, int clueId, int fromActorId);
549 void clickedByPlayer(int actor);
550 void enteredSet(int actor, int setId);
551 void otherAgentEnteredThisSet(int actor, int otherActorId);
552 void otherAgentExitedThisSet(int actor, int otherActorId);
553 void otherAgentEnteredCombatMode(int actorId, int otherActorId, int combatMode);
554 void shotAtAndMissed(int actorId);
555 bool shotAtAndHit(int actorId);
556 void retired(int actor, int retiredByActorId);
557 void goalChanged(int actor, int currentGoalNumber, int newGoalNumber);
558 bool reachedMovementTrackWaypoint(int actor, int waypointId);
559 void updateAnimation(int actor, int *animation, int *frame);
560 void changeAnimationMode(int actor, int mode);
561 void queryAnimationState(int actor, int *animationState, int *animationFrame, int *animationStateNext, int *animationNext);
562 void setAnimationState(int actor, int animationState, int animationFrame, int animationStateNext, int animationNext);
563 void fledCombat(int actor);
564
565 bool isInsideScript() const { return _inScriptCounter > 0; }
566
567 void callChangeAnimationMode(int actor, int mode) { _AIScripts[actor]->ChangeAnimationMode(mode); }
568 int callGetFriendlinessModifierIfGetsClue(int actor, int otherActorId, int clueId) {
569 return _AIScripts[actor]->GetFriendlinessModifierIfGetsClue(otherActorId, clueId);
570 }
571};
572
573} // End of namespace BladeRunner
574
575#endif
Definition: ai_script.h:31
Definition: ai_script.h:533
Definition: bladerunner.h:113
Definition: script.h:34