/* ScummVM - Graphic Adventure Engine * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT * file distributed with this source distribution. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ #include "gnap/gnap.h" #include "gnap/gamesys.h" #include "gnap/resource.h" namespace Gnap { enum { kHSPlatypus = 0, kHSExitUfoParty = 1, kHSExitUfo = 2, kHSExitShow = 3, kHSKissingLady = 4, kHSSpring = 5, kHSSpringGuy = 6, kHSDevice = 7, kHSWalkArea1 = 8, kHSWalkArea2 = 9 }; enum { kHSUfoExitLeft = 1, kHSUfoExitRight = 2, kHSUfoDevice = 3 }; int GnapEngine::scene44_init() { _gameSys->setAnimation(0, 0, 0); _gameSys->setAnimation(0, 0, 1); _gameSys->setAnimation(0, 0, 2); _gameSys->setAnimation(0, 0, 3); return 0xFF; } void GnapEngine::scene44_updateHotspots() { if (isFlag(kGFGnapControlsToyUFO)) { setHotspot(kHSPlatypus, 0, 0, 0, 0, SF_DISABLED); setHotspot(kHSUfoExitLeft, 0, 0, 10, 599, SF_EXIT_L_CURSOR); setHotspot(kHSUfoExitRight, 790, 0, 799, 599, SF_EXIT_R_CURSOR); setDeviceHotspot(kHSUfoDevice, -1, 534, -1, 599); _hotspotsCount = 4; } else { setHotspot(kHSPlatypus, 0, 0, 0, 0, SF_WALKABLE | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR); setHotspot(kHSExitUfoParty, 150, 580, 650, 600, SF_EXIT_D_CURSOR | SF_WALKABLE, 5, 9); setHotspot(kHSExitUfo, 0, 100, 10, 599, SF_EXIT_L_CURSOR, 0, 8); setHotspot(kHSExitShow, 790, 100, 799, 599, SF_EXIT_R_CURSOR, 10, 8); setHotspot(kHSKissingLady, 300, 160, 400, 315, SF_PLAT_CURSOR | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR, 5, 7); setHotspot(kHSSpring, 580, 310, 635, 375, SF_PLAT_CURSOR | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR, 7, 8); setHotspot(kHSSpringGuy, 610, 375, 690, 515, SF_PLAT_CURSOR | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR, 7, 8); setHotspot(kHSWalkArea1, 0, 0, 800, 445); setHotspot(kHSWalkArea2, 617, 0, 800, 600); setDeviceHotspot(kHSDevice, -1, -1, -1, -1); if (isFlag(kGFUnk13)) _hotspots[kHSKissingLady]._flags = SF_DISABLED; if (isFlag(kGFSpringTaken)) _hotspots[kHSSpring]._flags = SF_DISABLED; _hotspotsCount = 10; } } void GnapEngine::scene44_run() { queueInsertDeviceIcon(); _gameSys->insertSequence(0xF7, 0, 0, 0, kSeqLoop, 0, 0, 0); _gameSys->insertSequence(0xFC, 256, 0, 0, kSeqNone, 0, 0, 0); if (isFlag(kGFSpringTaken)) _s44_currSpringGuySequenceId = 0xF8; else _s44_currSpringGuySequenceId = 0xF9; _s44_nextSpringGuySequenceId = -1; _gameSys->setAnimation(_s44_currSpringGuySequenceId, 1, 4); _gameSys->insertSequence(_s44_currSpringGuySequenceId, 1, 0, 0, kSeqNone, 0, 0, 0); if (isFlag(kGFUnk13)) { if (_prevSceneNum != 50 || _sceneSavegameLoaded) { _s44_currKissingLadySequenceId = 0xF6; _s44_nextKissingLadySequenceId = -1; } else { setGrabCursorSprite(kItemGum); _s44_currKissingLadySequenceId = 0xF5; _s44_nextKissingLadySequenceId = 0xF6; _gameSys->setAnimation(0xF5, 1, 2); } } else { _s44_currKissingLadySequenceId = 0xEC; _s44_nextKissingLadySequenceId = -1; _gameSys->setAnimation(0xEC, 1, 2); } _gameSys->insertSequence(_s44_currKissingLadySequenceId, 1, 0, 0, kSeqNone, 0, 0, 0); if (isFlag(kGFGnapControlsToyUFO)) { _toyUfoId = 0; _toyUfoActionStatus = -1; _toyUfoSequenceId = toyUfoGetSequenceId(); _toyUfoNextSequenceId = _toyUfoSequenceId; if (_prevSceneNum == 43) _toyUfoX = 30; else _toyUfoX = 770; _gameSys->setAnimation(_toyUfoSequenceId | 0x10000, _toyUfoId, 3); _gameSys->insertSequence(_toyUfoSequenceId | 0x10000, _toyUfoId, 0, 0, kSeqNone, 0, _toyUfoX - 274, _toyUfoY - 128); endSceneInit(); } else { switch (_prevSceneNum) { case 43: initGnapPos(-1, 8, kDirUpRight); initPlatypusPos(-1, 7, kDirUpLeft); endSceneInit(); gnapWalkTo(2, 8, -1, 0x107B9, 1); platypusWalkTo(1, 8, -1, 0x107C2, 1); break; case 46: initGnapPos(11, 8, kDirUpRight); initPlatypusPos(11, 8, kDirUpLeft); endSceneInit(); gnapWalkTo(6, 8, -1, 0x107BA, 1); platypusWalkTo(7, 8, -1, 0x107D2, 1); break; case 50: initGnapPos(4, 8, kDirBottomRight); if (_sceneSavegameLoaded) { initPlatypusPos(_hotspotsWalkPos[4].x, _hotspotsWalkPos[4].y, kDirUnk4); } else if (!isFlag(kGFUnk13)) { _timers[0] = 50; _timers[1] = 20; _platX = 5; _platY = 8; _platypusSequenceId = 0xFD; _platypusFacing = kDirNone; _platypusId = 160; _platypusSequenceDatNum = 0; _gameSys->insertSequence(0xFD, 160, 0, 0, kSeqNone, 0, 0, 0); } endSceneInit(); break; default: initGnapPos(5, 11, kDirUpRight); initPlatypusPos(6, 11, kDirUpLeft); endSceneInit(); platypusWalkTo(6, 8, -1, 0x107C2, 1); gnapWalkTo(5, 8, -1, 0x107BA, 1); break; } } while (!_sceneDone) { if (!isSoundPlaying(0x1094B)) playSound(0x1094B, true); updateMouseCursor(); updateCursorByHotspot(); testWalk(0, 0, -1, -1, -1, -1); _sceneClickedHotspot = getClickedHotspotId(); updateGrabCursorSprite(0, 0); if (isFlag(kGFGnapControlsToyUFO)) { switch (_sceneClickedHotspot) { case kHSUfoExitLeft: if (_toyUfoActionStatus < 0) { _isLeavingScene = 1; _toyUfoActionStatus = 6; _newSceneNum = 43; toyUfoFlyTo(-35, -1, -35, 799, 0, 300, 3); } break; case kHSUfoExitRight: if (_toyUfoActionStatus < 0) { _isLeavingScene = 1; _toyUfoActionStatus = 6; _newSceneNum = 46; toyUfoFlyTo(835, -1, 0, 835, 0, 300, 3); } break; case kHSUfoDevice: runMenu(); scene44_updateHotspots(); _timers[4] = getRandom(20) + 20; break; } } else if (_sceneClickedHotspot <= 9) { switch (_sceneClickedHotspot) { case kHSDevice: runMenu(); scene44_updateHotspots(); _timers[4] = getRandom(20) + 20; break; case kHSPlatypus: if (_gnapActionStatus < 0) { if (_grabCursorSpriteIndex >= 0) { playGnapImpossible(_platX, _platY); } else { switch (_verbCursor) { case LOOK_CURSOR: playGnapMoan1(_platX, _platY); break; case GRAB_CURSOR: gnapKissPlatypus(0); break; case TALK_CURSOR: playGnapBrainPulsating(_platX, _platY); playPlatypusSequence(getPlatypusSequenceId()); break; case PLAT_CURSOR: playGnapImpossible(_platX, _platY); break; } } } break; case kHSExitUfoParty: _isLeavingScene = 1; gnapWalkTo(_hotspotsWalkPos[kHSExitUfoParty].x, _hotspotsWalkPos[kHSExitUfoParty].y, 0, 0x107AE, 1); _gnapActionStatus = 0; _newSceneNum = 40; break; case kHSExitUfo: _isLeavingScene = 1; gnapWalkTo(_hotspotsWalkPos[kHSExitUfo].x, _gnapY, 0, 0x107AF, 1); _gnapActionStatus = 0; platypusWalkTo(_hotspotsWalkPos[kHSExitUfo].x, _platY, -1, 0x107CF, 1); _newSceneNum = 43; break; case kHSExitShow: _isLeavingScene = 1; gnapWalkTo(_hotspotsWalkPos[kHSExitShow].x, _hotspotsWalkPos[kHSExitShow].y, 0, 0x107AB, 1); _gnapActionStatus = 0; _newSceneNum = 46; break; case kHSKissingLady: if (_grabCursorSpriteIndex >= 0) { _gnapActionStatus = 2; gnapWalkTo(_hotspotsWalkPos[kHSKissingLady].x, _hotspotsWalkPos[kHSKissingLady].y, 0, -1, 9); playGnapShowItem(_grabCursorSpriteIndex, _hotspotsWalkPos[kHSKissingLady].x - 1, _hotspotsWalkPos[kHSKissingLady].y); } else { switch (_verbCursor) { case LOOK_CURSOR: playGnapScratchingHead(4, 3); break; case GRAB_CURSOR: playGnapImpossible(0, 0); break; case TALK_CURSOR: _gnapIdleFacing = kDirUpLeft; gnapWalkTo(_hotspotsWalkPos[kHSKissingLady].x, _hotspotsWalkPos[kHSKissingLady].y, 0, getGnapSequenceId(gskBrainPulsating, 0, 0) | 0x10000, 1); _gnapActionStatus = 1; break; case PLAT_CURSOR: gnapUseDeviceOnPlatypuss(); platypusWalkTo(6, 7, 1, 0x107D2, 1); if (_gnapX == 7 && _gnapY == 7) gnapWalkStep(); playGnapIdle(5, 7); _platypusActionStatus = 4; break; } } break; case kHSSpring: if (_grabCursorSpriteIndex >= 0) { playGnapShowCurrItem(_hotspotsWalkPos[kHSSpring].x, _hotspotsWalkPos[kHSSpring].y, 8, 0); } else { switch (_verbCursor) { case LOOK_CURSOR: playGnapScratchingHead(8, 7); break; case GRAB_CURSOR: playGnapPullOutDevice(8, 0); playGnapUseDevice(8, 0); _s44_nextSpringGuySequenceId = 0xFB; invAdd(kItemSpring); setFlag(kGFSpringTaken); scene44_updateHotspots(); break; case TALK_CURSOR: playGnapImpossible(0, 0); break; case PLAT_CURSOR: playGnapImpossible(0, 0); break; } } break; case kHSSpringGuy: if (_grabCursorSpriteIndex >= 0) { playGnapShowCurrItem(_hotspotsWalkPos[kHSSpringGuy].x, _hotspotsWalkPos[kHSSpringGuy].y, 8, 0); } else { switch (_verbCursor) { case LOOK_CURSOR: if (isFlag(kGFSpringTaken)) playGnapMoan1(8, 7); else playGnapScratchingHead(8, 7); break; case TALK_CURSOR: _gnapIdleFacing = kDirUpRight; gnapWalkTo(_hotspotsWalkPos[kHSSpringGuy].x, _hotspotsWalkPos[kHSSpringGuy].y, -1, getGnapSequenceId(gskBrainPulsating, 0, 0) | 0x10000, 1); break; case GRAB_CURSOR: case PLAT_CURSOR: playGnapImpossible(0, 0); break; } } break; case kHSWalkArea1: case kHSWalkArea2: if (_gnapActionStatus < 0) gnapWalkTo(-1, -1, -1, -1, 1); break; } } if (_mouseClickState._left && _gnapActionStatus < 0) { _mouseClickState._left = false; if (isFlag(kGFGnapControlsToyUFO)) { _toyUfoActionStatus = 7; toyUfoFlyTo(-1, -1, 0, 799, 0, 300, 3); } else { gnapWalkTo(-1, -1, -1, -1, 1); } } scene44_updateAnimations(); toyUfoCheckTimer(); if (!_isLeavingScene) { if (_platypusActionStatus < 0 && !isFlag(kGFGnapControlsToyUFO) && _s44_currKissingLadySequenceId != 0xF5) updatePlatypusIdleSequence(); if (_gnapActionStatus < 0 && !isFlag(kGFGnapControlsToyUFO)) updateGnapIdleSequence(); if (!_timers[4]) { _timers[4] = getRandom(20) + 20; if (_gnapActionStatus < 0 && _platypusActionStatus < 0 && _s44_nextKissingLadySequenceId == -1) { switch (getRandom(20)) { case 0: _s44_nextKissingLadySequenceId = 0xED; break; case 1: _s44_nextKissingLadySequenceId = 0xEE; break; case 2: _s44_nextKissingLadySequenceId = 0xF0; break; case 3: _s44_nextKissingLadySequenceId = 0xF3; break; case 4: _s44_nextKissingLadySequenceId = 0xF4; break; default: _s44_nextKissingLadySequenceId = 0xEC; break; } if (_s44_nextKissingLadySequenceId != 0xEC && _s44_nextKissingLadySequenceId == _s44_currKissingLadySequenceId) _s44_nextKissingLadySequenceId = -1; } } if (!_timers[5]) { _timers[5] = getRandom(20) + 20; if (_gnapActionStatus < 0 && _platypusActionStatus < 0 && _s44_nextSpringGuySequenceId == -1) { if (getRandom(5) != 0) { if (!isFlag(kGFSpringTaken)) _s44_nextSpringGuySequenceId = 0xF9; } else { if (isFlag(kGFSpringTaken)) _s44_nextSpringGuySequenceId = 0xF8; else _s44_nextSpringGuySequenceId = 0xFA; } } } } checkGameKeys(); if (isKeyStatus1(8)) { clearKeyStatus1(8); runMenu(); scene44_updateHotspots(); _timers[4] = getRandom(20) + 20; } gameUpdateTick(); } } void GnapEngine::scene44_updateAnimations() { if (_gameSys->getAnimationStatus(0) == 2) { _gameSys->setAnimation(0, 0, 0); switch (_gnapActionStatus) { case 0: _sceneDone = true; break; case 1: _s44_nextKissingLadySequenceId = 0xEF; break; case 2: _s44_nextKissingLadySequenceId = 0xF2; break; } _gnapActionStatus = -1; } if (_gameSys->getAnimationStatus(1) == 2) { _gameSys->setAnimation(0, 0, 1); switch (_platypusActionStatus) { case 4: if (_gameSys->getAnimationStatus(2) == 2) { _gameSys->insertSequence(0xFE, _platypusId, _platypusSequenceId | (_platypusSequenceDatNum << 16), _platypusId, kSeqSyncWait, 0, 0, 0); _platypusSequenceId = 0xFE; _platypusSequenceDatNum = 0; _gameSys->setAnimation(0xFE, _platypusId, 1); _gameSys->removeSequence(_s44_currKissingLadySequenceId, 1, true); _platypusActionStatus = 5; } break; case 5: _sceneDone = true; _newSceneNum = 50; break; default: _platypusActionStatus = -1; break; } } if (_gameSys->getAnimationStatus(2) == 2) { if (_s44_nextKissingLadySequenceId == 0xF6) { _gameSys->insertSequence(_s44_nextKissingLadySequenceId, 1, _s44_currKissingLadySequenceId, 1, kSeqSyncWait, 0, 0, 0); initPlatypusPos(5, 8, kDirNone); _s44_currKissingLadySequenceId = _s44_nextKissingLadySequenceId; _s44_nextKissingLadySequenceId = -1; _gameSys->setAnimation(0, 0, 2); } else if (_s44_nextKissingLadySequenceId != -1) { _gameSys->insertSequence(_s44_nextKissingLadySequenceId, 1, _s44_currKissingLadySequenceId, 1, kSeqSyncWait, 0, 0, 0); _gameSys->setAnimation(_s44_nextKissingLadySequenceId, 1, 2); _s44_currKissingLadySequenceId = _s44_nextKissingLadySequenceId; _s44_nextKissingLadySequenceId = -1; _timers[4] = getRandom(20) + 20; } } if (_gameSys->getAnimationStatus(4) == 2) { if (_s44_currSpringGuySequenceId == 0xFB) { setGrabCursorSprite(kItemSpring); _s44_nextSpringGuySequenceId = 0xF8; } if (_s44_nextSpringGuySequenceId != -1) { _gameSys->insertSequence(_s44_nextSpringGuySequenceId, 1, _s44_currSpringGuySequenceId, 1, kSeqSyncWait, 0, 0, 0); _gameSys->setAnimation(_s44_nextSpringGuySequenceId, 1, 4); _s44_currSpringGuySequenceId = _s44_nextSpringGuySequenceId; _s44_nextSpringGuySequenceId = -1; _timers[5] = getRandom(20) + 20; } } if (_gameSys->getAnimationStatus(3) == 2) { switch (_toyUfoActionStatus) { case 6: _sceneDone = true; break; default: _toyUfoNextSequenceId = toyUfoGetSequenceId(); _gameSys->insertSequence(_toyUfoNextSequenceId | 0x10000, _toyUfoId + 1, _toyUfoSequenceId | 0x10000, _toyUfoId, kSeqSyncWait, 0, _toyUfoX - 274, _toyUfoY - 128); _toyUfoSequenceId = _toyUfoNextSequenceId; ++_toyUfoId; _gameSys->setAnimation(_toyUfoNextSequenceId | 0x10000, _toyUfoId, 3); break; } _toyUfoActionStatus = -1; } } } // End of namespace Gnap