From 63358b754e54ed96324bd42bbb2780c8f0302cf3 Mon Sep 17 00:00:00 2001 From: Nipun Garg Date: Tue, 25 Jun 2019 01:03:38 +0530 Subject: HDB: Add aiTurnBot functions --- engines/hdb/ai-bots.cpp | 53 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'engines/hdb/ai-bots.cpp') diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp index 24e9cfb116..f3c89dccd3 100644 --- a/engines/hdb/ai-bots.cpp +++ b/engines/hdb/ai-bots.cpp @@ -169,4 +169,57 @@ void aiOmniBotMissileAction(AIEntity *e) { } } +void aiTurnBotInit(AIEntity *e) { + e->aiAction = aiTurnBotAction; +} + +void aiTurnBotInit2(AIEntity *e) { + e->draw = g_hdb->_ai->getStandFrameDir(e); +} + +void aiTurnBotChoose(AIEntity *e) { + int xvAhead[5] = { 9, 0, 0, -1, 1 }, yvAhead[5] = { 9, -1, 1, 0, 0 }; + AIDir turnRight[5] = { DIR_NONE, DIR_RIGHT, DIR_LEFT, DIR_UP, DIR_DOWN }; + AIState dirState[5] = { STATE_NONE, STATE_MOVEUP, STATE_MOVEDOWN, STATE_MOVELEFT, STATE_MOVERIGHT }; + int xv, yv; + + xv = xvAhead[e->dir]; + yv = yvAhead[e->dir]; + if (g_hdb->_map->getMapBGTileFlags(e->tileX + xv, e->tileY + yv) & (kFlagSolid | kFlagWater)) { + e->xVel = e->yVel = 0; + e->animFrame = 0; + e->animDelay = e->animCycle; + e->dir = turnRight[e->dir]; + e->state = dirState[e->dir]; + } else { + e->xVel = xv * kPlayerMoveSpeed; + e->yVel = yv * kPlayerMoveSpeed; + if (!g_hdb->getActionMode()) { + e->xVel >>= 1; + e->yVel >>= 1; + } + e->goalX = e->tileX + xv; + e->goalY = e->tileY + yv; + e->state = dirState[e->dir]; + if (e->dir == DIR_DOWN) + e->animFrame = 3; + } +} + + +void aiTurnBotAction(AIEntity *e) { + if (e->goalX) + g_hdb->_ai->animateEntity(e); + else { + aiTurnBotChoose(e); + g_hdb->_ai->animateEntity(e); + if (e->onScreen) + warning("STUB: aiTurnBotAction: Play SND_TURNBOT_TURN"); + } + + if (e->onScreen && onEvenTile(e->x, e->y) && g_hdb->_ai->checkPlayerCollision(e->x, e->y, 0) && !g_hdb->_ai->playerDead()) + g_hdb->_ai->killPlayer(DEATH_NORMAL); +} + + } // End of Namespace -- cgit v1.2.3