diff options
author | Nipun Garg | 2019-06-25 02:08:23 +0530 |
---|---|---|
committer | Eugene Sandulenko | 2019-09-03 17:17:00 +0200 |
commit | 4657593aa414616f2611680d1d0147619ef0330b (patch) | |
tree | 154c8fe12e31a59cc33908c10ead650874d9063d | |
parent | 10246121e082f1c5dda7cf9b7171244d6811c27d (diff) | |
download | scummvm-rg350-4657593aa414616f2611680d1d0147619ef0330b.tar.gz scummvm-rg350-4657593aa414616f2611680d1d0147619ef0330b.tar.bz2 scummvm-rg350-4657593aa414616f2611680d1d0147619ef0330b.zip |
HDB: Add aiShockBot functions
-rw-r--r-- | engines/hdb/ai-bots.cpp | 70 | ||||
-rw-r--r-- | engines/hdb/ai-player.cpp | 16 | ||||
-rw-r--r-- | engines/hdb/hdb.h | 1 |
3 files changed, 71 insertions, 16 deletions
diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp index 54c0d18b75..faa4331624 100644 --- a/engines/hdb/ai-bots.cpp +++ b/engines/hdb/ai-bots.cpp @@ -221,5 +221,75 @@ void aiTurnBotAction(AIEntity *e) { g_hdb->_ai->killPlayer(DEATH_NORMAL); } +void aiShockBotInit(AIEntity *e) { + g_hdb->_ai->findPath(e); + e->aiAction = aiShockBotAction; + e->animCycle = 0; + e->sequence = 0; + e->aiDraw = aiShockBotShock; +} + +void aiShockBotInit2(AIEntity *e) { + e->standupFrames = e->standdownFrames = e->standleftFrames = e->standrightFrames = + e->moveupFrames = e->moverightFrames = e->moveleftFrames = e->movedownFrames; + + for (int i = 0; i < e->movedownFrames; i++) + e->standupGfx[i] = e->standleftGfx[i] = e->standrightGfx[i] = e->standdownGfx[i] = e->moveupGfx[i] = e->moveleftGfx[i] = e->moverightGfx[i] = e->movedownGfx[i]; + + e->draw = g_hdb->_ai->getStandFrameDir(e); +} + +void aiShockBotAction(AIEntity *e) { + if (e->goalX) { + if (!e->sequence) { + if (e->onScreen && g_hdb->_ai->checkPlayerCollision(e->x, e->y, 4) && !g_hdb->_ai->playerDead()) + g_hdb->_ai->killPlayer(DEATH_SHOCKED); + g_hdb->_ai->animateEntity(e); + } else + g_hdb->_ai->animEntFrames(e); + } else { + g_hdb->_ai->findPath(e); + e->sequence = 20; + g_hdb->_ai->animEntFrames(e); + if (e->onScreen) + warning("STUB: aiShockBotAction: Play SND_SHOCKBOT_AMBIENT"); + + } + + if (e->sequence) + e->sequence--; +} + +void aiShockBotShock(AIEntity *e, int mx, int my) { + int offX[8] = { -1, 0, 1, 1, 1, 0, -1, -1 }; + int offY[8] = { -1, -1, -1, 0, 1, 1, 1, 0 }; + + // Only on a exact tile boundary do we change the shocked tiles + // Start at top left and go around + if (g_hdb->_map->getMapBGTileFlags(e->tileX, e->tileY) & kFlagMetal) + e->special1Gfx[e->animFrame]->drawMasked(e->tileX * kTileWidth - mx, e->tileY * kTileHeight - my); + + uint32 flags; + for (int i = 0; i < 8; i++) { + flags = g_hdb->_map->getMapBGTileFlags(e->tileX + offX[i], e->tileY + offY[i]); + if (flags & kFlagMetal) { + // Is the shocking tile onScreen? + if (g_hdb->_map->checkXYOnScreen((e->tileX + offX[i]) * kTileWidth, (e->tileY + offY[i]) * kTileHeight)) { + // Draw shocking tile animation + e->special1Gfx[e->animFrame]->drawMasked((e->tileX + offX[i])*kTileWidth - mx, (e->tileY + offY[i])*kTileHeight - my); + // Did the player get fried? + // Check every 4 frames + if (e->onScreen && !e->animFrame && g_hdb->_ai->checkPlayerTileCollision(e->tileX + offX[i], e->tileY + offY[i]) && !g_hdb->_ai->playerDead()) { + g_hdb->_ai->killPlayer(DEATH_SHOCKED); + return; + } + if (!e->animFrame && g_hdb->_map->boomBarrelExist(e->tileX + offX[i], e->tileY + offY[i])) { + AIEntity *e2 = g_hdb->_ai->findEntityType(AI_BOOMBARREL, e->tileX + offX[i], e->tileY + offY[i]); + aiBarrelExplode(e2); + } + } + } + } +} } // End of Namespace diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp index d585d9bbf4..ea02debb60 100644 --- a/engines/hdb/ai-player.cpp +++ b/engines/hdb/ai-player.cpp @@ -320,22 +320,6 @@ void aiMaintBotInitAction(AIEntity *e) { warning("STUB: AI: aiMaintBotInitAction required"); } -void aiShockBotAction(AIEntity *e) { - warning("STUB: AI: aiShockBotAction required"); -} - -void aiShockBotShock(AIEntity *e, int mx, int my) { - warning("STUB: AI: aiShockBotShock required"); -} - -void aiShockBotInit(AIEntity *e) { - warning("STUB: AI: aiShockBotInit required"); -} - -void aiShockBotInit2(AIEntity *e) { - warning("STUB: AI: aiShockBotInit2 required"); -} - void aiScientistInit(AIEntity *e) { warning("STUB: AI: aiScientistInit required"); } diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h index 319db920b4..ab8cb24def 100644 --- a/engines/hdb/hdb.h +++ b/engines/hdb/hdb.h @@ -74,6 +74,7 @@ enum Flag { kFlagSolid = 0x3, kFlagPlayerDie = 0x8, kFlagInvisible = 0x20, + kFlagMetal = 0x40, kFlagForeground = 0x80, kFlagSlime = 0x201C, kFlagWater = 0x401C, |