aboutsummaryrefslogtreecommitdiff
path: root/engines/mohawk
diff options
context:
space:
mode:
authorMatthew Hoops2011-08-11 13:10:51 -0400
committerMatthew Hoops2011-08-11 13:14:03 -0400
commit1737190a7161ec77f1f3f0d6a72dfc1920850ee4 (patch)
treecff3e90f128e318a06c504e323d363887610911d /engines/mohawk
parent7ef6c73d61588482f2686c43047e0a4522c5baf8 (diff)
downloadscummvm-rg350-1737190a7161ec77f1f3f0d6a72dfc1920850ee4.tar.gz
scummvm-rg350-1737190a7161ec77f1f3f0d6a72dfc1920850ee4.tar.bz2
scummvm-rg350-1737190a7161ec77f1f3f0d6a72dfc1920850ee4.zip
MOHAWK: Implement the rest of the sunners code
Diffstat (limited to 'engines/mohawk')
-rw-r--r--engines/mohawk/riven.cpp172
-rw-r--r--engines/mohawk/riven.h1
-rw-r--r--engines/mohawk/riven_external.cpp27
3 files changed, 192 insertions, 8 deletions
diff --git a/engines/mohawk/riven.cpp b/engines/mohawk/riven.cpp
index 612b8b3685..ffd9621e02 100644
--- a/engines/mohawk/riven.cpp
+++ b/engines/mohawk/riven.cpp
@@ -209,8 +209,10 @@ void MohawkEngine_Riven::handleEvents() {
needsUpdate = true;
break;
case Common::EVENT_LBUTTONDOWN:
- if (_curHotspot >= 0)
+ if (_curHotspot >= 0) {
+ checkSunnerAlertClick();
runHotspotScript(_curHotspot, kMouseDownScript);
+ }
break;
case Common::EVENT_LBUTTONUP:
// See RivenScript::switchCard() for more information on why we sometimes
@@ -812,6 +814,138 @@ static void catherineIdleTimer(MohawkEngine_Riven *vm) {
vm->installTimer(&catherineIdleTimer, timeUntilNextMovie);
}
+static void sunnersTopStairsTimer(MohawkEngine_Riven *vm) {
+ // If the sunners are gone, we have no video to play
+ if (vm->_vars["jsunners"] != 0) {
+ vm->removeTimer();
+ return;
+ }
+
+ // Play a random sunners video if the script one is not playing already
+ // and then set a new timer for when the new video should be played
+
+ VideoHandle oldHandle = vm->_video->findVideoHandleRiven(1);
+ uint32 timerTime = 500;
+
+ if (oldHandle == NULL_VID_HANDLE || vm->_video->endOfVideo(oldHandle)) {
+ uint32 &sunnerTime = vm->_vars["jsunnertime"];
+
+ if (sunnerTime == 0) {
+ timerTime = vm->_rnd->getRandomNumberRng(2, 15) * 1000;
+ } else if (sunnerTime < vm->getTotalPlayTime()) {
+ VideoHandle handle = vm->_video->playMovieRiven(vm->_rnd->getRandomNumberRng(1, 3));
+
+ timerTime = vm->_video->getDuration(handle) + vm->_rnd->getRandomNumberRng(2, 15) * 1000;
+ }
+
+ sunnerTime = timerTime + vm->getTotalPlayTime();
+ }
+
+ vm->installTimer(&sunnersTopStairsTimer, timerTime);
+}
+
+static void sunnersMidStairsTimer(MohawkEngine_Riven *vm) {
+ // If the sunners are gone, we have no video to play
+ if (vm->_vars["jsunners"] != 0) {
+ vm->removeTimer();
+ return;
+ }
+
+ // Play a random sunners video if the script one is not playing already
+ // and then set a new timer for when the new video should be played
+
+ VideoHandle oldHandle = vm->_video->findVideoHandleRiven(1);
+ uint32 timerTime = 500;
+
+ if (oldHandle == NULL_VID_HANDLE || vm->_video->endOfVideo(oldHandle)) {
+ uint32 &sunnerTime = vm->_vars["jsunnertime"];
+
+ if (sunnerTime == 0) {
+ timerTime = vm->_rnd->getRandomNumberRng(1, 10) * 1000;
+ } else if (sunnerTime < vm->getTotalPlayTime()) {
+ // Randomize the video
+ int randValue = vm->_rnd->getRandomNumber(5);
+ uint16 movie = 4;
+ if (randValue == 4)
+ movie = 2;
+ else if (randValue == 5)
+ movie = 3;
+
+ VideoHandle handle = vm->_video->playMovieRiven(movie);
+
+ timerTime = vm->_video->getDuration(handle) + vm->_rnd->getRandomNumberRng(1, 10) * 1000;
+ }
+
+ sunnerTime = timerTime + vm->getTotalPlayTime();
+ }
+
+ vm->installTimer(&sunnersMidStairsTimer, timerTime);
+}
+
+static void sunnersLowerStairsTimer(MohawkEngine_Riven *vm) {
+ // If the sunners are gone, we have no video to play
+ if (vm->_vars["jsunners"] != 0) {
+ vm->removeTimer();
+ return;
+ }
+
+ // Play a random sunners video if the script one is not playing already
+ // and then set a new timer for when the new video should be played
+
+ VideoHandle oldHandle = vm->_video->findVideoHandleRiven(1);
+ uint32 timerTime = 500;
+
+ if (oldHandle == NULL_VID_HANDLE || vm->_video->endOfVideo(oldHandle)) {
+ uint32 &sunnerTime = vm->_vars["jsunnertime"];
+
+ if (sunnerTime == 0) {
+ timerTime = vm->_rnd->getRandomNumberRng(1, 30) * 1000;
+ } else if (sunnerTime < vm->getTotalPlayTime()) {
+ VideoHandle handle = vm->_video->playMovieRiven(vm->_rnd->getRandomNumberRng(3, 5));
+
+ timerTime = vm->_video->getDuration(handle) + vm->_rnd->getRandomNumberRng(1, 30) * 1000;
+ }
+
+ sunnerTime = timerTime + vm->getTotalPlayTime();
+ }
+
+ vm->installTimer(&sunnersLowerStairsTimer, timerTime);
+}
+
+static void sunnersBeachTimer(MohawkEngine_Riven *vm) {
+ // If the sunners are gone, we have no video to play
+ if (vm->_vars["jsunners"] != 0) {
+ vm->removeTimer();
+ return;
+ }
+
+ // Play a random sunners video if the script one is not playing already
+ // and then set a new timer for when the new video should be played
+
+ VideoHandle oldHandle = vm->_video->findVideoHandleRiven(3);
+ uint32 timerTime = 500;
+
+ if (oldHandle == NULL_VID_HANDLE || vm->_video->endOfVideo(oldHandle)) {
+ uint32 &sunnerTime = vm->_vars["jsunnertime"];
+
+ if (sunnerTime == 0) {
+ timerTime = vm->_rnd->getRandomNumberRng(1, 30) * 1000;
+ } else if (sunnerTime < vm->getTotalPlayTime()) {
+ // Unlike the other cards' scripts which automatically
+ // activate the MLST, we have to set it manually here.
+ uint16 mlstID = vm->_rnd->getRandomNumberRng(3, 8);
+ vm->_video->activateMLST(mlstID, vm->getCurCard());
+ VideoHandle handle = vm->_video->playMovieRiven(mlstID);
+
+ timerTime = vm->_video->getDuration(handle) + vm->_rnd->getRandomNumberRng(1, 30) * 1000;
+ }
+
+ sunnerTime = timerTime + vm->getTotalPlayTime();
+ }
+
+ vm->installTimer(&sunnersBeachTimer, timerTime);
+}
+
void MohawkEngine_Riven::installCardTimer() {
switch (getCurCardRMAP()) {
case 0x3a85: // Top of elevator on prison island
@@ -819,16 +953,16 @@ void MohawkEngine_Riven::installCardTimer() {
installTimer(&catherineIdleTimer, _rnd->getRandomNumberRng(1, 33) * 1000);
break;
case 0x77d6: // Sunners, top of stairs
- // TODO: Background Sunner videos
+ installTimer(&sunnersTopStairsTimer, 500);
break;
case 0x79bd: // Sunners, middle of stairs
- // TODO: Background Sunner videos
+ installTimer(&sunnersMidStairsTimer, 500);
break;
case 0x7beb: // Sunners, bottom of stairs
- // TODO: Background Sunner videos
+ installTimer(&sunnersLowerStairsTimer, 500);
break;
case 0xb6ca: // Sunners, shoreline
- // TODO: Background Sunner videos
+ installTimer(&sunnersBeachTimer, 500);
break;
}
}
@@ -846,6 +980,34 @@ void MohawkEngine_Riven::doVideoTimer(VideoHandle handle, bool force) {
_scriptMan->runStoredMovieOpcode();
}
+void MohawkEngine_Riven::checkSunnerAlertClick() {
+ // We need to do a manual hardcoded check for the sunners'
+ // alert movies.
+
+ uint32 &sunners = _vars["jsunners"];
+
+ // If the sunners are gone, there's nothing for us to do
+ if (sunners != 0)
+ return;
+
+ uint32 rmapCode = getCurCardRMAP();
+
+ // This is only for the mid/lower staircase sections
+ if (rmapCode != 0x79bd && rmapCode != 0x7beb)
+ return;
+
+ // Only set the sunners variable on the forward hotspot
+ if ((rmapCode == 0x79bd && _curHotspot != 1) || (rmapCode == 0x7beb && _curHotspot != 2))
+ return;
+
+ // If the alert video is no longer playing, we have nothing left to do
+ VideoHandle handle = _video->findVideoHandleRiven(1);
+ if (handle == NULL_VID_HANDLE || _video->endOfVideo(handle))
+ return;
+
+ sunners = 1;
+}
+
bool ZipMode::operator== (const ZipMode &z) const {
return z.name == name && z.id == id;
}
diff --git a/engines/mohawk/riven.h b/engines/mohawk/riven.h
index c7d36e585d..01a4fbb38c 100644
--- a/engines/mohawk/riven.h
+++ b/engines/mohawk/riven.h
@@ -164,6 +164,7 @@ private:
// Miscellaneous
bool _gameOver;
bool _ignoreNextMouseUp;
+ void checkSunnerAlertClick();
public:
// Stack/card/script funtions
diff --git a/engines/mohawk/riven_external.cpp b/engines/mohawk/riven_external.cpp
index 60e94ea795..c72dafaf7f 100644
--- a/engines/mohawk/riven_external.cpp
+++ b/engines/mohawk/riven_external.cpp
@@ -1889,21 +1889,42 @@ void RivenExternal::xjplaybeetle_1450(uint16 argc, uint16 *argv) {
}
void RivenExternal::xjlagoon700_alert(uint16 argc, uint16 *argv) {
- // TODO: Sunner related
+ // Handle sunner reactions (mid-staircase)
+
+ if (_vm->_vars["jsunners"] == 0)
+ _vm->_video->playMovieRiven(1);
}
void RivenExternal::xjlagoon800_alert(uint16 argc, uint16 *argv) {
- // TODO: Sunner related
+ // Handle sunner reactions (lower-staircase)
+
+ uint32 &sunners = _vm->_vars["jsunners"];
+
+ if (sunners == 0) {
+ // Show the sunners alert video
+ _vm->_video->playMovieRiven(1);
+ } else if (sunners == 1) {
+ // Show the sunners leaving if you moved forward in their "alert" status
+ _vm->_video->playMovieBlockingRiven(2);
+ _vm->_video->playMovieBlockingRiven(6);
+ sunners = 2;
+ _vm->refreshCard();
+ }
}
void RivenExternal::xjlagoon1500_alert(uint16 argc, uint16 *argv) {
- // Have the sunners move a bit as you get closer ;)
+ // Handle sunner reactions (beach)
+
uint32 &sunners = _vm->_vars["jsunners"];
+
if (sunners == 0) {
+ // Show the sunners alert video
_vm->_video->playMovieBlockingRiven(3);
} else if (sunners == 1) {
+ // Show the sunners leaving if you moved forward in their "alert" status
_vm->_video->playMovieBlockingRiven(2);
sunners = 2;
+ _vm->refreshCard();
}
}