diff options
author | Nipun Garg | 2019-06-20 17:47:01 +0530 |
---|---|---|
committer | Eugene Sandulenko | 2019-09-03 17:16:51 +0200 |
commit | e473c1d48931a87f7b45db3b7908affea4529d33 (patch) | |
tree | 8b1cddf0ec1681c9b27d2b09cbbd7e707bef02e7 /engines/hdb | |
parent | b0f714cb25c343fecb00656c2f0df028368126c5 (diff) | |
download | scummvm-rg350-e473c1d48931a87f7b45db3b7908affea4529d33.tar.gz scummvm-rg350-e473c1d48931a87f7b45db3b7908affea4529d33.tar.bz2 scummvm-rg350-e473c1d48931a87f7b45db3b7908affea4529d33.zip |
HDB: Add stopEntity()
Diffstat (limited to 'engines/hdb')
-rw-r--r-- | engines/hdb/ai-funcs.cpp | 58 | ||||
-rw-r--r-- | engines/hdb/ai.h | 3 |
2 files changed, 60 insertions, 1 deletions
diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp index 453d7cc428..8df88cf11c 100644 --- a/engines/hdb/ai-funcs.cpp +++ b/engines/hdb/ai-funcs.cpp @@ -428,6 +428,64 @@ bool AI::cacheEntGfx(AIEntity *e, bool init) { return true; } +// Stops the movement of an entity +void AI::stopEntity(AIEntity *e) { + if (e == _player) { + clearWaypoints(); + // Reset Player speed + e->moveSpeed = kPlayerMoveSpeed; + } + + // Reset animation + e->animFrame = 0; + + // Align with tile boundaries + e->x = e->tileX * kTileWidth; + e->y = e->tileY * kTileHeight; + e->goalX = e->tileX; + e->goalY = e->tileY; + e->drawXOff = e->drawYOff = 0; + + // Don't change the state of Diverters or Floating entities + switch (e->state) { + case STATE_FLOATLEFT: + case STATE_FLOATRIGHT: + case STATE_FLOATUP: + case STATE_FLOATDOWN: + e->state = STATE_FLOATING; + return; + } + + if (e->type != AI_DIVERTER) { + switch (e->dir) { + case DIR_UP: + if (e->standupFrames) + e->state = STATE_STANDUP; + else + e->state = STATE_NONE; + break; + case DIR_DOWN: + if (e->standdownFrames) + e->state = STATE_STANDDOWN; + else + e->state = STATE_NONE; + break; + case DIR_LEFT: + if (e->standleftFrames) + e->state = STATE_STANDLEFT; + else + e->state = STATE_NONE; + break; + case DIR_RIGHT: + if (e->standrightFrames) + e->state = STATE_STANDRIGHT; + else + e->state = STATE_NONE; + break; + } + } +} + AIEntity *AI::locateEntity(const char *luaName) { for (Common::Array<AIEntity *>::iterator it = _ents->begin(); it != _ents->end(); it++) { if (Common::matchString((*it)->entityName, luaName)) { diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h index 344c4b47e5..1eaa41ca00 100644 --- a/engines/hdb/ai.h +++ b/engines/hdb/ai.h @@ -356,7 +356,7 @@ struct AIEntity { AIDir dir2; // this is from TED uint16 x, y; - uint16 drawXOff, drawYOoff; // might need a drawing offset + uint16 drawXOff, drawYOff; // might need a drawing offset uint16 onScreen; // FLAG: is this entity onscreen? uint16 moveSpeed; // movement speed of this entity uint16 xVel, yVel; // movement values @@ -457,6 +457,7 @@ public: // Entity Functions AIEntity *spawn(AIType type, AIDir dir, int x, int y, char *funcInit, char *funcAction, char *funcUse, AIDir dir2, int level, int value1, int value2, int callInit); bool cacheEntGfx(AIEntity *e, bool init); + void stopEntity(AIEntity *e); AIEntity *locateEntity(const char *luaName); void removeEntity(AIEntity *e); void initAllEnts(); |