diff options
author | Peter Kohaut | 2016-09-10 18:16:17 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2016-09-29 22:33:40 +0200 |
commit | b67bca20b5db7f3d6473341efd7fabfa6532f465 (patch) | |
tree | 6fbbd28dc707dac1c3cacde2e8622cceea6d1b0f /engines/bladerunner/script | |
parent | 2888d0b3460cdca2dd52f8d6aa94b429d46345ad (diff) | |
download | scummvm-rg350-b67bca20b5db7f3d6473341efd7fabfa6532f465.tar.gz scummvm-rg350-b67bca20b5db7f3d6473341efd7fabfa6532f465.tar.bz2 scummvm-rg350-b67bca20b5db7f3d6473341efd7fabfa6532f465.zip |
BLADERUNNER: Pull in changes from madmoose
Diffstat (limited to 'engines/bladerunner/script')
-rw-r--r-- | engines/bladerunner/script/ai_00_mccoy.cpp | 174 | ||||
-rw-r--r-- | engines/bladerunner/script/ai_00_mccoy.h | 45 | ||||
-rw-r--r-- | engines/bladerunner/script/aiscript_officer_leroy.cpp | 87 | ||||
-rw-r--r-- | engines/bladerunner/script/aiscript_officer_leroy.h | 41 | ||||
-rw-r--r-- | engines/bladerunner/script/rc01.cpp | 195 | ||||
-rw-r--r-- | engines/bladerunner/script/script.cpp | 192 | ||||
-rw-r--r-- | engines/bladerunner/script/script.h | 75 |
7 files changed, 748 insertions, 61 deletions
diff --git a/engines/bladerunner/script/ai_00_mccoy.cpp b/engines/bladerunner/script/ai_00_mccoy.cpp new file mode 100644 index 0000000000..2d722f1c8b --- /dev/null +++ b/engines/bladerunner/script/ai_00_mccoy.cpp @@ -0,0 +1,174 @@ +/* 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_00_mccoy.h" + +namespace BladeRunner { + +AIScript_McCoy::AIScript_McCoy(BladeRunnerEngine *vm) + : AIScriptBase(vm) +{} + +void AIScript_McCoy::Initialize() +{ + dword_45A0D0_animation_state = 0; + dword_45A0D4 = 0; + dword_45A0D8 = 0; + dword_45A0DC = 30; + dword_45A0E0 = 1; + dword_45A0E4 = 0; + dword_45A0E8 = 3; +} + +void AIScript_McCoy::UpdateAnimation(int *animation, int *frame) +{ + *animation = *frame = 0; + switch (dword_45A0D0_animation_state) + { + case 0: + *animation = 19; + if (dword_45A0D8 < dword_45A0DC) + { + *frame = dword_45A0E8; + dword_45A0D4 += dword_45A0E0; + if (dword_45A0D4 > dword_45A0E8) + { + dword_45A0D4 = dword_45A0E8; + dword_45A0E0 = -1; + } + else + { + *frame = dword_45A0D4; + if (dword_45A0D4 < dword_45A0E4) + { + dword_45A0D4 = dword_45A0E4; + dword_45A0E0 = 1; + *frame = dword_45A0E4; + } + } + dword_45A0D8++; + } + else + { + dword_45A0D4 += dword_45A0E0; + dword_45A0DC = 0; + if (dword_45A0D4 == 18 && Random_Query(0, 2)) + { + dword_45A0E0 = -1; + dword_45A0D8 = 0; + dword_45A0E4 = 14; + dword_45A0E8 = 18; + dword_45A0DC = Random_Query(0, 30); + } + if (dword_45A0D4 == 26) + { + if (Random_Query(0, 2)) + { + dword_45A0E0 = -1; + dword_45A0D8 = 0; + dword_45A0E4 = 23; + dword_45A0E8 = 26; + dword_45A0DC = Random_Query(0, 30); + } + } + if (dword_45A0D4 >= Slice_Animation_Query_Number_Of_Frames(19)) + { + dword_45A0D4 = 0; + if (Random_Query(0, 2)) + { + dword_45A0D8 = 0; + dword_45A0E4 = 0; + dword_45A0E8 = 3; + dword_45A0DC = Random_Query(0, 45); + } + } + *frame = dword_45A0D4; + if (dword_45A0D4 < 0) + { + *frame = Slice_Animation_Query_Number_Of_Frames(19) - 1; + dword_45A0D4 = *frame; + } + } + break; + + // Continue walking (follows state 32) + case 30: + *animation = 13; + if (++dword_45A0D4 >= Slice_Animation_Query_Number_Of_Frames(13)) + dword_45A0D4 = 0; + *frame = dword_45A0D4; + + if (dword_45A0D4 == 2) + ; //Sound_Right_Footstep_Walk(0); + else if (dword_45A0D4 == 10) + ; //Sound_Left_Footstep_Walk(0); + + break; + + // Start walking + case 32: + dword_45A0D4 = 1; + dword_45A0D0_animation_state = 30; + *animation = 13; + *frame = 1; + break; + + case 58: + *animation = 47; + if (dword_45A0D4++ == 5) { + int stepSound; + switch (Random_Query(0, 2)) { + case 0: + stepSound = 595; + break; + case 1: + stepSound = 594; + break; + default: + stepSound = 593; + } + (void)stepSound; + // Ambient_Sounds_Play_Sound(stepSound, 39, 0, 0, 99); + } + if (dword_45A0D4 > Slice_Animation_Query_Number_Of_Frames(*animation) - 2) + dword_45A0D4 = 0; + *frame = dword_45A0D4; + break; + } +} + +void AIScript_McCoy::ChangeAnimationMode(int mode) +{ + switch (mode) + { + case 0: + dword_45A0D0_animation_state = 0; + dword_45A0D4 = 0; + break; + + case 1: + dword_45A0D0_animation_state = 32; + break; + } +} + +} // End of namespace BladeRunner diff --git a/engines/bladerunner/script/ai_00_mccoy.h b/engines/bladerunner/script/ai_00_mccoy.h new file mode 100644 index 0000000000..11c9f1d8cb --- /dev/null +++ b/engines/bladerunner/script/ai_00_mccoy.h @@ -0,0 +1,45 @@ +/* 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/script.h" + +#include "bladerunner/bladerunner.h" + +namespace BladeRunner { + +class AIScript_McCoy : public AIScriptBase { + int dword_45A0D0_animation_state; + int dword_45A0D4; + int dword_45A0D8; + int dword_45A0DC; + int dword_45A0E0; + int dword_45A0E4; + int dword_45A0E8; +public: + AIScript_McCoy(BladeRunnerEngine *vm); + + void Initialize(); + void UpdateAnimation(int *animation, int *frame); + void ChangeAnimationMode(int mode); +}; + +} // End of namespace BladeRunner diff --git a/engines/bladerunner/script/aiscript_officer_leroy.cpp b/engines/bladerunner/script/aiscript_officer_leroy.cpp new file mode 100644 index 0000000000..1acb096b01 --- /dev/null +++ b/engines/bladerunner/script/aiscript_officer_leroy.cpp @@ -0,0 +1,87 @@ +/* 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/aiscript_officer_leroy.h" + +namespace BladeRunner { + +AIScript_Officer_Leroy::AIScript_Officer_Leroy(BladeRunnerEngine *vm) + : AIScriptBase(vm) +{} + +void AIScript_Officer_Leroy::Initialize() +{ + var_45D5B0_animation_state = 0; + var_45D5B4_frame = 0; + var_45D5B8 = 0; + + Actor_Put_In_Set(23, 69); + Actor_Set_At_XYZ(23, -261.80f, 6.00f, 79.58f, 512); + // Actor_Set_Goal_Number(23, 0); + // Actor_Set_Frame_Rate_FPS(23, 8); +} + +void AIScript_Officer_Leroy::UpdateAnimation(int *animation, int *frame) +{ + if (var_45D5B8 == 0) { + *animation = 589; + var_45D5B4_frame++; + + if (var_45D5B4_frame >= Slice_Animation_Query_Number_Of_Frames(589)) + { + var_45D5B4_frame = 0; + var_45D5B8 = Random_Query(0, 2); + } + } else if (var_45D5B8 == 1) { + *animation = 590; + var_45D5B4_frame++; + + if (var_45D5B4_frame >= Slice_Animation_Query_Number_Of_Frames(590)) + { + var_45D5B4_frame = 0; + var_45D5B8 = Random_Query(0, 2); + } + } else if (var_45D5B8 == 2) { + *animation = 591; + var_45D5B4_frame++; + + if (var_45D5B4_frame >= Slice_Animation_Query_Number_Of_Frames(591)) + { + var_45D5B4_frame = 0; + var_45D5B8 = Random_Query(0, 2); + } + } + + *frame = var_45D5B4_frame; +} + +void AIScript_Officer_Leroy::ChangeAnimationMode(int mode) +{ + switch (mode) + { + case 1: + var_45D5B0_animation_state = 32; + break; + } +} + +} // End of namespace BladeRunner diff --git a/engines/bladerunner/script/aiscript_officer_leroy.h b/engines/bladerunner/script/aiscript_officer_leroy.h new file mode 100644 index 0000000000..7d81b625e9 --- /dev/null +++ b/engines/bladerunner/script/aiscript_officer_leroy.h @@ -0,0 +1,41 @@ +/* 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/script.h" + +#include "bladerunner/bladerunner.h" + +namespace BladeRunner { + +class AIScript_Officer_Leroy : public AIScriptBase { + int var_45D5B0_animation_state; + int var_45D5B4_frame; + int var_45D5B8; +public: + AIScript_Officer_Leroy(BladeRunnerEngine *vm); + + void Initialize(); + void UpdateAnimation(int *animation, int *frame); + void ChangeAnimationMode(int mode); +}; + +} // End of namespace BladeRunner diff --git a/engines/bladerunner/script/rc01.cpp b/engines/bladerunner/script/rc01.cpp index 73a5f899ac..fa1e42de2e 100644 --- a/engines/bladerunner/script/rc01.cpp +++ b/engines/bladerunner/script/rc01.cpp @@ -26,9 +26,12 @@ #include "bladerunner/audio_player.h" #include "bladerunner/bladerunner.h" +#include "common/debug.h" + namespace BladeRunner { void ScriptRC01::InitializeScene() { + // Game_Flag_Set(24); if (!Game_Flag_Query(24)) { Ambient_Sounds_Remove_All_Non_Looping_Sounds(1); Ambient_Sounds_Remove_All_Looping_Sounds(1); @@ -38,7 +41,7 @@ void ScriptRC01::InitializeScene() { Outtake_Play(33, 1); // DSCENT_E.VQA } - Game_Flag_Set(9); // Force flag 9 so McCoy will be in view + // Game_Flag_Set(9); // Force flag 9 so McCoy will be in view if (Game_Flag_Query(9)) { Setup_Scene_Information(-171.16, 5.55, 27.28, 616); } else if (Game_Flag_Query(114)) { @@ -46,6 +49,7 @@ void ScriptRC01::InitializeScene() { } else { Setup_Scene_Information( -10.98, -0.30, 318.15, 616); } + // Setup_Scene_Information(-151.98, -0.30, 318.15, 616); Scene_Exit_Add_2D_Exit(0, 314, 145, 340, 255, 0); if (Game_Flag_Query(249)) @@ -118,7 +122,67 @@ void ScriptRC01::InitializeScene() { } void ScriptRC01::SceneLoaded() { - if (!Game_Flag_Query(24)){ + Obstacle_Object("HYDRANT02", 1); + Obstacle_Object("PARKING METER 04", 1); + Obstacle_Object("CHEVY PROP", 1); + Obstacle_Object("PARKING METER 01", 1); + Obstacle_Object("T-CAN01", 1); + Obstacle_Object("BARICADE01", 1); + Obstacle_Object("BARICADE02", 1); + Obstacle_Object("DOOR LEFT", 1); + Unobstacle_Object("BOX06", 1); + Clickable_Object("DOORWAY01"); + Clickable_Object("DOOR LEFT"); + Clickable_Object("HYDRANT02"); + Clickable_Object("T-CAN01"); + Clickable_Object("BARICADE01"); + Clickable_Object("70_1"); + Clickable_Object("70_2"); + Clickable_Object("70_3"); + Clickable_Object("70_5"); + Clickable_Object("70_6"); + Unclickable_Object("BARICADE02"); + Unclickable_Object("BARICADE05"); + Unclickable_Object("SPINNER BODY"); + Unclickable_Object("HORSE01"); + Unclickable_Object("DOORWAY01"); + Unobstacle_Object("DOORWAY01", 1); + + if (Game_Flag_Query(186)) { + Unclickable_Object("70_1"); + Unclickable_Object("70_2"); + Unclickable_Object("70_3"); + Unclickable_Object("70_5"); + Unclickable_Object("70_6"); + Unclickable_Object("BARICADE01"); + Unclickable_Object("BARICADE03"); + Unclickable_Object("BARICADE04"); + Unobstacle_Object("70_1", 1); + Unobstacle_Object("70_2", 1); + Unobstacle_Object("70_3", 1); + Unobstacle_Object("70_5", 1); + Unobstacle_Object("70_6", 1); + Unobstacle_Object("BARICADE01", 1); + Unobstacle_Object("BARICADE02", 1); + Unobstacle_Object("BARICADE03", 1); + Unobstacle_Object("BARICADE04", 1); + Unobstacle_Object("BARICADE05", 1); + } + + if (!Game_Flag_Query(186)) { + Preload(13); + Preload(14); + Preload(19); + Preload(582); + Preload(589); + } + + /* + if (!Game_Flag_Query(163)) + Item_Add_To_World(66, 938, 69, -148.60f, -0.30f, 225.15f, 256, 24, 24, 0, 1, 0, 1); + */ + + if (!Game_Flag_Query(24)) { // ADQ_Flush(); Actor_Voice_Over(1830, 99); Actor_Voice_Over(1850, 99); @@ -131,6 +195,99 @@ void ScriptRC01::SceneLoaded() { } } +void ScriptRC01::sub_403850() +{ + if (Game_Flag_Query(186)) + return; + + if (Loop_Actor_Walk_To_Scene_Object(0, "BARICADE03", 36, 1, 0)) + return; + + Actor_Set_Goal_Number(23, 0); + Actor_Face_Object(0, "BARICADE03", 1); + // Loop_Actor_Walk_To_Actor(23, 0, 36, 1, 0); + Actor_Face_Actor(23, 0, 1); + Actor_Says(0, 4500, 14); + I_Sez("MG: We don't want any of that abstract art oozing out onto the street."); + Actor_Says(23, 10, 14); + Actor_Set_Goal_Number(23, 1); +} + +bool ScriptRC01::ClickedOn3DObject(const char *objectName) { + if (Object_Query_Click("BARICADE01", objectName) + || Object_Query_Click("BARICADE03", objectName) + || Object_Query_Click("BARICADE04", objectName) + || Object_Query_Click("70_1", objectName) + || Object_Query_Click("70_2", objectName) + || Object_Query_Click("70_3", objectName) + || Object_Query_Click("70_5", objectName) + || Object_Query_Click("70_6", objectName)) + { + sub_403850(); + return true; + } + + if (Object_Query_Click("HYDRANT02", objectName)) { + if (Loop_Actor_Walk_To_Scene_Object(0, "HYDRANT02", 60, 1, 0) == 0) { + if (Actor_Clue_Query(0, 26)) { + Actor_Says(0, 6975, 3); + } else { + Actor_Face_Object(0, "HYDRANT02", 1); + Actor_Voice_Over(1880, 99); + Actor_Voice_Over(1890, 99); + I_Sez("JM: That McCoy--he's one funny guy! Jet-black fire truck, hehehehe..."); + Actor_Clue_Acquire(0, 26, 1, -1); + } + } + return true; + } + + if (Object_Query_Click("DOOR LEFT", objectName)) + { + if (!Loop_Actor_Walk_To_Scene_Object(0, "DOOR LEFT", 48, 1, 0)) + { + Actor_Face_Object(0, "DOOR LEFT", 1); + if (Actor_Clue_Query(0, 2) || !Actor_Query_In_Set(23, 69) || Global_Variable_Query(1) != 1) + { + Actor_Says(0, 8570, 14); + } + else + { + Actor_Set_Goal_Number(23, 0); + Actor_Face_Actor(23, 0, 1); + Actor_Says(23, 0, 12); + Actor_Says(0, 4495, 13); + Actor_Clue_Acquire(0, 2, 1, 23); + } + Actor_Clue_Acquire(0, 1, 1, -1); + } + return true; + } + + if (Object_Query_Click("T-CAN01", objectName)) + { + if (!Loop_Actor_Walk_To_Scene_Object(0, "T-CAN01", 24, 1, 0)) + { + Actor_Face_Object(0, "T-CAN01", 1); + Actor_Voice_Over(1810, 99); + Actor_Voice_Over(1820, 99); + } + return true; + } + + return false; +} + +bool ScriptRC01::ClickedOn2DRegion(int region) { + if (region == 0) { + sub_403850(); + return 1; + } + + return 0; +} + + void ScriptRC01::SceneFrameAdvanced(int frame) { if (frame == 1) Sound_Play(118, 40, 0, 0, 50); // CARDOWN3.AUD @@ -154,11 +311,41 @@ void ScriptRC01::SceneFrameAdvanced(int frame) { Sound_Play(118, 40, 80, 80, 50); // CARDOWN3.AUD } - void ScriptRC01::SceneActorChangedGoal(int actorId, int newGoal, int oldGoal, bool currentSet) { - } +void ScriptRC01::PlayerWalkedIn() +{ + if (Game_Flag_Query(249) && !Game_Flag_Query(9) && !Game_Flag_Query(114)) { + // Extract to sub_4037AC(): + Player_Loses_Control(); + Game_Flag_Set(182); + Actor_Set_Immunity_To_Obstacles(0, true); + Loop_Actor_Walk_To_XYZ(0, -151.98, -0.30, 318.15, 0, 0, 0, 0); + Actor_Set_Immunity_To_Obstacles(0, false); + Player_Gains_Control(); + } + + if (Game_Flag_Query(114)) { + Player_Loses_Control(); + Loop_Actor_Walk_To_XYZ(0, -415.98, -0.30, 262.15, 0, 0, 0, 0); + Player_Gains_Control(); + Game_Flag_Reset(114); + } + + if (Game_Flag_Query(9)) { + Player_Loses_Control(); + Loop_Actor_Walk_To_XYZ(0, -203.45, 5.55, 85.05, 0, 0, 0, 0); + Player_Gains_Control(); + Game_Flag_Reset(9); + if (Game_Flag_Query(1) && !Game_Flag_Query(4)) { + Actor_Voice_Over(1910, 99); + Actor_Voice_Over(1920, 99); + Actor_Voice_Over(1930, 99); + Game_Flag_Set(4); + } + } +} } // End of namespace BladeRunner diff --git a/engines/bladerunner/script/script.cpp b/engines/bladerunner/script/script.cpp index c71326d75e..c93c5db4e4 100644 --- a/engines/bladerunner/script/script.cpp +++ b/engines/bladerunner/script/script.cpp @@ -24,21 +24,27 @@ #include "bladerunner/bladerunner.h" +#include "bladerunner/actor.h" +#include "bladerunner/actor_combat.h" #include "bladerunner/ambient_sounds.h" #include "bladerunner/audio_player.h" #include "bladerunner/audio_speech.h" #include "bladerunner/clues.h" +#include "bladerunner/combat.h" #include "bladerunner/gameflags.h" #include "bladerunner/gameinfo.h" +#include "bladerunner/settings.h" +#include "bladerunner/set_effects.h" #include "bladerunner/scene.h" +#include "bladerunner/scene_objects.h" +#include "bladerunner/slice_animations.h" +#include "bladerunner/slice_renderer.h" #include "bladerunner/text_resource.h" #include "bladerunner/vector.h" -#include "bladerunner/slice_renderer.h" -#include "bladerunner/actor.h" #include "bladerunner/waypoints.h" -#include "bladerunner/slice_animations.h" -#include "bladerunner/combat.h" -#include "bladerunner/settings.h" + +#include "bladerunner/script/ai_00_mccoy.h" +#include "bladerunner/script/aiscript_officer_leroy.h" namespace BladeRunner { @@ -47,8 +53,6 @@ bool Script::open(const Common::String &name) { if (name == "RC01") { _currentScript = new ScriptRC01(_vm); return true; } - _currentScript = new ScriptRC01(_vm); return true; - return false; } @@ -68,6 +72,26 @@ void Script::SceneLoaded() { _inScriptCounter--; } +bool Script::ClickedOn3DObject(const char *objectName) { + if (_inScriptCounter > 0) + return true; + + _inScriptCounter++; + bool result = _currentScript->ClickedOn3DObject(objectName); + _inScriptCounter--; + return result; +} + +bool Script::ClickedOn2DRegion(int region) { + if (_inScriptCounter > 0) + return true; + + _inScriptCounter++; + bool result = _currentScript->ClickedOn2DRegion(region); + _inScriptCounter--; + return result; +} + void Script::SceneFrameAdvanced(int frame) { _inScriptCounter++; _currentScript->SceneFrameAdvanced(frame); @@ -80,6 +104,12 @@ void Script::SceneActorChangedGoal(int actorId, int newGoal, int oldGoal, bool c _inScriptCounter--; } +void Script::PlayerWalkedIn() { + _inScriptCounter++; + _currentScript->PlayerWalkedIn(); + _inScriptCounter--; +} + void ScriptBase::Preload(int animationId) { _vm->_sliceRenderer->preload(animationId); } @@ -88,12 +118,12 @@ void ScriptBase::Actor_Put_In_Set(int actorId, int setId) { _vm->_actors[actorId]->setSetId(setId); } -void ScriptBase::Actor_Set_At_XYZ(int actorId, float x, float y, float z, int angle) { - _vm->_actors[actorId]->set_at_xyz(Vector3(x, y, z), angle, true, 0, 0); +void ScriptBase::Actor_Set_At_XYZ(int actorId, float x, float y, float z, int direction) { + _vm->_actors[actorId]->setAtXYZ(Vector3(x, y, z), direction); } void ScriptBase::Actor_Set_At_Waypoint(int actorId, int waypointId, int angle) { - _vm->_actors[actorId]->set_at_waypoint(waypointId, angle, 0, 0); + _vm->_actors[actorId]->setAtWaypoint(waypointId, angle, 0, 0); } bool ScriptBase::Region_Check(int left, int top, int right, int down) { @@ -101,10 +131,16 @@ bool ScriptBase::Region_Check(int left, int top, int right, int down) { return false; } -// ScriptBase::Object_Query_Click -// ScriptBase::Object_Do_Ground_Click +bool ScriptBase::Object_Query_Click(const char *objectName1, const char *objectName2) { + return strcmp(objectName1, objectName2) == 0; +} + +void ScriptBase::Object_Do_Ground_Click() { + //This is not implemented in game + return; +} -bool ScriptBase::Object_Mark_For_Hot_Mouse(char *objectName) { +bool ScriptBase::Object_Mark_For_Hot_Mouse(const char *objectName) { int objectId = _vm->_scene->findObject(objectName); if (objectId == -1) return false; @@ -115,7 +151,7 @@ void ScriptBase::Actor_Face_Actor(int actorId, int otherActorId, bool animate) { _vm->_actors[actorId]->faceActor(otherActorId, animate); } -void ScriptBase::Actor_Face_Object(int actorId, char *objectName, bool animate) { +void ScriptBase::Actor_Face_Object(int actorId, const char *objectName, bool animate) { _vm->_actors[actorId]->faceObject(objectName, animate); } @@ -242,7 +278,7 @@ void ScriptBase::Actor_Set_Health(int actorId, int hp, int maxHp) { void ScriptBase::Actor_Set_Targetable(int actorId, bool targetable) { _vm->_actors[actorId]->setTargetable(targetable); - + } void ScriptBase::Actor_Says(int actorId, int sentenceId, int animationMode){ @@ -302,6 +338,29 @@ void ScriptBase::Actor_Says_With_Pause(int actorId, int sentenceId, float pause, Player_Gains_Control(); } +#if 0 +void ScriptBase::Actor_Voice_Over(int sentenceId, int actorId) { + // Wait for any existing speech to end + _vm->loopActorSpeaking(); + + // TODO: Hack - This needs to go through the actor class + char name[13]; + sprintf(name, "%02d-%04d.AUD", actorId, sentenceId); + _vm->_audioSpeech->playSpeech(name); + + // warning("start voice over loop"); + while (true) + { + _vm->gameTick(); + if (_vm->shouldQuit()) + break; + if (!_vm->_audioSpeech->isPlaying()) + break; + } + // warning("end voice over loop"); +} +#endif + void ScriptBase::Actor_Voice_Over(int sentenceId, int actorId) { _vm->gameWaitForActive(); _vm->loopActorSpeaking(); @@ -328,7 +387,7 @@ void ScriptBase::Actor_Start_Speech_Sample(int actorId, int sentenceId) { } void ScriptBase::Actor_Start_Voice_Over_Sample(int sentenceId) { - _vm->loopActorSpeaking(); + _vm->loopActorSpeaking(); _vm->_voiceoverActor->speechPlay(sentenceId, true); } @@ -397,11 +456,11 @@ int ScriptBase::Actor_Query_Facing_1024(int actorId) { } void ScriptBase::Actor_Set_Frame_Rate_FPS(int actorId, int fps) { - _vm->_actors[actorId]->setFps(fps); + _vm->_actors[actorId]->setFPS(fps); } -int ScriptBase::Slice_Animation_Query_Number_Of_Frames(int animationId) { - return _vm->_sliceAnimations->getNumberOfFrames(animationId); +int ScriptBase::Slice_Animation_Query_Number_Of_Frames(int animation) { + return _vm->_sliceAnimations->getFrameCount(animation); } void ScriptBase::Actor_Change_Animation_Mode(int actorId, int animationMode) { @@ -414,9 +473,21 @@ int ScriptBase::Actor_Query_Animation_Mode(int actorId) { // ScriptBase::Loop_Actor_Walk_To_Actor // ScriptBase::Loop_Actor_Walk_To_Item -// ScriptBase::Loop_Actor_Walk_To_Scene_Object + +bool ScriptBase::Loop_Actor_Walk_To_Scene_Object(int actorId, const char *objectName, int distance, int a4, int a5) { + _vm->gameWaitForActive(); + + _vm->_actors[actorId]->loopWalkToSceneObject(objectName); + + return false; +} + // ScriptBase::Loop_Actor_Walk_To_Waypoint -// ScriptBase::Loop_Actor_Walk_To_XYZ + +void ScriptBase::Loop_Actor_Walk_To_XYZ(int actorId, float x, float y, float z, int a4, int a5, int a6, int a7) { + _vm->loopActorWalkToXYZ(actorId, x, y, z, a4, a5, a6, a7); +} + // ScriptBase::Async_Actor_Walk_To_Waypoint // ScriptBase::Async_Actor_Walk_To_XYZ // ScriptBase::Actor_Force_Stop_Walking @@ -487,30 +558,28 @@ int ScriptBase::Animation_Skip_To_Frame() { return 0; } - void ScriptBase::Delay(int miliseconds) { Player_Loses_Control(); int endTime = _vm->getTotalPlayTime() + miliseconds; while ((int)_vm->getTotalPlayTime() < endTime) _vm->gameTick(); Player_Gains_Control(); - } void ScriptBase::Player_Loses_Control() { - _vm->playerLosesControl(); + _vm->playerLosesControl(); } void ScriptBase::Player_Gains_Control() { - _vm->playerGainsControl(); + _vm->playerGainsControl(); } void ScriptBase::Player_Set_Combat_Mode(bool activate) { - if(!_vm->_combat->isActive() || activate) { - if(_vm->_combat->isActive() && activate) { + if (!_vm->_combat->isActive() || activate) { + if (_vm->_combat->isActive() && activate) { _vm->_combat->activate(); } - }else { + } else { _vm->_combat->deactivate(); } } @@ -520,9 +589,9 @@ bool ScriptBase::Player_Query_Combat_Mode() { } void ScriptBase::Player_Set_Combat_Mode_Access(bool enable) { - if(enable) { + if (enable) { _vm->_combat->enable(); - }else { + } else { _vm->_combat->disable(); } } @@ -547,6 +616,7 @@ int ScriptBase::Query_Difficulty_Level() { return _vm->_settings->getDifficulty(); } + void ScriptBase::Game_Flag_Set(int flag) { _vm->_gameFlags->set(flag); } @@ -614,11 +684,17 @@ void ScriptBase::Sound_Play(int id, int volume, int panFrom, int panTo, int prio // ScriptBase::Overlay_Remove void ScriptBase::Scene_Loop_Set_Default(int a) { - debug("Scene_Loop_Set_Default(%d)", a); + // debug("Scene_Loop_Set_Default(%d)", a); + + _vm->_scene->loopSetDefault(a); + // _vm->_scene->_defaultLoop = a; } void ScriptBase::Scene_Loop_Start_Special(int a, int b, int c) { - debug("Scene_Loop_Start_Special(%d, %d, %d)", a, b, c); + // debug("Scene_Loop_Start_Special(%d, %d, %d)", a, b, c); + + _vm->_scene->loopStartSpecial(a, b, c); + // _vm->_scene->_field_24_loop_start_special_param_1 = a; } void ScriptBase::Outtake_Play(int id, int noLocalization, int container) { @@ -725,7 +801,7 @@ void ScriptBase::Scene_2D_Region_Remove(int index) { // ScriptBase::Query_Score void ScriptBase::Set_Score(int a0, int a1) { - debug("STUB: Set_Score(%d, %d)", a0, a1); + // debug("STUB: Set_Score(%d, %d)", a0, a1); } void ScriptBase::Give_McCoy_Ammo(int ammoType, int ammo) { @@ -757,32 +833,32 @@ void ScriptBase::Actor_Retired_Here(int actorId, int width, int height, int reti Vector3 actorPosition; actor->getXYZ(&actorPosition.x, &actorPosition.y, &actorPosition.z); actor->retire(retired, width, height, retiredByActorId); - actor->set_at_xyz(actorPosition, actor->getFacing(), true, 0, true); + actor->setAtXYZ(actorPosition, actor->getFacing(), true, 0, true); _vm->_sceneObjects->setRetired(actorId, true); } -void ScriptBase::Clickable_Object(char *objectName) { +void ScriptBase::Clickable_Object(const char *objectName) { int objectId = _vm->_scene->findObject(objectName); if (objectId == -1) return; _vm->_scene->objectSetIsClickable(objectId, true, !_vm->_sceneIsLoading); } -void ScriptBase::Unclickable_Object(char *objectName) { +void ScriptBase::Unclickable_Object(const char *objectName) { int objectId = _vm->_scene->findObject(objectName); if (objectId == -1) return; _vm->_scene->objectSetIsClickable(objectId, false, !_vm->_sceneIsLoading); } -void ScriptBase::Obstacle_Object(char *objectName, bool updateWalkpath) { +void ScriptBase::Obstacle_Object(const char *objectName, bool updateWalkpath) { int objectId = _vm->_scene->findObject(objectName); if (objectId == -1) return; _vm->_scene->objectSetIsObstacle(objectId, true, !_vm->_sceneIsLoading, !_vm->_sceneIsLoading && updateWalkpath); } -void ScriptBase::Unobstacle_Object(char *objectName, bool updateWalkpath) { +void ScriptBase::Unobstacle_Object(const char *objectName, bool updateWalkpath) { int objectId = _vm->_scene->findObject(objectName); if (objectId == -1) return; @@ -793,18 +869,18 @@ void ScriptBase::Obstacle_Flag_All_Objects(bool isObstacle) { _vm->_scene->objectSetIsObstacleAll(isObstacle, !_vm->_sceneIsLoading); } -void ScriptBase::Combat_Target_Object(char *objectName) { +void ScriptBase::Combat_Target_Object(const char *objectName) { int objectId = _vm->_scene->findObject(objectName); if (objectId == -1) return; - _vm->_scene->objectSetIsCombatTarget(objectId, true, !_vm->_sceneIsLoading); + _vm->_scene->objectSetIsTarget(objectId, true, !_vm->_sceneIsLoading); } -void ScriptBase::Un_Combat_Target_Object(char *objectName) { +void ScriptBase::Un_Combat_Target_Object(const char *objectName) { int objectId = _vm->_scene->findObject(objectName); if (objectId == -1) return; - _vm->_scene->objectSetIsCombatTarget(objectId, true, !_vm->_sceneIsLoading); + _vm->_scene->objectSetIsTarget(objectId, true, !_vm->_sceneIsLoading); } void ScriptBase::Set_Fade_Color(float r, float g, float b) { @@ -841,5 +917,37 @@ void ScriptBase::I_Sez(const char *str) { _vm->ISez(str); } +AIScripts::AIScripts(BladeRunnerEngine *vm) + : _vm(vm), + _inScriptCounter(0) +{ + for (int i = 0; i != 100; ++i) + _AIScripts[i] = 0; + + _AIScripts[0] = new AIScript_McCoy(_vm); + _AIScripts[23] = new AIScript_Officer_Leroy(_vm); +} + +void AIScripts::Initialize(int actor) +{ + if (_AIScripts[actor]) + _AIScripts[actor]->Initialize(); +} + +void AIScripts::UpdateAnimation(int actor, int *animation, int *frame) +{ + _inScriptCounter++; + if (_AIScripts[actor]) + _AIScripts[actor]->UpdateAnimation(animation, frame); + _inScriptCounter--; +} + +void AIScripts::ChangeAnimationMode(int actor, int mode) +{ + _inScriptCounter++; + if (_AIScripts[actor]) + _AIScripts[actor]->ChangeAnimationMode(mode); + _inScriptCounter--; +} } // End of namespace BladeRunner diff --git a/engines/bladerunner/script/script.h b/engines/bladerunner/script/script.h index 97db6eb425..8f38657ae0 100644 --- a/engines/bladerunner/script/script.h +++ b/engines/bladerunner/script/script.h @@ -42,15 +42,15 @@ public: protected: void Preload(int animationId); - void Actor_Put_In_Set(int actorId, int setId); - void Actor_Set_At_XYZ(int actorId, float x, float y, float z, int angle); + void Actor_Put_In_Set(int id, int set); + void Actor_Set_At_XYZ(int actorId, float x, float y, float z, int direction); void Actor_Set_At_Waypoint(int actorId, int waypointId, int angle); bool Region_Check(int left, int top, int right, int down); - // Object_Query_Click - // Object_Do_Ground_Click - bool Object_Mark_For_Hot_Mouse(char *objectName); + bool Object_Query_Click(const char *objectName1, const char *objectName2); + void Object_Do_Ground_Click(); + bool Object_Mark_For_Hot_Mouse(const char *objectName); void Actor_Face_Actor(int actorId, int otherActorId, bool animate); - void Actor_Face_Object(int actorId, char *objectName, bool animate); + void Actor_Face_Object(int actorId, const char *objectName, bool animate); void Actor_Face_Item(int actorId, int itemId, bool animate); void Actor_Face_Waypoint(int actorId, int waypointId, bool animate); void Actor_Face_XYZ(int actorId, float x, float y, float z, bool animate); @@ -103,9 +103,9 @@ protected: int Actor_Query_Animation_Mode(int actorId); // Loop_Actor_Walk_To_Actor // Loop_Actor_Walk_To_Item - // Loop_Actor_Walk_To_Scene_Object + bool Loop_Actor_Walk_To_Scene_Object(int actorId, const char *objectName, int distance, int a4, int a5); // Loop_Actor_Walk_To_Waypoint - // Loop_Actor_Walk_To_XYZ + void Loop_Actor_Walk_To_XYZ(int actorId, float x, float y, float z, int a4, int a5, int a6, int a7); // Async_Actor_Walk_To_Waypoint // Async_Actor_Walk_To_XYZ // Actor_Force_Stop_Walking @@ -241,13 +241,13 @@ protected: void Disable_Shadows(int *animationsIdsList, int listSize); bool Query_System_Currently_Loading_Game(); void Actor_Retired_Here(int actorId, int width, int height, int retired, int retiredByActorId); - void Clickable_Object(char *objectName); - void Unclickable_Object(char *objectName); - void Obstacle_Object(char *objectName, bool updateWalkpath); - void Unobstacle_Object(char *objectName, bool updateWalkpath); + void Clickable_Object(const char *objectName); + void Unclickable_Object(const char *objectName); + void Obstacle_Object(const char *objectName, bool updateWalkpath); + void Unobstacle_Object(const char *objectName, bool updateWalkpath); void Obstacle_Flag_All_Objects(bool isObstacle); - void Combat_Target_Object(char *objectName); - void Un_Combat_Target_Object(char *objectName); + void Combat_Target_Object(const char *objectName); + void Un_Combat_Target_Object(const char *objectName); void Set_Fade_Color(float r, float g, float b); void Set_Fade_Density(float density); void Set_Fog_Color(char* fogName, float r, float g, float b); @@ -268,10 +268,17 @@ public: virtual void InitializeScene() = 0; virtual void SceneLoaded() = 0; + virtual bool ClickedOn3DObject(const char *objectName) = 0; + virtual bool ClickedOn2DRegion(int region) = 0; virtual void SceneFrameAdvanced(int frame) = 0; virtual void SceneActorChangedGoal(int actorId, int newGoal, int oldGoal, bool currentSet) = 0; + virtual void PlayerWalkedIn() = 0; }; +/* + * Scene Scripts + */ + class Script { public: BladeRunnerEngine *_vm; @@ -289,8 +296,11 @@ public: void InitializeScene(); void SceneLoaded(); + bool ClickedOn3DObject(const char *objectName); + bool ClickedOn2DRegion(int region); void SceneFrameAdvanced(int frame); void SceneActorChangedGoal(int actorId, int newGoal, int oldGoal, bool currentSet); + void PlayerWalkedIn(); }; #define DECLARE_SCRIPT(name) \ @@ -301,14 +311,49 @@ public: \ {} \ void InitializeScene(); \ void SceneLoaded(); \ + bool ClickedOn3DObject(const char *objectName); \ + bool ClickedOn2DRegion(int region); \ void SceneFrameAdvanced(int frame); \ void SceneActorChangedGoal(int actorId, int newGoal, int oldGoal, bool currentSet); \ -}; + void PlayerWalkedIn(); \ +private: +#define END_SCRIPT }; DECLARE_SCRIPT(RC01) + void sub_403850(); +END_SCRIPT #undef DECLARE_SCRIPT +/* + * Actor Scripts + */ + +class AIScriptBase : public ScriptBase { +public: + AIScriptBase(BladeRunnerEngine *vm) + : ScriptBase(vm) + {} + + virtual void Initialize() = 0; + virtual void UpdateAnimation(int *animation, int *frame) = 0; + virtual void ChangeAnimationMode(int mode) = 0; +}; + +class AIScripts { +public: + BladeRunnerEngine *_vm; + int _inScriptCounter; + AIScriptBase *_AIScripts[100]; + + AIScripts(BladeRunnerEngine *vm); + ~AIScripts(); + + void Initialize(int actor); + void UpdateAnimation(int actor, int *animation, int *frame); + void ChangeAnimationMode(int actor, int mode); +}; + } // End of namespace BladeRunner #endif |