diff options
-rw-r--r-- | engines/xeen/combat.cpp | 16 | ||||
-rw-r--r-- | engines/xeen/interface.cpp | 2 | ||||
-rw-r--r-- | engines/xeen/interface_map.cpp | 8 | ||||
-rw-r--r-- | engines/xeen/map.cpp | 20 | ||||
-rw-r--r-- | engines/xeen/map.h | 3 | ||||
-rw-r--r-- | engines/xeen/scripts.cpp | 1 |
6 files changed, 31 insertions, 19 deletions
diff --git a/engines/xeen/combat.cpp b/engines/xeen/combat.cpp index df9ba9bb50..c3590e7cdd 100644 --- a/engines/xeen/combat.cpp +++ b/engines/xeen/combat.cpp @@ -468,7 +468,7 @@ void Combat::moveMonsters() { for (int idx = 0; idx < (int)map._mobData._monsters.size(); ++idx) { MazeMonster &monster = map._mobData._monsters[idx]; - MonsterStruct &monsterData = map._monsterData[monster._spriteId]; + MonsterStruct &monsterData = *monster._monsterData; if (pt == monster._position) { _dangerPresent = true; @@ -667,7 +667,7 @@ bool Combat::monsterCanMove(const Common::Point &pt, int wallShift, int xDiff, int yDiff, int monsterId) { Map &map = *_vm->_map; MazeMonster &monster = map._mobData._monsters[monsterId]; - MonsterStruct &monsterData = map._monsterData[monster._spriteId]; + MonsterStruct &monsterData = *monster._monsterData; Common::Point tempPos = pt; if (map._isOutdoors) { @@ -798,7 +798,7 @@ void Combat::attackMonster(int monsterId) { } MazeMonster &monster = map._mobData._monsters[monsterIndex]; - MonsterStruct &monsterData = map._monsterData[monster._spriteId]; + MonsterStruct &monsterData = *monster._monsterData; if (monster._damageType) return; @@ -1089,7 +1089,7 @@ void Combat::setSpeedTable() { for (int monsterNum = 0; monsterNum < 3; ++monsterNum) { if (_attackMonsters[monsterNum] != -1) { MazeMonster &monster = map._mobData._monsters[_attackMonsters[monsterNum]]; - MonsterStruct &monsterData = map._monsterData[monster._spriteId]; + MonsterStruct &monsterData = *monster._monsterData; charSpeeds.push_back(monsterData._speed); maxSpeed = MAX(maxSpeed, monsterData._speed); @@ -1162,7 +1162,7 @@ Common::String Combat::getMonsterDescriptions() { for (int idx = 0; idx < 3; ++idx) { if (_attackMonsters[idx] != -1) { MazeMonster &monster = map._mobData._monsters[_attackMonsters[idx]]; - MonsterStruct &monsterData = map._monsterData[monster._spriteId]; + MonsterStruct &monsterData = *monster._monsterData; int textColor = monster.getTextColor(); Common::String format = "\n\v020\f%2u%s\fd"; @@ -1395,7 +1395,7 @@ void Combat::attack2(int damage, RangeType rangeType) { SoundManager &sound = *_vm->_sound; bool isDarkCc = _vm->_files->_isDarkCc; MazeMonster &monster = map._mobData._monsters[_monster2Attack]; - MonsterStruct &monsterData = map._monsterData[monster._spriteId]; + MonsterStruct &monsterData = *monster._monsterData; bool monsterDied = false; if (!isDarkCc && damage && rangeType && monster._spriteId == 89) @@ -1669,7 +1669,7 @@ bool Combat::hitMonster(Character &c, RangeType rangeType) { assert(_monster2Attack != -1); MazeMonster &monster = map._mobData._monsters[_monster2Attack]; - MonsterStruct &monsterData = map._monsterData[monster._spriteId]; + MonsterStruct &monsterData = *monster._monsterData; if (monster._damageType != DT_PHYSICAL) chance += 20; @@ -1737,7 +1737,7 @@ int Combat::getMonsterResistence(RangeType rangeType) { Map &map = *_vm->_map; assert(_monster2Attack != -1); MazeMonster &monster = map._mobData._monsters[_monster2Attack]; - MonsterStruct &monsterData = map._monsterData[monster._spriteId]; + MonsterStruct &monsterData = *monster._monsterData; int resistence = 0, damage = 0; if (rangeType != RT_0 && rangeType != RT_3) { diff --git a/engines/xeen/interface.cpp b/engines/xeen/interface.cpp index d69abef90f..611eccb843 100644 --- a/engines/xeen/interface.cpp +++ b/engines/xeen/interface.cpp @@ -1924,7 +1924,7 @@ void Interface::doCombat() { if (++index == 5 && combat._attackMonsters[0] != -1) { MazeMonster &monster = map._mobData._monsters[combat._monster2Attack]; - MonsterStruct &monsterData = map._monsterData[monster._spriteId]; + MonsterStruct &monsterData = *monster._monsterData; sound.playFX(monsterData._fx); } diff --git a/engines/xeen/interface_map.cpp b/engines/xeen/interface_map.cpp index a54b95fb64..de19a9957a 100644 --- a/engines/xeen/interface_map.cpp +++ b/engines/xeen/interface_map.cpp @@ -707,7 +707,7 @@ void InterfaceMap::animate3d() { MazeMonster &monster = map._mobData._monsters[idx]; if (!monster._damageType) { if (monster._frame < 8) { - MonsterStruct &monsterData = map._monsterData[monster._spriteId]; + MonsterStruct &monsterData = *monster._monsterData; if (!monsterData._loopAnimation) { // Monster isn't specially looped, so cycle through the 8 frames monster._frame = (monster._frame + 1) % 8; @@ -755,7 +755,7 @@ void InterfaceMap::animate3d() { } else { monster._effect3 = (monster._effect3 + 1) % 8; if (monster._effect3 == 0) { - MonsterStruct &monsterData = map._monsterData[monster._spriteId]; + MonsterStruct &monsterData = *monster._monsterData; monster._effect1 = monster._effect2 = monsterData._animationEffect; } } @@ -2625,7 +2625,7 @@ void InterfaceMap::setIndoorsMonsters() { */ void InterfaceMap::setMonsterSprite(DrawStruct &drawStruct, MazeMonster &monster, SpriteResource *sprites, int frame, int defaultY) { - MonsterStruct &monsterData = _vm->_map->_monsterData[monster._spriteId]; + MonsterStruct &monsterData = *monster._monsterData; bool flying = monsterData._flying; drawStruct._frame = frame; @@ -3331,7 +3331,7 @@ void InterfaceMap::setOutdoorsMonsters() { // TODO: Double-check.. this section looks *weird* MazeMonster &monster = map._mobData._monsters[ds._frame]; - MonsterStruct &monsterData = map._monsterData[monster._spriteId]; + MonsterStruct &monsterData = *monster._monsterData; ds._frame = monster._frame; diff --git a/engines/xeen/map.cpp b/engines/xeen/map.cpp index 439d5a8251..2017978398 100644 --- a/engines/xeen/map.cpp +++ b/engines/xeen/map.cpp @@ -660,11 +660,20 @@ MazeMonster::MazeMonster() { _effect3 = 0; _sprites = nullptr; _attackSprites = nullptr; + _monsterData = nullptr; } +/** + * Return the text color to use when displaying the monster's name in combat + * to indicate how damaged they are + */ int MazeMonster::getTextColor() const { - warning("TODO: getTextColor"); - return 0; + if (_hp == _monsterData->_hp) + return 15; + else if (_hp >= (_monsterData->_hp / 2)) + return 9; + else + return 32; } /*------------------------------------------------------------------------*/ @@ -682,7 +691,7 @@ MazeWallItem::MazeWallItem() { MonsterObjectData::MonsterObjectData(XeenEngine *vm): _vm(vm) { } -void MonsterObjectData::synchronize(XeenSerializer &s, MonsterData monsterData) { +void MonsterObjectData::synchronize(XeenSerializer &s, MonsterData &monsterData) { Common::Array<MobStruct> mobStructs; MobStruct mobStruct; byte b; @@ -781,10 +790,11 @@ void MonsterObjectData::synchronize(XeenSerializer &s, MonsterData monsterData) mon._spriteId = _monsterSprites[mon._id]._spriteId; mon._sprites = &_monsterSprites[mon._id]._sprites; mon._attackSprites = &_monsterSprites[mon._id]._attackSprites; + mon._monsterData = &monsterData[mon._spriteId]; + mon._frame = _vm->getRandomNumber(7); - MonsterStruct &md = monsterData[mon._spriteId]; + MonsterStruct &md = *mon._monsterData; mon._hp = md._hp; - mon._frame = _vm->getRandomNumber(7); mon._effect1 = mon._effect2 = md._animationEffect; if (md._animationEffect) mon._effect3 = _vm->getRandomNumber(7); diff --git a/engines/xeen/map.h b/engines/xeen/map.h index 85a1b8b5a5..bd74837788 100644 --- a/engines/xeen/map.h +++ b/engines/xeen/map.h @@ -253,6 +253,7 @@ struct MazeMonster { int _effect3; SpriteResource *_sprites; SpriteResource *_attackSprites; + MonsterStruct *_monsterData; MazeMonster(); @@ -306,7 +307,7 @@ public: public: MonsterObjectData(XeenEngine *vm); - void synchronize(XeenSerializer &s, MonsterData monsterData); + void synchronize(XeenSerializer &s, MonsterData &monsterData); }; class HeadData { diff --git a/engines/xeen/scripts.cpp b/engines/xeen/scripts.cpp index 7aab04c4c4..0d701fe3da 100644 --- a/engines/xeen/scripts.cpp +++ b/engines/xeen/scripts.cpp @@ -503,6 +503,7 @@ void Scripts::cmdSpawn(Common::Array<byte> ¶ms) { MazeMonster &monster = _vm->_map->_mobData._monsters[params[0]]; MonsterStruct &monsterData = _vm->_map->_monsterData[monster._spriteId]; + monster._monsterData = &monsterData; monster._position.x = params[1]; monster._position.y = params[2]; monster._frame = _vm->getRandomNumber(7); |