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 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897
|
/* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#include "bladerunner/script/ai_script.h"
//#include "common/debug.h"
namespace BladeRunner {
AIScriptFreeSlotA::AIScriptFreeSlotA(BladeRunnerEngine *vm) : AIScriptBase(vm) {
_var1 = 0;
_var2 = 1;
_fallSpeed = 0.0f;
_fallHeightCurrent = 0.0f; // not initialized in original
_fallHeightTarget = 0.0f; // not initialized in original
}
void AIScriptFreeSlotA::Initialize() {
_animationFrame = 0;
_animationState = 0;
_animationStateNext = 0;
_animationNext = 0;
_var1 = 0;
_var2 = 1;
_fallSpeed = 0.0f;
_fallHeightCurrent = 0.0f; // not initialized in original
_fallHeightTarget = 0.0f; // not initialized in original
World_Waypoint_Set(525, kSetKP02, -780.0f, -615.49f, 2611.0f);
// TODO: A bug? world waypoint 526 is unused
World_Waypoint_Set(526, kSetKP02, -780.0f, -615.49f, 2759.0f);
}
bool AIScriptFreeSlotA::Update() {
switch (Global_Variable_Query(kVariableChapter)) {
case 4:
// Act 4
if (Actor_Query_Which_Set_In(kActorMcCoy) == kSetUG15
&& Actor_Query_Which_Set_In(kActorFreeSlotA) == kSetUG15
) {
int goal = Actor_Query_Goal_Number(kActorFreeSlotA);
if ((goal == kGoalFreeSlotAUG15RunToOtherSide
|| goal == kGoalFreeSlotAUG15RunBack)
&& Actor_Query_Inch_Distance_From_Actor(kActorFreeSlotA, kActorMcCoy) <= 48
) {
Actor_Set_Goal_Number(kActorFreeSlotA, kGoalFreeSlotAUG15Attack);
} else if (goal == kGoalFreeSlotAUG15Fall) {
float x, y, z;
Actor_Query_XYZ(kActorMcCoy, &x, &y, &z);
_fallHeightCurrent += _fallSpeed;
if (_fallHeightTarget < _fallHeightCurrent) {
_fallSpeed -= 0.2f;
} else {
_fallHeightCurrent = _fallHeightTarget;
Actor_Set_Goal_Number(kActorFreeSlotA, kGoalFreeSlotADefault);
}
Actor_Set_At_XYZ(kActorFreeSlotA, x, _fallHeightCurrent, z, Actor_Query_Facing_1024(kActorFreeSlotA));
}
return true;
}
switch (Actor_Query_Goal_Number(kActorFreeSlotA)) {
case kGoalFreeSlotAWalkAround:
#if BLADERUNNER_ORIGINAL_BUGS
if (Actor_Query_Which_Set_In(kActorFreeSlotA) == Player_Query_Current_Set()
&& Actor_Query_Inch_Distance_From_Actor(kActorFreeSlotA, kActorMcCoy) <= 48
) {
Actor_Set_Goal_Number(kActorFreeSlotA, kGoalFreeSlotAAttackMcCoy);
}
#else
if (Actor_Query_Which_Set_In(kActorFreeSlotA) == Player_Query_Current_Set()
&& Actor_Query_Inch_Distance_From_Actor(kActorFreeSlotA, kActorMcCoy) <= 54
) {
Actor_Set_Goal_Number(kActorFreeSlotA, kGoalFreeSlotAAttackMcCoy);
}
#endif // BLADERUNNER_ORIGINAL_BUGS
break;
case kGoalFreeSlotAAttackMcCoy:
if (Actor_Query_Which_Set_In(kActorFreeSlotA) != Player_Query_Current_Set()) {
Actor_Set_Goal_Number(kActorFreeSlotA, kGoalFreeSlotAWalkAround);
}
break;
case kGoalFreeSlotAGone:
if (Actor_Query_Which_Set_In(kActorFreeSlotA) != Player_Query_Current_Set()) {
Game_Flag_Reset(kFlagRatWalkingAround);
Game_Flag_Reset(kFlagUG15BridgeWillBreak);
#if BLADERUNNER_ORIGINAL_BUGS
Actor_Set_Goal_Number(kActorFreeSlotA, kGoalFreeSlotADefault);
#else
Actor_Set_Goal_Number(kActorFreeSlotA, kGoalFreeSlotAGoneIntermediate);
#endif
}
break;
default:
if (!Game_Flag_Query(kFlagRatWalkingAround)) {
Game_Flag_Set(kFlagRatWalkingAround);
Actor_Set_Goal_Number(kActorFreeSlotA, kGoalFreeSlotAWalkAround);
Actor_Set_Targetable(kActorFreeSlotA, true);
}
}
return true;
case 5:
// Act 5
if (Actor_Query_Goal_Number(kActorFreeSlotA) < kGoalFreeSlotAAct5Default) {
AI_Movement_Track_Flush(kActorFreeSlotA);
Actor_Set_Goal_Number(kActorFreeSlotA, kGoalFreeSlotAAct5Default);
} else {
#if BLADERUNNER_ORIGINAL_BUGS
if (Actor_Query_Goal_Number(kActorFreeSlotA) == kGoalFreeSlotAAct5Prepare
&& Actor_Query_Which_Set_In(kActorMcCoy) == kSetKP02
) {
Actor_Set_Targetable(kActorFreeSlotA, true);
Actor_Set_Goal_Number(kActorFreeSlotA, kGoalFreeSlotAAct5KP02Attack);
}
#else
// copying the behavior of Rat B (kActorFreeSlotB) because it works without the bug
// Fixes the bug where the Rat A is killed in KP02 but when McCoy re-enters it is there alive
// in idle mode and non-target-able
if (Actor_Query_Goal_Number(kActorFreeSlotA) != kGoalFreeSlotAAct5Prepare
|| Actor_Query_Which_Set_In(kActorMcCoy) != kSetKP02
) {
if (Actor_Query_Goal_Number(kActorFreeSlotA) == kGoalFreeSlotAGone) {
if (Actor_Query_Which_Set_In(kActorFreeSlotA) != Player_Query_Current_Set()) {
Non_Player_Actor_Combat_Mode_Off(kActorFreeSlotA);
#if BLADERUNNER_ORIGINAL_BUGS
Actor_Set_Goal_Number(kActorFreeSlotA, kGoalFreeSlotAAct5Default);
#else
Actor_Set_Goal_Number(kActorFreeSlotA, kGoalFreeSlotAGoneIntermediate);
#endif
return true;
}
}
return false;
}
Actor_Set_Goal_Number(kActorFreeSlotA, kGoalFreeSlotAAct5KP02Attack);
Actor_Set_Targetable(kActorFreeSlotA, true);
return true;
#endif // BLADERUNNER_ORIGINAL_BUGS
}
return true;
default:
return false;
}
}
void AIScriptFreeSlotA::TimerExpired(int timer) {
//return false;
}
void AIScriptFreeSlotA::CompletedMovementTrack() {
// debug("Rat A completed move with Goal: %d", Actor_Query_Goal_Number(kActorFreeSlotA));
switch (Actor_Query_Goal_Number(kActorFreeSlotA)) {
case kGoalFreeSlotAUG15WalkOut:
Actor_Set_Goal_Number(kActorFreeSlotA, kGoalFreeSlotAUG15RunToOtherSide);
break;
case kGoalFreeSlotAUG15RunToOtherSide:
Actor_Set_Goal_Number(kActorFreeSlotA, kGoalFreeSlotAUG15RunBack);
break;
case kGoalFreeSlotAUG15RunBack:
Actor_Set_Goal_Number(kActorFreeSlotA, kGoalFreeSlotAUG15Wait);
break;
case kGoalFreeSlotAWalkAround:
Actor_Set_Goal_Number(kActorFreeSlotA, kGoalFreeSlotAWalkAroundRestart);
break;
case kGoalFreeSlotAWalkAroundRestart:
Actor_Set_Goal_Number(kActorFreeSlotA, kGoalFreeSlotAWalkAround);
break;
case kGoalFreeSlotAAct5Default:
Actor_Set_Goal_Number(kActorFreeSlotA, kGoalFreeSlotAAct5Prepare);
break;
case kGoalFreeSlotAAct5KP02Attack:
Non_Player_Actor_Combat_Mode_On(kActorFreeSlotA, kActorCombatStateIdle, false, kActorMcCoy, 8, kAnimationModeCombatIdle, kAnimationModeCombatWalk, kAnimationModeCombatRun, 0, 0, 100, 5, 300, false);
break;
default:
return; //false;
}
return; //true;
}
void AIScriptFreeSlotA::ReceivedClue(int clueId, int fromActorId) {
//return false;
}
void AIScriptFreeSlotA::ClickedByPlayer() {
if (Actor_Query_Goal_Number(kActorFreeSlotA) == kGoalFreeSlotAGone) {
Actor_Face_Actor(kActorMcCoy, kActorFreeSlotA, true);
if (_vm->_cutContent && !Game_Flag_Query(kFlagMcCoyCommentsOnHoodooRats)) {
Game_Flag_Set(kFlagMcCoyCommentsOnHoodooRats);
// Note: Quote 1060 mentions "Hoodoo Rats". Quote 1070 is *boop* in ENG version.
// However, quote 1070 is similar to 1060 quote in FRA, DEU, ESP and ITA versions
// with the only difference being not mentioning the "Hoodoo Rats" name.
// It uses a generic "rats" in its place.
// For those four languages one of the two quotes will play (random chance 50%)
if ((_vm->_language == Common::DE_DEU
|| _vm->_language == Common::ES_ESP
|| _vm->_language == Common::FR_FRA
|| _vm->_language == Common::IT_ITA)
&& (Random_Query(1, 2) == 1)) {
Actor_Voice_Over(1070, kActorVoiceOver); // "rats"
} else {
Actor_Voice_Over(1060, kActorVoiceOver); // "Hoodoo rats"
}
Actor_Voice_Over(1080, kActorVoiceOver);
Actor_Voice_Over(1090, kActorVoiceOver);
} else {
if (Random_Query(1, 2) == 1) {
Actor_Says(kActorMcCoy, 8655, 16);
} else {
Actor_Says(kActorMcCoy, 8665, 16);
}
}
}
//return false;
}
void AIScriptFreeSlotA::EnteredSet(int setId) {
// return false;
}
void AIScriptFreeSlotA::OtherAgentEnteredThisSet(int otherActorId) {
// return false;
}
void AIScriptFreeSlotA::OtherAgentExitedThisSet(int otherActorId) {
#if !BLADERUNNER_ORIGINAL_BUGS
if (otherActorId == kActorMcCoy && Actor_Query_Goal_Number(kActorFreeSlotA) == kGoalFreeSlotAGone) {
if (Global_Variable_Query(kVariableChapter) == 4) {
Game_Flag_Reset(kFlagRatWalkingAround);
Game_Flag_Reset(kFlagUG15BridgeWillBreak);
} else if (Global_Variable_Query(kVariableChapter) == 5) {
Non_Player_Actor_Combat_Mode_Off(kActorFreeSlotA);
}
Actor_Set_Goal_Number(kActorFreeSlotA, kGoalFreeSlotAGoneIntermediate);
}
#endif // BLADERUNNER_ORIGINAL_BUGS
// return false;
}
void AIScriptFreeSlotA::OtherAgentEnteredCombatMode(int otherActorId, int combatMode) {
// return false;
}
void AIScriptFreeSlotA::ShotAtAndMissed() {
if (Actor_Query_In_Set(kActorFreeSlotA, kSetUG15)) {
checkIfOnBridge();
}
}
bool AIScriptFreeSlotA::ShotAtAndHit() {
if (Actor_Query_In_Set(kActorFreeSlotA, kSetUG15)) {
checkIfOnBridge();
// This goal "kGoalFreeSlotAUG15Die" circumvents the proper process
// a proper combat with the rat and it dying when its health reaches <= 0
// ie. being "retired".
// Thus, since the rat never actually 'dies' from being shot,
// its Actor::retire() is not called in this case (UG15 bridge rat),
// and so its bounding box is not affected. Thus, the rat corpse remains clickable.
Actor_Set_Goal_Number(kActorFreeSlotA, kGoalFreeSlotAUG15Die);
return true;
}
return false;
}
void AIScriptFreeSlotA::Retired(int byActorId) {
Actor_Set_Goal_Number(kActorFreeSlotA, kGoalFreeSlotAGone);
}
int AIScriptFreeSlotA::GetFriendlinessModifierIfGetsClue(int otherActorId, int clueId) {
return 0;
}
bool AIScriptFreeSlotA::GoalChanged(int currentGoalNumber, int newGoalNumber) {
// debug("Rat A goal changed from %d to: %d", currentGoalNumber, newGoalNumber);
switch (newGoalNumber) {
case kGoalFreeSlotAUG15Wait:
AI_Movement_Track_Flush(kActorFreeSlotA);
Actor_Change_Animation_Mode(kActorFreeSlotA, kAnimationModeIdle);
Actor_Set_Targetable(kActorFreeSlotA, false);
break;
case kGoalFreeSlotAUG15WalkOut:
// kSetUG15
Actor_Force_Stop_Walking(kActorMcCoy);
AI_Movement_Track_Flush(kActorFreeSlotA);
World_Waypoint_Set(444, kSetUG15, -48.75f, 44.66f, 87.57f);
AI_Movement_Track_Append(kActorFreeSlotA, 444, 1);
AI_Movement_Track_Repeat(kActorFreeSlotA);
break;
case kGoalFreeSlotAUG15RunToOtherSide:
// kSetUG15
AI_Movement_Track_Flush(kActorFreeSlotA);
World_Waypoint_Set(444, kSetUG15, -237.0f, 48.07f, 208.0f);
AI_Movement_Track_Append(kActorFreeSlotA, 444, 1);
AI_Movement_Track_Repeat(kActorFreeSlotA);
Actor_Set_Targetable(kActorFreeSlotA, true);
break;
case kGoalFreeSlotAUG15RunBack:
// kSetUG15
AI_Movement_Track_Flush(kActorFreeSlotA);
World_Waypoint_Set(444, kSetUG15, 3.52f, 52.28f, 90.68f);
AI_Movement_Track_Append(kActorFreeSlotA, 444, 0);
AI_Movement_Track_Repeat(kActorFreeSlotA);
break;
case kGoalFreeSlotAUG15Attack:
Player_Loses_Control();
Actor_Force_Stop_Walking(kActorMcCoy);
AI_Movement_Track_Flush(kActorFreeSlotA);
Actor_Face_Actor(kActorFreeSlotA, kActorMcCoy, true);
Actor_Change_Animation_Mode(kActorFreeSlotA, kAnimationModeCombatAttack);
Actor_Change_Animation_Mode(kActorMcCoy, kAnimationModeDie);
break;
case kGoalFreeSlotAUG15Die:
AI_Movement_Track_Flush(kActorFreeSlotA);
Actor_Set_Targetable(kActorFreeSlotA, false);
Game_Flag_Set(kFlagUG15RatShot);
_animationState = 7;
_animationFrame = 0;
break;
case kGoalFreeSlotAWalkAround:
AI_Movement_Track_Flush(kActorFreeSlotA);
goToRandomUGxx();
AI_Movement_Track_Repeat(kActorFreeSlotA);
break;
case kGoalFreeSlotAWalkAroundRestart:
// kSetFreeSlotG
AI_Movement_Track_Flush(kActorFreeSlotA);
AI_Movement_Track_Append(kActorFreeSlotA, 39, 1);
AI_Movement_Track_Repeat(kActorFreeSlotA);
break;
case kGoalFreeSlotAAttackMcCoy:
Actor_Set_Targetable(kActorFreeSlotA, true);
Non_Player_Actor_Combat_Mode_On(kActorFreeSlotA, kActorCombatStateIdle, false, kActorMcCoy, 8, kAnimationModeCombatIdle, kAnimationModeCombatWalk, kAnimationModeCombatRun, 25, 0, 75, 5, 300, false);
break;
case kGoalFreeSlotAUG15Fall:
Actor_Force_Stop_Walking(kActorFreeSlotA);
AI_Movement_Track_Flush(kActorFreeSlotA);
_fallHeightCurrent = 52.46f;
_fallSpeed = -4.0f;
_fallHeightTarget = -10.0f;
if (_animationState != 7
&& _animationState != 8
) {
_animationState = 7;
_animationFrame = 0;
}
break;
case kGoalFreeSlotAUG15Prepare:
AI_Movement_Track_Flush(kActorFreeSlotA);
Actor_Put_In_Set(kActorFreeSlotA, kSetUG15);
Actor_Set_At_XYZ(kActorFreeSlotA, 3.52f, 52.28f, 90.68f, 700);
Actor_Set_Goal_Number(kActorFreeSlotA, kGoalFreeSlotAUG15Wait);
break;
case kGoalFreeSlotAAct5Default:
// kSetFreeSlotG
AI_Movement_Track_Append(kActorFreeSlotA, 39, 0);
AI_Movement_Track_Repeat(kActorFreeSlotA);
break;
case kGoalFreeSlotAAct5KP02Attack:
// kSetKP02
AI_Movement_Track_Flush(kActorFreeSlotA);
AI_Movement_Track_Append(kActorFreeSlotA, 525, 0);
AI_Movement_Track_Repeat(kActorFreeSlotA);
break;
#if BLADERUNNER_ORIGINAL_BUGS
#else
case kGoalFreeSlotAGoneIntermediate:
Actor_Set_Health(kActorFreeSlotA, 20, 20);
if (Global_Variable_Query(kVariableChapter) == 4) {
Actor_Set_Goal_Number(kActorFreeSlotA, kGoalFreeSlotADefault);
} else if (Global_Variable_Query(kVariableChapter) == 5) {
Actor_Set_Goal_Number(kActorFreeSlotA, kGoalFreeSlotAAct5Default);
}
break;
#endif
case kGoalFreeSlotAGone:
#if BLADERUNNER_ORIGINAL_BUGS
Actor_Set_Health(kActorFreeSlotA, 20, 20);
#endif
// A bug? What does this friendliness affect?
Actor_Set_Friendliness_To_Other(kActorFreeSlotA, kActorMcCoy, 40);
break;
default:
return false;
}
return true;
}
bool AIScriptFreeSlotA::UpdateAnimation(int *animation, int *frame) {
switch (_animationState) {
case 0:
*animation = kModelAnimationRatIdle;
++_animationFrame;
if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(kModelAnimationRatIdle)) {
_animationFrame = 0;
}
break;
case 1:
*animation = kModelAnimationRatSlowWalk;
if (_var1) {
--_var1;
} else {
_animationFrame += _var2;
if (_animationFrame < 8) {
_var2 = 1;
} else {
if (_animationFrame > 8) {
_var2 = -1;
} else if (Random_Query(0, 4)) {
_var2 = -_var2;
}
}
if (_animationFrame >= 7 && _animationFrame <= 9) {
_var1 = Random_Query(0, 1);
}
}
break;
case 2:
*animation = kModelAnimationRatSlowWalk;
++_animationFrame;
if (_animationFrame > Slice_Animation_Query_Number_Of_Frames(kModelAnimationRatSlowWalk) - 1) {
*animation = kModelAnimationRatIdle;
_animationFrame = 0;
_animationState = 0;
}
break;
case 3:
*animation = kModelAnimationRatRunning;
++_animationFrame;
if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(kModelAnimationRatRunning)) {
_animationFrame = 0;
}
break;
case 4:
*animation = kModelAnimationRatJumpAttack;
++_animationFrame;
if (_animationFrame == 1) {
int snd;
if (Random_Query(1, 2) == 1) {
snd = 9010;
} else {
snd = 9015;
}
Sound_Play_Speech_Line(kActorFreeSlotA, snd, 75, 0, 99);
}
if (_animationFrame == 3) {
Ambient_Sounds_Play_Sound(kSfxRATTY4, 99, 0, 0, 20);
Actor_Combat_AI_Hit_Attempt(kActorFreeSlotA);
}
if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(kModelAnimationRatJumpAttack)) {
_animationState = 0;
_animationFrame = 0;
Actor_Change_Animation_Mode(kActorFreeSlotA, kAnimationModeCombatIdle);
}
break;
case 5:
// This is an animation for Maggie (exploding) but is also used for generic death states (rats, generic walkers)
// probably for debug purposes
*animation = kModelAnimationMaggieExploding;
++_animationFrame;
if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(kModelAnimationMaggieExploding) - 1) {
Actor_Change_Animation_Mode(kActorFreeSlotA, kAnimationModeIdle);
}
break;
case 6:
if (_animationFrame == 1) {
Ambient_Sounds_Play_Sound(kSfxRATTY3, 99, 0, 0, 20);
}
*animation = kModelAnimationRatHurt;
++_animationFrame;
if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(kModelAnimationRatHurt)) {
_animationFrame = 0;
_animationState = 0;
Actor_Change_Animation_Mode(kActorFreeSlotA, kAnimationModeIdle);
}
break;
case 7:
*animation = kModelAnimationRatDying;
++_animationFrame;
if (_animationFrame == 1) {
Ambient_Sounds_Play_Sound(kSfxRATTY5, 99, 0, 0, 25);
}
if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(kModelAnimationRatDying) - 1) {
// -1 in the clause is ok here since the next _animationState is 8 which will maintain the last frame (Slice_Animation_Query_Number_Of_Frames(kModelAnimationRatDying) - 1)
_animationFrame = Slice_Animation_Query_Number_Of_Frames(kModelAnimationRatDying) - 1;
_animationState = 8;
Actor_Set_Goal_Number(kActorFreeSlotA, kGoalFreeSlotAGone);
}
break;
case 8:
*animation = kModelAnimationRatDying;
_animationFrame = Slice_Animation_Query_Number_Of_Frames(kModelAnimationRatDying) - 1;
break;
default:
debugC(6, kDebugAnimation, "AIScriptFreeSlotA::UpdateAnimation() - Current _animationState (%d) is not supported", _animationState);
break;
}
*frame = _animationFrame;
return true;
}
bool AIScriptFreeSlotA::ChangeAnimationMode(int mode) {
switch (mode) {
case kAnimationModeIdle:
if ((unsigned int)(_animationState - 1) > 1) {
_animationState = 0;
_animationFrame = 0;
} else if (_animationState == 1) {
_animationState = 2;
}
break;
case kAnimationModeWalk:
_animationState = 3;
_animationFrame = 0;
break;
case 4:
if ((unsigned int)(_animationState - 1) > 1) {
_animationState = 0;
_animationFrame = 0;
} else if (_animationState == 1) {
_animationState = 2;
}
break;
case 6:
_animationState = 4;
_animationFrame = 0;
break;
case 7:
_animationState = 3;
_animationFrame = 0;
break;
case 8:
_animationState = 3;
_animationFrame = 0;
break;
case 21:
_animationState = 6;
_animationFrame = 0;
break;
case 43:
_animationState = 1;
_animationFrame = 0;
break;
case kAnimationModeDie:
_animationState = 7;
_animationFrame = 0;
break;
default:
debugC(6, kDebugAnimation, "AIScriptFreeSlotA::ChangeAnimationMode(%d) - Target mode is not supported", mode);
break;
}
return true;
}
void AIScriptFreeSlotA::QueryAnimationState(int *animationState, int *animationFrame, int *animationStateNext, int *animationNext) {
*animationState = _animationState;
*animationFrame = _animationFrame;
*animationStateNext = _animationStateNext;
*animationNext = _animationNext;
}
void AIScriptFreeSlotA::SetAnimationState(int animationState, int animationFrame, int animationStateNext, int animationNext) {
_animationState = animationState;
_animationFrame = animationFrame;
_animationStateNext = animationStateNext;
_animationNext = animationNext;
}
bool AIScriptFreeSlotA::ReachedMovementTrackWaypoint(int waypointId) {
if (Actor_Query_Which_Set_In(kActorFreeSlotA) == kSetUG01) {
if (waypointId == 465) {
Actor_Change_Animation_Mode(kActorFreeSlotA, 43);
}
} else if (Actor_Query_Goal_Number(kActorFreeSlotA) == kGoalFreeSlotAUG15RunToOtherSide) {
Actor_Face_Actor(kActorFreeSlotA, kActorMcCoy, true);
}
return true;
}
void AIScriptFreeSlotA::FledCombat() {
// return false;
}
void AIScriptFreeSlotA::checkIfOnBridge() {
if (_vm->_cutContent && Query_Difficulty_Level() == kGameDifficultyEasy) {
// Make the bridge indestructible on easy mode for the enhanced version
return;
}
float x, y, z;
Actor_Query_XYZ(kActorFreeSlotA, &x, &y, &z);
// bug? this should probably check if McCoy is close enough because bridge will break long after rat died and player tries to walk through
if (-150.0 <= x && x < -30.0f) {
Game_Flag_Set(kFlagUG15BridgeWillBreak);
}
}
void AIScriptFreeSlotA::goToRandomUGxx() {
switch (Random_Query(1, 14)) {
case 1:
// kSetUG01
#if BLADERUNNER_ORIGINAL_BUGS
AI_Movement_Track_Append(kActorFreeSlotA, 450, 1);
AI_Movement_Track_Append(kActorFreeSlotA, 451, 5);
AI_Movement_Track_Append(kActorFreeSlotA, 450, 0);
break;
#else
// Don't put rats in UG01 when Lucy is also here
if (!Actor_Query_In_Set(kActorLucy, kSetUG01)) {
AI_Movement_Track_Append(kActorFreeSlotA, 450, 1);
AI_Movement_Track_Append(kActorFreeSlotA, 451, 5);
AI_Movement_Track_Append(kActorFreeSlotA, 450, 0);
break;
}
#endif // BLADERUNNER_ORIGINAL_BUGS
// fall through
case 2:
// kSetUG01
#if BLADERUNNER_ORIGINAL_BUGS
World_Waypoint_Set(463, kSetUG01, 144.98f, -50.13f, -175.75f);
World_Waypoint_Set(464, kSetUG01, 105.6f, -50.13f, -578.46f);
World_Waypoint_Set(465, kSetUG01, 62.0f, -50.13f, -574.0f);
AI_Movement_Track_Append(kActorFreeSlotA, 463, 1);
AI_Movement_Track_Append(kActorFreeSlotA, 464, 1);
AI_Movement_Track_Append(kActorFreeSlotA, 465, 5);
AI_Movement_Track_Append(kActorFreeSlotA, 463, 5);
break;
#else
// Don't put rats in UG01 when Lucy is also here
if (!Actor_Query_In_Set(kActorLucy, kSetUG01)) {
World_Waypoint_Set(463, kSetUG01, 144.98f, -50.13f, -175.75f);
World_Waypoint_Set(464, kSetUG01, 105.6f, -50.13f, -578.46f);
World_Waypoint_Set(465, kSetUG01, 62.0f, -50.13f, -574.0f);
AI_Movement_Track_Append(kActorFreeSlotA, 463, 1);
AI_Movement_Track_Append(kActorFreeSlotA, 464, 1);
AI_Movement_Track_Append(kActorFreeSlotA, 465, 5);
AI_Movement_Track_Append(kActorFreeSlotA, 463, 5);
break;
}
#endif // BLADERUNNER_ORIGINAL_BUGS
// fall through
case 3:
// kSetUG04
AI_Movement_Track_Append(kActorFreeSlotA, 446, 15);
AI_Movement_Track_Append(kActorFreeSlotA, 447, 1);
AI_Movement_Track_Append(kActorFreeSlotA, 449, 1);
AI_Movement_Track_Append(kActorFreeSlotA, 448, 2);
AI_Movement_Track_Append(kActorFreeSlotA, 449, 0);
break;
case 4:
// kSetUG04
World_Waypoint_Set(463, kSetUG04, -22.7f, 6.39f, 33.12f);
World_Waypoint_Set(464, kSetUG04, -6.70f, -1.74f, -362.88f);
World_Waypoint_Set(465, kSetUG04, 164.0f, 11.87f, -1013.0f);
AI_Movement_Track_Append(kActorFreeSlotA, 463, 2);
AI_Movement_Track_Append(kActorFreeSlotA, 464, 0);
AI_Movement_Track_Append(kActorFreeSlotA, 465, 0);
break;
case 5:
// kSetUG05
AI_Movement_Track_Append(kActorFreeSlotA, 457, 15);
AI_Movement_Track_Append(kActorFreeSlotA, 458, 0);
AI_Movement_Track_Append(kActorFreeSlotA, 459, 15);
break;
case 6:
// kSetUG06
AI_Movement_Track_Append(kActorFreeSlotA, 460, 15);
AI_Movement_Track_Append(kActorFreeSlotA, 461, 5);
AI_Movement_Track_Append(kActorFreeSlotA, 460, 15);
break;
case 7:
// kSetUG07 or kSetFreeSlotG
#if BLADERUNNER_ORIGINAL_BUGS
if (Actor_Query_In_Set(kActorClovis, kSetUG07)) {
// this check is not very effective since Clovis
// will spawn in the set when McCoy goes to the downwards exit
// at which point a rat may already be in the set and that could
// make them collide with Clovis' path
AI_Movement_Track_Append(kActorFreeSlotA, 39, 10); // kSetFreeSlotG
} else {
World_Waypoint_Set(463, kSetUG07, -88.78f, -12.21f, -184.08f);
World_Waypoint_Set(464, kSetUG07, 250.0f, -12.21f, -342.0f);
World_Waypoint_Set(465, kSetUG07, -164.78f, -12.21f, -832.08f);
AI_Movement_Track_Append(kActorFreeSlotA, 463, 5);
AI_Movement_Track_Append(kActorFreeSlotA, 464, 1);
// TODO: A bug? the waypoint 465 is created but is unused
}
break;
#else
// Don't put rats in UG07 after the UG18 Guzza scene
// since Clovis may be there too and that does not work well
if (!Game_Flag_Query(kFlagUG18GuzzaScene)) {
World_Waypoint_Set(463, kSetUG07, -88.78f, -12.21f, -184.08f);
World_Waypoint_Set(464, kSetUG07, 250.0f, -12.21f, -342.0f);
World_Waypoint_Set(465, kSetUG07, -164.78f, -12.21f, -832.08f);
AI_Movement_Track_Append(kActorFreeSlotA, 463, 5);
AI_Movement_Track_Append(kActorFreeSlotA, 464, 1);
// TODO: A bug? the waypoint 465 is created but is unused
break;
}
#endif // BLADERUNNER_ORIGINAL_BUGS
// fall through
case 8:
// kSetUG07
#if BLADERUNNER_ORIGINAL_BUGS
World_Waypoint_Set(463, kSetUG07, -88.78f, -12.21f, -184.08f);
World_Waypoint_Set(464, kSetUG07, 250.0f, -12.21f, -342.0f);
World_Waypoint_Set(465, kSetUG07, -164.78f, -12.21f, -832.08f);
AI_Movement_Track_Append(kActorFreeSlotA, 464, 5);
AI_Movement_Track_Append(kActorFreeSlotA, 463, 1);
// TODO: A bug? the waypoint 465 is created but is unused
break;
#else
// Don't put rats in UG07 after the UG18 Guzza scene
// since Clovis may be there too and that does not work well
if (!Game_Flag_Query(kFlagUG18GuzzaScene)) {
World_Waypoint_Set(463, kSetUG07, -88.78f, -12.21f, -184.08f);
World_Waypoint_Set(464, kSetUG07, 250.0f, -12.21f, -342.0f);
World_Waypoint_Set(465, kSetUG07, -164.78f, -12.21f, -832.08f);
AI_Movement_Track_Append(kActorFreeSlotA, 464, 5);
AI_Movement_Track_Append(kActorFreeSlotA, 463, 1);
// TODO: A bug? the waypoint 465 is created but is unused
break;
}
#endif // BLADERUNNER_ORIGINAL_BUGS
// fall through
case 9:
// kSetUG07
#if BLADERUNNER_ORIGINAL_BUGS
World_Waypoint_Set(463, kSetUG07, -88.78f, -12.21f, -184.08f);
World_Waypoint_Set(464, kSetUG07, 250.0f, -12.21f, -342.0f);
World_Waypoint_Set(465, kSetUG07, -164.78f, -12.21f, -832.08f);
AI_Movement_Track_Append(kActorFreeSlotA, 464, 5);
AI_Movement_Track_Append(kActorFreeSlotA, 465, 1);
// TODO: A bug? the waypoint 463 is created but is unused
break;
#else
// Don't put rats in UG07 after the UG18 Guzza scene
// since Clovis may be there too and that does not work well
if (!Game_Flag_Query(kFlagUG18GuzzaScene)) {
World_Waypoint_Set(463, kSetUG07, -88.78f, -12.21f, -184.08f);
World_Waypoint_Set(464, kSetUG07, 250.0f, -12.21f, -342.0f);
World_Waypoint_Set(465, kSetUG07, -164.78f, -12.21f, -832.08f);
AI_Movement_Track_Append(kActorFreeSlotA, 464, 5);
AI_Movement_Track_Append(kActorFreeSlotA, 465, 1);
// TODO: A bug? the waypoint 463 is created but is unused
break;
}
#endif // BLADERUNNER_ORIGINAL_BUGS
// fall through
case 10:
// kSetUG07
#if BLADERUNNER_ORIGINAL_BUGS
World_Waypoint_Set(463, kSetUG07, -88.78f, -12.21f, -184.08f);
World_Waypoint_Set(464, kSetUG07, 250.0f, -12.21f, -342.0f);
World_Waypoint_Set(465, kSetUG07, -164.78f, -12.21f, -832.08f);
AI_Movement_Track_Append(kActorFreeSlotA, 465, 5);
AI_Movement_Track_Append(kActorFreeSlotA, 464, 1);
// TODO: A bug? the waypoint 463 is created but is unused
break;
#else
// Don't put rats in UG07 after the UG18 Guzza scene
// since Clovis may be there too and that does not work well
if (!Game_Flag_Query(kFlagUG18GuzzaScene)) {
World_Waypoint_Set(463, kSetUG07, -88.78f, -12.21f, -184.08f);
World_Waypoint_Set(464, kSetUG07, 250.0f, -12.21f, -342.0f);
World_Waypoint_Set(465, kSetUG07, -164.78f, -12.21f, -832.08f);
AI_Movement_Track_Append(kActorFreeSlotA, 465, 5);
AI_Movement_Track_Append(kActorFreeSlotA, 464, 1);
// TODO: A bug? the waypoint 463 is created but is unused
break;
}
#endif // BLADERUNNER_ORIGINAL_BUGS
// fall through
case 11:
// kSetUG09
World_Waypoint_Set(463, kSetUG09, 91.0f, 156.94f, -498.0f);
World_Waypoint_Set(464, kSetUG09, -149.0f, 156.94f, -498.0f);
AI_Movement_Track_Append(kActorFreeSlotA, 463, 5);
AI_Movement_Track_Append(kActorFreeSlotA, 464, 1);
break;
case 12:
// kSetUG09
World_Waypoint_Set(463, kSetUG09, 91.0f, 156.94f, -498.0f);
World_Waypoint_Set(464, kSetUG09, -149.0f, 156.94f, -498.0f);
AI_Movement_Track_Append(kActorFreeSlotA, 464, 5);
AI_Movement_Track_Append(kActorFreeSlotA, 463, 1);
break;
case 13:
// kSetUG09
#if BLADERUNNER_ORIGINAL_BUGS
// this makes the rat appear on the pipe (top left) but this is buggy
// since it appears floating there
World_Waypoint_Set(463, kSetUG09, -152.51f, 277.31f, 311.98f);
World_Waypoint_Set(464, kSetUG09, -124.51f, 275.08f, 319.98f);
AI_Movement_Track_Append(kActorFreeSlotA, 463, 1);
AI_Movement_Track_Append(kActorFreeSlotA, 464, 8);
AI_Movement_Track_Append(kActorFreeSlotA, 463, 1);
#else
// replacing with something more normal
World_Waypoint_Set(463, kSetUG09, 91.0f, 156.94f, -498.0f);
World_Waypoint_Set(464, kSetUG09, -29.60f, 156.94f, -498.0f);
AI_Movement_Track_Append(kActorFreeSlotA, 463, 1);
AI_Movement_Track_Append(kActorFreeSlotA, 464, 1);
AI_Movement_Track_Append(kActorFreeSlotA, 463, 1);
#endif
break;
case 14:
// kSetUG12
World_Waypoint_Set(463, kSetUG12, -360.67f, 21.39f, 517.55f);
World_Waypoint_Set(464, kSetUG12, -250.67f, 21.39f, 477.55f);
World_Waypoint_Set(465, kSetUG12, -248.67f, 21.39f, -1454.45f);
AI_Movement_Track_Append(kActorFreeSlotA, 463, 1);
AI_Movement_Track_Append(kActorFreeSlotA, 464, 8);
AI_Movement_Track_Append(kActorFreeSlotA, 465, 1);
break;
default:
// kSetFreeSlotG
AI_Movement_Track_Append(kActorFreeSlotA, 39, Random_Query(1, 10));
break;
}
}
} // End of namespace BladeRunner
|