diff options
author | Nipun Garg | 2019-06-21 21:29:05 +0530 |
---|---|---|
committer | Eugene Sandulenko | 2019-09-03 17:16:54 +0200 |
commit | c12d1a2cec905df6c1c0496ff11760e27d556924 (patch) | |
tree | 800287abb9c9b4da306f6aedf3af20a2c43736db | |
parent | bf98bcca010613957ac0630e3ff715a738d7a819 (diff) | |
download | scummvm-rg350-c12d1a2cec905df6c1c0496ff11760e27d556924.tar.gz scummvm-rg350-c12d1a2cec905df6c1c0496ff11760e27d556924.tar.bz2 scummvm-rg350-c12d1a2cec905df6c1c0496ff11760e27d556924.zip |
HDB: Add stubbed animateEntity()
-rw-r--r-- | engines/hdb/ai-funcs.cpp | 121 | ||||
-rw-r--r-- | engines/hdb/ai.h | 1 | ||||
-rw-r--r-- | engines/hdb/hdb.h | 21 |
3 files changed, 135 insertions, 8 deletions
diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp index 50f030f296..a9d56c8a54 100644 --- a/engines/hdb/ai-funcs.cpp +++ b/engines/hdb/ai-funcs.cpp @@ -653,6 +653,127 @@ void AI::killPlayer(Death method) { warning("STUB: killPlayer: Stop Music"); } +/* + Note from original: + Moves the entity along toward its goal, sets current frame to draw + depending on its current state. Special checking is done for the + player in here to move him along his waypoints. +*/ +void AI::animateEntity(AIEntity *e) { + + int bgTileFlags, bgTileIndex; + int fgTileFlags, fgTileIndex; + + // Move entity if player is not dead + if (!_playerDead) { + e->x += e->xVel; + e->y += e->yVel; + e->tileX = e->x / kTileWidth; + e->tileY = e->y / kTileHeight; + } + + // For non-players, check for trigger being hit + if (onEvenTile(e->x, e->y)) { + warning("STUB: animateEntity: Check for Triggers being hit"); + } + + // If player, then scroll the screen with the player + if (e == _player && !_playerDead) { + if (!_cameraLock) + g_hdb->_map->centerMapXY(e->x + 16, e->y + 16); + + // Check if player walked into teleporter + warning("STUB: animateEntity: Check Teleporter List"); + + // Check for bad tiles (DEATH) + int cx = (e->x + 16) / kTileWidth; + int cy = (e->y + 16) / kTileHeight; + bgTileFlags = g_hdb->_map->getMapBGTileFlags(cx, cy); + fgTileFlags = g_hdb->_map->getMapFGTileFlags(cx, cy); + if ((bgTileFlags & kFlagPlayerDie) && !(checkFloating(cx, cy)) && !(fgTileFlags & kFlagGrating)) { + if (bgTileFlags & kFlagEnergyFloor) + killPlayer(DEATH_SHOCKED); + else if ((bgTileFlags & kFlagPlasmaFloor) || (bgTileFlags & kFlagRadFloor)) + killPlayer(DEATH_FRIED); + else + killPlayer(DEATH_NORMAL); + return; + } + + // Check if player wants to stop + // If yes, sets last waypoint right in front of player + int xOff = 0, yOff = 0; + if (_numWaypoints > 1) { + + switch (e->dir) { + case DIR_UP: + xOff = 0; + yOff = -1; + break; + case DIR_DOWN: + xOff = 0; + yOff = 1; + break; + case DIR_LEFT: + xOff = -1; + yOff = 0; + break; + case DIR_RIGHT: + xOff = 1; + yOff = 0; + break; + case DIR_NONE: + warning("AI-FUNCS: animateEntity: DIR_NONE found"); + break; + } + if ((e->tileX+xOff == _waypoints[_numWaypoints-1].x && e->tileY + yOff == _waypoints[_numWaypoints - 1].y) && e->level == _waypoints[_numWaypoints - 1].level) { + memset(&_waypoints[0], 0, sizeof(_waypoints)); + _numWaypoints = 1; + _waypoints[0].x = e->tileX + xOff; + _waypoints[0].y = e->tileY + yOff; + _waypoints[0].level = e->level; + e->goalX = e->tileX + xOff; + e->goalY = e->tileY + yOff; + } + } + } + + // Check for moving up/down stair levels + bgTileIndex = g_hdb->_map->getMapBGTileIndex(e->tileX, e->tileY); + bgTileFlags = g_hdb->_map->getMapBGTileFlags(e->tileX, e->tileY); + fgTileFlags = g_hdb->_map->getMapFGTileFlags(e->tileX, e->tileY); + if (bgTileFlags & kFlagStairTop) + e->level = 2; + else if (bgTileFlags & kFlagStairBot) + e->level = 1; + + // Reached goal? + // Cinematic require less accuracy for NPCs + int result; + if (_cineActive && e != _player) + result = (abs(e->x - (e->goalX * kTileWidth)) <= abs(e->xVel)) && (abs(e->y - (e->goalY * kTileHeight)) <= abs(e->yVel)); + else + result = (e->x == e->goalX * kTileWidth) && (e->y == e->goalY * kTileHeight); + + if (result) { + // If player, this is a waypoint goal. + // Drop one waypoint from list + if (e == _player) { + removeFirstWaypoint(); + _playerEmerging = false; + } + + // If entity not player, stop it here + // If entity is player and no waypoints are left, stop it here + if (e != _player || (!_numWaypoints && e == _player)) { + warning("STUB: animateEntity: Stop entity"); + } else if (onEvenTile(e->x, e->y)) + setEntityGoal(e, _waypoints[0].x, _waypoints[0].y); + } + + animEntFrames(e); +} + void AI::animEntFrames(AIEntity *e) { int max = 1; // Set current graphic to draw diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h index 67db4bbcbe..5c9dee107e 100644 --- a/engines/hdb/ai.h +++ b/engines/hdb/ai.h @@ -574,6 +574,7 @@ public: void initAllEnts(); void killPlayer(Death method); + void animateEntity(AIEntity *e); void animEntFrames(AIEntity *e); void animLuaEntity(const char *initName, AIState st); void drawEnts(int x, int y, int w, int h); diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h index b748101894..0a3e0a4a1d 100644 --- a/engines/hdb/hdb.h +++ b/engines/hdb/hdb.h @@ -69,14 +69,19 @@ enum GameState { }; enum Flag { - kFlagInvisible = 0x20, - kFlagForeground = 0x80, - kFlagStairTop = 0x400000, - kFlagAnimSlow = 0x800000, - kFlagAnimMedium = 0x1000000, - kFlagAnimFast = 0x1800000, - kFlagGrating = 0x4000000, - kFlagMasked = 0x2000000 + kFlagPlayerDie = 0x8, + kFlagInvisible = 0x20, + kFlagForeground = 0x80, + kFlagEnergyFloor = 0x40000, + kFlagPlasmaFloor = 0x6000D, + kFlagRadFloor = 0x6800D, + kFlagStairBot = 0x200000, + kFlagStairTop = 0x400000, + kFlagAnimSlow = 0x800000, + kFlagAnimMedium = 0x1000000, + kFlagAnimFast = 0x1800000, + kFlagGrating = 0x4000000, + kFlagMasked = 0x2000000 }; enum { |