diff options
author | Nipun Garg | 2019-06-19 22:46:33 +0530 |
---|---|---|
committer | Eugene Sandulenko | 2019-09-03 17:16:50 +0200 |
commit | c31fb72e698ae481d7dc13daeb7a43326386abae (patch) | |
tree | ecabfbfe1406731096f68550dc23af731c3bcc26 /engines | |
parent | 977a264462ee32c3a83aaeaa165deeaabd41b7dc (diff) | |
download | scummvm-rg350-c31fb72e698ae481d7dc13daeb7a43326386abae.tar.gz scummvm-rg350-c31fb72e698ae481d7dc13daeb7a43326386abae.tar.bz2 scummvm-rg350-c31fb72e698ae481d7dc13daeb7a43326386abae.zip |
HDB: Add lookAtXY and lookAtEntity
Diffstat (limited to 'engines')
-rw-r--r-- | engines/hdb/ai-funcs.cpp | 55 | ||||
-rw-r--r-- | engines/hdb/ai.h | 5 |
2 files changed, 60 insertions, 0 deletions
diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp index 32a473479f..bf55c392b0 100644 --- a/engines/hdb/ai-funcs.cpp +++ b/engines/hdb/ai-funcs.cpp @@ -100,4 +100,59 @@ bool AI::walkThroughEnt(AIType type) { void AI::getItemSound(AIType type) { warning("STUB: AI: getItemSound required"); } + +void AI::lookAtEntity(AIEntity *e) { + lookAtXY(e->tileX, e->tileY); +} + +// Change player direction to XY +void AI::lookAtXY(int x, int y) { + int distX, distY; + + distX = abs(_player->tileX - x); + distY = abs(_player->tileY - y); + + if (distX > distY) { + // X takes precedence + if (x < _player->tileX) { + _player->dir = DIR_LEFT; + } else if (x > _player->tileX) { + _player->dir = DIR_RIGHT; + } else if (y < _player->tileY) { + _player->dir = DIR_UP; + } else { + _player->dir = DIR_DOWN; + } + } else { + // Y takes precedence + if (y < _player->tileY) { + _player->dir = DIR_UP; + } else if (y > _player->tileY) { + _player->dir = DIR_DOWN; + } else if (x < _player->tileX) { + _player->dir = DIR_LEFT; + } else { + _player->dir = DIR_RIGHT; + } + } + + switch (_player->dir) { + case DIR_UP: + _player->state = STATE_STANDUP; + warning("STUB: Set _player->draw to Player standup_gfx"); + break; + case DIR_DOWN: + _player->state = STATE_STANDDOWN; + warning("STUB: Set _player->draw to Player standdown_gfx"); + break; + case DIR_LEFT: + _player->state = STATE_STANDLEFT; + warning("STUB: Set _player->draw to Player standleft_gfx"); + break; + case DIR_RIGHT: + _player->state = STATE_STANDRIGHT; + warning("STUB: Set _player->draw to Player standright_gfx"); + break; + } +} } // End of Namespace diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h index 84423dfb8a..1c2f07a90e 100644 --- a/engines/hdb/ai.h +++ b/engines/hdb/ai.h @@ -404,6 +404,7 @@ public: bool getTableEnt(AIType type); bool walkThroughEnt(AIType type); void getItemSound(AIType type); + void lookAtEntity(AIEntity *e); // Player Functions AIEntity *getPlayer() { @@ -475,6 +476,10 @@ public: void cineFadeIn(bool isBlack, int steps); void cineFadeOut(bool isBlack, int steps); + // Waypoint & Movement Functions + void lookAtXY(int x, int y); + + // Cinematic Variables Common::Array<CineCommand *> _cine; private: |