aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/hdb/ai-player.cpp4
-rw-r--r--engines/hdb/ai-use.cpp24
2 files changed, 22 insertions, 6 deletions
diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 6a32df5f2d..ca5797c591 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -1444,10 +1444,6 @@ void aiNoneInit2(AIEntity *e) {
warning("STUB: AI: aiNoneInit2 required");
}
-void callbackDoorOpenClose(int x, int y) {
- warning("STUB: AI: callbackDoorOpenClose required");
-}
-
// Utility Functions
void aiAnimateStanddown(AIEntity *e, int speed) {
if (e->value2-- > 0)
diff --git a/engines/hdb/ai-use.cpp b/engines/hdb/ai-use.cpp
index 83a294d86a..188244ce1f 100644
--- a/engines/hdb/ai-use.cpp
+++ b/engines/hdb/ai-use.cpp
@@ -67,10 +67,30 @@ bool AI::useTouchplateOn(AIEntity *e, int x, int y, int targetX, int targetY, in
return false;
}
+void callbackDoorOpenClose(int x, int y) {
+ int tileIndex = g_hdb->_map->getMapBGTileIndex(x, y);
+
+ // is the door gonna close on something? if so, wait again
+ if (!g_hdb->_ai->findEntity(x, y)) {
+ g_hdb->_ai->addCallback(CALLBACK_DOOR_OPEN_CLOSE, x, y, kDelay5Seconds);
+ return;
+ }
+
+ g_hdb->_ai->addAnimateTarget(x, y, tileIndex, tileIndex + 3, ANIM_SLOW, false, true, NULL);
+ if (g_hdb->_map->onScreen(x, y))
+ warning("STUB: Play SND_DOOR_OPEN_CLOSE");
+ return;
+}
+
// Normal Door
bool AI::useDoorOpenClose(AIEntity *e, int x, int y) {
- warning("STUB: Define useDoorOpenClose");
- return false;
+ int tileIndex = g_hdb->_map->getMapBGTileIndex(x, y);
+
+ addAnimateTarget(x, y, tileIndex, tileIndex - 3, ANIM_SLOW, false, true, NULL);
+ addCallback(CALLBACK_DOOR_OPEN_CLOSE, x, y, kDelay5Seconds);
+ if (g_hdb->_map->onScreen(x, y))
+ warning("Play SND_DOOR_OPEN_CLOSE");
+ return true;
}
void callbackAutoDoorOpenClose(int x, int y) {