void Scene1202::update() { Scene::update(); if (_isPuzzleSolved) { if (!isSoundPlaying(3)) leaveScene(0); } else if (_counter == 0 && isSolved()) { _clickedIndex = 0; SetMessageHandler(&Scene1202::hmSolved); setGlobalVar(V_TNT_DUMMY_BUILT, 1); _palette->copyToBasePalette(_paletteData); _palette->startFadeToPalette(24); playSound(3); _isPuzzleSolved = true; } else if (_clickedIndex >= 0 && _counter == 0) { // Swap TNT positions int destIndex = kScene1202Table[_clickedIndex]; sendMessage(_asTntItems[_clickedIndex], 0x2001, getSubVar(VA_TNT_POSITIONS, destIndex)); sendMessage(_asTntItems[destIndex], 0x2001, getSubVar(VA_TNT_POSITIONS, _clickedIndex)); int temp = getSubVar(VA_TNT_POSITIONS, destIndex); setSubVar(VA_TNT_POSITIONS, destIndex, getSubVar(VA_TNT_POSITIONS, _clickedIndex)); setSubVar(VA_TNT_POSITIONS, _clickedIndex, temp); _counter = 2; _clickedIndex = -1; playSound(_soundToggle ? 1 : 2); _soundToggle = !_soundToggle; } }
uint32 AsScene3009Symbol::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { case NM_KLAYMEN_CLIMB_LADDER: if (param.asInteger()) { if (_symbolIndex == 11) _symbolIndex = 0; else _symbolIndex++; } else { if (_symbolIndex == 0) _symbolIndex = 11; else _symbolIndex--; } startAnimation(kAsScene3009SymbolFileHashes[_symbolPosition / 3], _symbolIndex, -1); _newStickFrameIndex = _symbolIndex; setSubVar(VA_CURR_CANNON_SYMBOLS, _symbolPosition, _symbolIndex); if (_symbolPosition / 3 == 0) { sendMessage(_parentScene, 0x2001, 0); } else { sendMessage(_parentScene, 0x2003, 0); } messageResult = 1; break; } return messageResult; }
uint32 AsScene1307Key::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { case 0x1011: if (_isClickable) { sendMessage(_parentScene, 0x4826, 0); stRemoveKey(); messageResult = 1; } break; case 0x2000: _isClickable = param.asInteger() != 0; break; case 0x2001: setSubVar(VA_CURR_KEY_SLOT_NUMBERS, _keyIndex, param.asInteger()); stMoveKey(); break; case 0x2003: playSound(3); stUnlock(); break; case 0x2004: playSound(2); stInsert(); break; } return messageResult; }
void SmackerScene::nextVideo() { debug(0, "SmackerScene::nextVideo()"); _fileHashListIndex++; if (_fileHashList && _fileHashList[_fileHashListIndex] != 0) { uint32 smackerFileHash = _fileHashList[_fileHashListIndex]; ResourceHandle resourceHandle; _vm->_res->queryResource(smackerFileHash, resourceHandle); if (resourceHandle.type() != kResTypeVideo) { // Not a Smacker file _vm->_screen->setSmackerDecoder(NULL); sendMessage(_parentModule, 0x1009, 0); return; } _videoPlayedBefore = getSubVar(VA_SMACKER_PLAYED, smackerFileHash); if (!_videoPlayedBefore) setSubVar(VA_SMACKER_PLAYED, smackerFileHash, 1); if (_fileHashListIndex == 0) _smackerPlayer = addSmackerPlayer(new SmackerPlayer(_vm, this, smackerFileHash, _doubleSurface, false)); else _smackerPlayer->open(smackerFileHash, false); _vm->_screen->setSmackerDecoder(_smackerPlayer->getSmackerDecoder()); } else { _vm->_screen->setSmackerDecoder(NULL); sendMessage(_parentModule, 0x1009, 0); } }
uint32 SsScene2504Button::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); switch (messageNum) { case 0x1011: if (_countdown == 0 && !_isSoundPlaying) { setVisible(true); _countdown = 2; if (getSubVar(VA_LOCKS_DISABLED, 0x01180951)) setSubVar(VA_LOCKS_DISABLED, 0x01180951, 0); else setSubVar(VA_LOCKS_DISABLED, 0x01180951, 1); playSound(2); } messageResult = 1; break; } return messageResult; }
Scene2901::Scene2901(NeverhoodEngine *vm, Module *parentModule, int which) : Scene(vm, parentModule), _currLocationButtonNum(which), _selectedButtonNum(which), _currWhirlButtonNum(0), _prevWhirlButtonNum(0), _countdown1(1), _skipCountdown(0), _blinkOn(0) { _isButton2Broken = getGlobalVar(V_ENTRANCE_OPEN) != 0; setSubVar(V_TELEPORTER_DEST_AVAILABLE, which, 1); setSubVar(V_TELEPORTER_DEST_AVAILABLE, 5, 1); setSubVar(V_TELEPORTER_DEST_AVAILABLE, 4, 1); if (_currLocationButtonNum == 3) setSubVar(V_TELEPORTER_DEST_AVAILABLE, 2, 1); setBackground(kScene2901FileHashes1[_currLocationButtonNum]); setPalette(kScene2901FileHashes1[_currLocationButtonNum]); for (uint i = 0; i < 6; ++i) { if (i != 2 || !_isButton2Broken) { _ssLocationButtons[i] = insertSprite<SsScene2901LocationButton>(this, _currLocationButtonNum, i); addCollisionSprite(_ssLocationButtons[i]); _ssLocationButtonLights[i] = insertSprite<SsScene2901LocationButtonLight>(_currLocationButtonNum, i); } } if (_isButton2Broken) insertSprite<SsScene2901BrokenButton>(_currLocationButtonNum); _ssBigButton = insertSprite<SsScene2901BigButton>(this, _currLocationButtonNum); addCollisionSprite(_ssBigButton); insertPuzzleMouse(kScene2901FileHashes2[_currLocationButtonNum], 20, 620); SetUpdateHandler(&Scene2901::update); SetMessageHandler(&Scene2901::handleMessage); }
void Module2000::createScene(int sceneNum, int which) { debug(1, "Module2000::createScene(%d, %d)", sceneNum, which); _sceneNum = sceneNum; switch (_sceneNum) { case 0: _vm->gameState().sceneNum = 0; _childObject = new Scene2001(_vm, this, which); break; case 1: _vm->gameState().sceneNum = 1; createNavigationScene(getGlobalVar(V_WORLDS_JOINED) ? 0x004B7B48 : 0x004B7B00, which); break; case 2: _vm->gameState().sceneNum = 2; setGlobalVar(V_WORLDS_JOINED, 1); setSubVar(V_TELEPORTER_DEST_AVAILABLE, 1, 1); createSmackerScene(0x204B2031, true, true, false); break; } SetUpdateHandler(&Module2000::updateScene); _childObject->handleUpdate(); }
Scene1201::Scene1201(NeverhoodEngine *vm, Module *parentModule, int which) : Scene(vm, parentModule), _creatureExploded(false), _asMatch(NULL), _asTntMan(NULL), _asCreature(NULL), _asTntManRope(NULL), _asLeftDoor(NULL), _asRightDoor(NULL), _asTape(NULL) { int16 topY1, topY2, topY3, topY4; int16 x1, x2; Sprite *tempSprite; SetUpdateHandler(&Scene1201::update); SetMessageHandler(&Scene1201::handleMessage); setHitRects(0x004AEBD0); if (!getSubVar(VA_IS_PUZZLE_INIT, 0xE8058B52)) { setSubVar(VA_IS_PUZZLE_INIT, 0xE8058B52, 1); for (uint32 index = 0; index < 18; index++) setSubVar(VA_TNT_POSITIONS, index, kScene1201InitArray[index]); } insertScreenMouse(0x9A2C0409); _asTape = insertSprite<AsScene1201Tape>(this, 3, 1100, 243, 340, 0x9148A011); addCollisionSprite(_asTape); tempSprite = insertStaticSprite(0x03C82530, 100); topY1 = tempSprite->getY() + tempSprite->getDrawRect().height; tempSprite = insertStaticSprite(0x88182069, 200); topY2 = tempSprite->getY() + tempSprite->getDrawRect().height; tempSprite = insertStaticSprite(0x476014E0, 300); topY3 = tempSprite->getY() + tempSprite->getDrawRect().height; tempSprite = insertStaticSprite(0x04063110, 500); topY4 = tempSprite->getY() + 1; _asTntManRope = insertSprite<AsScene1201TntManRope>(getGlobalVar(V_TNT_DUMMY_BUILT) && which != 1); _asTntManRope->setClipRect(0, topY4, 640, 480); insertStaticSprite(0x400B04B0, 1200); tempSprite = insertStaticSprite(0x40295462, 1200); x1 = tempSprite->getX(); tempSprite = insertStaticSprite(0xA29223FA, 1200); x2 = tempSprite->getX() + tempSprite->getDrawRect().width; _asKlaymenHead = insertSprite<AsScene1201KlaymenHead>(); if (which < 0) { // Restoring game insertKlaymen<KmScene1201>(364, 333); setMessageList(0x004AEC08); } else if (which == 3) { // Klaymen standing after the weasel exploded insertKlaymen<KmScene1201>(400, 329); setMessageList(0x004AEC08); } else if (which == 2) { // Klaymen entering from the right if (getGlobalVar(V_CREATURE_ANGRY) && !getGlobalVar(V_CREATURE_EXPLODED)) { insertKlaymen<KmScene1201>(374, 333); setMessageList(0x004AEC08); } else { insertKlaymen<KmScene1201>(640, 329); setMessageList(0x004AEC20); } } else if (which == 1) { // Klaymen returning from the TNT console if (getGlobalVar(V_KLAYMEN_IS_DELTA_X)) { insertKlaymen<KmScene1201>(364, 333); _klaymen->setDoDeltaX(1); } else { insertKlaymen<KmScene1201>(246, 333); } setMessageList(0x004AEC30); } else { // Klaymen entering from the left insertKlaymen<KmScene1201>(0, 336); setMessageList(0x004AEC10); } _klaymen->setClipRect(x1, 0, x2, 480); _klaymen->setRepl(64, 0); if (getGlobalVar(V_CREATURE_ANGRY) && !getGlobalVar(V_CREATURE_EXPLODED)) { setBackground(0x4019A2C4); setPalette(0x4019A2C4); _asRightDoor = NULL; } else { setBackground(0x40206EC5); setPalette(0x40206EC5); _asRightDoor = insertSprite<AsScene1201RightDoor>(_klaymen, which == 2); } if (getGlobalVar(V_TNT_DUMMY_BUILT)) { insertStaticSprite(0x10002ED8, 500); if (!getGlobalVar(V_CREATURE_EXPLODED)) { _asTntMan = insertSprite<AsScene1201TntMan>(this, _asTntManRope, which == 1); _asTntMan->setClipRect(x1, 0, x2, 480); _asTntMan->setRepl(64, 0); addCollisionSprite(_asTntMan); tempSprite = insertSprite<AsScene1201TntManFlame>(_asTntMan); tempSprite->setClipRect(x1, 0, x2, 480); } uint32 tntIndex = 1; while (tntIndex < 18) { uint32 elemIndex = getSubVar(VA_TNT_POSITIONS, tntIndex); int16 clipY2; if (kScene1201PointArray[elemIndex].y < 175) clipY2 = topY1; else if (kScene1201PointArray[elemIndex].y < 230) clipY2 = topY2; else clipY2 = topY3; insertSprite<SsScene1201Tnt>(tntIndex, getSubVar(VA_TNT_POSITIONS, tntIndex), clipY2); elemIndex = getSubVar(VA_TNT_POSITIONS, tntIndex + 1); if (kScene1201PointArray[elemIndex].y < 175) clipY2 = topY1; else if (kScene1201PointArray[elemIndex].y < 230) clipY2 = topY2; else clipY2 = topY3; insertSprite<SsScene1201Tnt>(tntIndex + 1, getSubVar(VA_TNT_POSITIONS, tntIndex + 1), clipY2); tntIndex += 3; } if (getGlobalVar(V_CREATURE_ANGRY) && !getGlobalVar(V_CREATURE_EXPLODED)) { setRectList(0x004AEE58); } else { setRectList(0x004AEDC8); } } else { insertStaticSprite(0x8E8A1981, 900); uint32 tntIndex = 0; while (tntIndex < 18) { uint32 elemIndex = getSubVar(VA_TNT_POSITIONS, tntIndex); int16 clipY2; if (kScene1201PointArray[elemIndex].x < 300) { clipY2 = 480; } else { if (kScene1201PointArray[elemIndex].y < 175) clipY2 = topY1; else if (kScene1201PointArray[elemIndex].y < 230) clipY2 = topY2; else clipY2 = topY3; } insertSprite<SsScene1201Tnt>(tntIndex, getSubVar(VA_TNT_POSITIONS, tntIndex), clipY2); tntIndex++; } if (getGlobalVar(V_CREATURE_ANGRY) && !getGlobalVar(V_CREATURE_EXPLODED)) setRectList(0x004AEE18); else setRectList(0x004AED88); } tempSprite = insertStaticSprite(0x63D400BC, 900); _asLeftDoor = insertSprite<AsScene1201LeftDoor>(_klaymen); _asLeftDoor->setClipRect(x1, tempSprite->getDrawRect().y, tempSprite->getDrawRect().x2(), 480); if (getGlobalVar(V_CREATURE_ANGRY) && getGlobalVar(V_MATCH_STATUS) == 0) setGlobalVar(V_MATCH_STATUS, 1); _asMatch = NULL; if (getGlobalVar(V_MATCH_STATUS) < 3) { _asMatch = insertSprite<AsScene1201Match>(this); addCollisionSprite(_asMatch); } if (getGlobalVar(V_CREATURE_ANGRY) && getGlobalVar(V_CREATURE_EXPLODED) == 0) { _asCreature = insertSprite<AsScene1201Creature>(this, _klaymen); _asCreature->setClipRect(x1, 0, x2, 480); } }