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