diff options
author | Nipun Garg | 2019-07-03 21:12:52 +0530 |
---|---|---|
committer | Eugene Sandulenko | 2019-09-03 17:17:09 +0200 |
commit | 661ee3b104770ddb801af4aa2ab07df00c494eee (patch) | |
tree | 8721969a8de47efea5b053b8e5c38cf9f278e6c7 /engines/hdb | |
parent | 73b7b830984025a8f5b877652cce758267be43ca (diff) | |
download | scummvm-rg350-661ee3b104770ddb801af4aa2ab07df00c494eee.tar.gz scummvm-rg350-661ee3b104770ddb801af4aa2ab07df00c494eee.tar.bz2 scummvm-rg350-661ee3b104770ddb801af4aa2ab07df00c494eee.zip |
HDB: Add useTarget()
Diffstat (limited to 'engines/hdb')
-rw-r--r-- | engines/hdb/ai-use.cpp | 43 | ||||
-rw-r--r-- | engines/hdb/ai.h | 3 |
2 files changed, 46 insertions, 0 deletions
diff --git a/engines/hdb/ai-use.cpp b/engines/hdb/ai-use.cpp index 37951f97de..f63c608b72 100644 --- a/engines/hdb/ai-use.cpp +++ b/engines/hdb/ai-use.cpp @@ -88,6 +88,49 @@ bool AI::isOpenDoor(int x, int y) { return false; } +bool AI::useTarget(int x, int y, int targetX, int targetY, int newTile, int *worked) { + int tileIndex; + + // open a locked door? + if (isClosedDoor(targetX, targetY)) { + tileIndex = g_hdb->_map->getMapBGTileIndex(targetX, targetY); + + addAnimateTarget(targetX, targetY, tileIndex, tileIndex - 3, ANIM_SLOW, false, true, NULL); + g_hdb->_map->setMapBGTileIndex(x, y, newTile); + if (g_hdb->_map->onScreen(x, y)) + g_hdb->_sound->playSound(SND_DOOR_OPEN_CLOSE); + *worked = 1; + return false; // return FALSE because we need to be able to do it some more + } + + // close an open door? + if (isOpenDoor(targetX, targetY)) { + tileIndex = g_hdb->_map->getMapBGTileIndex(targetX, targetY); + + addAnimateTarget(targetX, targetY, tileIndex, tileIndex + 3, ANIM_SLOW, false, true, NULL); + g_hdb->_map->setMapBGTileIndex(x, y, newTile); + if (g_hdb->_map->onScreen(x, y)) + g_hdb->_sound->playSound(SND_DOOR_OPEN_CLOSE); + *worked = 1; + return false; // return FALSE because we need to be able to do it some more + } + + // open up a bridge? + tileIndex = g_hdb->_map->getMapFGTileIndex(targetX, targetY); + if (tileIndex == _targetBridgeU || + tileIndex == _targetBridgeD || + tileIndex == _targetBridgeL || + tileIndex == _targetBridgeR) { + addBridgeExtend(targetX, targetY, tileIndex); + g_hdb->_map->setMapBGTileIndex(x, y, newTile); + *worked = 1; + return true; // return TRUE because we can't open it again + } + + *worked = 0; + return false; +} + // Black Door Switch bool AI::useSwitch(AIEntity *e, int x, int y, int targetX, int targetY, int onTile) { warning("STUB: Define useSwitch"); diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h index 7a9b74f67c..14495b3c8b 100644 --- a/engines/hdb/ai.h +++ b/engines/hdb/ai.h @@ -1217,6 +1217,9 @@ private: bool isClosedDoor(int x, int y); bool isOpenDoor(int x, int y); + // MAIN FUNCTION : handles all animation of targeted tiles & changing the state of the "switch" + bool useTarget(int x, int y, int targetX, int targetY, int newTile, int *worked); + // Black Door Switch bool useSwitch(AIEntity *e, int x, int y, int targetX, int targetY, int onTile); bool useSwitchOn(AIEntity *e, int x, int y, int targetX, int targetY, int offTile); |