From bebb2e39567f24d35a12e875ad7a935e894bfca5 Mon Sep 17 00:00:00 2001 From: Nipun Garg Date: Sun, 30 Jun 2019 03:39:40 +0530 Subject: HDB: Add utility functions aiAnimateStanddown, aiGenericAction, aiGetItemAction --- engines/hdb/ai-player.cpp | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'engines') 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 -- cgit v1.2.3