SAGA2: Implement teleport_place console command

This commit is contained in:
Eugene Sandulenko 2022-10-30 23:48:15 +01:00
parent 74577539c1
commit 07cc180374
No known key found for this signature in database
GPG Key ID: 014D387312D34F08
5 changed files with 43 additions and 1 deletions

View File

@ -53,6 +53,7 @@ Console::Console(Saga2Engine *vm) : GUI::Debugger() {
registerCmd("teleport_on_click", WRAP_METHOD(Console, cmdTeleportOnClick));
registerCmd("teleport_on_map", WRAP_METHOD(Console, cmdTeleportOnMap));
registerCmd("teleport", WRAP_METHOD(Console, cmdTeleport));
registerCmd("teleport_place", WRAP_METHOD(Console, cmdTeleportPlace));
registerCmd("teleport_to_npc", WRAP_METHOD(Console, cmdTeleportToNPC));
registerCmd("teleport_npc", WRAP_METHOD(Console, cmdTeleportNPC));
registerCmd("teleport_npc_here", WRAP_METHOD(Console, cmdTeleportNPCHere));
@ -310,6 +311,41 @@ bool Console::cmdTeleportPartyHere(int argc, const char **argv) {
return true;
}
bool Console::cmdTeleportPlace(int argc, const char **argv) {
if (argc < 1)
debugPrintf("Usage: %s <place id>/<place name>\n", argv[0]);
else {
int placenum = -1;
if (!Common::isDigit(argv[1][0])) {
// First, assemble the name
Common::String place = argv[1];
for (int i = 2; i < argc; i++)
place += Common::String(" ") + argv[i];
for (uint i = 0; i < g_vm->_mapFeatures.size(); ++i) {
if (g_vm->_mapFeatures[i] && !place.compareToIgnoreCase(g_vm->_mapFeatures[i]->getText())) {
placenum = i;
break;
}
}
} else {
placenum = atoi(argv[1]);
}
if (placenum == -1) {
debugPrintf("Unknown place\n");
return true;
}
Actor *a = getCenterActor();
a->setLocation(g_vm->_mapFeatures[placenum]->getLocation());
}
return true;
}
bool Console::cmdSaveLoc(int argc, const char **argv) {
if (argc != 1)
debugPrintf("Usage: %s\n", argv[0]);

View File

@ -74,6 +74,8 @@ private:
bool cmdTeleportNPCHere(int argc, const char **argv);
// Input: <None>. Teleport the three brothers to the center actor.
bool cmdTeleportPartyHere(int argc, const char **argv);
// Input: <place id>/<place name>. Teleports the center character to the given place name or number.
bool cmdTeleportPlace(int argc, const char **argv);
// Input: <None>. Saves the current location locally.
bool cmdSaveLoc(int argc, const char **argv);
// Input: <None>. Teleports the center actor to the location saved with cmdSaveLoc.

View File

@ -68,6 +68,9 @@ public:
int16 getV() {
return _featureCoords.v;
}
TilePoint getLocation() {
return _featureCoords;
}
char *getText() {
return _name;
}

View File

@ -39,6 +39,7 @@
#include "saga2/band.h"
#include "saga2/beegee.h"
#include "saga2/calendar.h"
#include "saga2/console.h"
#include "saga2/contain.h"
#include "saga2/detection.h"
#include "saga2/dispnode.h"

View File

@ -30,7 +30,6 @@
#include "engines/advancedDetector.h"
#include "engines/engine.h"
#include "saga2/console.h"
#include "saga2/gfx.h"
#include "saga2/idtypes.h"
#include "saga2/weapons.h"
@ -47,6 +46,7 @@ class MemoryWriteStreamDynamic;
namespace Saga2 {
class ContainerManager;
class Console;
class Timer;
class TimerList;
class BandList;