diff options
author | Nipun Garg | 2019-06-25 00:32:23 +0530 |
---|---|---|
committer | Eugene Sandulenko | 2019-09-03 17:16:59 +0200 |
commit | 70888532f8d6ab04b612eafe7de0256f0ce39172 (patch) | |
tree | 692894adc22c0fb933e398c6d3ec99ec5edfe8cd /engines | |
parent | 12a677d9007b93893fab0c223a297a5a5c207693 (diff) | |
download | scummvm-rg350-70888532f8d6ab04b612eafe7de0256f0ce39172.tar.gz scummvm-rg350-70888532f8d6ab04b612eafe7de0256f0ce39172.tar.bz2 scummvm-rg350-70888532f8d6ab04b612eafe7de0256f0ce39172.zip |
HDB: Add checkPlayerCollision functions
Diffstat (limited to 'engines')
-rw-r--r-- | engines/hdb/ai-funcs.cpp | 22 | ||||
-rw-r--r-- | engines/hdb/ai.h | 4 |
2 files changed, 26 insertions, 0 deletions
diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp index 4d265d1e8d..585d33356c 100644 --- a/engines/hdb/ai-funcs.cpp +++ b/engines/hdb/ai-funcs.cpp @@ -1452,6 +1452,28 @@ AIEntity *AI::legalMoveOverWaterIgnore(int tileX, int tileY, int level, int *res return hit; } +AIEntity *AI::playerCollision(int topBorder, int bottomBorder, int leftBorder, int rightBorder) { + AIEntity *e; + for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) { + e = *it; + if (e == _player || !e->onScreen) + continue; + if (e->x > (_player->x - 32 - leftBorder) && e->x < (_player->x + 32 + rightBorder) && e->y >(_player->y - 32 - topBorder) && e->y < (_player->y + 32 + bottomBorder)) + return e; + } + return NULL; +} + +bool AI::checkPlayerTileCollision(int x, int y) { + debug(9, "STUB: checkPlayerTileCollison: g_hdb->getDebug() required"); + return (_player->tileX == x && _player->tileY == y); +} + +bool AI::checkPlayerCollision(int x, int y, int border) { + debug(9, "STUB: checkPlayerCollison: g_hdb->getDebug() required"); + return (x > (_player->x - 32 + border) && x < (_player->x - 32 - border) && y >(_player->y - 32 + border) && y < (_player->y - 32 - border)); +} + bool AI::checkFloating(int x, int y) { for (Common::Array<AIEntity *>::iterator it = _floats->begin(); it != _floats->end(); it++) { if ((*it)->tileX == x && (*it)->tileY == y) diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h index 04c20187d3..9c49e3e14d 100644 --- a/engines/hdb/ai.h +++ b/engines/hdb/ai.h @@ -652,6 +652,10 @@ public: void addAnimateTarget(int x, int y, int start, int end, AnimSpeed speed, bool killAuto, bool inMap, const char *tileName); void animateTargets(); + AIEntity *playerCollision(int topBorder, int bottomBorder, int leftBorder, int rightBorder); + bool checkPlayerTileCollision(int x, int y); + bool checkPlayerCollision(int x, int y, int border); + // List functions void addToActionList(int actionIndex, int x, int y, char *funcLuaInit, char *funcLuaUse); bool checkActionList(AIEntity *e, int x, int y, bool lookAndGrab); |