diff --git a/engines/myst3/script.cpp b/engines/myst3/script.cpp index d4752fe3f3a..315d711d26d 100644 --- a/engines/myst3/script.cpp +++ b/engines/myst3/script.cpp @@ -1126,6 +1126,20 @@ void Script::varDecrementMin(Context &c, const Opcode &cmd) { _vm->_state->setVar(cmd.args[0], value); } +void Script::varDecrementMinLooping(Context &c, const Opcode &cmd) { + debugC(kDebugScript, "Opcode %d: Decrement var %d in range [%d, %d]", + cmd.op, cmd.args[0], cmd.args[1], cmd.args[2]); + + int32 value = _vm->_state->getVar(cmd.args[0]); + + value--; + + if (value < cmd.args[1]) + value = cmd.args[2]; + + _vm->_state->setVar(cmd.args[0], value); +} + void Script::varAddValueMax(Context &c, const Opcode &cmd) { debugC(kDebugScript, "Opcode %d: Add value %d to var %d with max value %d", cmd.op, cmd.args[0], cmd.args[1], cmd.args[2]); diff --git a/engines/myst3/script.h b/engines/myst3/script.h index 94aa1b566db..4727fb4d25f 100644 --- a/engines/myst3/script.h +++ b/engines/myst3/script.h @@ -176,6 +176,7 @@ private: DECLARE_OPCODE(varAddValueMaxLooping); DECLARE_OPCODE(varDecrement); DECLARE_OPCODE(varDecrementMin); + DECLARE_OPCODE(varDecrementMinLooping); DECLARE_OPCODE(varAddValueMax); DECLARE_OPCODE(varSubValueMin); DECLARE_OPCODE(varZeroRange);