aboutsummaryrefslogtreecommitdiff
path: root/engines/hdb/ai-use.cpp
diff options
context:
space:
mode:
authorNipun Garg2019-07-03 21:12:52 +0530
committerEugene Sandulenko2019-09-03 17:17:09 +0200
commit661ee3b104770ddb801af4aa2ab07df00c494eee (patch)
tree8721969a8de47efea5b053b8e5c38cf9f278e6c7 /engines/hdb/ai-use.cpp
parent73b7b830984025a8f5b877652cce758267be43ca (diff)
downloadscummvm-rg350-661ee3b104770ddb801af4aa2ab07df00c494eee.tar.gz
scummvm-rg350-661ee3b104770ddb801af4aa2ab07df00c494eee.tar.bz2
scummvm-rg350-661ee3b104770ddb801af4aa2ab07df00c494eee.zip
HDB: Add useTarget()
Diffstat (limited to 'engines/hdb/ai-use.cpp')
-rw-r--r--engines/hdb/ai-use.cpp43
1 files changed, 43 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");