aboutsummaryrefslogtreecommitdiff
path: root/engines/hdb/ai-player.cpp
diff options
context:
space:
mode:
authorNipun Garg2019-06-30 03:39:40 +0530
committerEugene Sandulenko2019-09-03 17:17:05 +0200
commitbebb2e39567f24d35a12e875ad7a935e894bfca5 (patch)
tree0e6bf6a361a58bc794b6c5bde0e35d1a3510ff15 /engines/hdb/ai-player.cpp
parent2f67167c272bb25891334de9ee0376dbd37b2763 (diff)
downloadscummvm-rg350-bebb2e39567f24d35a12e875ad7a935e894bfca5.tar.gz
scummvm-rg350-bebb2e39567f24d35a12e875ad7a935e894bfca5.tar.bz2
scummvm-rg350-bebb2e39567f24d35a12e875ad7a935e894bfca5.zip
HDB: Add utility functions
aiAnimateStanddown, aiGenericAction, aiGetItemAction
Diffstat (limited to 'engines/hdb/ai-player.cpp')
-rw-r--r--engines/hdb/ai-player.cpp31
1 files changed, 28 insertions, 3 deletions
diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 8ff503c10c..100f186fef 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -1274,15 +1274,40 @@ void callbackDoorOpenClose(int x, int y) {
// Utility Functions
void aiAnimateStanddown(AIEntity *e, int speed) {
- warning("STUB: AI: aiAnimateStanddown required");
+ if (e->value2-- > 0)
+ return;
+ e->value2 = speed;
+
+ if (e->type == AI_GUY && e->animFrame > 0)
+ e->value2 = 0;
+ e->draw = e->standdownGfx[e->animFrame];
+ e->animFrame++;
+ if (e->animFrame >= e->standdownFrames)
+ e->animFrame = 0;
}
void aiGenericAction(AIEntity *e) {
- warning("STUB: AI: aiGenericAction required");
+ if (!e->goalX)
+ g_hdb->_ai->findPath(e);
+ else if (onEvenTile(e->x, e->y))
+ debug(9, "STUB: Play SND_FOOTSTEPS");
+ g_hdb->_ai->animateEntity(e);
}
void aiGetItemAction(AIEntity *e) {
- warning("STUB: AI: aiGetItemAction required");
+ if (!e->onScreen)
+ return;
+
+ AIEntity *p = g_hdb->_ai->getPlayer();
+ if (abs(p->x - e->x) < 16 && abs(p->y - e->y) < 16 && e->level == p->level) {
+ if (e->aiUse)
+ e->aiUse(e);
+ if (e->luaFuncUse[0])
+ g_hdb->_lua->callFunction(e->luaFuncUse, 0);
+
+ g_hdb->_ai->getItemSound(e->type);
+ g_hdb->_ai->addToInventory(e);
+ }
}
} // End of Namespace