diff options
author | Nipun Garg | 2019-06-25 01:03:38 +0530 |
---|---|---|
committer | Eugene Sandulenko | 2019-09-03 17:16:59 +0200 |
commit | 63358b754e54ed96324bd42bbb2780c8f0302cf3 (patch) | |
tree | cc7aa69b4742ce4c4dfd4a9c63c1c57d9d1782f0 | |
parent | 087f84b38b94ee56e67c874cb281bec057f6cb80 (diff) | |
download | scummvm-rg350-63358b754e54ed96324bd42bbb2780c8f0302cf3.tar.gz scummvm-rg350-63358b754e54ed96324bd42bbb2780c8f0302cf3.tar.bz2 scummvm-rg350-63358b754e54ed96324bd42bbb2780c8f0302cf3.zip |
HDB: Add aiTurnBot functions
-rw-r--r-- | engines/hdb/ai-bots.cpp | 53 | ||||
-rw-r--r-- | engines/hdb/ai-player.cpp | 12 |
2 files changed, 53 insertions, 12 deletions
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 diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp index 32de22b2f2..d585d9bbf4 100644 --- a/engines/hdb/ai-player.cpp +++ b/engines/hdb/ai-player.cpp @@ -460,10 +460,6 @@ void aiSlugSlingerInit2(AIEntity *e) { warning("STUB: AI: aiSlugSlingerInit2 required"); } -void aiTurnBotAction(AIEntity *e) { - warning("STUB: AI: aiTurnBotAction required"); -} - void aiPushBotAction(AIEntity *e) { warning("STUB: AI: aiPushBotAction required"); } @@ -552,14 +548,6 @@ void aiDragonDraw(AIEntity *e, int mx, int my) { warning("STUB: AI: aiDragonDraw required"); } -void aiTurnBotInit(AIEntity *e) { - warning("STUB: AI: aiTurnBotInit required"); -} - -void aiTurnBotInit2(AIEntity *e) { - warning("STUB: AI: aiTurnBotInit2 required"); -} - void aiListenBotInit(AIEntity *e) { warning("STUB: AI: aiListenBotInit required"); } |