diff options
-rw-r--r-- | engines/xeen/character.cpp | 28 | ||||
-rw-r--r-- | engines/xeen/character.h | 2 | ||||
-rw-r--r-- | engines/xeen/events.cpp | 8 | ||||
-rw-r--r-- | engines/xeen/events.h | 2 | ||||
-rw-r--r-- | engines/xeen/interface.cpp | 116 | ||||
-rw-r--r-- | engines/xeen/interface.h | 2 | ||||
-rw-r--r-- | engines/xeen/interface_map.h | 2 |
7 files changed, 159 insertions, 1 deletions
diff --git a/engines/xeen/character.cpp b/engines/xeen/character.cpp index 4e4a4da697..fb1447d84c 100644 --- a/engines/xeen/character.cpp +++ b/engines/xeen/character.cpp @@ -1757,5 +1757,33 @@ int Character::makeItem(int p1, int itemIndex, int p3) { return category; } +void Character::subtractHitPoints(int amount) { + SoundManager &sound = *Party::_vm->_sound; + _currentHp -= amount; + bool flag = _currentHp <= 10; + + if (_currentHp < 1) { + int v = getMaxHP() + _currentHp; + if (v >= 1) { + _conditions[UNCONSCIOUS] = 1; + sound.playFX(38);; + } else { + _conditions[DEAD] = 1; + flag = true; + if (_currentHp > 0) + _currentHp = 0; + } + + if (flag) { + // Check for breaking equipped armor + for (int idx = 0; idx < INV_ITEMS_TOTAL; ++idx) { + XeenItem &item = _armor[idx]; + if (item._id && item._frame) + item._bonusFlags |= ITEMFLAG_BROKEN; + } + } + } +} + } // End of namespace Xeen diff --git a/engines/xeen/character.h b/engines/xeen/character.h index c9a787cbc5..7fc13f1015 100644 --- a/engines/xeen/character.h +++ b/engines/xeen/character.h @@ -309,6 +309,8 @@ public: int getNumAwards() const; int makeItem(int p1, int itemIndex, int p3); + + void subtractHitPoints(int amount); }; } // End of namespace Xeen diff --git a/engines/xeen/events.cpp b/engines/xeen/events.cpp index e0c3b26dc6..89a1ac3b50 100644 --- a/engines/xeen/events.cpp +++ b/engines/xeen/events.cpp @@ -168,6 +168,14 @@ bool EventsManager::wait(uint numFrames, bool interruptable) { return false; } +void EventsManager::ipause(int amount) { + updateGameCounter(); + do { + _vm->_interface->draw3d(true); + pollEventsAndWait(); + } while (!_vm->shouldQuit() && timeElapsed() < amount); +} + /** * Handles moving to the next game frame */ diff --git a/engines/xeen/events.h b/engines/xeen/events.h index 1705bb43d3..5d6918b0da 100644 --- a/engines/xeen/events.h +++ b/engines/xeen/events.h @@ -90,6 +90,8 @@ public: uint32 timeElapsed5() const { return _frameCounter - _gameCounters[5]; } bool wait(uint numFrames, bool interruptable = false); + + void ipause(int amount); }; class GameEvent { diff --git a/engines/xeen/interface.cpp b/engines/xeen/interface.cpp index c31ff844d9..0d734aa0ce 100644 --- a/engines/xeen/interface.cpp +++ b/engines/xeen/interface.cpp @@ -695,6 +695,32 @@ void Interface::perform() { _vm->_moveMonsters = true; break; + case Common::KEYCODE_b: + chargeStep(); + + if (map.getCell(2) < map.mazeData()._difficulties._wallNoPass + && !map._isOutdoors) { + switch (party._mazeDirection) { + case DIR_NORTH: + ++party._mazePosition.y; + break; + case DIR_EAST: + ++party._mazePosition.x; + break; + case DIR_SOUTH: + --party._mazePosition.y; + break; + case DIR_WEST: + --party._mazePosition.x; + break; + } + chargeStep(); + stepTime(); + } else { + bash(party._mazePosition, party._mazeDirection); + } + break; + case Common::KEYCODE_i: // Show Info dialog _vm->_moveMonsters = false; @@ -1086,4 +1112,94 @@ void Interface::rest() { } } +void Interface::bash(const Common::Point &pt, Direction direction) { + EventsManager &events = *_vm->_events; + Map &map = *_vm->_map; + Party &party = *_vm->_party; + Screen &screen = *_vm->_screen; + SoundManager &sound = *_vm->_sound; + + if (map._isOutdoors) + return; + + sound.playFX(31); + + uint charNum1 = 0, charNum2 = 0; + for (uint charIdx = 0; charIdx < party._activeParty.size(); ++charIdx) { + Character &c = party._activeParty[charIdx]; + Condition condition = c.worstCondition(); + + if (!(condition == ASLEEP || (condition >= PARALYZED && + condition <= ERADICATED))) { + if (charNum1) { + charNum2 = charIdx + 1; + break; + } else { + charNum1 = charIdx + 1; + } + } + } + + party._activeParty[charNum1 - 1].subtractHitPoints(2); + _charPowSprites.draw(screen._windows[0], 0, + Common::Point(CHAR_FACES_X[charNum1 - 1], 150)); + screen._windows[0].update(); + + if (charNum2) { + party._activeParty[charNum2 - 1].subtractHitPoints(2); + _charPowSprites.draw(screen._windows[0], 0, + Common::Point(CHAR_FACES_X[charNum2 - 1], 150)); + screen._windows[0].update(); + } + + int cell = map.mazeLookup(Common::Point(pt.x + SCREEN_POSITIONING_X[direction][7], + pt.y + SCREEN_POSITIONING_Y[direction][7]), 0, 0xffff); + if (cell != INVALID_CELL) { + int v = map.getCell(2); + + if (v == 7) { + ++_wo[207]; + ++_wo[267]; + ++_wo[287]; + } else if (v == 14) { + ++_wo[267]; + ++_wo[287]; + } else if (v == 15) { + ++_wo[287]; + } else { + int might = party._activeParty[charNum1 - 1].getStat(MIGHT) + + _vm->getRandomNumber(1, 30); + if (charNum2) + might += party._activeParty[charNum2 - 1].getStat(MIGHT); + + int bashThreshold = (v == 9) ? map.mazeData()._difficulties._bashGrate : + map.mazeData()._difficulties._bashWall; + if (might >= bashThreshold) { + // Remove the wall on the current cell, and the reverse wall + // on the cell we're bashing through to + map.setWall(pt, direction, 3); + switch (direction) { + case DIR_NORTH: + map.setWall(Common::Point(pt.x, pt.y + 1), DIR_SOUTH, 3); + break; + case DIR_EAST: + map.setWall(Common::Point(pt.x + 1, pt.y), DIR_WEST, 3); + break; + case DIR_SOUTH: + map.setWall(Common::Point(pt.x, pt.y - 1), DIR_NORTH, 3); + break; + case DIR_WEST: + map.setWall(Common::Point(pt.x - 1, pt.y), DIR_EAST, 3); + break; + } + } + } + } + + party.checkPartyDead(); + events.ipause(2); + charIconsPrint(true); +} + + } // End of namespace Xeen diff --git a/engines/xeen/interface.h b/engines/xeen/interface.h index cecc5c3a58..9d7cb5cd4f 100644 --- a/engines/xeen/interface.h +++ b/engines/xeen/interface.h @@ -106,6 +106,8 @@ public: void perform(); void rest(); + + void bash(const Common::Point &pt, Direction direction); }; } // End of namespace Xeen diff --git a/engines/xeen/interface_map.h b/engines/xeen/interface_map.h index 197f239404..034d1a6746 100644 --- a/engines/xeen/interface_map.h +++ b/engines/xeen/interface_map.h @@ -96,7 +96,6 @@ private: SpriteResource _spellFxSprites; SpriteResource _fecpSprites; SpriteResource _blessSprites; - SpriteResource _charPowSprites; int _combatFloatCounter; void initDrawStructs(); @@ -130,6 +129,7 @@ protected: public: OutdoorDrawList _outdoorList; IndoorDrawList _indoorList; + SpriteResource _charPowSprites; SpriteResource _globalSprites; bool _upDoorText; Common::String _screenText; |