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
AIScriptTyrellGuard(BladeRunnerEngine * vm)27 AIScriptTyrellGuard::AIScriptTyrellGuard(BladeRunnerEngine *vm) : AIScriptBase(vm) {
28 _frameDelta = 1;
29 _resumeIdleAfterFramesetCompletesFlag = false;
30 }
31
Initialize()32 void AIScriptTyrellGuard::Initialize() {
33 _animationFrame = 0;
34 _animationState = 0;
35 _animationStateNext = 0;
36 _animationNext = 0;
37
38 _frameDelta = 1;
39 _resumeIdleAfterFramesetCompletesFlag = false;
40 Actor_Set_Goal_Number(kActorTyrellGuard, 0);
41 }
42
Update()43 bool AIScriptTyrellGuard::Update() {
44 return false;
45 }
46
TimerExpired(int timer)47 void AIScriptTyrellGuard::TimerExpired(int timer) {
48 switch (timer) {
49 case kActorTimerAIScriptCustomTask0:
50 AI_Countdown_Timer_Reset(kActorTyrellGuard, kActorTimerAIScriptCustomTask0);
51 if (Actor_Query_Which_Set_In(kActorMcCoy) == kSetTB02_TB03) {
52 Actor_Set_Goal_Number(kActorTyrellGuard, kGoalTyrellGuardWakeUpAndArrestMcCoy);
53 }
54 break;
55
56 case kActorTimerAIScriptCustomTask1:
57 AI_Countdown_Timer_Reset(kActorTyrellGuard, kActorTimerAIScriptCustomTask1);
58 Actor_Set_Goal_Number(kActorTyrellGuard, kGoalTyrellGuardArrestMcCoy);
59 break;
60 }
61 }
62
CompletedMovementTrack()63 void AIScriptTyrellGuard::CompletedMovementTrack() {
64 //return false;
65 }
66
ReceivedClue(int clueId,int fromActorId)67 void AIScriptTyrellGuard::ReceivedClue(int clueId, int fromActorId) {
68 //return false;
69 }
70
ClickedByPlayer()71 void AIScriptTyrellGuard::ClickedByPlayer() {
72 //return false;
73 }
74
EnteredSet(int setId)75 void AIScriptTyrellGuard::EnteredSet(int setId) {
76 // return false;
77 }
78
OtherAgentEnteredThisSet(int otherActorId)79 void AIScriptTyrellGuard::OtherAgentEnteredThisSet(int otherActorId) {
80 // return false;
81 }
82
OtherAgentExitedThisSet(int otherActorId)83 void AIScriptTyrellGuard::OtherAgentExitedThisSet(int otherActorId) {
84 // return false;
85 }
86
OtherAgentEnteredCombatMode(int otherActorId,int combatMode)87 void AIScriptTyrellGuard::OtherAgentEnteredCombatMode(int otherActorId, int combatMode) {
88 // return false;
89 }
90
ShotAtAndMissed()91 void AIScriptTyrellGuard::ShotAtAndMissed() {
92 // return false;
93 }
94
ShotAtAndHit()95 bool AIScriptTyrellGuard::ShotAtAndHit() {
96 return false;
97 }
98
Retired(int byActorId)99 void AIScriptTyrellGuard::Retired(int byActorId) {
100 // return false;
101 }
102
GetFriendlinessModifierIfGetsClue(int otherActorId,int clueId)103 int AIScriptTyrellGuard::GetFriendlinessModifierIfGetsClue(int otherActorId, int clueId) {
104 return 0;
105 }
106
GoalChanged(int currentGoalNumber,int newGoalNumber)107 bool AIScriptTyrellGuard::GoalChanged(int currentGoalNumber, int newGoalNumber) {
108 switch (newGoalNumber) {
109 case kGoalTyrellGuardSleeping:
110 if (currentGoalNumber != newGoalNumber) {
111 Actor_Change_Animation_Mode(kActorTyrellGuard, 55);
112 AI_Countdown_Timer_Start(kActorTyrellGuard, kActorTimerAIScriptCustomTask0, 30);
113 }
114 return true;
115
116 case kGoalTyrellGuardWakeUpAndArrestMcCoy:
117 Actor_Change_Animation_Mode(kActorTyrellGuard, kAnimationModeIdle);
118 Delay(1000);
119 Actor_Says(kActorTyrellGuard, 320, 14);
120 Actor_Change_Animation_Mode(kActorTyrellGuard, 50);
121 Ambient_Sounds_Play_Sound(kSfxTBALARM, 100, 0, 0, 0);
122 Delay(1000);
123 Actor_Force_Stop_Walking(kActorMcCoy);
124 Actor_Set_Goal_Number(kActorMcCoy, kGoalMcCoyArrested);
125 return true;
126
127 case kGoalTyrellGuardWakeUp:
128 AI_Countdown_Timer_Reset(kActorTyrellGuard, kActorTimerAIScriptCustomTask0);
129 Actor_Says(kActorTyrellGuard, 310, 14);
130 AI_Countdown_Timer_Start(kActorTyrellGuard, kActorTimerAIScriptCustomTask1, 20);
131 return true;
132
133 case kGoalTyrellGuardArrestMcCoy:
134 Actor_Change_Animation_Mode(kActorTyrellGuard, 50);
135 Ambient_Sounds_Play_Sound(kSfxTBALARM, 100, 0, 0, 0);
136 Delay(1000);
137 Actor_Force_Stop_Walking(kActorMcCoy);
138 Actor_Set_Goal_Number(kActorMcCoy, kGoalMcCoyArrested);
139 return true;
140
141 case kGoalTyrellGuardWait:
142 AI_Countdown_Timer_Reset(kActorTyrellGuard, kActorTimerAIScriptCustomTask1);
143 return true;
144 }
145 return false;
146 }
147
UpdateAnimation(int * animation,int * frame)148 bool AIScriptTyrellGuard::UpdateAnimation(int *animation, int *frame) {
149 switch (_animationState) {
150 case 0:
151 *animation = kModelAnimationTyrellGuardSittingIdle;
152 ++_animationFrame;
153 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(kModelAnimationTyrellGuardSittingIdle)) {
154 _animationFrame = 0;
155 }
156 break;
157
158 case 1:
159 *animation = kModelAnimationTyrellGuardSittingSleepingWakingUp;
160 if (_animationFrame <= 5) {
161 _frameDelta = 1;
162 } else if (_animationFrame >= 12) {
163 _frameDelta = -1;
164 }
165 _animationFrame += _frameDelta;
166 break;
167
168 case 2:
169 *animation = kModelAnimationTyrellGuardSittingSleepingWakingUp;
170 ++_animationFrame;
171 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(kModelAnimationTyrellGuardSittingSleepingWakingUp)) {
172 _animationFrame = 0;
173 _animationState = 0;
174 }
175 break;
176
177 case 3:
178 *animation = kModelAnimationTyrellGuardSittingCalmTalk;
179 if (_animationFrame == 0 && _resumeIdleAfterFramesetCompletesFlag) {
180 *animation = kModelAnimationTyrellGuardSittingIdle;
181 _animationState = 0;
182 } else {
183 ++_animationFrame;
184 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) {
185 _animationFrame = 0;
186 }
187 }
188 break;
189
190 case 4:
191 *animation = kModelAnimationTyrellGuardSittingExplainTalk;
192 ++_animationFrame;
193 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(kModelAnimationTyrellGuardSittingExplainTalk)) {
194 *animation = kModelAnimationTyrellGuardSittingCalmTalk;
195 _animationFrame = 0;
196 _animationState = 3;
197 }
198 break;
199
200 case 5:
201 *animation = kModelAnimationTyrellGuardSittingHandOverHeadTalk;
202 ++_animationFrame;
203 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(kModelAnimationTyrellGuardSittingHandOverHeadTalk)) {
204 *animation = kModelAnimationTyrellGuardSittingCalmTalk;
205 _animationFrame = 0;
206 _animationState = 3;
207 }
208 break;
209
210 case 6:
211 *animation = kModelAnimationTyrellGuardSittingSuggestTalk;
212 ++_animationFrame;
213 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(kModelAnimationTyrellGuardSittingSuggestTalk)) {
214 *animation = kModelAnimationTyrellGuardSittingCalmTalk;
215 _animationFrame = 0;
216 _animationState = 3;
217 }
218 break;
219
220 case 7:
221 *animation = kModelAnimationTyrellGuardSittingUpsetTalk;
222 ++_animationFrame;
223 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(kModelAnimationTyrellGuardSittingUpsetTalk)) {
224 *animation = kModelAnimationTyrellGuardSittingCalmTalk;
225 _animationFrame = 0;
226 _animationState = 3;
227 }
228 break;
229
230 case 8:
231 *animation = kModelAnimationTyrellGuardSittingGestureGive;
232 ++_animationFrame;
233 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(kModelAnimationTyrellGuardSittingGestureGive)) {
234 *animation = kModelAnimationTyrellGuardSittingIdle;
235 _animationFrame = 0;
236 _animationState = 0;
237 }
238 break;
239
240 case 9:
241 *animation = kModelAnimationTyrellGuardSittingMaybeHugsMonitors;
242 ++_animationFrame;
243 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(kModelAnimationTyrellGuardSittingMaybeHugsMonitors)) {
244 *animation = kModelAnimationTyrellGuardSittingIdle;
245 _animationFrame = 0;
246 _animationState = 0;
247 }
248 break;
249
250 case 10:
251 *animation = kModelAnimationTyrellGuardSittingSleepingWakingUp;
252 ++_animationFrame;
253 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(kModelAnimationTyrellGuardSittingSleepingWakingUp)) {
254 *animation = kModelAnimationTyrellGuardSittingIdle;
255 _animationFrame = 0;
256 _animationState = 0;
257 }
258 break;
259
260 case 11:
261 *animation = kModelAnimationTyrellGuardSittingPressingAlertButton;
262 ++_animationFrame;
263 if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(kModelAnimationTyrellGuardSittingPressingAlertButton)) {
264 *animation = kModelAnimationTyrellGuardSittingIdle;
265 _animationFrame = 0;
266 _animationState = 0;
267 }
268 break;
269 }
270
271 *frame = _animationFrame;
272 return true;
273 }
274
ChangeAnimationMode(int mode)275 bool AIScriptTyrellGuard::ChangeAnimationMode(int mode) {
276 switch (mode) {
277 case kAnimationModeIdle:
278 switch (_animationState) {
279 case 0:
280 _animationState = 8;
281 _animationFrame = 0;
282 break;
283
284 case 1:
285 _animationState = 2;
286 break;
287
288 case 3:
289 // fall through
290 case 4:
291 // fall through
292 case 5:
293 // fall through
294 case 6:
295 // fall through
296 case 7:
297 _resumeIdleAfterFramesetCompletesFlag = true;
298 break;
299
300 case 8:
301 break;
302
303 default:
304 _animationState = 0;
305 _animationFrame = 0;
306 break;
307 }
308 break;
309
310 case kAnimationModeTalk:
311 if (_animationState == 1) {
312 _animationState = 2;
313 } else if ((_animationState - 1 != 7 && _animationState - 1 != 10) || _animationState - 1 > 10) {
314 _animationState = 3;
315 _animationFrame = 0;
316 _resumeIdleAfterFramesetCompletesFlag = false;
317 }
318 break;
319
320 case 12:
321 if (_animationState == 1) {
322 _animationState = 2;
323 } else if ((_animationState - 1 != 7 && _animationState - 1 != 10) || _animationState - 1 > 10) {
324 _animationState = 4;
325 _animationFrame = 0;
326 _resumeIdleAfterFramesetCompletesFlag = false;
327 }
328 break;
329
330 case 13:
331 if (_animationState == 1) {
332 _animationState = 2;
333 } else if ((_animationState - 1 != 7 && _animationState - 1 != 10) || _animationState - 1 > 10) {
334 _animationState = 5;
335 _animationFrame = 0;
336 _resumeIdleAfterFramesetCompletesFlag = false;
337 }
338 break;
339
340 case 14:
341 if (_animationState == 1) {
342 _animationState = 2;
343 } else if ((_animationState - 1 != 7 && _animationState - 1 != 10) || _animationState - 1 > 10) {
344 _animationState = 6;
345 _animationFrame = 0;
346 _resumeIdleAfterFramesetCompletesFlag = false;
347 }
348 break;
349
350 case 15:
351 if (_animationState == 1) {
352 _animationState = 2;
353 } else if ((_animationState - 1 != 7 && _animationState - 1 != 10) || _animationState - 1 > 10) {
354 _animationState = 7;
355 _animationFrame = 0;
356 _resumeIdleAfterFramesetCompletesFlag = false;
357 }
358 break;
359
360 case 23:
361 _animationState = 8;
362 _animationFrame = 0;
363 break;
364
365 case 50:
366 _animationState = 11;
367 _animationFrame = 0;
368 break;
369
370 case 43:
371 // fall through
372 case 55:
373 if (_animationState != 1) {
374 _animationState = 1;
375 _animationFrame = 0;
376 }
377 break;
378 }
379 return true;
380 }
381
QueryAnimationState(int * animationState,int * animationFrame,int * animationStateNext,int * animationNext)382 void AIScriptTyrellGuard::QueryAnimationState(int *animationState, int *animationFrame, int *animationStateNext, int *animationNext) {
383 *animationState = _animationState;
384 *animationFrame = _animationFrame;
385 *animationStateNext = _animationStateNext;
386 *animationNext = _animationNext;
387 }
388
SetAnimationState(int animationState,int animationFrame,int animationStateNext,int animationNext)389 void AIScriptTyrellGuard::SetAnimationState(int animationState, int animationFrame, int animationStateNext, int animationNext) {
390 _animationState = animationState;
391 _animationFrame = animationFrame;
392 _animationStateNext = animationStateNext;
393 _animationNext = animationNext;
394 }
395
ReachedMovementTrackWaypoint(int waypointId)396 bool AIScriptTyrellGuard::ReachedMovementTrackWaypoint(int waypointId) {
397 return true;
398 }
399
FledCombat()400 void AIScriptTyrellGuard::FledCombat() {
401 // return false;
402 }
403
404 } // End of namespace BladeRunner
405