aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorNipun Garg2019-06-27 01:08:23 +0530
committerEugene Sandulenko2019-09-03 17:17:01 +0200
commitd3c2c935a52d59a088feaa82a3ac46fc356c8267 (patch)
tree8921ed6e37a489bdc742430d18c5af0162b4012d /engines
parent9f3fab3b4e466738a38f71912f12726b34eff035 (diff)
downloadscummvm-rg350-d3c2c935a52d59a088feaa82a3ac46fc356c8267.tar.gz
scummvm-rg350-d3c2c935a52d59a088feaa82a3ac46fc356c8267.tar.bz2
scummvm-rg350-d3c2c935a52d59a088feaa82a3ac46fc356c8267.zip
HDB: Add aiFourFirer functions
Diffstat (limited to 'engines')
-rw-r--r--engines/hdb/ai-bots.cpp70
-rw-r--r--engines/hdb/ai-player.cpp12
2 files changed, 70 insertions, 12 deletions
diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index 837b1e75dd..f7c6cbce12 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -949,4 +949,74 @@ void aiMaintBotAction(AIEntity *e) {
}
}
+void aiFourFirerInit(AIEntity *e) {
+ e->value1 = 0;
+ e->aiAction = aiFourFirerAction;
+}
+
+void aiFourFirerInit2(AIEntity *e) {
+ e->draw = g_hdb->_ai->getStandFrameDir(e);
+}
+
+void aiFourFirerAction(AIEntity *e) {
+ AIEntity *p = g_hdb->_ai->getPlayer(), *fire, *hit;
+ AIState state[5] = {STATE_NONE, STATE_STANDUP, STATE_STANDDOWN, STATE_STANDLEFT, STATE_STANDRIGHT};
+ AIDir turn[5] = {DIR_NONE, DIR_RIGHT, DIR_LEFT, DIR_UP, DIR_DOWN};
+ int shoot, xv, yv, result;
+
+ // Time to turn right?
+ if (!e->value1) {
+ e->dir = turn[e->dir];
+ e->state = state[e->dir];
+ e->value1 = 16;
+ if (e->onScreen)
+ warning("STUB: aiFourFirerAction: Play SND_FOURFIRE_TURN");
+ }
+ e->value1--;
+
+ // Waiting before firing again?
+ if (e->sequence) {
+ e->sequence--;
+ return;
+ }
+
+ g_hdb->_ai->animEntFrames(e);
+
+ // Can we see the player on the same level?
+ if ((e->level != p->level) || g_hdb->_ai->playerDead() || !e->onScreen)
+ return;
+
+ // Check player direction
+ shoot = xv = yv = 0;
+ 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->y == e->y && p->x < e->x) { shoot = 1; xv = -1; } break;
+ case DIR_RIGHT: if (p->y == e->y && p->x > e->x) { shoot = 1; xv = 1; } break;
+ case DIR_NONE: warning("aiFourFirerAction: DIR_NONE found"); break;
+ }
+
+ // Shoot if needed
+ // Make sure not shooting into solid tile
+ // Make sure if shooting at entity it is the player
+ hit = g_hdb->_ai->legalMoveOverWater(e->tileX + xv, e->tileY + yv, e->level, &result);
+ if (hit && hit->type == AI_GUY)
+ hit = NULL;
+
+ if (shoot && !hit && result) {
+ fire = 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);
+ if (g_hdb->_map->onScreen(e->tileX, e->tileY))
+ warning("STUB: aiFourFirerAction: Play SND_FOUR_FIRE");
+ fire->xVel = xv * kPlayerMoveSpeed * 2;
+ fire->yVel = yv * kPlayerMoveSpeed * 2;
+ if (!g_hdb->getActionMode()) {
+ fire->xVel >>= 1;
+ fire->yVel >>= 1;
+ }
+ e->sequence = 16;
+ if (hitPlayer(fire->tileX*kTileWidth, fire->tileY*kTileHeight))
+ g_hdb->_ai->killPlayer(DEATH_FRIED);
+ }
+}
+
} // End of Namespace
diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index c74a393240..24ad5ed1ee 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -316,18 +316,6 @@ void aiScientistInit2(AIEntity *e) {
warning("STUB: AI: aiScientistInit2 required");
}
-void aiFourFirerInit(AIEntity *e) {
- warning("STUB: AI: aiFourFirerInit required");
-}
-
-void aiFourFirerInit2(AIEntity *e) {
- warning("STUB: AI: aiFourFirerInit2 required");
-}
-
-void aiFourFirerAction(AIEntity *e) {
- warning("STUB: AI: aiFourFirerAction required");
-}
-
void aiSlugAttackAction(AIEntity *e) {
warning("STUB: AI: aiSlugAttackAction required");
}