From 5e24974ad5ba3031867a92b7936b0b3bb112f9d5 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Tue, 16 Feb 2010 17:32:17 +0000 Subject: Implement xpisland990_elevcombo which allows you to free Catherine. svn-id: r48072 --- engines/mohawk/riven_external.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/engines/mohawk/riven_external.cpp b/engines/mohawk/riven_external.cpp index edabc10946..964fda5ba3 100644 --- a/engines/mohawk/riven_external.cpp +++ b/engines/mohawk/riven_external.cpp @@ -1201,10 +1201,29 @@ void RivenExternal::xgwatch(uint16 argc, uint16 *argv) { // pspit (Prison Island) external commands // ------------------------------------------------------------------------------------ -// Yeah, none of these are done yet :P +static uint16 getComboDigit(uint32 correctCombo, uint32 digitsCorrect) { + static const uint32 powers[] = { 100000, 10000, 1000, 100, 10, 1 }; + return (correctCombo % powers[digitsCorrect]) / powers[digitsCorrect + 1]; +} void RivenExternal::xpisland990_elevcombo(uint16 argc, uint16 *argv) { - // TODO: Elevator combo check + // Play button sound based on argv[0] + _vm->_sound->playSound(argv[0] + 5, false); + + // It is impossible to get here if Gehn is not trapped. However, + // the original also disallows brute forcing the ending if you have + // not yet trapped Gehn. + if (*_vm->matchVarToString("agehn") != 4) + return; + + uint32 *correctDigits = _vm->matchVarToString("pelevcombo"); + + // pelevcombo keeps count of how many buttons we have pressed in the correct order. + // When pelevcombo is 5, clicking the handle will show the video freeing Catherine. + if (argv[0] == getComboDigit(*_vm->matchVarToString("pcorrectorder"), *correctDigits)) + *correctDigits += 1; + else + *correctDigits = 0; } void RivenExternal::xpscpbtn(uint16 argc, uint16 *argv) { -- cgit v1.2.3