aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorNipun Garg2019-06-25 00:35:53 +0530
committerEugene Sandulenko2019-09-03 17:16:59 +0200
commitfcdd7511d1a9648b9692fb05cc93eeaa6fedfc02 (patch)
tree5b8302ef1e215f59b8c8e02211560648968df387 /engines
parentb9b19478942727f84e42df81295b61fff322780d (diff)
downloadscummvm-rg350-fcdd7511d1a9648b9692fb05cc93eeaa6fedfc02.tar.gz
scummvm-rg350-fcdd7511d1a9648b9692fb05cc93eeaa6fedfc02.tar.bz2
scummvm-rg350-fcdd7511d1a9648b9692fb05cc93eeaa6fedfc02.zip
HDB: Add findPath()
Diffstat (limited to 'engines')
-rw-r--r--engines/hdb/ai-funcs.cpp54
-rw-r--r--engines/hdb/ai.h1
-rw-r--r--engines/hdb/hdb.h6
-rw-r--r--engines/hdb/map-loader.h13
4 files changed, 71 insertions, 3 deletions
diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 585d33356c..f13e9d575a 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -1375,6 +1375,60 @@ int AI::checkForTouchplate(int x, int y) {
return 0;
}
+bool AI::findPath(AIEntity *e) {
+ int x, y, xv = 0, yv = 0, max;
+ ArrowPath *here;
+
+ // Initial Pointing Direction to search in
+ x = e->tileX;
+ y = e->tileY;
+ here = findArrowPath(x, y);
+ // Only look for GO arrows at this first location
+ if (here && here->type == 1)
+ e->dir = here->dir;
+
+ switch (e->dir) {
+ case DIR_UP:
+ yv = -1;
+ break;
+ case DIR_DOWN:
+ yv = 1;
+ break;
+ case DIR_LEFT:
+ xv = -1;
+ break;
+ case DIR_RIGHT:
+ xv = 1;
+ break;
+ case DIR_NONE:
+ warning("findPath: DIR_NONE found");
+ break;
+ }
+
+ if (xv)
+ max = g_hdb->_map->_width;
+ else
+ max = g_hdb->_map->_height;
+
+ ArrowPath *arrowPath;
+ uint32 flags;
+ while (max--) {
+ arrowPath = findArrowPath(x + xv, y + yv);
+ if (arrowPath) {
+ setEntityGoal(e, arrowPath->tileX, arrowPath->tileY);
+ return true;
+ } else {
+ flags = g_hdb->_map->getMapBGTileFlags(x + xv, y + yv);
+ if (flags & kFlagSolid)
+ return false;
+ }
+ x += xv;
+ y += yv;
+ }
+
+ return false;
+}
+
AIEntity *AI::legalMove(int tileX, int tileY, int level, int *result) {
uint32 bgFlags = g_hdb->_map->getMapBGTileFlags(tileX, tileY);
uint32 fgFlags = g_hdb->_map->getMapFGTileFlags(tileX, tileY);
diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h
index b5cf719fd0..bd25f555fa 100644
--- a/engines/hdb/ai.h
+++ b/engines/hdb/ai.h
@@ -654,6 +654,7 @@ public:
void moveEnts();
int checkForTouchplate(int x, int y);
+ bool findPath(AIEntity *e);
AIEntity *legalMove(int tileX, int tileY, int level, int *result);
AIEntity *legalMoveOverWater(int tileX, int tileY, int level, int *result);
AIEntity *legalMoveOverWaterIgnore(int tileX, int tileY, int level, int *result, AIEntity *ignore);
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index 139d610964..319db920b4 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -70,10 +70,13 @@ enum GameState {
};
enum Flag {
+ kFlagMonsterBlock = 0x2,
kFlagSolid = 0x3,
kFlagPlayerDie = 0x8,
kFlagInvisible = 0x20,
kFlagForeground = 0x80,
+ kFlagSlime = 0x201C,
+ kFlagWater = 0x401C,
kFlagEnergyFloor = 0x40000,
kFlagPlasmaFloor = 0x6000D,
kFlagRadFloor = 0x6800D,
@@ -81,9 +84,10 @@ enum Flag {
kFlagStairTop = 0x400000,
kFlagAnimSlow = 0x800000,
kFlagAnimMedium = 0x1000000,
+ kFlagMasked = 0x2000000,
kFlagAnimFast = 0x1800000,
kFlagGrating = 0x4000000,
- kFlagMasked = 0x2000000
+ kFlagPlummet = 0x8000000
};
enum {
diff --git a/engines/hdb/map-loader.h b/engines/hdb/map-loader.h
index f59159a699..69c82a8ee5 100644
--- a/engines/hdb/map-loader.h
+++ b/engines/hdb/map-loader.h
@@ -77,6 +77,16 @@ public:
void drawGratings();
void drawForegrounds();
+ bool isLoaded() {
+ return _mapLoaded;
+ }
+
+ bool onScreen(int x, int y) {
+ if ((x >= _mapX / kTileWidth) && (x < (_mapX / kTileWidth) + kScreenXTiles) && (y >= _mapY / kTileHeight) && (y < (_mapY / kTileHeight) + kScreenYTiles))
+ return true;
+ return false;
+ }
+
uint32 getMapBGTileFlags(int x, int y);
uint32 getMapFGTileFlags(int x, int y);
uint16 getMapBGTileIndex(int x, int y);
@@ -95,6 +105,7 @@ public:
// Check if one of the tiles in a range exists in the map on either layer
bool checkOneTileExistInRange(int tileIndex, int count);
+ uint16 _width, _height;
int _mapX, _mapY; // Coordinates of Map
int _mapTileX, _mapTileY; // Tile Coordinates of Map
int _mapTileXOff, _mapTileYOff; // Tile Coordinates Offset (0-31)
@@ -112,8 +123,6 @@ public:
private:
char _name[32];
- uint16 _width;
- uint16 _height;
uint32 _backgroundOffset;
uint32 _foregroundOffset;
uint16 _iconNum;