From edaeb0f105e7a12c19db01cf897a89d4fba985f5 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 11 Mar 2018 21:56:28 +0100 Subject: BLADERUNNER: Added Moraji actor --- engines/bladerunner/module.mk | 1 + engines/bladerunner/script/ai/moraji.cpp | 464 +++++++++++++++++++++++++++++++ engines/bladerunner/script/ai_script.cpp | 1 + engines/bladerunner/script/ai_script.h | 5 + 4 files changed, 471 insertions(+) create mode 100644 engines/bladerunner/script/ai/moraji.cpp diff --git a/engines/bladerunner/module.mk b/engines/bladerunner/module.mk index 9305922866..0874770276 100644 --- a/engines/bladerunner/module.mk +++ b/engines/bladerunner/module.mk @@ -76,6 +76,7 @@ MODULE_OBJS = \ script/ai/marcus.o \ script/ai/mccoy.o \ script/ai/mia.o \ + script/ai/moraji.o \ script/ai/murray.o \ script/ai/newscaster.o \ script/ai/officer_leary.o \ diff --git a/engines/bladerunner/script/ai/moraji.cpp b/engines/bladerunner/script/ai/moraji.cpp new file mode 100644 index 0000000000..a1896b0e6f --- /dev/null +++ b/engines/bladerunner/script/ai/moraji.cpp @@ -0,0 +1,464 @@ +/* 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 2 + * 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "bladerunner/script/ai_script.h" + +namespace BladeRunner { + +AIScriptMoraji::AIScriptMoraji(BladeRunnerEngine *vm) : AIScriptBase(vm) { + _var1 = 1; + _var2 = 0; +} + +void AIScriptMoraji::Initialize() { + _animationFrame = 0; + _animationState = 0; + _animationStateNext = 0; + _animationNext = 0; + + _var1 = 1; + _var2 = 0; + + Actor_Set_Goal_Number(kActorMoraji, 0); +} + +bool AIScriptMoraji::Update() { + if (Actor_Query_Goal_Number(kActorMoraji) || Player_Query_Current_Scene() != 29 || Game_Flag_Query(269)) { + if (Actor_Query_Goal_Number(kActorMoraji) == 19) { + Actor_Says(kActorMoraji, 80, 13); + _animationState = 9; + _animationFrame = -1; + Actor_Set_Goal_Number(kActorMoraji, 18); + } + return false; + } else { + AI_Countdown_Timer_Reset(kActorMoraji, 2); + AI_Countdown_Timer_Start(kActorMoraji, 2, 30); + Game_Flag_Set(269); + return true; + } + +} + +void AIScriptMoraji::TimerExpired(int timer) { + if (timer != 2) { + return; //false; + } + + AI_Countdown_Timer_Reset(kActorMoraji, 2); + if (Actor_Query_Goal_Number(kActorMoraji) != 20 + && Actor_Query_Goal_Number(kActorMoraji) != 21 + && Actor_Query_Goal_Number(kActorMoraji) != 99) { + Game_Flag_Set(271); + } + return; //true; +} + +void AIScriptMoraji::CompletedMovementTrack() { + if (Actor_Query_Goal_Number(kActorMoraji) != 11) + return; //false + + AI_Countdown_Timer_Reset(kActorMoraji, 2); + Game_Flag_Set(271); + _animationState = 3; + + return; //true; +} + +void AIScriptMoraji::ReceivedClue(int clueId, int fromActorId) { + //return false; +} + +void AIScriptMoraji::ClickedByPlayer() { + //return false; +} + +void AIScriptMoraji::EnteredScene(int sceneId) { + // return false; +} + +void AIScriptMoraji::OtherAgentEnteredThisScene(int otherActorId) { + // return false; +} + +void AIScriptMoraji::OtherAgentExitedThisScene(int otherActorId) { + // return false; +} + +void AIScriptMoraji::OtherAgentEnteredCombatMode(int otherActorId, int combatMode) { + // return false; +} + +void AIScriptMoraji::ShotAtAndMissed() { + // return false; +} + +bool AIScriptMoraji::ShotAtAndHit() { + if (Actor_Query_Goal_Number(kActorMoraji)) { + if (Actor_Query_Goal_Number(kActorMoraji) == 21) { + Game_Flag_Set(713); + Actor_Set_Goal_Number(kActorMoraji, 22); + Actor_Set_Goal_Number(kActorOfficerGrayford, 101); + + return true; + } else { + return false; + } + } else { + Actor_Set_Goal_Number(kActorMoraji, 5); + return true; + } +} + +void AIScriptMoraji::Retired(int byActorId) { + // return false; +} + +int AIScriptMoraji::GetFriendlinessModifierIfGetsClue(int otherActorId, int clueId) { + return 0; +} + +bool AIScriptMoraji::GoalChanged(int currentGoalNumber, int newGoalNumber) { + switch (newGoalNumber) { + case 0: + Actor_Put_In_Set(kActorMoraji, kSetDR05); + Actor_Set_At_XYZ(kActorMoraji, 50.0f, 0.30f, 35.0f, 414); + Actor_Set_Targetable(kActorMoraji, 1); + return false; + case 5: + Actor_Set_Targetable(kActorMoraji, 0); + Sound_Play(4, 100, 0, 0, 50); + _animationState = 10; + _animationFrame = 0; + Actor_Retired_Here(kActorMoraji, 60, 16, 1, -1); + return true; + case 10: + Actor_Set_Targetable(kActorMoraji, 0); + _animationState = 8; + _animationFrame = 1; + return true; + case 11: + _animationState = 3; + _animationFrame = 0; + AI_Movement_Track_Flush(kActorMoraji); + AI_Movement_Track_Append_Run(kActorMoraji, 95, 0); + AI_Movement_Track_Append_Run(kActorMoraji, 96, 0); + AI_Movement_Track_Append_Run(kActorMoraji, 97, 0); + AI_Movement_Track_Append_Run(kActorMoraji, 98, 0); + AI_Movement_Track_Repeat(kActorMoraji); + return true; + case 20: + _animationState = 11; + return true; + case 21: + Actor_Retired_Here(kActorMoraji, 60, 16, 0, -1); + Actor_Set_Targetable(kActorMoraji, 1); + return true; + case 22: + _animationFrame = -1; + _animationState = 13; + return true; + case 23: + Actor_Set_Targetable(kActorMoraji, 0); + _animationState = 14; + Actor_Retired_Here(kActorMoraji, 60, 16, 1, -1); + return true; + break; + case 30: + if (Player_Query_Current_Scene() == 29) { + Game_Flag_Set(515); + Set_Enter(kSetDR01_DR02_DR04, kSetCT05); + } else { + if (Actor_Query_In_Set(kActorMoraji, kSetDR05)) { + Actor_Set_Goal_Number(kActorMoraji, 99); + } else { + Actor_Set_Goal_Number(kActorMoraji, 20); + } + Game_Flag_Set(266); + } + return true; + case 99: + AI_Movement_Track_Flush(kActorMoraji); + AI_Movement_Track_Append(kActorMoraji, 41, 0); + AI_Movement_Track_Repeat(kActorMoraji); + return true; + default: + break; + } + + return false; +} + +bool AIScriptMoraji::UpdateAnimation(int *animation, int *frame) { + switch (_animationState) { + case 0: + *animation = 733; + if (_var2) { + _var2--; + } else { + _animationFrame += _var1; + if (!Random_Query(0, 10)) { + _var1 = -_var1; + } + if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) { + _animationFrame = 0; + } + if (_animationFrame < 0) { + _animationFrame = Slice_Animation_Query_Number_Of_Frames(*animation) - 1; + } + _var2 = Random_Query(0, 1); + } + break; + + case 1: + _animationFrame = 0; + *animation = _animationNext; + _animationState = _animationStateNext; + break; + + case 2: + *animation = 290; + _animationFrame++; + if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(290)) + _animationFrame = 0; + break; + + case 3: + *animation = 732; + _animationFrame++; + if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(732)) + _animationFrame = 0; + break; + + case 4: + break; + + case 5: + *animation = 734; + _animationFrame++; + if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(734)) { + _animationFrame = 0; + _animationState = Random_Query(0, 2) + 5; + } + break; + + case 6: + *animation = 735; + _animationFrame++; + if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(735)) { + _animationFrame = 0; + _animationState = 5; + *animation = 735; + } + break; + + case 7: + *animation = 736; + _animationFrame++; + if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(736)) { + _animationFrame = 0; + _animationState = 5; + *animation = 736; + } + break; + + case 8: + *animation = 737; + _animationFrame++; + if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(737)) { + _animationFrame = 0; + _animationState = 0; + *animation = 733; + Actor_Set_Goal_Number(kActorMoraji, 19); + } + if (_animationFrame == 6) { + Ambient_Sounds_Play_Sound(488, 69, 0, 0, 20); + } + break; + + case 9: + *animation = 742; + _animationFrame++; + if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(742)) { + _animationFrame = 0; + _animationState = 3; + *animation = 732; + Actor_Set_Goal_Number(kActorMoraji, 11); + } + break; + + case 10: + *animation = 738; + if (_animationFrame < Slice_Animation_Query_Number_Of_Frames(738) - 1) { + ++_animationFrame; + } + break; + + case 11: + *animation = 739; + _animationFrame++; + if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(739)) { + Actor_Set_Goal_Number(kActorMoraji, 21); + _animationFrame = 0; + _animationState = 12; + *animation = 740; + } + break; + + case 12: + *animation = 740; + if (_var2) { + _var2--; + } else { + _animationFrame += _var1; + if (!Random_Query(0, 5)) { + _var1 = -_var1; + } + if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) { + _animationFrame = 0; + } + if (_animationFrame < 0) { + _animationFrame = Slice_Animation_Query_Number_Of_Frames(*animation) - 1; + } + _var2 = Random_Query(0, 2); + } + break; + + case 13: + *animation = 741; + _animationFrame++; + if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(741) - 1) { + _animationFrame = Slice_Animation_Query_Number_Of_Frames(*animation) - 1; + Actor_Set_Goal_Number(kActorMoraji, 23); + } + break; + + case 14: + *animation = 741; + _animationFrame = Slice_Animation_Query_Number_Of_Frames(741) - 1; + break; + + default: + break; + } + *frame = _animationFrame; + + return true; +} + +bool AIScriptMoraji::ChangeAnimationMode(int mode) { + switch (mode) { + case 0: + if (_animationState != 12 && Actor_Query_Goal_Number(kActorMoraji) != 11) { + _animationState = 0; + _animationFrame = 0; + } + return 1; + + case 1: + _animationState = 2; + _animationFrame = 0; + return 1; + + case 2: + if (_animationState) { + if (_animationState != 3 || _animationState > 3) { + _animationState = 3; + _animationFrame = 0; + } + } else { + _animationState = 1; + _animationStateNext = 3; + _animationNext = 732; + } + break; + + case 3: + if (_animationState != 12) { + if (_animationState) { + _animationState = 5; + _animationFrame = 0; + } else { + _animationState = 1; + _animationStateNext = 5; + _animationNext = 734; + } + } + break; + + case 12: + if (_animationState) { + _animationState = 6; + _animationFrame = 0; + } else { + _animationState = 1; + _animationStateNext = 6; + _animationNext = 735; + } + break; + + case 13: + if (_animationState) { + _animationState = 7; + _animationFrame = 0; + } else { + _animationState = 1; + _animationStateNext = 7; + _animationNext = 736; + } + break; + + case 48: + _animationState = 13; + _animationFrame = -1; + break; + } + + return true; +} + +void AIScriptMoraji::QueryAnimationState(int *animationState, int *animationFrame, int *animationStateNext, int *animationNext) { + *animationState = _animationState; + *animationFrame = _animationFrame; + *animationStateNext = _animationStateNext; + *animationNext = _animationNext; +} + +void AIScriptMoraji::SetAnimationState(int animationState, int animationFrame, int animationStateNext, int animationNext) { + _animationState = animationState; + _animationFrame = animationFrame; + _animationStateNext = animationStateNext; + _animationNext = animationNext; +} + +bool AIScriptMoraji::ReachedMovementTrackWaypoint(int waypointId) { + if (waypointId == 96) + AI_Countdown_Timer_Reset(kActorMoraji, 2); + + return true; +} + +void AIScriptMoraji::FledCombat() { + // return false; +} + +} // End of namespace BladeRunner diff --git a/engines/bladerunner/script/ai_script.cpp b/engines/bladerunner/script/ai_script.cpp index e2e9e2ad1a..7034fa9a27 100644 --- a/engines/bladerunner/script/ai_script.cpp +++ b/engines/bladerunner/script/ai_script.cpp @@ -62,6 +62,7 @@ AIScripts::AIScripts(BladeRunnerEngine *vm, int actorCount) { _AIScripts[kActorMurray] = new AIScriptMurray(_vm); // 31 _AIScripts[kActorHawkersBarkeep] = new AIScriptHawkersBarkeep(_vm); // 32 _AIScripts[kActorSergeantWalls] = new AIScriptSergeantWalls(_vm); // 34 + _AIScripts[kActorMoraji] = new AIScriptMoraji(_vm); // 35 _AIScripts[kActorHysteriaPatron1] = new AIScriptHysteriaPatron1(_vm); // 47 _AIScripts[kActorHysteriaPatron2] = new AIScriptHysteriaPatron2(_vm); // 48 _AIScripts[kActorHysteriaPatron3] = new AIScriptHysteriaPatron3(_vm); // 49 diff --git a/engines/bladerunner/script/ai_script.h b/engines/bladerunner/script/ai_script.h index b15fc90ca1..f7d5370ebb 100644 --- a/engines/bladerunner/script/ai_script.h +++ b/engines/bladerunner/script/ai_script.h @@ -246,6 +246,11 @@ END_SCRIPT DECLARE_SCRIPT(SergeantWalls) END_SCRIPT +DECLARE_SCRIPT(Moraji) + int _var1; + int _var2; +END_SCRIPT + DECLARE_SCRIPT(HysteriaPatron1) END_SCRIPT -- cgit v1.2.3