aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorNipun Garg2019-06-25 00:37:26 +0530
committerEugene Sandulenko2019-09-03 17:16:59 +0200
commitbb674ec9c190bd19f4ce9e26c20e6ad92cb89986 (patch)
tree9739b717c8a6a4c6a41be9b216c2531249de4449 /engines
parentfcdd7511d1a9648b9692fb05cc93eeaa6fedfc02 (diff)
downloadscummvm-rg350-bb674ec9c190bd19f4ce9e26c20e6ad92cb89986.tar.gz
scummvm-rg350-bb674ec9c190bd19f4ce9e26c20e6ad92cb89986.tar.bz2
scummvm-rg350-bb674ec9c190bd19f4ce9e26c20e6ad92cb89986.zip
HDB: Add OmniBot functions
Diffstat (limited to 'engines')
-rw-r--r--engines/hdb/ai-bots.cpp132
-rw-r--r--engines/hdb/ai-player.cpp16
-rw-r--r--engines/hdb/module.mk1
3 files changed, 133 insertions, 16 deletions
diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
new file mode 100644
index 0000000000..25d734a720
--- /dev/null
+++ b/engines/hdb/ai-bots.cpp
@@ -0,0 +1,132 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "hdb/hdb.h"
+
+namespace HDB {
+
+void aiOmniBotInit(AIEntity *e) {
+ if (e->value1 == 1)
+ e->aiAction = aiOmniBotMove;
+ else if (g_hdb->_ai->findPath(e))
+ e->aiAction = aiOmniBotAction;
+}
+
+void aiOmniBotInit2(AIEntity *e) {
+ e->standdownGfx[0] = e->movedownGfx[0];
+ e->standupGfx[0] = e->movedownGfx[0];
+ e->standleftGfx[0] = e->moveleftGfx[0];
+ e->standrightGfx[0] = e->moverightGfx[0];
+ e->standdownFrames = e->standupFrames = e->standleftFrames = e->standrightFrames = 1;
+ e->draw = g_hdb->_ai->getStandFrameDir(e);
+}
+
+void aiOmniBotMove(AIEntity *e) {
+ if (e->goalX)
+ g_hdb->_ai->animateEntity(e);
+ else
+ g_hdb->_ai->animEntFrames(e);
+}
+
+void aiOmniBotAction(AIEntity *e) {
+ AIEntity *p = g_hdb->_ai->getPlayer();
+ if (e->goalX) {
+ if (!e->sequence) {
+ g_hdb->_ai->animateEntity(e);
+ // Is the Player collding?
+ if (e->onScreen && (p->level = e->level) && g_hdb->_ai->checkPlayerCollision(e->x, e->y, 4) && !g_hdb->_ai->playerDead()) {
+ g_hdb->_ai->killPlayer(DEATH_FRIED);
+ return;
+ }
+
+ // Shoot player ?
+ if (onEvenTile(e->x, e->y) && g_hdb->getActionMode()) {
+ int xv = 0, yv = 0, result;
+ int shoot = 0;
+ AIEntity *omni;
+ // FIXME: Is reloading Player required here?
+ p = g_hdb->_ai->getPlayer();
+
+ // On same level/screen?
+ if ((e->level != p->level) || g_hdb->_ai->playerDead() || !e->onScreen)
+ return;
+
+ // Is Player in Line of Sight?
+ switch (e->dir) {
+ case DIR_UP:
+ if (p->x == e->x && p->y < e->y) {
+ shoot = 1;
+ yv = -1;
+ }
+ break;
+ case DIR_DOWN:
+ if (p->x == e->x && p->y > e->y) {
+ shoot = 1;
+ yv = 1;
+ }
+ break;
+ case DIR_LEFT:
+ if (p->x < e->x && p->y == e->y) {
+ shoot = 1;
+ xv = -1;
+ }
+ break;
+ case DIR_RIGHT:
+ if (p->x > e->x && p->y == e->y) {
+ shoot = 1;
+ xv = 1;
+ }
+ break;
+ case DIR_NONE:
+ warning("aiOmniBotAction: DIR_NONE found");
+ break;
+ }
+
+ // If shoot = 1, take the shot
+ // (1) Check we're not shooting into a solid tile
+ // (2) Check we're not shooting into an Entity unless it's the player
+ AIEntity *hit = g_hdb->_ai->legalMoveOverWater(e->tileX+xv, e->tileY + yv, e->level, &result);
+ if (shoot && !hit && result) {
+ omni = g_hdb->_ai->spawn(AI_OMNIBOT_MISSILE, e->dir, e->tileX + xv, e->tileY + yv, NULL, NULL, NULL, DIR_NONE, e->level, 0, 0, 1);
+ omni->xVel = xv * kPlayerMoveSpeed * 2;
+ omni->yVel = yv * kPlayerMoveSpeed * 2;
+ if (g_hdb->_map->onScreen(e->tileX, e->tileY))
+ warning("STUB: aiOmniBotAction: Play SND_OMNIBOT_FIRE");
+ if (!g_hdb->getActionMode()) {
+ omni->xVel >>= 1;
+ omni->yVel >>= 1;
+ }
+ e->sequence = 16;
+ }
+ }
+ }
+ } else {
+ g_hdb->_ai->findPath(e);
+ if (e->onScreen)
+ warning("STUB: aiOmniBotAction: Play SND_OMNIBOT_AMBIENT");
+ }
+
+ if (e->sequence)
+ e->sequence--;
+}
+
+} // End of Namespace
diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 4cace98e76..940ddcb94c 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -480,14 +480,6 @@ void aiPushBotAction(AIEntity *e) {
warning("STUB: AI: aiPushBotAction required");
}
-void aiOmniBotAction(AIEntity *e) {
- warning("STUB: AI: aiOmniBotAction required");
-}
-
-void aiOmniBotMove(AIEntity *e) {
- warning("STUB: AI: aiOmniBotMove required");
-}
-
void aiLaserAction(AIEntity *e) {
warning("STUB: AI: aiLaserAction required");
}
@@ -588,14 +580,6 @@ void aiListenBotInit2(AIEntity *e) {
warning("STUB: AI: aiListenBotInit2 required");
}
-void aiOmniBotInit(AIEntity *e) {
- warning("STUB: AI: aiOmniBotInit required");
-}
-
-void aiOmniBotInit2(AIEntity *e) {
- warning("STUB: AI: aiOmniBotInit2 required");
-}
-
void aiLaserInit(AIEntity *e) {
warning("STUB: AI: aiLaserInit required");
}
diff --git a/engines/hdb/module.mk b/engines/hdb/module.mk
index 432998def9..bf53ad0473 100644
--- a/engines/hdb/module.mk
+++ b/engines/hdb/module.mk
@@ -1,6 +1,7 @@
MODULE := engines/hdb
MODULE_OBJS := \
+ ai-bots.o \
ai-cinematic.o \
ai-funcs.o \
ai-init.o \