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 #include "bladerunner/script/ai_script.h"
24
25 namespace BladeRunner {
26
AIScriptMcCoy(BladeRunnerEngine * vm)27 AIScriptMcCoy::AIScriptMcCoy(BladeRunnerEngine *vm) : AIScriptBase(vm) {
28 _animationLoopCounter = 0;
29 _animationLoopLength = 0;
30 _animationLoopDirection = 0;
31 _animationLoopFrameMin = 0;
32 _animationLoopFrameMax = 0;
33 _animationStateNextSpecial = 0;
34 _animationNextSpecial = 0;
35 _nextSoundId = -1;
36 _NR10SteeleShooting = false;
37 _fallSpeed = 0.0f;
38 _fallHeightCurrent = 0.0f;
39 _fallHeightTarget = 0.0f;
40 }
41
Initialize()42 void AIScriptMcCoy::Initialize() {
43 _animationState = 0;
44 _animationFrame = 0;
45 _animationLoopCounter = 0;
46 _animationLoopLength = 30;
47 _animationLoopDirection = 1;
48 _animationLoopFrameMin = 0;
49 _animationLoopFrameMax = 3;
50 _animationStateNextSpecial = 3;
51 _animationNextSpecial = kModelAnimationMcCoyProtestingTalk;
52 _nextSoundId = -1;
53 _NR10SteeleShooting = false;
54 _fallSpeed = 0;
55 Actor_Set_Goal_Number(kActorMcCoy, kGoalMcCoyDefault);
56 }
57
Update()58 bool AIScriptMcCoy::Update() {
59 if (_nextSoundId != -1) {
60 Sound_Play(_nextSoundId, 100, 0, 0, 50);
61 _nextSoundId = -1;
62 }
63
64 switch (Actor_Query_Goal_Number(kActorMcCoy)) {
65 case kGoalMcCoyBB11PrepareToRunAway:
66 Actor_Set_Goal_Number(kActorMcCoy, kGoalMcCoyBB11RunAway);
67 return true;
68
69 case kGoalMcCoyBB11RunAway:
70 if ( Actor_Query_Inch_Distance_From_Waypoint(kActorMcCoy, 316) < 36
71 && !Game_Flag_Query(kFlagBB11SadikPunchedMcCoy)
72 ) {
73 Actor_Change_Animation_Mode(kActorMcCoy, kAnimationModeHit);
74 Game_Flag_Set(kFlagBB11SadikPunchedMcCoy);
75 }
76
77 if (Actor_Query_Inch_Distance_From_Waypoint(kActorMcCoy, 316) < 4) {
78 Actor_Set_Goal_Number(kActorMcCoy, kGoalMcCoyBB11GetCaught);
79 }
80 return true;
81
82 case kGoalMcCoyNRxxStandUp:
83 Actor_Set_Goal_Number(kActorMcCoy, kGoalMcCoyDefault);
84 if (Player_Query_Current_Set() == kSetNR03) {
85 Loop_Actor_Walk_To_XYZ(kActorMcCoy, -166.0f, -70.19f, -501.0f, 0, false, false, false);
86 Actor_Face_Heading(kActorMcCoy, 300, false);
87 } else {
88 Loop_Actor_Walk_To_XYZ(kActorMcCoy, -461.0f, 0.0f, -373.0f, 0, false, false, false);
89 }
90 Player_Gains_Control();
91 return true;
92
93 case kGoalMcCoyNR01LayDrugged:
94 if (Global_Variable_Query(kVariableNR01GetUpCounter) >= 13) {
95 Global_Variable_Set(kVariableNR01GetUpCounter, 500);
96 }
97 #if BLADERUNNER_ORIGINAL_BUGS
98 if (Global_Variable_Query(kVariableNR01GetUpCounter) > 0) {
99 Global_Variable_Decrement(kVariableNR01GetUpCounter, 1);
100 }
101 #else
102 // Make it easier for McCoy to get up
103 // and possible at all for (our) high fps setting
104 if (Global_Variable_Query(kVariableNR01GetUpCounter) > 0) {
105 uint maxRandBound = 1;
106 if (Global_Variable_Query(kVariableNR01GetUpCounter) < 13) {
107 if (_vm->_framesPerSecondMax) {
108 maxRandBound = 4;
109 } else {
110 maxRandBound = 2;
111 }
112 }
113
114 if ((Random_Query(1, maxRandBound)) == 1) {
115 Global_Variable_Decrement(kVariableNR01GetUpCounter, 1);
116 }
117 }
118 #endif
119 break;
120
121 case kGoalMcCoyNR04PassOut:
122 Actor_Set_Goal_Number(kActorMcCoy, kGoalMcCoyDefault);
123 Actor_Set_Goal_Number(kActorEarlyQ, kGoalEarlyQNR04TakeDisk);
124 return true;
125
126 case kGoalMcCoyNR10Fall:
127 fallDown();
128 break;
129
130 case kGoalMcCoyUG15Fall:
131 fallDown();
132 break;
133
134 case kGoalMcCoyUG15Die:
135 Actor_Retired_Here(kActorMcCoy, 12, 48, true, -1);
136 Actor_Set_Goal_Number(kActorMcCoy, kGoalMcCoyGone);
137 break;
138 }
139 return false;
140 }
141
TimerExpired(int timer)142 void AIScriptMcCoy::TimerExpired(int timer) {
143 }
144
CompletedMovementTrack()145 void AIScriptMcCoy::CompletedMovementTrack() {
146 }
147
ReceivedClue(int clueId,int fromActorId)148 void AIScriptMcCoy::ReceivedClue(int clueId, int fromActorId) {
149 switch (clueId) {
150 case kClueDispatchHitAndRun: // added case for cut content
151 // fall through
152 case kClueChopstickWrapper:
153 // fall through
154 case kClueSushiMenu:
155 Spinner_Set_Selectable_Destination_Flag(kSpinnerDestinationChinatown, true);
156 break;
157
158 case kClueDragonflyEarring:
159 // fall through
160 case kClueBombingSuspect:
161 Spinner_Set_Selectable_Destination_Flag(kSpinnerDestinationAnimoidRow, true);
162 break;
163
164 case kClueKingstonKitchenBox1:
165 // fall through
166 case kClueKingstonKitchenBox2:
167 if (Query_Difficulty_Level() == kGameDifficultyEasy) {
168 Spinner_Set_Selectable_Destination_Flag(kSpinnerDestinationAnimoidRow, true);
169 }
170 break;
171
172 case kClueDragonflyCollection:
173 Spinner_Set_Selectable_Destination_Flag(kSpinnerDestinationNightclubRow, true);
174 break;
175
176 case kClueHysteriaToken:
177 // fall through
178 case kClueCarRegistration1:
179 // fall through
180 case kClueCarRegistration2:
181 // fall through
182 case kClueCarRegistration3:
183 // fall through
184 case kClueLichenDogWrapper:
185 Spinner_Set_Selectable_Destination_Flag(kSpinnerDestinationHysteriaHall, true);
186 Spinner_Set_Selectable_Destination_Flag(kSpinnerDestinationNightclubRow, true);
187 break;
188
189 case kClueWeaponsCache:
190 // fall through
191 case kClueWeaponsOrderForm:
192 // fall through
193 case kClueShippingForm:
194 // fall through
195 case kCluePoliceIssueWeapons:
196 Global_Variable_Increment(kVariableCorruptedGuzzaEvidence, 1);
197 break;
198
199 case kClueFolder:
200 Global_Variable_Increment(kVariableCorruptedGuzzaEvidence, 5);
201 break;
202
203 case kClueHomelessManKid:
204 // fall through
205 case kClueOriginalRequisitionForm:
206 Global_Variable_Increment(kVariableCorruptedGuzzaEvidence, 3);
207 break;
208
209 case kClueScaryChair:
210 // fall through
211 case kClueIzosStashRaided:
212 Global_Variable_Increment(kVariableCorruptedGuzzaEvidence, 2);
213 break;
214
215 case kClueDNATyrell:
216 // fall through
217 case kClueDNASebastian:
218 // fall through
219 case kClueDNAChew:
220 // fall through
221 case kClueDNAMoraji:
222 // fall through
223 case kClueDNALutherLance:
224 // fall through
225 case kClueDNAMarcus:
226 Global_Variable_Increment(kVariableDNAEvidence, 1);
227 break;
228 }
229
230 if ( Global_Variable_Query(kVariableCorruptedGuzzaEvidence) > 6
231 && Global_Variable_Query(kVariableChapter) > 3
232 && !Actor_Clue_Query(kActorMcCoy, kClueGuzzaFramedMcCoy)
233 ) {
234 Delay(500);
235 Actor_Voice_Over(3320, kActorVoiceOver);
236 switch (clueId) {
237 case kClueWeaponsCache:
238 // fall through
239 case kClueWeaponsOrderForm:
240 // fall through
241 case kClueGuzzasCash:
242 // fall through
243 case kCluePoliceIssueWeapons:
244 // fall through
245 case kClueIzosStashRaided:
246 // fall through
247 case kClueOriginalRequisitionForm:
248 Actor_Voice_Over(3340, kActorVoiceOver);
249 Actor_Voice_Over(3350, kActorVoiceOver);
250 Actor_Voice_Over(3360, kActorVoiceOver);
251 Actor_Voice_Over(3370, kActorVoiceOver);
252 Actor_Voice_Over(3380, kActorVoiceOver);
253 break;
254
255 case kClueHomelessManKid:
256 Actor_Voice_Over(3330, kActorVoiceOver);
257 break;
258
259 case kClueScaryChair:
260 Actor_Voice_Over(3390, kActorVoiceOver);
261 Actor_Voice_Over(3400, kActorVoiceOver);
262 Actor_Voice_Over(3420, kActorVoiceOver);
263 break;
264 }
265
266 Actor_Clue_Acquire(kActorMcCoy, kClueGuzzaFramedMcCoy, true, -1);
267
268 if (clueId == kClueFolder) {
269 // if McCoy just got the folder
270 Actor_Voice_Over(2780, kActorVoiceOver);
271 Actor_Voice_Over(2800, kActorVoiceOver);
272 Actor_Voice_Over(2810, kActorVoiceOver);
273 } else if (Actor_Clue_Query(kActorMcCoy, kClueFolder)) {
274 // if McCoy already had the folder
275 Actor_Voice_Over(3430, kActorVoiceOver);
276 Actor_Voice_Over(3440, kActorVoiceOver);
277 Actor_Voice_Over(3450, kActorVoiceOver);
278 Actor_Voice_Over(3460, kActorVoiceOver);
279 Actor_Voice_Over(3470, kActorVoiceOver);
280 Actor_Voice_Over(3480, kActorVoiceOver);
281 Actor_Voice_Over(3490, kActorVoiceOver);
282 Actor_Voice_Over(3500, kActorVoiceOver);
283 } else {
284 // if McCoy never got the folder
285 Actor_Voice_Over(3510, kActorVoiceOver);
286 Actor_Voice_Over(3520, kActorVoiceOver);
287 Actor_Voice_Over(3530, kActorVoiceOver);
288 Actor_Voice_Over(3540, kActorVoiceOver);
289 }
290 }
291 }
292
ClickedByPlayer()293 void AIScriptMcCoy::ClickedByPlayer() {
294 }
295
EnteredSet(int setId)296 void AIScriptMcCoy::EnteredSet(int setId) {
297 }
298
OtherAgentEnteredThisSet(int otherActorId)299 void AIScriptMcCoy::OtherAgentEnteredThisSet(int otherActorId) {
300 }
301
OtherAgentExitedThisSet(int otherActorId)302 void AIScriptMcCoy::OtherAgentExitedThisSet(int otherActorId) {
303 }
304
OtherAgentEnteredCombatMode(int otherActorId,int combatMode)305 void AIScriptMcCoy::OtherAgentEnteredCombatMode(int otherActorId, int combatMode) {
306 }
307
ShotAtAndMissed()308 void AIScriptMcCoy::ShotAtAndMissed() {
309 }
310
ShotAtAndHit()311 bool AIScriptMcCoy::ShotAtAndHit() {
312 return false;
313 }
314
Retired(int byActorId)315 void AIScriptMcCoy::Retired(int byActorId) {
316 if (byActorId == kActorSteele && Actor_Query_In_Set(kActorSteele, kSetHF06)) {
317 if (Actor_Query_In_Set(kActorDektora, kSetHF06)
318 && Actor_Query_Goal_Number(kActorDektora) != kGoalDektoraGone) {
319 Non_Player_Actor_Combat_Mode_On(kActorSteele, kActorCombatStateUncover, true, kActorDektora, 15, kAnimationModeCombatIdle, kAnimationModeCombatWalk, kAnimationModeCombatRun, 0, 0, 100, 25, 300, false);
320 } else if (Actor_Query_In_Set(kActorLucy, kSetHF06)
321 && Actor_Query_Goal_Number(kActorLucy) != kGoalLucyGone
322 ) {
323 Non_Player_Actor_Combat_Mode_On(kActorSteele, kActorCombatStateUncover, true, kActorLucy, 15, kAnimationModeCombatIdle, kAnimationModeCombatWalk, kAnimationModeCombatRun, 0, 0, 100, 25, 300, false);
324 }
325 }
326
327 if (Actor_Query_In_Set(kActorMcCoy, kSetHF05)
328 && Actor_Query_In_Set(kActorOfficerLeary, kSetHF05)
329 && Actor_Query_In_Set(kActorDektora, kSetHF05)
330 && Actor_Query_Goal_Number(kActorDektora) != kGoalDektoraGone
331 ) {
332 Non_Player_Actor_Combat_Mode_On(kActorOfficerLeary, kActorCombatStateUncover, true, kActorDektora, 4, kAnimationModeCombatIdle, kAnimationModeCombatWalk, kAnimationModeCombatRun, 0, 0, 100, 25, 300, false);
333 }
334
335 if (Actor_Query_In_Set(kActorMcCoy, kSetHF05)
336 && Actor_Query_In_Set(kActorOfficerGrayford, kSetHF05)
337 && Actor_Query_In_Set(kActorDektora, kSetHF05)
338 && Actor_Query_Goal_Number(kActorDektora) != kGoalDektoraGone
339 ) {
340 Non_Player_Actor_Combat_Mode_On(kActorOfficerGrayford, kActorCombatStateUncover, true, kActorDektora, 4, kAnimationModeCombatIdle, kAnimationModeCombatWalk, kAnimationModeCombatRun, 0, 0, 100, 25, 300, false);
341 }
342
343 if (Actor_Query_In_Set(kActorMcCoy, kSetHF05)
344 && Actor_Query_In_Set(kActorOfficerLeary, kSetHF05)
345 && Actor_Query_In_Set(kActorLucy, kSetHF05)
346 && Actor_Query_Goal_Number(kActorLucy) != kGoalLucyGone
347 ) {
348 Non_Player_Actor_Combat_Mode_On(kActorOfficerLeary, kActorCombatStateUncover, true, kActorLucy, 4, kAnimationModeCombatIdle, kAnimationModeCombatWalk, kAnimationModeCombatRun, 0, 0, 100, 25, 300, false);
349 }
350
351 if (Actor_Query_In_Set(kActorMcCoy, kSetHF05)
352 && Actor_Query_In_Set(kActorOfficerGrayford, kSetHF05)
353 && Actor_Query_In_Set(kActorLucy, kSetHF05)
354 && Actor_Query_Goal_Number(kActorLucy) != kGoalLucyGone
355 ) {
356 Non_Player_Actor_Combat_Mode_On(kActorOfficerGrayford, kActorCombatStateUncover, true, kActorLucy, 4, kAnimationModeCombatIdle, kAnimationModeCombatWalk, kAnimationModeCombatRun, 0, 0, 100, 25, 300, false);
357 }
358 }
359
GetFriendlinessModifierIfGetsClue(int otherActorId,int clueId)360 int AIScriptMcCoy::GetFriendlinessModifierIfGetsClue(int otherActorId, int clueId) {
361 return 0;
362 }
363
GoalChanged(int currentGoalNumber,int newGoalNumber)364 bool AIScriptMcCoy::GoalChanged(int currentGoalNumber, int newGoalNumber) {
365 unsigned int affectionTowards;
366 switch (newGoalNumber) {
367 case kGoalMcCoyDefault:
368 return true;
369
370 case kGoalMcCoyDodge:
371 dodge();
372 return true;
373
374 case 2:
375 _animationFrame = 0;
376 _animationState = 47;
377 return true;
378
379 case kGoalMcCoyBB11GetUp:
380 Actor_Set_At_Waypoint(kActorMcCoy, 315, 263);
381 _animationState = 53;
382 _animationFrame = Slice_Animation_Query_Number_Of_Frames(kModelAnimationMcCoyFallsOnHisBack) - 1;
383 Actor_Set_Invisible(kActorMcCoy, false);
384 return true;
385
386 case kGoalMcCoyBB11RunAway:
387 Async_Actor_Walk_To_Waypoint(kActorMcCoy, 316, 0, true);
388 return true;
389
390 case kGoalMcCoyBB11GetCaught:
391 Actor_Face_Actor(kActorMcCoy, kActorSadik, true);
392 return true;
393
394 case kGoalMcCoyNRxxSitAtTable:
395 Player_Loses_Control();
396 Actor_Change_Animation_Mode(kActorMcCoy, kAnimationModeIdle);
397 return true;
398
399 case kGoalMcCoyNR01ThrownOut:
400 Actor_Put_In_Set(kActorMcCoy, kSetNR01);
401 Actor_Set_At_XYZ(kActorMcCoy, -204.0f, 24.0f, -817.0f, 256);
402 Actor_Set_Invisible(kActorMcCoy, false);
403 if (Game_Flag_Query(kFlagNR01McCoyIsDrugged)) {
404 Actor_Set_Goal_Number(kActorMcCoy, kGoalMcCoyNR01LayDrugged);
405 } else {
406 _animationState = 53;
407 _animationFrame = Slice_Animation_Query_Number_Of_Frames(kModelAnimationMcCoyFallsOnHisBack) - 1;
408 // redundant?
409 Actor_Set_Invisible(kActorMcCoy, false);
410 }
411 return true;
412
413 case kGoalMcCoyNR01GetUp:
414 Actor_Face_Heading(kActorMcCoy, 512, false);
415 Actor_Face_Heading(kActorMcCoy, 768, true);
416 if (Random_Query(0, 1)) {
417 Actor_Change_Animation_Mode(kActorMcCoy, 18);
418 } else {
419 Actor_Change_Animation_Mode(kActorMcCoy, 16);
420 }
421 Delay(150);
422 Actor_Change_Animation_Mode(kActorMcCoy, kAnimationModeIdle);
423 Actor_Set_Goal_Number(kActorMcCoy, kGoalMcCoyDefault);
424 Player_Gains_Control();
425 return true;
426
427 case kGoalMcCoyNR01LayDrugged:
428 Global_Variable_Set(kVariableNR01GetUpCounter, 0);
429 Player_Set_Combat_Mode_Access(false);
430 Player_Gains_Control();
431 Scene_Exits_Disable();
432 _animationState = 68;
433 _animationFrame = Slice_Animation_Query_Number_Of_Frames(kModelAnimationMcCoyFallsOnHisBack) - 1;
434 return true;
435
436 case kGoalMcCoyNR04Drink:
437 Actor_Change_Animation_Mode(kActorMcCoy, 75);
438 return true;
439
440 case kGoalMcCoyNR11Shoot:
441 _NR10SteeleShooting = Actor_Query_Goal_Number(kActorSteele) == kGoalSteeleNR11Shoot;
442 Actor_Change_Animation_Mode(kActorMcCoy, kAnimationModeCombatAttack);
443 return true;
444
445 case kGoalMcCoyNR10Fall:
446 Player_Set_Combat_Mode(false);
447 Preload(kModelAnimationMcCoyFallsOnHisBack);
448 Set_Enter(kSetNR10, kSceneNR10);
449 Player_Loses_Control();
450 Actor_Force_Stop_Walking(kActorMcCoy);
451 Actor_Put_In_Set(kActorMcCoy, kSetNR10);
452 Actor_Set_At_XYZ(kActorMcCoy, 14.0f, 110.84f, -300.0f, 926);
453 Actor_Change_Animation_Mode(kActorMcCoy, kAnimationModeDie);
454 _animationState = 27;
455 _animationFrame = 0;
456 _fallHeightTarget = 2.84f;
457 _fallHeightCurrent = 110.84f;
458 _fallSpeed = -6.0f;
459 return true;
460
461 case kGoalMcCoyUG07Caught:
462 _animationState = 62;
463 _animationFrame = 0;
464 return true;
465
466 case kGoalMcCoyUG07BrokenFinger:
467 _animationState = 64;
468 _animationFrame = 0;
469 return true;
470
471 case kGoalMcCoyUG07Released:
472 _animationState = 65;
473 _animationFrame = 0;
474 return true;
475
476 case kGoalMcCoyCallWithGuzza:
477 Sound_Play(kSfxSPNBEEP9, 50, 0, 0, 50);
478 Delay(1000);
479 Sound_Play(kSfxVIDFONE1, 30, 0, 0, 50);
480 Delay(1000);
481 Sound_Play(kSfxSPNBEEP9, 50, 0, 0, 50);
482 Actor_Says(kActorGuzza, 1380, kAnimationModeTalk);
483 Actor_Says(kActorMcCoy, 6610, 13);
484 Actor_Says(kActorGuzza, 1390, kAnimationModeTalk);
485 Actor_Says(kActorMcCoy, 6615, 18);
486 if (_vm->_cutContent) {
487 Actor_Says(kActorGuzza, 1400, kAnimationModeTalk);
488 Actor_Says(kActorGuzza, 1410, kAnimationModeTalk);
489 Actor_Says(kActorMcCoy, 6620, 15);
490 }
491 Actor_Says(kActorGuzza, 1420, kAnimationModeTalk);
492 Actor_Says(kActorMcCoy, 6625, 11);
493 Actor_Says(kActorGuzza, 1430, kAnimationModeTalk);
494 Actor_Says(kActorMcCoy, 6630, 12);
495 Actor_Says(kActorMcCoy, 6635, 17);
496 Actor_Says(kActorMcCoy, 6640, 13);
497 Actor_Says(kActorMcCoy, 6645, 19);
498 Actor_Says(kActorMcCoy, 6650, 18);
499 Actor_Says(kActorMcCoy, 6655, 11);
500 Actor_Says(kActorGuzza, 1440, kAnimationModeTalk);
501 Actor_Says(kActorMcCoy, 6660, 17);
502 Actor_Says(kActorMcCoy, 6665, 13);
503 Delay(1000);
504 Actor_Says(kActorGuzza, 1450, kAnimationModeTalk);
505 Actor_Says(kActorMcCoy, 6670, 14);
506 Actor_Says(kActorMcCoy, 6675, 11);
507 Actor_Says(kActorGuzza, 1460, kAnimationModeTalk);
508 Actor_Says(kActorMcCoy, 6680, 12);
509 Actor_Says(kActorGuzza, 1470, kAnimationModeTalk);
510 Actor_Says(kActorMcCoy, 6685, 13);
511 Delay(500);
512 Actor_Says(kActorMcCoy, 6695, 16);
513 #if BLADERUNNER_ORIGINAL_BUGS
514 Actor_Says(kActorMcCoy, 6700, 17);
515 #else
516 // McCoy is interrupted here
517 Actor_Says_With_Pause(kActorMcCoy, 6700, 0.0f, 17);
518 #endif // BLADERUNNER_ORIGINAL_BUGS
519 Actor_Says(kActorGuzza, 1480, kAnimationModeTalk);
520 Actor_Says(kActorMcCoy, 6705, 11);
521 Sound_Play(kSfxSPNBEEP9, 50, 0, 0, 50);
522 return true;
523
524 case kGoalMcCoyUG15Fall:
525 Actor_Force_Stop_Walking(kActorMcCoy);
526 Player_Loses_Control();
527 _fallHeightCurrent = 48.07f;
528 _fallSpeed = -4.0f;
529 _fallHeightTarget = -20.0f;
530 if (_animationState != 27
531 && _animationState != 50
532 ) {
533 _animationState = 50;
534 _animationFrame = Slice_Animation_Query_Number_Of_Frames(kModelAnimationMcCoyFallsOnHisBack) - 1;
535 }
536 return true;
537
538 case 400:
539 Actor_Set_Health(kActorMcCoy, 50, 50);
540 Game_Flag_Set(kFlagKP02Available);
541 affectionTowards = Global_Variable_Query(kVariableAffectionTowards);
542 if (affectionTowards == kAffectionTowardsSteele) {
543 Actor_Modify_Friendliness_To_Other(kActorSteele, kActorMcCoy, 3);
544 } else if (affectionTowards == kAffectionTowardsDektora) {
545 Actor_Modify_Friendliness_To_Other(kActorSteele, kActorMcCoy, -5);
546 Actor_Modify_Friendliness_To_Other(kActorClovis, kActorMcCoy, 3);
547 } else if (affectionTowards == kAffectionTowardsLucy) {
548 Actor_Modify_Friendliness_To_Other(kActorSteele, kActorMcCoy, -5);
549 Actor_Modify_Friendliness_To_Other(kActorClovis, kActorMcCoy, 5);
550 }
551
552 if (Game_Flag_Query(kFlagMcCoyFreedOfAccusations)) {
553 Actor_Modify_Friendliness_To_Other(kActorSteele, kActorMcCoy, 3);
554 }
555
556 if (Actor_Query_Friendliness_To_Other(kActorSteele, kActorMcCoy) < Actor_Query_Friendliness_To_Other(kActorClovis, kActorMcCoy)) {
557 Game_Flag_Set(kFlagMcCoyIsHelpingReplicants);
558 }
559
560 affectionTowards = Global_Variable_Query(kVariableAffectionTowards);
561 if (affectionTowards == kAffectionTowardsSteele) {
562 if (Game_Flag_Query(kFlagMcCoyIsHelpingReplicants)) {
563 Global_Variable_Set(kVariableAffectionTowards, kAffectionTowardsNone);
564 }
565 } else if (affectionTowards == kAffectionTowardsDektora
566 || affectionTowards == kAffectionTowardsLucy
567 ) {
568 if (!Game_Flag_Query(kFlagMcCoyIsHelpingReplicants)) {
569 Global_Variable_Set(kVariableAffectionTowards, kAffectionTowardsNone);
570 }
571 }
572
573 if (!Game_Flag_Query(kFlagMcCoyIsHelpingReplicants)) {
574 Game_Flag_Set(kFlagMaggieHasBomb);
575 }
576
577 Ambient_Sounds_Remove_All_Non_Looping_Sounds(true);
578 Ambient_Sounds_Remove_All_Looping_Sounds(1u);
579 Global_Variable_Set(kVariableChapter, 5);
580 Outtake_Play(kOuttakeMovieD, false, -1);
581
582 if (Game_Flag_Query(kFlagMcCoyFreedOfAccusations)) {
583 Chapter_Enter(5, kSetMA07, kSceneMA07);
584 } else {
585 Game_Flag_Set(kFlagMA06ToMA02);
586 Chapter_Enter(5, kSetMA02_MA04, kSceneMA02);
587 }
588 return true;
589
590 case kGoalMcCoyArrested:
591 Music_Stop(3u);
592 Player_Set_Combat_Mode(false);
593 Actor_Change_Animation_Mode(kActorMcCoy, kAnimationModeIdle);
594 _animationState = 0;
595 _animationFrame = 0;
596 Game_Flag_Set(kFlagMcCoyArrested);
597 Set_Enter(kSetPS09, kScenePS09);
598 return true;
599 }
600 return false;
601 }
602
UpdateAnimation(int * animation,int * frame)603 bool AIScriptMcCoy::UpdateAnimation(int *animation, int *frame) {
604 int v7;
605 switch (_animationState) {
606 case 0:
607 *animation = kModelAnimationMcCoyIdle;
608 if (_animationLoopCounter < _animationLoopLength) {
609 _animationFrame += _animationLoopDirection;
610 if (_animationFrame > _animationLoopFrameMax) {
611 _animationFrame = _animationLoopFrameMax;
612 _animationLoopDirection = -1;
613 } else if (_animationFrame < _animationLoopFrameMin) {
614 _animationFrame = _animationLoopFrameMin;
615 _animationLoopDirection = 1;
616 }
617 ++_animationLoopCounter;
618 } else {
619 _animationFrame += _animationLoopDirection;
620 _animationLoopLength = 0;
621 if (_animationFrame == 18 && Random_Query(0, 2)) {
622 _animationLoopDirection = -1;
623 _animationLoopCounter = 0;
624 _animationLoopFrameMin = 14;
625 _animationLoopFrameMax = 18;
626 _animationLoopLength = Random_Query(0, 30);
627 }
628 if (_animationFrame == 26) {
629 if (Random_Query(0, 2)) {
630 _animationLoopDirection = -1;
631 _animationLoopCounter = 0;
632 _animationLoopFrameMin = 23;
633 _animationLoopFrameMax = 26;
634 _animationLoopLength = Random_Query(0, 30);
635 }
636 }
637 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
638 _animationFrame = 0;
639 if (Random_Query(0, 2)) {
640 _animationLoopCounter = 0;
641 _animationLoopFrameMin = 0;
642 _animationLoopFrameMax = 3;
643 _animationLoopLength = Random_Query(0, 45);
644 }
645 }
646 if (_animationFrame < 0) {
647 _animationFrame = Slice_Animation_Query_Number_Of_Frames(*animation) - 1;
648 }
649 }
650 break;
651
652 case 3:
653 // fall through
654 case 4:
655 if (_animationFrame == 0 && !Game_Flag_Query(kFlagMcCoyAnimation1)) {
656 _animationFrame = 1;
657 _animationState = _animationStateNextSpecial;
658 *animation = _animationNextSpecial;
659 _animationStateNextSpecial = 4;
660 _animationNextSpecial = kModelAnimationMcCoyProtestingTalk;
661 } else if (_animationFrame <= 4 && Game_Flag_Query(kFlagMcCoyAnimation1)) {
662 Game_Flag_Reset(kFlagMcCoyAnimation1);
663 *animation = kModelAnimationMcCoyIdle;
664 _animationFrame = 0;
665 _animationState = 0;
666 } else {
667 *animation = kModelAnimationMcCoyProtestingTalk;
668 ++_animationFrame;
669 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
670 _animationFrame = 0;
671 }
672 }
673 break;
674
675 case 5:
676 *animation = kModelAnimationMcCoyScratchHeadTalk;
677 ++_animationFrame;
678 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
679 _animationFrame = 0;
680 _animationState = 3;
681 *animation = kModelAnimationMcCoyProtestingTalk;
682 }
683 break;
684
685 case 6:
686 *animation = kModelAnimationMcCoyScratchEarLongerTalk;
687 ++_animationFrame;
688 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
689 _animationFrame = 0;
690 _animationState = 3;
691 *animation = kModelAnimationMcCoyProtestingTalk;
692 }
693 break;
694
695 case 7:
696 *animation = kModelAnimationMcCoyPointingTalk;
697 ++_animationFrame;
698 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
699 _animationFrame = 0;
700 _animationState = 3;
701 *animation = kModelAnimationMcCoyProtestingTalk;
702 }
703 break;
704
705 case 8:
706 *animation = kModelAnimationMcCoyUpsetTalk;
707 ++_animationFrame;
708 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
709 _animationFrame = 0;
710 _animationState = 3;
711 *animation = kModelAnimationMcCoyProtestingTalk;
712 }
713 break;
714
715 case 9:
716 *animation = kModelAnimationMcCoyDismissiveTalk;
717 ++_animationFrame;
718 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
719 _animationFrame = 0;
720 _animationState = 3;
721 *animation = kModelAnimationMcCoyProtestingTalk;
722 }
723 break;
724
725 case 10:
726 *animation = kModelAnimationMcCoyScratchEarTalk;
727 ++_animationFrame;
728 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
729 _animationFrame = 0;
730 _animationState = 3;
731 *animation = kModelAnimationMcCoyProtestingTalk;
732 }
733 break;
734
735 case 11:
736 *animation = kModelAnimationMcCoyHandsOnWaistTalk;
737 ++_animationFrame;
738 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
739 _animationFrame = 0;
740 _animationState = 3;
741 *animation = kModelAnimationMcCoyProtestingTalk;
742 }
743 break;
744
745 case 12:
746 *animation = kModelAnimationMcCoyScratchEarLongerTalk;
747 ++_animationFrame;
748 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
749 _animationFrame = 0;
750 _animationState = 3;
751 *animation = kModelAnimationMcCoyProtestingTalk;
752 }
753 break;
754
755 case 13:
756 *animation = kModelAnimationMcCoyIdle;
757 if (_animationFrame < Slice_Animation_Query_Number_Of_Frames(*animation) / 2) {
758 _animationFrame -= 3;
759 if (_animationFrame <= 0) {
760 _animationFrame = 0;
761 *animation = _animationNext;
762 _animationState = _animationStateNext;
763 }
764 } else {
765 _animationFrame += 3;
766 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
767 _animationFrame = 0;
768 *animation = _animationNext;
769 _animationState = _animationStateNext;
770 }
771 }
772 break;
773
774 case 14:
775 *animation = kModelAnimationMcCoyWithGunIdle;
776 ++_animationFrame;
777 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
778 _animationState = 14;
779 _animationFrame = 0;
780 }
781 break;
782
783 case 15:
784 *animation = kModelAnimationMcCoyWithGunUnholsterGun;
785 ++_animationFrame;
786 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
787 _animationFrame = 0;
788 _animationState = 14;
789 *animation = kModelAnimationMcCoyWithGunIdle;
790 }
791 break;
792
793 case 16:
794 *animation = kModelAnimationMcCoyWithGunHolsterGun;
795 ++_animationFrame;
796 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
797 *animation = kModelAnimationMcCoyIdle;
798 _animationFrame = 0;
799 _animationState = 0;
800 }
801 break;
802
803 case 17:
804 // this is just frame 0 always, McCoy doesn't animated shoot in this animation State
805 // animation state 21 is for the full shooting animation
806 *animation = kModelAnimationMcCoyWithGunShooting;
807 _animationFrame = 0;
808 // weird, but thats in game code
809 if (Slice_Animation_Query_Number_Of_Frames(*animation) <= 0) {
810 _animationFrame = 0;
811 _animationState = 17;
812 }
813 break;
814
815 case 18:
816 *animation = kModelAnimationMcCoyWithGunAiming;
817 ++_animationFrame;
818 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
819 _animationFrame = 0;
820 _animationState = 17;
821 *animation = kModelAnimationMcCoyWithGunShooting;
822 }
823 break;
824
825 case 19:
826 *animation = kModelAnimationMcCoyWithGunStopAimResumeIdle;
827 ++_animationFrame;
828 if (_animationFrame >= 12) {
829 _animationFrame = 0;
830 _animationState = 14;
831 *animation = kModelAnimationMcCoyWithGunIdle;
832 }
833 break;
834
835 case 21:
836 *animation = kModelAnimationMcCoyWithGunShooting;
837 ++_animationFrame;
838 if (_animationFrame == 1
839 && Actor_Query_Goal_Number(kActorMcCoy) == kGoalMcCoyNR11Shoot
840 && _NR10SteeleShooting
841 ) {
842 _nextSoundId = kSfxSMCAL3;
843 }
844 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
845 _animationState = 17;
846 _animationFrame = 0;
847 *animation = kModelAnimationMcCoyWithGunShooting;
848 #if BLADERUNNER_ORIGINAL_BUGS
849 #else
850 // Resume combat idle position even when shot at a target -- if it's no longer a target (dead or moved)
851 ChangeAnimationMode(kAnimationModeCombatIdle);
852 #endif // BLADERUNNER_ORIGINAL_BUGS
853
854 if (Actor_Query_Goal_Number(kActorMcCoy) == kGoalMcCoyNR11Shoot) {
855 _animationFrame = 0;
856 _animationState = 21;
857 _NR10SteeleShooting = true;
858 *animation = kModelAnimationMcCoyWithGunShooting;
859 }
860 }
861 break;
862
863 case 22:
864 _animationFrame = 0;
865 _animationState = 17;
866 *animation = kModelAnimationMcCoyWithGunShooting;
867 break;
868
869 case 23:
870 *animation = kModelAnimationMcCoyWithGunGotHitRight;
871 ++_animationFrame;
872 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
873 _animationFrame = 0;
874 _animationState = 14;
875 *animation = kModelAnimationMcCoyWithGunIdle;
876 Actor_Change_Animation_Mode(kActorMcCoy, kAnimationModeCombatIdle);
877 }
878 break;
879
880 case 24:
881 *animation = kModelAnimationMcCoyWithGunGotHitRight;
882 ++_animationFrame;
883 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
884 _animationFrame = 0;
885 _animationState = 14;
886 *animation = kModelAnimationMcCoyWithGunIdle;
887 Actor_Change_Animation_Mode(kActorMcCoy, kAnimationModeCombatIdle);
888 }
889 break;
890
891 case 25:
892 *animation = kModelAnimationMcCoyGotHitRight;
893 ++_animationFrame;
894 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
895 *animation = kModelAnimationMcCoyIdle;
896 _animationFrame = 0;
897 _animationState = 0;
898 Actor_Change_Animation_Mode(kActorMcCoy, kAnimationModeIdle);
899 }
900 break;
901
902 case 26:
903 *animation = kModelAnimationMcCoyGotHitRight;
904 ++_animationFrame;
905 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
906 *animation = kModelAnimationMcCoyIdle;
907 _animationFrame = 0;
908 _animationState = 0;
909 Actor_Change_Animation_Mode(kActorMcCoy, kAnimationModeIdle);
910 }
911 break;
912
913 case 27:
914 *animation = kModelAnimationMcCoyFallsOnHisBack;
915 ++_animationFrame;
916 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
917 _animationFrame = Slice_Animation_Query_Number_Of_Frames(*animation) - 1;
918 _animationState = 50;
919 UG15fall();
920 if (Actor_Query_Goal_Number(kActorMcCoy) == kGoalMcCoyNR04Drink) {
921 Actor_Set_Goal_Number(kActorMcCoy, kGoalMcCoyNR04PassOut);
922 }
923 }
924 break;
925
926 case 28:
927 *animation = kModelAnimationMcCoyWithGunShotDead;
928 ++_animationFrame;
929 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
930 _animationFrame = Slice_Animation_Query_Number_Of_Frames(*animation) - 1;
931 _animationState = 50;
932 UG15fall();
933 }
934 break;
935
936 case 29:
937 *animation = kModelAnimationMcCoyFallsOnHisBack;
938 _animationFrame += _animationLoopDirection;
939 if (_animationFrame < 14) {
940 _animationLoopDirection = 1;
941 }
942 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
943 Actor_Change_Animation_Mode(kActorMcCoy, kAnimationModeDie);
944 *animation = kModelAnimationMcCoyFallsOnHisBack;
945 _animationState = 27;
946 _animationFrame = Slice_Animation_Query_Number_Of_Frames(*animation) - 1;
947 }
948 break;
949
950 case 30:
951 *animation = kModelAnimationMcCoyWalking;
952 ++_animationFrame;
953 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
954 _animationFrame = 0;
955 }
956 if (_animationFrame == 2) {
957 Sound_Right_Footstep_Walk(kActorMcCoy);
958 } else if (_animationFrame == 10) {
959 Sound_Left_Footstep_Walk(kActorMcCoy);
960 }
961 break;
962
963 case 31:
964 *animation = kModelAnimationMcCoyRunning;
965 ++_animationFrame;
966 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
967 _animationFrame = 0;
968 }
969 if (_animationFrame == 5) {
970 Sound_Left_Footstep_Run(kActorMcCoy);
971 } else if (_animationFrame == 12) {
972 Sound_Right_Footstep_Run(kActorMcCoy);
973 }
974 break;
975
976 case 32:
977 _animationFrame = 1;
978 _animationState = 30;
979 *animation = kModelAnimationMcCoyWalking;
980 break;
981
982 case 36:
983 *animation = kModelAnimationMcCoyWithGunWalking;
984 ++_animationFrame;
985 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
986 _animationFrame = 0;
987 }
988 if (_animationFrame == 15) {
989 Sound_Left_Footstep_Walk(kActorMcCoy);
990 }
991 if (_animationFrame == 6) {
992 Sound_Right_Footstep_Walk(kActorMcCoy);
993 }
994 break;
995
996 case 37:
997 *animation = kModelAnimationMcCoyWithGunRunning;
998 ++_animationFrame;
999 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
1000 _animationFrame = 0;
1001 }
1002 if (_animationFrame == 6) {
1003 Sound_Left_Footstep_Run(kActorMcCoy);
1004 }
1005 if (_animationFrame == 0) {
1006 Sound_Right_Footstep_Run(kActorMcCoy);
1007 }
1008 break;
1009
1010 case 38:
1011 *animation = kModelAnimationMcCoyClimbStairsUp;
1012 ++_animationFrame;
1013 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
1014 _animationFrame = 0;
1015 }
1016 if (_animationFrame == 9) {
1017 Sound_Left_Footstep_Walk(kActorMcCoy);
1018 } else if (_animationFrame == 4) {
1019 Sound_Right_Footstep_Walk(kActorMcCoy);
1020 }
1021 if (Game_Flag_Query(kFlagHF07toHF05)) {
1022 walkStairsLeft(0.5f);
1023 }
1024 break;
1025
1026 case 39:
1027 *animation = kModelAnimationMcCoyClimbStairsDown;
1028 ++_animationFrame;
1029 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
1030 _animationFrame = 0;
1031 }
1032 if (_animationFrame == 8) {
1033 Sound_Left_Footstep_Walk(kActorMcCoy);
1034 } else if (_animationFrame == 3) {
1035 Sound_Right_Footstep_Walk(kActorMcCoy);
1036 }
1037 if (Game_Flag_Query(kFlagHF05toHF07)) {
1038 walkStairsRight(-0.2f);
1039 }
1040 break;
1041
1042 case 40:
1043 *animation = kModelAnimationMcCoyWithGunClimbStairsUp;
1044 ++_animationFrame;
1045 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
1046 _animationFrame = 0;
1047 }
1048 if (_animationFrame == 8) {
1049 Sound_Left_Footstep_Walk(kActorMcCoy);
1050 } else if (_animationFrame == 3) {
1051 Sound_Right_Footstep_Walk(kActorMcCoy);
1052 }
1053 if (Game_Flag_Query(kFlagHF07toHF05)) {
1054 walkStairsLeft(0.5f);
1055 }
1056 break;
1057
1058 case 41:
1059 *animation = kModelAnimationMcCoyWithGunClimbStairsDown;
1060 ++_animationFrame;
1061 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
1062 _animationFrame = 0;
1063 }
1064 if (_animationFrame == 9) {
1065 Sound_Left_Footstep_Walk(kActorMcCoy);
1066 } else if (_animationFrame == 4) {
1067 Sound_Right_Footstep_Walk(kActorMcCoy);
1068 }
1069 if (Game_Flag_Query(kFlagHF05toHF07)) {
1070 walkStairsRight(-0.2f);
1071 }
1072 break;
1073
1074 case 42:
1075 *animation = kModelAnimationMcCoyClimbsLadderUp;
1076 ++_animationFrame;
1077 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation) - 1) { //why -1?
1078 _animationFrame = 0;
1079 }
1080 switch (_animationFrame) {
1081 case 9:
1082 Sound_Left_Footstep_Walk(kActorMcCoy);
1083 break;
1084
1085 case 4:
1086 Sound_Right_Footstep_Walk(kActorMcCoy);
1087 break;
1088
1089 case 1:
1090 Sound_Right_Footstep_Walk(kActorMcCoy);
1091 break;
1092 }
1093 break;
1094
1095 case 43:
1096 *animation = kModelAnimationMcCoyClimbsLadderDown;
1097 ++_animationFrame;
1098 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation) - 1) { //why -1?
1099 _animationFrame = 0;
1100 }
1101 switch (_animationFrame) {
1102 case 1:
1103 Sound_Right_Footstep_Walk(kActorMcCoy);
1104 break;
1105
1106 case 4:
1107 Sound_Right_Footstep_Walk(kActorMcCoy);
1108 break;
1109
1110 case 9:
1111 Sound_Left_Footstep_Walk(kActorMcCoy);
1112 break;
1113 }
1114 break;
1115
1116 case 44:
1117 *animation = kModelAnimationMcCoyThrowsBeggarInTrash;
1118 ++_animationFrame;
1119 if (_animationFrame == 127) {
1120 Game_Flag_Set(kFlagCT04BodyDumped);
1121 }
1122 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
1123 *animation = kModelAnimationMcCoyIdle;
1124 _animationFrame = 0;
1125 ChangeAnimationMode(kAnimationModeIdle);
1126 Actor_Set_At_XYZ(kActorMcCoy, -203.41f, -621.3f, 724.57f, 538);
1127 Player_Gains_Control();
1128 }
1129 break;
1130
1131 case 45:
1132 *animation = kModelAnimationMcCoyEntersSpinner;
1133 ++_animationFrame;
1134 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
1135 Actor_Set_Invisible(kActorMcCoy, true);
1136 *animation = kModelAnimationMcCoyIdle;
1137 _animationFrame = 0;
1138 ChangeAnimationMode(kAnimationModeIdle);
1139 }
1140 break;
1141
1142 case 46:
1143 Actor_Set_Invisible(kActorMcCoy, false);
1144 *animation = kModelAnimationMcCoyExitsSpinner;
1145 ++_animationFrame;
1146 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
1147 *animation = kModelAnimationMcCoyIdle;
1148 _animationFrame = 0;
1149 Player_Gains_Control();
1150 ChangeAnimationMode(kAnimationModeIdle);
1151 Actor_Face_Heading(kActorMcCoy, (Actor_Query_Facing_1024(kActorMcCoy) + 512) & 1023, false);
1152 }
1153 break;
1154
1155 case 47:
1156 *animation = kModelAnimationMcCoyLeaningOver;
1157 ++_animationFrame;
1158 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
1159 _animationFrame = 0;
1160 _animationState = 48;
1161 *animation = kModelAnimationMcCoyLeaningOverSearching;
1162 }
1163 break;
1164
1165 case 48:
1166 *animation = kModelAnimationMcCoyLeaningOverSearching;
1167 ++_animationFrame;
1168 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
1169 _animationFrame = 0;
1170 _animationState = 49;
1171 *animation = kModelAnimationMcCoyLeaningOverResumeIdle;
1172 }
1173 break;
1174
1175 case 49:
1176 *animation = kModelAnimationMcCoyLeaningOverResumeIdle;
1177 ++_animationFrame;
1178 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
1179 Actor_Set_Goal_Number(kActorMcCoy, kGoalMcCoyDefault);
1180 *animation = kModelAnimationMcCoyIdle;
1181 _animationFrame = 0;
1182 ChangeAnimationMode(kAnimationModeIdle);
1183 }
1184 break;
1185
1186 case 50:
1187 *animation = kModelAnimationMcCoyFallsOnHisBack;
1188 _animationFrame = Slice_Animation_Query_Number_Of_Frames(*animation) - 1;
1189 break;
1190
1191 case 51:
1192 *animation = kModelAnimationMcCoyDodgeAndDrawGun;
1193 ++_animationFrame;
1194 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
1195 Player_Set_Combat_Mode(true);
1196 ChangeAnimationMode(kAnimationModeCombatIdle);
1197 Actor_Set_Goal_Number(kActorMcCoy, kGoalMcCoyDefault);
1198 _animationFrame = 0;
1199 Player_Gains_Control();
1200 }
1201 break;
1202
1203 case 52:
1204 *animation = kModelAnimationMcCoyDiesInAgony;
1205 ++_animationFrame;
1206 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
1207 _animationFrame = Slice_Animation_Query_Number_Of_Frames(*animation) - 1;
1208 _animationState = 50;
1209 }
1210 break;
1211
1212 case 53:
1213 *animation = kModelAnimationMcCoyFallsOnHisBack;
1214 --_animationFrame;
1215 if (_animationFrame <= 0) {
1216 Actor_Change_Animation_Mode(kActorMcCoy, kAnimationModeIdle);
1217 *animation = kModelAnimationMcCoyIdle;
1218 _animationFrame = 0;
1219 _animationState = 0;
1220 if (Actor_Query_Goal_Number(kActorMcCoy) == kGoalMcCoyBB11GetUp) {
1221 Actor_Set_Goal_Number(kActorMcCoy, kGoalMcCoyBB11PrepareToRunAway);
1222 }
1223 if (Actor_Query_Goal_Number(kActorMcCoy) == kGoalMcCoyNR01ThrownOut) {
1224 Actor_Set_Goal_Number(kActorMcCoy, kGoalMcCoyNR01GetUp);
1225 }
1226 }
1227 break;
1228
1229 case 55:
1230 *animation = kModelAnimationMcCoyGivesFromPocket;
1231 ++_animationFrame;
1232 if (_animationFrame == 7) {
1233 Actor_Change_Animation_Mode(kActorMaggie, kAnimationModeFeeding);
1234 }
1235 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
1236 *animation = kModelAnimationMcCoyIdle;
1237 _animationState = 0;
1238 }
1239 break;
1240
1241 case 56:
1242 *animation = kModelAnimationMcCoyStartled;
1243 ++_animationFrame;
1244 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
1245 _animationFrame = 0;
1246 if (Actor_Query_Which_Set_In(kActorMcCoy) == kSetUG15) {
1247 _animationState = 27;
1248 } else {
1249 *animation = kModelAnimationMcCoyIdle;
1250 _animationState = 0;
1251 Actor_Change_Animation_Mode(kActorMcCoy, kAnimationModeIdle);
1252 }
1253 }
1254 break;
1255
1256 case 57:
1257 *animation = kModelAnimationMcCoyTiedInChairIdle;
1258 ++_animationFrame;
1259 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
1260 _animationFrame = 0;
1261 }
1262 if (!Game_Flag_Query(kFlagMcCoyTiedDown)) {
1263 _animationFrame = 0;
1264 _animationState = 59;
1265 *animation = kModelAnimationMcCoyTiedInChairFreed;
1266 }
1267 break;
1268
1269 case 58:
1270 *animation = kModelAnimationMcCoyTiedInChairMoving;
1271 ++_animationFrame;
1272 if (_animationFrame == 6) {
1273 // Play one of kSfxCHARMTL7, kSfxCHARMTL8, kSfxCHARMTL9
1274 Ambient_Sounds_Play_Sound(Random_Query(kSfxCHARMTL7, kSfxCHARMTL9), 39, 0, 0, 99);
1275 }
1276 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation) - 1) { //why -1? a bug?
1277 _animationFrame = 0;
1278 }
1279 break;
1280
1281 case 59:
1282 *animation = kModelAnimationMcCoyTiedInChairFreed;
1283 ++_animationFrame;
1284 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
1285 *animation = kModelAnimationMcCoyIdle;
1286 _animationFrame = 0;
1287 _animationLoopLength = 0;
1288 _animationState = 0;
1289 Player_Gains_Control();
1290 Item_Add_To_World(kItemChair, kModelAnimationYukonHotelChair, kSetCT08_CT51_UG12, -110.0, 0.0, -192.0, 0, 48, 32, false, true, false, false);
1291 }
1292 break;
1293
1294 case 60:
1295 *animation = kModelAnimationMcCoySittingToUseConsole;
1296 if (_animationFrame < Slice_Animation_Query_Number_Of_Frames(*animation) - 1) {
1297 ++_animationFrame;
1298 }
1299 break;
1300
1301 case 61:
1302 *animation = kModelAnimationMcCoySittingToUseConsole;
1303 --_animationFrame;
1304 if (_animationFrame <= 0) {
1305 *animation = kModelAnimationMcCoyIdle;
1306 _animationFrame = 0;
1307 _animationState = 0;
1308 if (Actor_Query_Goal_Number(kActorMcCoy) == kGoalMcCoyNRxxSitAtTable) {
1309 Actor_Set_Goal_Number(kActorMcCoy, kGoalMcCoyNRxxStandUp);
1310 }
1311 }
1312 break;
1313
1314 case 62:
1315 *animation = kModelAnimationMcCoyWithGunGrabbedByArm0;
1316 ++_animationFrame;
1317 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
1318 _animationFrame = 0;
1319 _animationState = 63;
1320 *animation = kModelAnimationMcCoyWithGunGrabbedByArm1;
1321 }
1322 break;
1323
1324 case 63:
1325 *animation = kModelAnimationMcCoyWithGunGrabbedByArm1;
1326 ++_animationFrame;
1327 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
1328 _animationFrame = 0;
1329 }
1330 break;
1331
1332 case 64:
1333 *animation = kModelAnimationMcCoyWithGunGrabbedByArmHurt;
1334 ++_animationFrame;
1335 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
1336 _animationFrame = 0;
1337 _animationState = 63;
1338 *animation = kModelAnimationMcCoyWithGunGrabbedByArm1;
1339 }
1340 break;
1341
1342 case 65:
1343 *animation = kModelAnimationMcCoyWithGunGrabbedByArmFreed;
1344 ++_animationFrame;
1345 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
1346 _animationFrame = 0;
1347 _animationState = 14;
1348 *animation = kModelAnimationMcCoyWithGunIdle;
1349 Actor_Set_Goal_Number(kActorMcCoy, kGoalMcCoyDefault);
1350 }
1351 break;
1352
1353 case 66:
1354 *animation = kModelAnimationMcCoyGiveMovement;
1355 ++_animationFrame;
1356 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
1357 Actor_Change_Animation_Mode(kActorMcCoy, kAnimationModeIdle);
1358 *animation = kModelAnimationMcCoyIdle;
1359 _animationFrame = 0;
1360 _animationState = 0;
1361 }
1362 break;
1363
1364 case 67:
1365 *animation = kModelAnimationMcCoyDrinkingBooze;
1366 ++_animationFrame;
1367 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
1368 Actor_Change_Animation_Mode(kActorMcCoy, kAnimationModeIdle);
1369 *animation = kModelAnimationMcCoyIdle;
1370 _animationState = 0;
1371 _animationFrame = 0;
1372 if (Actor_Query_Goal_Number(kActorMcCoy) == kGoalMcCoyNR04Drink) {
1373 Actor_Change_Animation_Mode(kActorMcCoy, kAnimationModeDie);
1374 }
1375 }
1376 break;
1377
1378 case 68:
1379 *animation = kModelAnimationMcCoyFallsOnHisBack;
1380 v7 = Slice_Animation_Query_Number_Of_Frames(*animation) - 1 - Global_Variable_Query(kVariableNR01GetUpCounter);
1381 if (_animationFrame < v7) {
1382 ++_animationFrame;
1383 } else if (_animationFrame > v7) {
1384 --_animationFrame;
1385 }
1386 if (_animationFrame <= 0) {
1387 Actor_Change_Animation_Mode(kActorMcCoy, kAnimationModeIdle);
1388 *animation = kModelAnimationMcCoyIdle;
1389 _animationState = 0;
1390 _animationFrame = 0;
1391 Game_Flag_Reset(kFlagNR01McCoyIsDrugged);
1392 Scene_Exits_Enable();
1393 Player_Set_Combat_Mode_Access(true);
1394 Actor_Set_Goal_Number(kActorMcCoy, kGoalMcCoyDefault);
1395 }
1396 break;
1397
1398 case 69:
1399 *animation = kModelAnimationMcCoyCrouchingDown;
1400 ++_animationFrame;
1401 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
1402 Actor_Change_Animation_Mode(kActorMcCoy, kAnimationModeSit);
1403 *animation = kModelAnimationMcCoyCrouchedIdle;
1404 }
1405 break;
1406
1407 case 70:
1408 *animation = kModelAnimationMcCoyCrouchedIdle;
1409 ++_animationFrame;
1410 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
1411 _animationFrame = 0;
1412 }
1413 break;
1414
1415 case 71:
1416 *animation = kModelAnimationMcCoyCrouchedGetsUp;
1417 ++_animationFrame;
1418 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
1419 Actor_Change_Animation_Mode(kActorMcCoy, kAnimationModeIdle);
1420 *animation = kModelAnimationMcCoyIdle;
1421 _animationFrame = 0;
1422 _animationState = 0;
1423 Player_Gains_Control();
1424 }
1425 break;
1426 }
1427 *frame = _animationFrame;
1428 return true;
1429 }
1430
ChangeAnimationMode(int mode)1431 bool AIScriptMcCoy::ChangeAnimationMode(int mode) {
1432 switch (mode) {
1433 case kAnimationModeIdle:
1434 if (Game_Flag_Query(kFlagMcCoyTiedDown)) {
1435 if (_animationFrame <= 6) {
1436 // Play one of kSfxCHARMTL7, kSfxCHARMTL8, kSfxCHARMTL9
1437 Ambient_Sounds_Play_Sound(Random_Query(kSfxCHARMTL7, kSfxCHARMTL9), 39, 0, 0, 99);
1438 }
1439 _animationState = 57;
1440 _animationFrame = 0;
1441 return true;
1442 }
1443 switch (_animationState) {
1444 case 3:
1445 // fall through
1446 case 4:
1447 // fall through
1448 case 5:
1449 // fall through
1450 case 6:
1451 // fall through
1452 case 7:
1453 // fall through
1454 case 8:
1455 // fall through
1456 case 9:
1457 // fall through
1458 case 10:
1459 // fall through
1460 case 11:
1461 // fall through
1462 case 12:
1463 Game_Flag_Set(kFlagMcCoyAnimation1);
1464 _animationLoopCounter = 0;
1465 _animationLoopLength = 30;
1466 _animationLoopFrameMin = 0;
1467 _animationLoopDirection = 1;
1468 _animationLoopFrameMax = 3;
1469 return true;
1470
1471 case 14:
1472 // fall through
1473 case 17:
1474 // fall through
1475 case 20:
1476 // fall through
1477 case 21:
1478 // fall through
1479 case 36:
1480 _animationState = 16;
1481 _animationFrame = 0;
1482 return true;
1483
1484 case 15:
1485 _animationState = 16;
1486 _animationFrame = 16 - ((16 * _animationFrame) / 12);
1487 return true;
1488
1489 case 16:
1490 // fall through
1491 case 25:
1492 // fall through
1493 case 26:
1494 // fall through
1495 case 55:
1496 return true;
1497
1498 case 60:
1499 _animationState = 61;
1500 return true;
1501
1502 default:
1503 _animationState = 0;
1504 _animationFrame = 0;
1505 _animationLoopLength = 0;
1506 return true;
1507 }
1508 break;
1509
1510 case kAnimationModeWalk:
1511 if (_animationState != 27
1512 && _animationState != 50
1513 ) {
1514 if (Game_Flag_Query(kFlagMcCoyTiedDown)) {
1515 _animationState = 58;
1516 _animationFrame = 0;
1517 } else {
1518 _animationState = 32;
1519 _animationFrame = 0;
1520 }
1521 }
1522 break;
1523
1524 case kAnimationModeRun:
1525 if (_animationState != 27
1526 && _animationState != 50
1527 ) {
1528 if (Game_Flag_Query(kFlagMcCoyTiedDown)) {
1529 _animationState = 58;
1530 _animationFrame = 4;
1531 } else {
1532 _animationState = 31;
1533 _animationFrame = 0;
1534 }
1535 }
1536 break;
1537
1538 case kAnimationModeTalk:
1539 if (_animationState < 3 || _animationState > 12) {
1540 _animationState = 13;
1541 _animationStateNext = 3;
1542 _animationNext = kModelAnimationMcCoyProtestingTalk;
1543 } else {
1544 Game_Flag_Reset(kFlagMcCoyAnimation1);
1545 _animationStateNextSpecial = 4;
1546 _animationNextSpecial = kModelAnimationMcCoyProtestingTalk;
1547 }
1548 break;
1549
1550 case kAnimationModeCombatIdle:
1551 switch (_animationState) {
1552 case 14:
1553 // fall through
1554 case 15:
1555 // fall through
1556 case 19:
1557 // fall through
1558 case 21:
1559 break;
1560
1561 case 16:
1562 _animationState = 15;
1563 _animationFrame = 12 - ((12 * _animationFrame) / 16);
1564 break;
1565
1566 case 17:
1567 // fall through
1568 case 20:
1569 _animationState = 19;
1570 _animationFrame = 0;
1571 break;
1572
1573 case 18:
1574 _animationState = 19;
1575 _animationFrame = 13 * ((8 - _animationFrame) / 8);
1576 break;
1577
1578 case 22:
1579 _animationState = 19;
1580 _animationFrame = 41;
1581 break;
1582
1583 case 36:
1584 // fall through
1585 case 37:
1586 // fall through
1587 case 40:
1588 // fall through
1589 case 41:
1590 // fall through
1591 case 51:
1592 _animationState = 14;
1593 _animationFrame = 0;
1594 break;
1595
1596 default:
1597 _animationState = 15;
1598 _animationFrame = 0;
1599 break;
1600 }
1601 break;
1602
1603 case kAnimationModeCombatAim:
1604 switch (_animationState) {
1605 case 17:
1606 // fall through
1607 case 18:
1608 // fall through
1609 case 21:
1610 break;
1611
1612 case 19:
1613 _animationState = 18;
1614 _animationFrame = 8 * (13 - _animationFrame) / 13;
1615 break;
1616
1617 case 22:
1618 _animationState = 22;
1619 _animationFrame = 0;
1620 break;
1621
1622 default:
1623 _animationState = 18;
1624 _animationFrame = 0;
1625 break;
1626 }
1627 break;
1628
1629 case kAnimationModeCombatAttack:
1630 _animationState = 21;
1631 _animationFrame = 0;
1632 break;
1633
1634 case kAnimationModeCombatWalk:
1635 if (_animationState != 27 && _animationState != 50) {
1636 _animationState = 36;
1637 _animationFrame = 0;
1638 }
1639 break;
1640
1641 case kAnimationModeCombatRun:
1642 if (_animationState != 27 && _animationState != 50) {
1643 _animationState = 37;
1644 _animationFrame = 0;
1645 }
1646 break;
1647
1648 case 9:
1649 // fall through
1650 case 12:
1651 if (_animationState < 3 || _animationState > 12) {
1652 _animationState = 13;
1653 _animationStateNext = 5;
1654 _animationNext = kModelAnimationMcCoyScratchHeadTalk;
1655 } else {
1656 Game_Flag_Reset(kFlagMcCoyAnimation1);
1657 _animationStateNextSpecial = 5;
1658 _animationNextSpecial = kModelAnimationMcCoyScratchHeadTalk;
1659 }
1660 break;
1661
1662 case 10:
1663 // fall through
1664 case 13:
1665 if (_animationState < 3 || _animationState > 12) {
1666 _animationState = 13;
1667 _animationStateNext = 6;
1668 _animationNext = kModelAnimationMcCoyScratchEarLongerTalk;
1669 } else {
1670 Game_Flag_Reset(kFlagMcCoyAnimation1);
1671 _animationStateNextSpecial = 6;
1672 _animationNextSpecial = kModelAnimationMcCoyScratchEarLongerTalk;
1673 }
1674 break;
1675
1676 case 11:
1677 // fall through
1678 case 14:
1679 if (_animationState < 3 || _animationState > 12) {
1680 _animationState = 13;
1681 _animationStateNext = 7;
1682 _animationNext = kModelAnimationMcCoyPointingTalk;
1683 } else {
1684 Game_Flag_Reset(kFlagMcCoyAnimation1);
1685 _animationStateNextSpecial = 7;
1686 _animationNextSpecial = kModelAnimationMcCoyPointingTalk;
1687 }
1688 break;
1689
1690 case 15:
1691 if (_animationState < 3 || _animationState > 12) {
1692 _animationState = 13;
1693 _animationStateNext = 8;
1694 _animationNext = kModelAnimationMcCoyUpsetTalk;
1695 } else {
1696 Game_Flag_Reset(kFlagMcCoyAnimation1);
1697 _animationStateNextSpecial = 8;
1698 _animationNextSpecial = kModelAnimationMcCoyUpsetTalk;
1699 }
1700 break;
1701
1702 case 16:
1703 if (_animationState < 3 || _animationState > 12) {
1704 _animationState = 13;
1705 _animationStateNext = 9;
1706 _animationNext = kModelAnimationMcCoyDismissiveTalk;
1707 } else {
1708 Game_Flag_Reset(kFlagMcCoyAnimation1);
1709 _animationStateNextSpecial = 9;
1710 _animationNextSpecial = kModelAnimationMcCoyDismissiveTalk;
1711 }
1712 break;
1713
1714 case 17:
1715 if (_animationState < 3 || _animationState > 12) {
1716 _animationState = 13;
1717 _animationStateNext = 10;
1718 _animationNext = kModelAnimationMcCoyScratchEarTalk;
1719 } else {
1720 Game_Flag_Reset(kFlagMcCoyAnimation1);
1721 _animationStateNextSpecial = 10;
1722 _animationNextSpecial = kModelAnimationMcCoyScratchEarTalk;
1723 }
1724 break;
1725
1726 case 18:
1727 if (_animationState < 3 || _animationState > 12) {
1728 _animationState = 13;
1729 _animationStateNext = 11;
1730 _animationNext = kModelAnimationMcCoyHandsOnWaistTalk;
1731 } else {
1732 Game_Flag_Reset(kFlagMcCoyAnimation1);
1733 _animationStateNextSpecial = 11;
1734 _animationNextSpecial = kModelAnimationMcCoyHandsOnWaistTalk;
1735 }
1736 break;
1737
1738 case 19:
1739 if (_animationState < 3 || _animationState > 12) {
1740 _animationState = 13;
1741 _animationStateNext = 12;
1742 _animationNext = kModelAnimationMcCoyScratchEarLongerTalk;
1743 } else {
1744 Game_Flag_Reset(kFlagMcCoyAnimation1);
1745 _animationStateNextSpecial = 12;
1746 _animationNextSpecial = kModelAnimationMcCoyScratchEarLongerTalk;
1747 }
1748 break;
1749
1750 case kAnimationModeDodge:
1751 dodge();
1752 break;
1753
1754 case kAnimationModeHit:
1755 switch (_animationState) {
1756 case 14:
1757 // fall through
1758 case 15:
1759 // fall through
1760 case 17:
1761 // fall through
1762 case 18:
1763 // fall through
1764 case 19:
1765 // fall through
1766 case 20:
1767 // fall through
1768 case 21:
1769 // fall through
1770 case 22:
1771 if (Random_Query(0, 1) == 1) {
1772 _animationState = 24;
1773 } else {
1774 _animationState = 23;
1775 }
1776 _animationFrame = 0;
1777 break;
1778
1779 default:
1780 if (Random_Query(0, 1) == 1) {
1781 _animationState = 26;
1782 } else {
1783 _animationState = 25;
1784 }
1785 _animationFrame = 0;
1786 break;
1787 }
1788 break;
1789
1790 case kAnimationModeCombatHit:
1791 if (Random_Query(0, 1) == 1) {
1792 _animationState = 23;
1793 } else {
1794 _animationState = 24;
1795 }
1796 _animationFrame = 0;
1797 break;
1798
1799 case 23:
1800 _animationState = 66;
1801 _animationFrame = 0;
1802 break;
1803
1804 case 29:
1805 Player_Loses_Control();
1806 _animationFrame = 0;
1807 _animationState = 71;
1808 break;
1809
1810 case 38:
1811 _animationState = 47;
1812 _animationFrame = 0;
1813 break;
1814
1815 case 39:
1816 _animationFrame = 0;
1817 _animationState = 52;
1818 if (Player_Query_Current_Set() == kSetCT02) {
1819 _animationFrame = 23;
1820 }
1821 break;
1822
1823 case 40:
1824 _animationState = 44;
1825 _animationFrame = 0;
1826 break;
1827
1828 case kAnimationModeSpinnerGetIn:
1829 _animationState = 45;
1830 _animationFrame = 0;
1831 break;
1832
1833 case kAnimationModeSpinnerGetOut:
1834 _animationState = 46;
1835 _animationFrame = 0;
1836 Player_Loses_Control();
1837 break;
1838
1839 case kAnimationModeWalkUp:
1840 _animationState = 38;
1841 _animationFrame = 0;
1842 break;
1843
1844 case kAnimationModeWalkDown:
1845 _animationState = 39;
1846 _animationFrame = 0;
1847 break;
1848
1849 case kAnimationModeCombatWalkUp:
1850 _animationState = 40;
1851 _animationFrame = 0;
1852 break;
1853
1854 case kAnimationModeCombatWalkDown:
1855 _animationState = 41;
1856 _animationFrame = 0;
1857 break;
1858
1859 case kAnimationModeDie:
1860 switch (_animationState) {
1861 case 14:
1862 // fall through
1863 case 15:
1864 // fall through
1865 case 17:
1866 // fall through
1867 case 18:
1868 // fall through
1869 case 19:
1870 // fall through
1871 case 20:
1872 // fall through
1873 case 21:
1874 // fall through
1875 case 22:
1876 _animationState = 28;
1877 _animationFrame = 0;
1878 break;
1879
1880 case 27:
1881 // fall through
1882 case 28:
1883 // fall through
1884 case 50:
1885 break;
1886
1887 default:
1888 _animationState = 27;
1889 _animationFrame = 0;
1890 break;
1891 }
1892 break;
1893
1894 case kAnimationModeCombatDie:
1895 _animationState = 28;
1896 _animationFrame = 0;
1897 break;
1898
1899 case 51:
1900 _animationState = 27;
1901 _animationFrame = 0;
1902 break;
1903
1904 case kAnimationModeFeeding:
1905 _animationState = 55;
1906 _animationFrame = 0;
1907 break;
1908
1909 case kAnimationModeSit:
1910 if (_animationState != 60 && (Player_Query_Current_Set() == kSetNR03 || Player_Query_Current_Set() == kSetNR05_NR08)) {
1911 _animationState = 60;
1912 _animationFrame = 0;
1913 } else {
1914 _animationFrame = 0;
1915 _animationState = 70;
1916 }
1917 break;
1918
1919 case kAnimationModeClimbUp:
1920 // fall through
1921 case kAnimationModeCombatClimbUp:
1922 _animationState = 42;
1923 _animationFrame = 0;
1924 break;
1925
1926 case kAnimationModeClimbDown:
1927 // fall through
1928 case kAnimationModeCombatClimbDown:
1929 _animationState = 43;
1930 _animationFrame = 0;
1931 break;
1932
1933 case 68:
1934 _animationState = 29;
1935 _animationFrame = Slice_Animation_Query_Number_Of_Frames(kModelAnimationMcCoyFallsOnHisBack) - 1;
1936 _animationLoopDirection = -1;
1937 break;
1938
1939 case 75:
1940 _animationState = 67;
1941 _animationFrame = 0;
1942 break;
1943
1944 case 85:
1945 _animationFrame = 0;
1946 _animationState = 69;
1947 break;
1948 }
1949 return true;
1950 }
1951
QueryAnimationState(int * animationState,int * animationFrame,int * animationStateNext,int * animationNext)1952 void AIScriptMcCoy::QueryAnimationState(int *animationState, int *animationFrame, int *animationStateNext, int *animationNext) {
1953 *animationState = _animationState;
1954 *animationFrame = _animationFrame;
1955 *animationStateNext = _animationStateNext;
1956 *animationNext = _animationNext;
1957 }
1958
SetAnimationState(int animationState,int animationFrame,int animationStateNext,int animationNext)1959 void AIScriptMcCoy::SetAnimationState(int animationState, int animationFrame, int animationStateNext, int animationNext) {
1960 _animationState = animationState;
1961 _animationFrame = animationFrame;
1962 _animationStateNext = animationStateNext;
1963 _animationNext = animationNext;
1964 }
1965
ReachedMovementTrackWaypoint(int waypointId)1966 bool AIScriptMcCoy::ReachedMovementTrackWaypoint(int waypointId) {
1967 return true;
1968 }
1969
FledCombat()1970 void AIScriptMcCoy::FledCombat() {}
1971
fallDown()1972 void AIScriptMcCoy::fallDown() {
1973 float x, y, z;
1974 Actor_Query_XYZ(kActorMcCoy, &x, &y, &z);
1975 _fallHeightCurrent = _fallHeightCurrent + _fallSpeed;
1976 if (_fallHeightTarget < _fallHeightCurrent) {
1977 _fallSpeed = _fallSpeed - 0.2f;
1978 } else {
1979 _fallHeightCurrent = _fallHeightTarget;
1980 Actor_Set_Goal_Number(kActorMcCoy, kGoalMcCoyDefault);
1981 Actor_Retired_Here(kActorMcCoy, 12, 48, true, -1);
1982 }
1983 return Actor_Set_At_XYZ(kActorMcCoy, x, _fallHeightCurrent, z, Actor_Query_Facing_1024(kActorMcCoy));
1984 }
1985
UG15fall()1986 void AIScriptMcCoy::UG15fall() {
1987 if (Actor_Query_Which_Set_In(kActorMcCoy) == kSetUG15
1988 && Actor_Query_Goal_Number(kActorMcCoy) != kGoalMcCoyUG15Fall
1989 && !Game_Flag_Query(kFlagUG15BridgeBroken)
1990 ) {
1991 float x, y, z;
1992 Actor_Query_XYZ(kActorMcCoy, &x, &y, &z);
1993 if (z < 220.0f && -210.0f < x && x < -70.0f) {
1994 Game_Flag_Set(kFlagUG15BridgeBroken);
1995 Scene_Loop_Set_Default(3); // kUG15LoopMainLoopBridgeBroken
1996 Scene_Loop_Start_Special(kSceneLoopModeOnce, 2, true); // kUG15LoopBridgeBreaks
1997 Actor_Set_Goal_Number(kActorMcCoy, kGoalMcCoyUG15Fall);
1998 Actor_Query_XYZ(kActorFreeSlotA, &x, &y, &z);
1999 if (-200.0 < x && x < -62.0f) {
2000 Actor_Set_Goal_Number(kActorFreeSlotA, kGoalFreeSlotAUG15Fall);
2001 }
2002 } else {
2003 Actor_Set_Goal_Number(kActorMcCoy, kGoalMcCoyUG15Die);
2004 }
2005 }
2006 }
2007
dodge()2008 void AIScriptMcCoy::dodge() {
2009 int setId = Actor_Query_Which_Set_In(kActorMcCoy);
2010 if (setId == kSetCT02) {
2011 _animationState = 51;
2012 _animationFrame = 0;
2013 Player_Loses_Control();
2014 Game_Flag_Set(kFlagCT02ZubenFled);
2015 } else if (setId == kSetRC03 || setId == kSetUG15) {
2016 _animationState = 56;
2017 _animationFrame = 0;
2018 }
2019 }
2020
walkStairsLeft(float stepHeight)2021 void AIScriptMcCoy::walkStairsLeft(float stepHeight) {
2022 float x, y, z;
2023 int currentAngle = Actor_Query_Facing_1024(kActorMcCoy);
2024 Actor_Query_XYZ(kActorMcCoy, &x, &y, &z);
2025 int angle = currentAngle - 12;
2026 if (angle < 0) {
2027 angle = currentAngle + 1012;
2028 }
2029 if (angle > 1023) {
2030 angle -= 1024;
2031 }
2032 Actor_Set_At_XYZ(kActorMcCoy, x, y + stepHeight, z, angle);
2033 }
2034
walkStairsRight(float stepHeight)2035 void AIScriptMcCoy::walkStairsRight(float stepHeight) {
2036 float x, y, z;
2037 int currentAngle = Actor_Query_Facing_1024(kActorMcCoy);
2038 Actor_Query_XYZ(kActorMcCoy, &x, &y, &z);
2039 int angle = currentAngle + 15;
2040 if (angle < 0) {
2041 angle = currentAngle + 1039;
2042 }
2043 if (angle > 1023) {
2044 angle -= 1024;
2045 }
2046 return Actor_Set_At_XYZ(kActorMcCoy, x, y + stepHeight, z, angle);
2047 }
2048
2049 } // End of namespace BladeRunner
2050