[Scummvm-git-logs] scummvm branch-2-8 -> 4ea4bcd12c71aa7e992974c643e0e2275ff44aa5
antoniou79
noreply at scummvm.org
Thu Jan 25 20:29:50 UTC 2024
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
4ea4bcd12c BLADERUNNER: Debugger commands ammo and sound
Commit: 4ea4bcd12c71aa7e992974c643e0e2275ff44aa5
https://github.com/scummvm/scummvm/commit/4ea4bcd12c71aa7e992974c643e0e2275ff44aa5
Author: antoniou79 (a.antoniou79 at gmail.com)
Date: 2024-01-25T22:29:36+02:00
Commit Message:
BLADERUNNER: Debugger commands ammo and sound
Ammo is to show or add ammo for McCoy, sound is to play sound effects
Also made minor improvements to usability of cmdSay() and cmdMusic()
Changed paths:
engines/bladerunner/debugger.cpp
engines/bladerunner/debugger.h
diff --git a/engines/bladerunner/debugger.cpp b/engines/bladerunner/debugger.cpp
index f9248d83c97..ab7f628e6df 100644
--- a/engines/bladerunner/debugger.cpp
+++ b/engines/bladerunner/debugger.cpp
@@ -23,6 +23,7 @@
#include "bladerunner/actor.h"
#include "bladerunner/ambient_sounds.h"
+#include "bladerunner/audio_player.h"
#include "bladerunner/bladerunner.h"
#include "bladerunner/boundingbox.h"
#include "bladerunner/combat.h"
@@ -123,6 +124,7 @@ Debugger::Debugger(BladeRunnerEngine *vm) : GUI::Debugger() {
registerCmd("loop", WRAP_METHOD(Debugger, cmdLoop));
registerCmd("pos", WRAP_METHOD(Debugger, cmdPosition));
registerCmd("music", WRAP_METHOD(Debugger, cmdMusic));
+ registerCmd("sound", WRAP_METHOD(Debugger, cmdSoundFX));
registerCmd("say", WRAP_METHOD(Debugger, cmdSay));
registerCmd("scene", WRAP_METHOD(Debugger, cmdScene));
registerCmd("var", WRAP_METHOD(Debugger, cmdVariable));
@@ -142,6 +144,7 @@ Debugger::Debugger(BladeRunnerEngine *vm) : GUI::Debugger() {
registerCmd("difficulty", WRAP_METHOD(Debugger, cmdDifficulty));
registerCmd("outtake", WRAP_METHOD(Debugger, cmdOuttake));
registerCmd("playvqa", WRAP_METHOD(Debugger, cmdPlayVqa));
+ registerCmd("ammo", WRAP_METHOD(Debugger, cmdAmmo));
#if BLADERUNNER_ORIGINAL_BUGS
#else
registerCmd("effect", WRAP_METHOD(Debugger, cmdEffect));
@@ -719,64 +722,106 @@ const char* kMusicTracksArr[] = {"Animoid Row (G)", // kMusicAra
"Love Theme"}; // kMusicLoveSong
bool Debugger::cmdMusic(int argc, const char** argv) {
- if (argc != 2) {
+ bool invalidSyntax = false;
+
+ if (argc == 2) {
+ Common::String trackArgStr = argv[1];
+ if (trackArgStr == "list") {
+ for (int i = 0; i < (int)_vm->_gameInfo->getMusicTrackCount(); ++i) {
+ debugPrintf("%2d - %s\n", i, kMusicTracksArr[i]);
+ }
+ return true;
+
+ } else if (trackArgStr == "stop") {
+ _vm->_music->stop(0u);
+ //_vm->_ambientSounds->removeLoopingSound(kSfxMUSBLEED, 0);
+ } else if (Common::isDigit(*argv[1])) {
+ int musicId = atoi(argv[1]);
+
+ if ((musicId == 0 && !isAllZeroes(trackArgStr))
+ || musicId < 0
+ || musicId >= (int)_vm->_gameInfo->getMusicTrackCount()) {
+ debugPrintf("Invalid music track id specified.\nPlease choose an integer between 0 and %d.\n", (int)_vm->_gameInfo->getMusicTrackCount() - 1);
+ return true;
+
+ } else {
+ _vm->_music->stop(0u);
+ _vm->_music->play(_vm->_gameInfo->getMusicTrack(musicId), 100, 0, 0, -1, kMusicLoopPlayOnce, 0);
+ //debugPrintf("Now playing track %2d - \"%s\" (%s)\n", musicId, kMusicTracksArr[musicId], _vm->_gameInfo->getMusicTrack(musicId).c_str());
+ debugPrintf("Now playing track %2d - \"%s\"\n", musicId, kMusicTracksArr[musicId]);
+ return false;
+
+ }
+ //_vm->_ambientSounds->removeLoopingSound(kSfxMUSBLEED, 0);
+ //_vm->_ambientSounds->addLoopingSound(kSfxMUSBLEED, 100, 0, 0);
+ } else {
+ invalidSyntax = true;
+ }
+ } else {
+ invalidSyntax = true;
+ }
+
+ if (invalidSyntax) {
debugPrintf("Play the specified music track, list the available tracks\nor stop the current playing track.\n");
debugPrintf("Usage: %s (list|stop|<musicId>)\n", argv[0]);
debugPrintf("musicId can be in [0, %d]\n", (int)_vm->_gameInfo->getMusicTrackCount() - 1);
- return true;
}
+ return true;
+}
- Common::String trackArgStr = argv[1];
- if (trackArgStr == "list") {
- for (int i = 0; i < (int)_vm->_gameInfo->getMusicTrackCount(); ++i) {
- debugPrintf("%2d - %s\n", i, kMusicTracksArr[i]);
- }
- return true;
- } else if (trackArgStr == "stop") {
- _vm->_music->stop(0u);
- //_vm->_ambientSounds->removeLoopingSound(kSfxMUSBLEED, 0);
- } else {
- int musicId = atoi(argv[1]);
+bool Debugger::cmdSoundFX(int argc, const char** argv) {
+ bool invalidSyntax = false;
+ // Play the specified (by id) Sound Effect (similar to ScriptBase::Sound_Play())
+ if (argc == 2 && Common::isDigit(*argv[1])) {
+ int sfxId = atoi(argv[1]);
+ if (sfxId >= 0 && sfxId < (int)_vm->_gameInfo->getSfxTrackCount()) {
+ _vm->_audioPlayer->playAud(_vm->_gameInfo->getSfxTrack(sfxId), 100, 0, 0, 50);
+ return false;
- if ((musicId == 0 && !isAllZeroes(trackArgStr))
- || musicId < 0
- || musicId >= (int)_vm->_gameInfo->getMusicTrackCount()) {
- debugPrintf("Invalid music track id specified.\nPlease choose an integer between 0 and %d.\n", (int)_vm->_gameInfo->getMusicTrackCount() - 1);
- return true;
} else {
- _vm->_music->stop(0u);
- _vm->_music->play(_vm->_gameInfo->getMusicTrack(musicId), 100, 0, 0, -1, kMusicLoopPlayOnce, 0);
- //debugPrintf("Now playing track %2d - \"%s\" (%s)\n", musicId, kMusicTracksArr[musicId], _vm->_gameInfo->getMusicTrack(musicId).c_str());
- debugPrintf("Now playing track %2d - \"%s\"\n", musicId, kMusicTracksArr[musicId]);
+ debugPrintf("soundId can be in [0, %d]\n", (int)_vm->_gameInfo->getSfxTrackCount() - 1);
}
- //_vm->_ambientSounds->removeLoopingSound(kSfxMUSBLEED, 0);
- //_vm->_ambientSounds->addLoopingSound(kSfxMUSBLEED, 100, 0, 0);
+ } else {
+ invalidSyntax = true;
}
- return false;
+
+ if (invalidSyntax) {
+ debugPrintf("Play the specified sound effect id.\n");
+ debugPrintf("Usage: %s <soundFXId>\n", argv[0]);
+ debugPrintf("soundId can be in [0, %d]\n", (int)_vm->_gameInfo->getSfxTrackCount() - 1);
+ }
+ return true;
}
bool Debugger::cmdSay(int argc, const char **argv) {
- if (argc != 3) {
- debugPrintf("Actor will say specified line.\n");
- debugPrintf("Usage: %s <actorId> <sentenceId>\n", argv[0]);
- return true;
- }
+ bool invalidSyntax = false;
- int actorId = atoi(argv[1]);
- int sentenceId = atoi(argv[2]);
+ if (argc == 3 && Common::isDigit(*argv[1]) && Common::isDigit(*argv[2])) {
+ int actorId = atoi(argv[1]);
+ int sentenceId = atoi(argv[2]);
- Actor *actor = nullptr;
- if ((actorId >= 0 && actorId < (int)_vm->_gameInfo->getActorCount()) || (actorId == kActorVoiceOver)) {
- actor = _vm->_actors[actorId];
- }
+ Actor *actor = nullptr;
+ if ((actorId >= 0 && actorId < (int)_vm->_gameInfo->getActorCount()) || (actorId == kActorVoiceOver)) {
+ actor = _vm->_actors[actorId];
+ }
- if (actor == nullptr) {
- debugPrintf("Unknown actor %i\n", actorId);
- return true;
+ if (actor == nullptr) {
+ debugPrintf("Unknown actor %i\n", actorId);
+ return true;
+
+ }
+ actor->speechPlay(sentenceId, true);
+ return false;
+
+ } else {
+ invalidSyntax = true;
}
- actor->speechPlay(sentenceId, true);
- return false;
+ if (invalidSyntax) {
+ debugPrintf("Actor will say the specified line.\n");
+ debugPrintf("Usage: %s <actorId> <sentenceId>\n", argv[0]);
+ }
+ return true;
}
const struct SceneList {
@@ -3106,4 +3151,115 @@ bool Debugger::cmdPlayVqa(int argc, const char** argv) {
return false;
}
+/**
+* Auxiliary function to get a descriptive string for a given ammo type
+*/
+Common::String Debugger::getAmmoTypeDescription(int ammoType) {
+ Common::String ammoTypeStr;
+ switch (ammoType) {
+ default:
+ // fall through
+ case 0:
+ ammoTypeStr = Common::String::format("Plain (%d)", 0);
+ break;
+ case 1:
+ ammoTypeStr = Common::String::format("Bob's bullets (%d)", 1);
+ break;
+ case 2:
+ ammoTypeStr = Common::String::format("Izo's stash (%d)", 2);
+ break;
+ }
+ return ammoTypeStr;
+
+}
+
+/**
+* Show or add to McCoy's ammo for an ammo type
+* Note: We add and not set, as adding is directly supported by the scripts,
+* whereas setting the value explicitly is not and could cause side-effects (eg. ammoType 0 should never get 0 ammo).
+*/
+bool Debugger::cmdAmmo(int argc, const char** argv) {
+ bool invalidSyntax = false;
+
+ if (_vm->_settings->getDifficulty() == kGameDifficultyEasy) {
+ debugPrintf("---\nNote: Currently playing in Easy Mode.\nAll ammo is infinite, regardless of the amount shown or added here\n---\n");
+ }
+
+ if (argc == 1) {
+ for (int i = 0; i < _vm->_settings->getAmmoTypesCount(); ++i) {
+ if (i == 0 || _vm->_settings->getDifficulty() == kGameDifficultyEasy) {
+ debugPrintf("Current ammo for ammo type: %s is infinite (%d)\n", getAmmoTypeDescription(i).c_str(), _vm->_settings->getAmmo(i));
+ } else {
+ debugPrintf("Current ammo for ammo type: %s is: %d\n", getAmmoTypeDescription(i).c_str(), _vm->_settings->getAmmo(i));
+ }
+ }
+ return true;
+
+ } else if (argc == 2 || argc == 3) {
+ if (Common::isDigit(*argv[1])) {
+ int argAmmoType = atoi(argv[1]);
+ if (argAmmoType >= 0 && argAmmoType < _vm->_settings->getAmmoTypesCount()) {
+ if (argc == 2) {
+ if (argAmmoType == 0 || _vm->_settings->getDifficulty() == kGameDifficultyEasy) {
+ debugPrintf("Current ammo for ammo type: %s is infinite (%d)\n", getAmmoTypeDescription(argAmmoType).c_str(), _vm->_settings->getAmmo(argAmmoType));
+ } else {
+ debugPrintf("Current ammo for ammo type: %s is: %d\n", getAmmoTypeDescription(argAmmoType).c_str(), _vm->_settings->getAmmo(argAmmoType));
+ }
+ return true;
+
+ } else { // argc == 3
+ if (Common::isDigit(*argv[2])) {
+ int argAmmoAmmount = atoi(argv[2]);
+ if (argAmmoAmmount >= 0) {
+ if (argAmmoType == 0) {
+ debugPrintf("Current ammo for ammo type: %s is infinite (%d)\n", getAmmoTypeDescription(argAmmoType).c_str(), _vm->_settings->getAmmo(argAmmoType));
+ } else {
+ if (_vm->_kia->isOpen()) {
+ debugPrintf("Sorry, modifying ammo when KIA is open is not supported\n");
+ } else {
+ _vm->_settings->addAmmo(argAmmoType, argAmmoAmmount);
+ if ( _vm->_settings->getDifficulty() == kGameDifficultyEasy) {
+ debugPrintf("Current ammo for ammo type: %s is infinite (%d)\n", getAmmoTypeDescription(argAmmoType).c_str(), _vm->_settings->getAmmo(argAmmoType));
+ } else {
+ debugPrintf("Current ammo for ammo type: %s set to: %d\n", getAmmoTypeDescription(argAmmoType).c_str(), _vm->_settings->getAmmo(argAmmoType));
+ }
+ }
+ }
+ return true;
+
+ } else {
+ debugPrintf("Error - Please specify and valid ammo amount to add\n");
+ return true;
+
+ }
+ } else {
+ invalidSyntax = true;
+ }
+ }
+ } else {
+ debugPrintf("Invalid ammo type specified. Valid values are 0 - %d\n", _vm->_settings->getAmmoTypesCount() - 1);
+ return true;
+
+ }
+ } else {
+ invalidSyntax = true;
+ }
+ } else {
+ invalidSyntax = true;
+ }
+
+ if (invalidSyntax) {
+ // invalid syntax
+ debugPrintf("Show or add to McCoy's ammo amount for an ammo type\n");
+ debugPrintf("Valid ammo types: \n");
+ for (int i = 0; i < _vm->_settings->getAmmoTypesCount(); ++i) {
+ debugPrintf("%d: %s\n", i, getAmmoTypeDescription(i).c_str());
+ }
+ debugPrintf("Usage 1: %s\n", argv[0]);
+ debugPrintf("Usage 2: %s <ammoType>\n", argv[0]);
+ debugPrintf("Usage 3: %s <ammo type> <ammo amount to add>\n", argv[0]);
+ }
+ return true;
+}
+
} // End of namespace BladeRunner
diff --git a/engines/bladerunner/debugger.h b/engines/bladerunner/debugger.h
index 5dfff041b89..a2b72e94dcc 100644
--- a/engines/bladerunner/debugger.h
+++ b/engines/bladerunner/debugger.h
@@ -116,6 +116,7 @@ public:
bool cmdLoop(int argc, const char **argv);
bool cmdPosition(int argc, const char **argv);
bool cmdMusic(int argc, const char** argv);
+ bool cmdSoundFX(int argc, const char** argv);
bool cmdSay(int argc, const char **argv);
bool cmdScene(int argc, const char **argv);
bool cmdVariable(int argc, const char **argv);
@@ -134,6 +135,7 @@ public:
bool cmdDifficulty(int argc, const char **argv);
bool cmdOuttake(int argc, const char** argv);
bool cmdPlayVqa(int argc, const char** argv);
+ bool cmdAmmo(int argc, const char** argv);
#if BLADERUNNER_ORIGINAL_BUGS
#else
bool cmdEffect(int argc, const char **argv);
@@ -142,6 +144,7 @@ public:
bool cmdVk(int argc, const char **argv);
Common::String getDifficultyDescription(int difficultyValue);
+ Common::String getAmmoTypeDescription(int ammoType);
void drawDebuggerOverlay();
void drawBBox(Vector3 start, Vector3 end, View *view, Graphics::Surface *surface, int color);
More information about the Scummvm-git-logs
mailing list