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 
27 namespace BladeRunner {
28 
29 class BladeRunnerEngine;
30 
31 class AIScriptBase : public ScriptBase {
32 protected:
33  int _animationState;
34  int _animationFrame;
35  int _animationStateNext;
36  int _animationNext;
37 
38 public:
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) \
70 class AIScript##name : public AIScriptBase { \
71 public: \
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(); \
94 private:
95 #define END_SCRIPT };
96 
97 DECLARE_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);
116 END_SCRIPT
117 
118 DECLARE_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);
124 END_SCRIPT
125 
126 DECLARE_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();
140 END_SCRIPT
141 
142 DECLARE_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();
148 END_SCRIPT
149 
150 DECLARE_SCRIPT(Guzza)
151  int _frameDelta;
152  int _counter;
153  int _state;
154  bool _resumeIdleAfterFramesetCompletesFlag;
155 END_SCRIPT
156 
157 DECLARE_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();
167 END_SCRIPT
168 
169 DECLARE_SCRIPT(Lucy)
170  bool _resumeIdleAfterFramesetCompletesFlag;
171 
172  void voightKampffTest();
173  void checkCombat();
174 END_SCRIPT
175 
176 DECLARE_SCRIPT(Izo)
177  int _var1;
178  int _var2;
179  int _varNumOfTimesToHoldCurrentFrame;
180  int _varChooseIdleAnimation;
181  bool _resumeIdleAfterFramesetCompletesFlag;
182 
183  void dialogueWithIzo();
184  void modifyWaypoints();
185 END_SCRIPT
186 
187 DECLARE_SCRIPT(Sadik)
188  int _nextSoundId;
189  int _varChooseIdleAnimation;
190  int _varNumOfTimesToHoldCurrentFrame;
191  int _var4;
192  bool _resumeIdleAfterFramesetCompletesFlag;
193 END_SCRIPT
194 
195 DECLARE_SCRIPT(Crazylegs)
196  bool _resumeIdleAfterFramesetCompletesFlag;
197 END_SCRIPT
198 
199 DECLARE_SCRIPT(Luther)
200  bool _resumeIdleAfterFramesetCompletesFlag;
201 END_SCRIPT
202 
203 DECLARE_SCRIPT(Grigorian)
204  int _varChooseIdleAnimation;
205  int _varNumOfTimesToHoldCurrentFrame;
206 END_SCRIPT
207 
208 DECLARE_SCRIPT(Transient)
209 END_SCRIPT
210 
211 DECLARE_SCRIPT(Lance)
212 END_SCRIPT
213 
214 DECLARE_SCRIPT(BulletBob)
215  int _varChooseIdleAnimation;
216  int _var2;
217  int _var3;
218  int _varNumOfTimesToHoldCurrentFrame;
219 END_SCRIPT
220 
221 DECLARE_SCRIPT(Runciter)
222  int _varChooseIdleAnimation;
223  int var_45CD7C;
224  int var_45CD80;
225  int _varNumOfTimesToHoldCurrentFrame;
226  int var_45CD88;
227 END_SCRIPT
228 
229 DECLARE_SCRIPT(InsectDealer)
230  bool _resumeIdleAfterFramesetCompletesFlag;
231  int _state;
232  int _frameDelta;
233  int _var2;
234  int _counter;
235 END_SCRIPT
236 
237 DECLARE_SCRIPT(TyrellGuard)
238  int _frameDelta;
239  bool _resumeIdleAfterFramesetCompletesFlag;
240 END_SCRIPT
241 
242 DECLARE_SCRIPT(EarlyQ)
243  int _varNumOfTimesToHoldCurrentFrame;
244  int _varChooseIdleAnimation;
245  int _var3;
246  bool _resumeIdleAfterFramesetCompletesFlag;
247 END_SCRIPT
248 
249 DECLARE_SCRIPT(Zuben)
250  int _animationLoopCounter;
251  int _animationLoopLength;
252  int _animationLoopFrameMin;
253  int _animationLoopDirection;
254  int _animationLoopFrameMax;
255 
256  void dialogue();
257 END_SCRIPT
258 
259 DECLARE_SCRIPT(Hasan)
260  int _var1;
261  int _var2;
262  int _varNumOfTimesToHoldCurrentFrame;
263  int _var4;
264  int _var5;
265  int _varChooseIdleAnimation;
266 END_SCRIPT
267 
268 DECLARE_SCRIPT(Marcus)
269 END_SCRIPT
270 
271 DECLARE_SCRIPT(Mia)
272  bool _resumeIdleAfterFramesetCompletesFlag;
273 END_SCRIPT
274 
275 DECLARE_SCRIPT(OfficerLeary)
276  int _varChooseIdleAnimation;
277  bool _idleModeRequestedWhileInTalkingState;
278 END_SCRIPT
279 
280 DECLARE_SCRIPT(OfficerGrayford)
281  int _varChooseIdleAnimation;
282  bool _resumeIdleAfterFramesetCompletesFlag;
283  int _varNumOfTimesToHoldCurrentFrame;
284 END_SCRIPT
285 
286 DECLARE_SCRIPT(Hanoi)
287  bool _resumeIdleAfterFramesetCompletesFlag;
288  int _varChooseIdleAnimation;
289  int _varNumOfTimesToHoldCurrentFrame;
290  int _var4;
291 END_SCRIPT
292 
293 DECLARE_SCRIPT(Baker)
294 END_SCRIPT
295 
296 DECLARE_SCRIPT(DeskClerk)
297  int _varChooseIdleAnimation;
298  bool _resumeIdleAfterFramesetCompletesFlag;
299  int _varNumOfTimesToHoldCurrentFrame;
300 END_SCRIPT
301 
302 DECLARE_SCRIPT(HowieLee)
303  int _varIdleStatesToggle;
304 END_SCRIPT
305 
306 DECLARE_SCRIPT(FishDealer)
307  bool _resumeIdleAfterFramesetCompletesFlag;
308 END_SCRIPT
309 
310 DECLARE_SCRIPT(Klein)
311 END_SCRIPT
312 
313 DECLARE_SCRIPT(Murray)
314  bool _resumeIdleAfterFramesetCompletesFlag;
315 END_SCRIPT
316 
317 DECLARE_SCRIPT(HawkersBarkeep)
318  int _varChooseIdleAnimation;
319  int _varNumOfTimesToHoldCurrentFrame;
320  int _var3;
321  bool _resumeIdleAfterFramesetCompletesFlag;
322 END_SCRIPT
323 
324 DECLARE_SCRIPT(Holloway)
325  bool _resumeIdleAfterFramesetCompletesFlag;
326 END_SCRIPT
327 
328 DECLARE_SCRIPT(SergeantWalls)
329 END_SCRIPT
330 
331 DECLARE_SCRIPT(Moraji)
332  int _var1;
333  int _varNumOfTimesToHoldCurrentFrame;
334 END_SCRIPT
335 
336 DECLARE_SCRIPT(TheBard)
337 END_SCRIPT
338 
339 DECLARE_SCRIPT(Photographer)
340  int _varNumOfTimesToHoldCurrentFrame;
341  int _var2;
342  bool _resumeIdleAfterFramesetCompletesFlag;
343 END_SCRIPT
344 
345 DECLARE_SCRIPT(Dispatcher)
346 END_SCRIPT
347 
348 DECLARE_SCRIPT(AnsweringMachine)
349 END_SCRIPT
350 
351 DECLARE_SCRIPT(Rajif)
352 END_SCRIPT
353 
354 DECLARE_SCRIPT(GovernorKolvig)
355 END_SCRIPT
356 
357 DECLARE_SCRIPT(EarlyQBartender)
358  int _varChooseIdleAnimation;
359  int _var2;
360  bool _resumeIdleAfterFramesetCompletesFlag;
361 END_SCRIPT
362 
363 DECLARE_SCRIPT(HawkersParrot)
364 END_SCRIPT
365 
366 DECLARE_SCRIPT(TaffyPatron)
367 END_SCRIPT
368 
369 DECLARE_SCRIPT(LockupGuard)
370 END_SCRIPT
371 
372 DECLARE_SCRIPT(Teenager)
373 END_SCRIPT
374 
375 DECLARE_SCRIPT(HysteriaPatron1)
376 END_SCRIPT
377 
378 DECLARE_SCRIPT(HysteriaPatron2)
379 END_SCRIPT
380 
381 DECLARE_SCRIPT(HysteriaPatron3)
382 END_SCRIPT
383 
384 DECLARE_SCRIPT(ShoeshineMan)
385  bool _state;
386 END_SCRIPT
387 
388 DECLARE_SCRIPT(Tyrell)
389  bool _resumeIdleAfterFramesetCompletesFlag;
390  int _varChooseIdleAnimation;
391 END_SCRIPT
392 
393 DECLARE_SCRIPT(Chew)
394  int _varNumOfTimesToHoldCurrentFrame;
395  int _varChooseIdleAnimation;
396  int _var3;
397  bool _resumeIdleAfterFramesetCompletesFlag;
398 END_SCRIPT
399 
400 DECLARE_SCRIPT(Gaff)
401 END_SCRIPT
402 
403 DECLARE_SCRIPT(Bryant)
404 END_SCRIPT
405 
406 DECLARE_SCRIPT(Taffy)
407 END_SCRIPT
408 
409 DECLARE_SCRIPT(Sebastian)
410  bool _resumeIdleAfterFramesetCompletesFlag;
411 
412  void dialogue();
413  void setMcCoyIsABladeRunner();
414 END_SCRIPT
415 
416 DECLARE_SCRIPT(Rachael)
417  bool _resumeIdleAfterFramesetCompletesFlag;
418 
419  void dialogue_start();
420  void dialogue_agenda1();
421  void dialogue_agenda2();
422  void dialogue_act4();
423 END_SCRIPT
424 
425 DECLARE_SCRIPT(GeneralDoll)
426  bool _resumeIdleAfterFramesetCompletesFlag;
427 END_SCRIPT
428 
429 DECLARE_SCRIPT(Isabella)
430  int _var1;
431  int _varNumOfTimesToHoldCurrentFrame;
432  int _varChooseIdleAnimation;
433  int _var4;
434 END_SCRIPT
435 
436 DECLARE_SCRIPT(BlimpGuy)
437 END_SCRIPT
438 
439 DECLARE_SCRIPT(Newscaster)
440 END_SCRIPT
441 
442 DECLARE_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);
449 END_SCRIPT
450 
451 DECLARE_SCRIPT(MaleAnnouncer)
452 END_SCRIPT
453 
454 DECLARE_SCRIPT(FreeSlotA)
455  int _var1;
456  int _var2;
457  float _fallSpeed;
458  float _fallHeightCurrent;
459  float _fallHeightTarget;
460 
461  void checkIfOnBridge();
462  void goToRandomUGxx();
463 END_SCRIPT
464 
465 DECLARE_SCRIPT(FreeSlotB)
466  int _var1;
467  int _var2;
468 
469  void goToRandomUGxx();
470 END_SCRIPT
471 
472 DECLARE_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);
481 END_SCRIPT
482 
483 DECLARE_SCRIPT(GenericWalkerA)
484  bool isInside;
485  float deltaX;
486  float deltaZ;
487 
488  void movingStart();
489  void movingUpdate();
490  bool prepareWalker();
491  bool preparePath();
492 END_SCRIPT
493 
494 DECLARE_SCRIPT(GenericWalkerB)
495  bool isInside;
496  float deltaX;
497  float deltaZ;
498 
499  void movingStart();
500  void movingUpdate();
501  bool prepareWalker();
502  bool preparePath();
503 END_SCRIPT
504 
505 DECLARE_SCRIPT(GenericWalkerC)
506  bool isInside;
507  float deltaX;
508  float deltaZ;
509 
510  void movingStart();
511  void movingUpdate();
512  bool prepareWalker();
513  bool preparePath();
514 END_SCRIPT
515 
516 DECLARE_SCRIPT(Mutant1)
517  bool _resumeIdleAfterFramesetCompletesFlag;
518 END_SCRIPT
519 
520 DECLARE_SCRIPT(Mutant2)
521  int _var1;
522  bool _resumeIdleAfterFramesetCompletesFlag;
523 END_SCRIPT
524 
525 DECLARE_SCRIPT(Mutant3)
526  int _var1;
527  bool _resumeIdleAfterFramesetCompletesFlag;
528 END_SCRIPT
529 
530 #undef DECLARE_SCRIPT
531 #undef END_SCRIPT
532 
533 class AIScripts {
534 private:
535  BladeRunnerEngine *_vm;
536  int _inScriptCounter;
537  int _actorCount;
538  AIScriptBase **_AIScripts;
539  bool *_actorUpdating;
540 public:
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: actor.h:31
Definition: ai_script.h:533
Definition: ai_script.h:31
Definition: script.h:34
Definition: bladerunner.h:113