diff options
Diffstat (limited to 'engines')
-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); |