diff options
author | Nipun Garg | 2019-07-03 05:50:36 +0530 |
---|---|---|
committer | Eugene Sandulenko | 2019-09-03 17:17:08 +0200 |
commit | d88f4fb7c0a8600d57652419faa51b175a0aac10 (patch) | |
tree | 7b12f7709fb6b3db684e98c81976a8d68cae057e | |
parent | 7d08524b77a1bebf2ad5e472442525a57c29b70c (diff) | |
download | scummvm-rg350-d88f4fb7c0a8600d57652419faa51b175a0aac10.tar.gz scummvm-rg350-d88f4fb7c0a8600d57652419faa51b175a0aac10.tar.bz2 scummvm-rg350-d88f4fb7c0a8600d57652419faa51b175a0aac10.zip |
HDB: Add callbackDoorOpenClose() and use function
-rw-r--r-- | engines/hdb/ai-player.cpp | 4 | ||||
-rw-r--r-- | engines/hdb/ai-use.cpp | 24 |
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) { |