diff options
-rw-r--r-- | engines/xeen/dialogs_whowill.cpp | 5 | ||||
-rw-r--r-- | engines/xeen/interface.cpp | 10 | ||||
-rw-r--r-- | engines/xeen/resources.cpp | 8 | ||||
-rw-r--r-- | engines/xeen/scripts.cpp | 61 | ||||
-rw-r--r-- | engines/xeen/scripts.h | 4 | ||||
-rw-r--r-- | engines/xeen/xeen.cpp | 2 |
6 files changed, 70 insertions, 20 deletions
diff --git a/engines/xeen/dialogs_whowill.cpp b/engines/xeen/dialogs_whowill.cpp index 10bbae26ee..fd72154cba 100644 --- a/engines/xeen/dialogs_whowill.cpp +++ b/engines/xeen/dialogs_whowill.cpp @@ -84,8 +84,8 @@ int WhoWill::execute(int message, int action, bool type) { if (_buttonValue == 27) { _buttonValue = 0; break; - } else if (_buttonValue >= 201 && _buttonValue <= 206) { - _buttonValue -= 201; + } else if (_buttonValue >= Common::KEYCODE_F1 && _buttonValue <= Common::KEYCODE_F6) { + _buttonValue -= Common::KEYCODE_F1 - 1; if (_buttonValue > (int)party._activeParty.size()) continue; @@ -97,7 +97,6 @@ int WhoWill::execute(int message, int action, bool type) { } } - intf._face1State = intf._face2State = 2; screen._windows[36].close(); return _buttonValue; diff --git a/engines/xeen/interface.cpp b/engines/xeen/interface.cpp index de4137ebd6..ded3d9ca00 100644 --- a/engines/xeen/interface.cpp +++ b/engines/xeen/interface.cpp @@ -269,22 +269,24 @@ void Interface::perform() { Party &party = *_vm->_party; Scripts &scripts = *_vm->_scripts; Spells &spells = *_vm->_spells; - const Common::Rect waitBounds(8, 8, 224, 140); + const Common::Rect WAIT_BOUNDS(8, 8, 224, 140); events.updateGameCounter(); draw3d(true); - // Wait for a frame + // Wait for a frame or a user event do { events.pollEventsAndWait(); checkEvents(_vm); + + if (events._leftButton && WAIT_BOUNDS.contains(events._mousePos)) + _buttonValue = Common::KEYCODE_SPACE; } while (!_buttonValue && events.timeElapsed() < 1 && !_vm->_party->_partyDead); if (!_buttonValue && !_vm->_party->_partyDead) return; - if (_buttonValue == Common::KEYCODE_SPACE || - (events._leftButton && waitBounds.contains(events._mousePos))) { + if (_buttonValue == Common::KEYCODE_SPACE) { int lookupId = map.mazeLookup(party._mazePosition, WALL_SHIFTS[party._mazeDirection][2]); diff --git a/engines/xeen/resources.cpp b/engines/xeen/resources.cpp index 2716f245b3..5c76d29173 100644 --- a/engines/xeen/resources.cpp +++ b/engines/xeen/resources.cpp @@ -107,10 +107,10 @@ const char *const SURFACE_NAMES[16] = { }; const char *const WHO_ACTIONS[32] = { - "aSearch", "aOpen", "aDrink", "aMine", "aTouch", "aRead", "aLearn", "aTake", - "aBang", "aSteal", "aBribe", "aPay", "aSit", "aTry", "aTurn", "aBathe", - "aDestroy", "aPull", "aDescend", "aTossACoin", "aPray", "aJoin", "aAct", - "aPlay", "aPush", "aRub", "aPick", "aEat", "aSign", "aClose", "aLook", "aTry" + "search", "open", "drink", "mine", "touch", "read", "learn", "take", + "bang", "steal", "bribe", "pay", "sit", "try", "turn", "bathe", + "destroy", "pull", "descend", "toss a coin", "pray", "join", "act", + "play", "push", "rub", "pick", "eat", "sign", "close", "look", "try" }; const char *const WHO_WILL_ACTIONS[4] = { diff --git a/engines/xeen/scripts.cpp b/engines/xeen/scripts.cpp index ef101b9377..f1bce0438c 100644 --- a/engines/xeen/scripts.cpp +++ b/engines/xeen/scripts.cpp @@ -207,12 +207,63 @@ int Scripts::checkEvents() { return _scriptResult; } -void Scripts::giveTreasure() { - // TODO -} +void Scripts::openGrate(int wallVal, int action) { + Combat &combat = *_vm->_combat; + Interface &intf = *_vm->_interface; + Map &map = *_vm->_map; + Party &party = *_vm->_party; + SoundManager &sound = *_vm->_sound; + bool isDarkCc = _vm->_files->_isDarkCc; + + if ((wallVal != 13 || map._currentIsGrate) && (!isDarkCc || wallVal != 9 || + map.mazeData()._wallKind != 2)) { + if (wallVal != 9 && !map._currentIsGrate) { + int charIndex = WhoWill::show(_vm, 13, action, false) - 1; + if (charIndex >= 0) { + // There is a 1 in 4 chance the character will receive damage + if (_vm->getRandomNumber(1, 4) == 1) { + combat.giveCharDamage(map.mazeData()._trapDamage, + (DamageType)_vm->getRandomNumber(0, 6), charIndex); + } -void Scripts::openGrate(int v1, int v2) { - // TODO + // Check whether character can unlock the door + Character &c = party._activeParty[charIndex]; + if ((c.getThievery() + _vm->getRandomNumber(1, 20)) < + map.mazeData()._difficulties._unlockDoor) + return; + + c._experience += map.mazeData()._difficulties._unlockDoor * c.getCurrentLevel(); + } + + // Set the wall state for the wall party is facing + map.setCellSurfaceFlags(party._mazePosition, 0x80); + map.setWall(party._mazePosition, party._mazeDirection, wallVal); + + // Set the wall state for the reverse wall in the next cell over + Common::Point pt = party._mazePosition; + Direction dir = (Direction)((int)party._mazeDirection ^ 2); + switch (party._mazeDirection) { + case DIR_NORTH: + pt.y++; + break; + case DIR_EAST: + pt.x++; + break; + case DIR_SOUTH: + pt.y--; + break; + case DIR_WEST: + pt.x--; + break; + } + + map.setCellSurfaceFlags(pt, 0x80); + map.setWall(pt, dir, wallVal); + sound.playFX(10); + } + + intf.draw3d(true); + } } typedef void(Scripts::*ScriptMethodPtr)(Common::Array<byte> &); diff --git a/engines/xeen/scripts.h b/engines/xeen/scripts.h index 1db672bd18..d347ec07bf 100644 --- a/engines/xeen/scripts.h +++ b/engines/xeen/scripts.h @@ -233,9 +233,7 @@ public: int checkEvents(); - void giveTreasure(); - - void openGrate(int v1, int v2); + void openGrate(int v1, int action); }; } // End of namespace Xeen diff --git a/engines/xeen/xeen.cpp b/engines/xeen/xeen.cpp index 1410d65627..a1604a5eab 100644 --- a/engines/xeen/xeen.cpp +++ b/engines/xeen/xeen.cpp @@ -333,7 +333,7 @@ void XeenEngine::gameLoop() { if (shouldQuit() || _quitMode) return; } - _scripts->giveTreasure(); + _party->giveTreasure(); // Main user interface handler for waiting for and processing user input _interface->perform(); |