diff options
-rw-r--r-- | engines/xeen/combat.cpp | 9 | ||||
-rw-r--r-- | engines/xeen/combat.h | 5 | ||||
-rw-r--r-- | engines/xeen/interface_map.cpp | 71 | ||||
-rw-r--r-- | engines/xeen/interface_map.h | 5 | ||||
-rw-r--r-- | engines/xeen/map.cpp | 1 | ||||
-rw-r--r-- | engines/xeen/map.h | 3 | ||||
-rw-r--r-- | engines/xeen/resources.cpp | 21 | ||||
-rw-r--r-- | engines/xeen/resources.h | 6 |
8 files changed, 117 insertions, 4 deletions
diff --git a/engines/xeen/combat.cpp b/engines/xeen/combat.cpp index b3ef4fda71..077205394e 100644 --- a/engines/xeen/combat.cpp +++ b/engines/xeen/combat.cpp @@ -25,8 +25,9 @@ namespace Xeen { -Combat::Combat(XeenEngine *vm): _vm(vm) { - _attackMon1 = _attackMon2 = _attackMon3 = 0; +Combat::Combat(XeenEngine *vm): _vm(vm), _attackMon1(_attackMonsters[0]), + _attackMon2(_attackMonsters[1]), _attackMon3(_attackMonsters[2]) { + Common::fill(&_attackMonsters[0], &_attackMonsters[26], 0); Common::fill(&_charsArray1[0], &_charsArray1[12], 0); Common::fill(&_monPow[0], &_monPow[12], 0); Common::fill(&_monsterScale[0], &_monsterScale[12], 0); @@ -35,4 +36,8 @@ Combat::Combat(XeenEngine *vm): _vm(vm) { Common::fill(&_shooting[0], &_shooting[6], 0); } +void Combat::clear() { + Common::fill(&_attackMonsters[0], &_attackMonsters[26], -1); +} + } // End of namespace Xeen diff --git a/engines/xeen/combat.h b/engines/xeen/combat.h index 24a358716f..4ead4047cf 100644 --- a/engines/xeen/combat.h +++ b/engines/xeen/combat.h @@ -33,15 +33,18 @@ class Combat { private: XeenEngine *_vm; public: + int _attackMonsters[26]; int _charsArray1[12]; bool _monPow[12]; int _monsterScale[12]; int _elemPow[12]; int _elemScale[12]; bool _shooting[6]; - int _attackMon1, _attackMon2, _attackMon3; + int &_attackMon1, _attackMon2, _attackMon3; public: Combat(XeenEngine *vm); + + void clear(); }; } // End of namespace Xeen diff --git a/engines/xeen/interface_map.cpp b/engines/xeen/interface_map.cpp index cc99b3ee86..f4c0dc0845 100644 --- a/engines/xeen/interface_map.cpp +++ b/engines/xeen/interface_map.cpp @@ -371,9 +371,80 @@ InterfaceMap::InterfaceMap(XeenEngine *vm): _vm(vm) { _isShooting = false; _charsShooting = false; _objNumber = 0; + _combatFloatCounter = 0; } void InterfaceMap::setIndoorsMonsters() { + Combat &combat = *_vm->_combat; + Map &map = *_vm->_map; + Direction dir = _vm->_party._mazeDirection; + const int INDOOR_MONSTERS_Y[4] = { 2, 34, 53, 59 }; + + combat.clear(); + for (uint monsterIdx = 0; monsterIdx < map._mobData._monsters.size(); ++monsterIdx) { + MazeMonster &monster = map._mobData._monsters[monsterIdx]; + SpriteResource *sprites = monster._sprites; + int frame = monster._frame; + + if (frame >= 8) { + sprites = monster._attackSprites; + frame -= 8; + } + + // The following long sequence sets up monsters in the various positions + if (monster._position.x == SCREEN_POSITIONING_X[dir][2] && + monster._position.y == SCREEN_POSITIONING_Y[dir][2]) { + monster._field4 = 1; + if (combat._attackMonsters[0] == -1) { + combat._attackMonsters[0] = monsterIdx; + setMonsterSprite(_indoorList[156], monster, sprites, frame, INDOOR_MONSTERS_Y[0]); + } else if (combat._attackMonsters[1] == -1) { + combat._attackMonsters[1] = monsterIdx; + setMonsterSprite(_indoorList[150], monster, sprites, frame, INDOOR_MONSTERS_Y[0]); + } else if (combat._attackMonsters[2] == -1) { + combat._attackMonsters[2] = monsterIdx; + setMonsterSprite(_indoorList[153], monster, sprites, frame, INDOOR_MONSTERS_Y[0]); + } + } + + if (monster._position.x == SCREEN_POSITIONING_X[dir][7] && + monster._position.y == SCREEN_POSITIONING_Y[dir][7]) { + monster._field4 = 1; + if (!_wo[27]) { + if (combat._attackMonsters[3] == -1) { + combat._attackMonsters[3] = monsterIdx; + setMonsterSprite(_indoorList[132], monster, sprites, frame, INDOOR_MONSTERS_Y[1]); + } else if (combat._attackMonsters[4] == -1) { + combat._attackMonsters[4] = monsterIdx; + setMonsterSprite(_indoorList[130], monster, sprites, frame, INDOOR_MONSTERS_Y[1]); + } else if (combat._attackMonsters[2] == -1) { + combat._attackMonsters[5] = monsterIdx; + setMonsterSprite(_indoorList[131], monster, sprites, frame, INDOOR_MONSTERS_Y[1]); + } + } + } + } +} + +void InterfaceMap::setMonsterSprite(DrawStruct &drawStruct, MazeMonster &monster, SpriteResource *sprites, + int frame, int defaultY) { + MonsterStruct &monsterData = _vm->_map->_monsterData[monster._spriteId]; + bool flying = monsterData._flying; + + _indoorList[156]._frame = frame; + _indoorList[156]._sprites = sprites; + _indoorList[156]._y = defaultY; + + if (flying) { + _indoorList[156]._x = COMBAT_FLOAT_X[_combatFloatCounter]; + _indoorList[156]._y = COMBAT_FLOAT_Y[_combatFloatCounter]; + } else { + _indoorList[156]._x = 0; + } + + _indoorList[156]._flags &= SPRFLAG_HORIZ_FLIPPED | SPRFLAG_4000 | SPRFLAG_2000; + if (monster._effect2) + _indoorList[156]._flags = MONSTER_EFFECT_FLAGS[monster._effect2][monster._effect3]; } diff --git a/engines/xeen/interface_map.h b/engines/xeen/interface_map.h index 01cd1d2c48..ea40c30a79 100644 --- a/engines/xeen/interface_map.h +++ b/engines/xeen/interface_map.h @@ -24,6 +24,7 @@ #define XEEN_INTERFACE_MAP_H #include "common/scummsys.h" +#include "xeen/map.h" #include "xeen/screen.h" namespace Xeen { @@ -81,8 +82,12 @@ public: class InterfaceMap { private: XeenEngine *_vm; + int _combatFloatCounter; void initDrawStructs(); + + void setMonsterSprite(DrawStruct &drawStruct, MazeMonster &monster, + SpriteResource *sprites, int frame, int defaultY); protected: byte _wp[20]; byte _wo[308]; diff --git a/engines/xeen/map.cpp b/engines/xeen/map.cpp index 507e4fc422..c136dee534 100644 --- a/engines/xeen/map.cpp +++ b/engines/xeen/map.cpp @@ -638,6 +638,7 @@ MazeMonster::MazeMonster() { _frame = 0; _id = 0; _spriteId = 0; + _field4 = 0; _hp = 0; _effect1 = _effect2 = 0; _effect3 = 0; diff --git a/engines/xeen/map.h b/engines/xeen/map.h index faffe97c97..821922bd7f 100644 --- a/engines/xeen/map.h +++ b/engines/xeen/map.h @@ -250,6 +250,7 @@ struct MazeMonster { int _frame; int _id; int _spriteId; + int _field4; int _hp; int _effect1, _effect2; int _effect3; @@ -352,7 +353,6 @@ private: XeenEngine *_vm; MazeData _mazeData[9]; Common::String _mazeName; - MonsterData _monsterData; SpriteResource _wallPicSprites; int _townPortalSide; int _sideObj; @@ -365,6 +365,7 @@ private: public: bool _isOutdoors; MonsterObjectData _mobData; + MonsterData _monsterData; MazeEvents _events; HeadData _headData; AnimationInfo _animationInfo; diff --git a/engines/xeen/resources.cpp b/engines/xeen/resources.cpp index e56ad1656e..87540b8df4 100644 --- a/engines/xeen/resources.cpp +++ b/engines/xeen/resources.cpp @@ -445,5 +445,26 @@ const int DRAW_FRAMES[25][2] = { { 1, 1 } }; +const int COMBAT_FLOAT_X[8] = { -2, -1, 0, 1, 2, 1, 0, -1 }; + +const int COMBAT_FLOAT_Y[8] = { -2, 0, 2, 0, -1, 0, 2, 0 }; + +const int MONSTER_EFFECT_FLAGS[15][8] = { + { 0x104, 0x105, 0x106, 0x107, 0x108, 0x109, 0x10A, 0x10B }, + { 0x10C, 0x10D, 0x10E, 0x10F, 0x0, 0x0, 0x0, 0x0 }, + { 0x110, 0x111, 0x112, 0x113, 0x0, 0x0, 0x0, 0x0 }, + { 0x114, 0x115, 0x116, 0x117, 0x0, 0x0, 0x0, 0x0 }, + { 0x200, 0x201, 0x202, 0x203, 0x0, 0x0, 0x0, 0x0 }, + { 0x300, 0x301, 0x302, 0x303, 0x400, 0x401, 0x402, 0x403 }, + { 0x500, 0x501, 0x502, 0x503, 0x0, 0x0, 0x0, 0x0 }, + { 0x600, 0x601, 0x602, 0x603, 0x0, 0x0, 0x0, 0x0 }, + { 0x604, 0x605, 0x606, 0x607, 0x608, 0x609, 0x60A, 0x60B }, + { 0x60C, 0x60D, 0x60E, 0x60F, 0x0, 0x0, 0x0, 0x0 }, + { 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100 }, + { 0x101, 0x101, 0x101, 0x101, 0x101, 0x101, 0x101, 0x101 }, + { 0x102, 0x102, 0x102, 0x102, 0x102, 0x102, 0x102, 0x102 }, + { 0x103, 0x103, 0x103, 0x103, 0x103, 0x103, 0x103, 0x103 }, + { 0x108, 0x108, 0x108, 0x108, 0x108, 0x108, 0x108, 0x108 } +}; } // End of namespace Xeen diff --git a/engines/xeen/resources.h b/engines/xeen/resources.h index bed9569163..2160d55c53 100644 --- a/engines/xeen/resources.h +++ b/engines/xeen/resources.h @@ -94,6 +94,12 @@ extern const int DRAW_NUMBERS[25]; extern const int DRAW_FRAMES[25][2]; +extern const int COMBAT_FLOAT_X[8]; + +extern const int COMBAT_FLOAT_Y[8]; + +extern const int MONSTER_EFFECT_FLAGS[15][8]; + } // End of namespace Xeen #endif /* XEEN_RESOURCES_H */ |