bool DrasculaEngine::runCurrentChapter() { int n; _rightMouseButton = 0; previousMusic = -1; if (currentChapter != 2) { int soc = 0; for (n = 0; n < 6; n++) { soc = soc + CHARACTER_WIDTH; _frameX[n] = soc; } } for (n = 1; n < ARRAYSIZE(inventoryObjects); n++) inventoryObjects[n] = 0; for (n = 0; n < NUM_FLAGS; n++) flags[n] = 0; if (currentChapter == 2) { flags[16] = 1; flags[17] = 1; flags[27] = 1; } for (n = 1; n < 7; n++) inventoryObjects[n] = n; if (currentChapter == 1) { pickObject(28); if (!_loadedDifferentChapter) animation_1_1(); selectVerb(kVerbNone); loadPic("2aux62.alg", drawSurface2); trackProtagonist = 1; objExit = 104; if (_loadedDifferentChapter) { if (!loadGame(_currentSaveSlot)) { return true; } } else { enterRoom(62); curX = -20; curY = 56; gotoObject(65, 145); } // REMINDER: This is a good place to debug animations } else if (currentChapter == 2) { addObject(kItemPhone); trackProtagonist = 3; objExit = 162; if (!_loadedDifferentChapter) enterRoom(14); else { if (!loadGame(_currentSaveSlot)) { return true; } } } else if (currentChapter == 3) { addObject(kItemPhone); addObject(kItemEarplugs); addObject(kItemSickle); addObject(kItemHandbag); addObject(kItemCross); addObject(kItemReefer); addObject(kItemOneCoin); flags[1] = 1; trackProtagonist = 1; objExit = 99; if (!_loadedDifferentChapter) enterRoom(20); else { if (!loadGame(_currentSaveSlot)) { return true; } } // From here onwards the items have different IDs } else if (currentChapter == 4) { addObject(kItemPhone2); addObject(kItemCross2); addObject(kItemReefer2); addObject(kItemOneCoin2); objExit = 100; if (!_loadedDifferentChapter) { enterRoom(21); trackProtagonist = 0; curX = 235; curY = 164; } else { if (!loadGame(_currentSaveSlot)) { return true; } } } else if (currentChapter == 5) { addObject(28); addObject(7); addObject(9); addObject(11); addObject(13); addObject(14); addObject(15); addObject(17); addObject(20); trackProtagonist = 1; objExit = 100; if (!_loadedDifferentChapter) { enterRoom(45); } else { if (!loadGame(_currentSaveSlot)) { return true; } } } else if (currentChapter == 6) { addObject(28); addObject(9); trackProtagonist = 1; objExit = 104; if (!_loadedDifferentChapter) { enterRoom(58); animation_1_6(); } else { if (!loadGame(_currentSaveSlot)) { return true; } loadPic("auxdr.alg", drawSurface2); } } showCursor(); while (!shouldQuit()) { if (characterMoved == 0) { stepX = STEP_X; stepY = STEP_Y; } if (characterMoved == 0 && walkToObject == 1) { trackProtagonist = trackFinal; walkToObject = 0; } if (currentChapter == 2) { // NOTE: the checks for room number 14 below are a hack used in the original // game, and move the character to a place where his feet are not drawn above // the pianist's head. Originally, walkToObject was not updated properly, which // lead to an incorrect setting of the protagonist's tracking flag (above). This // made the character start walking off screen, as his actual position was // different than the displayed one if (_roomNumber == 3 && (curX == 279) && (curY + curHeight == 101)) { gotoObject(178, 121); gotoObject(169, 135); } else if (_roomNumber == 14 && (curX == 214) && (curY + curHeight == 121)) { walkToObject = 1; gotoObject(190, 130); } else if (_roomNumber == 14 && (curX == 246) && (curY + curHeight == 112)) { walkToObject = 1; gotoObject(190, 130); } } moveCursor(); updateScreen(); if (currentChapter == 2) { if (musicStatus() == 0 && roomMusic != 0) playMusic(roomMusic); } else { if (musicStatus() == 0) playMusic(roomMusic); } delay(25); #ifndef _WIN32_WCE // FIXME // This and the following #ifndefs disable the excess updateEvents() calls *within* the game loop. // Events such as keypresses or mouse clicks are dropped on the ground with no processing // by these calls. They are properly handled by the implicit call through getScan() below. // It is not a good practice to not process events and indeed this created problems with synthesized // events in the wince port. updateEvents(); #endif if (!_menuScreen && takeObject == 1) checkObjects(); #ifdef _WIN32_WCE if (_rightMouseButton) { if (_menuScreen) { #else if (_rightMouseButton == 1 && _menuScreen) { #endif _rightMouseButton = 0; delay(100); if (currentChapter == 2) { loadPic(menuBackground, cursorSurface); loadPic(menuBackground, backSurface); } else { loadPic(99, cursorSurface); loadPic(99, backSurface); } setPalette((byte *)&gamePalette); _menuScreen = false; #ifndef _WIN32_WCE // FIXME: This call here is in hope that it will catch the rightmouseup event so the // next if block won't be executed. This too is not a good coding practice. I've recoded it // with a mutual exclusive if block for the menu. I would commit this properly but I cannot test // for other (see Desktop) ports right now. updateEvents(); #endif #ifdef _WIN32_WCE } else { #else } // Do not show the inventory screen in chapter 5, if the right mouse button is clicked // while the plug (object 16) is held // Fixes bug #2059621 - "DRASCULA: Plug bug" if (_rightMouseButton == 1 && !_menuScreen && !(currentChapter == 5 && pickedObject == 16)) { #endif _rightMouseButton = 0; delay(100); characterMoved = 0; if (trackProtagonist == 2) trackProtagonist = 1; if (currentChapter == 4) { loadPic("icons2.alg", backSurface); loadPic("icons2.alg", cursorSurface); } else if (currentChapter == 5) { loadPic("icons3.alg", backSurface); loadPic("icons3.alg", cursorSurface); } else if (currentChapter == 6) { loadPic("iconsp.alg", backSurface); loadPic("iconsp.alg", cursorSurface); } else { loadPic("icons.alg", backSurface); loadPic("icons.alg", cursorSurface); } _menuScreen = true; #ifndef _WIN32_WCE updateEvents(); #endif selectVerb(kVerbNone); } #ifdef _WIN32_WCE } #endif if (_leftMouseButton == 1 && _menuBar) { delay(100); selectVerbFromBar(); } else if (_leftMouseButton == 1 && takeObject == 0) { delay(100); if (verify1()) return true; } else if (_leftMouseButton == 1 && takeObject == 1) { if (verify2()) return true; } _menuBar = (_mouseY < 24 && !_menuScreen) ? true : false; Common::KeyCode key = getScan(); if (key == Common::KEYCODE_F1 && !_menuScreen) { selectVerb(kVerbLook); } else if (key == Common::KEYCODE_F2 && !_menuScreen) { selectVerb(kVerbPick); } else if (key == Common::KEYCODE_F3 && !_menuScreen) { selectVerb(kVerbOpen); } else if (key == Common::KEYCODE_F4 && !_menuScreen) { selectVerb(kVerbClose); } else if (key == Common::KEYCODE_F5 && !_menuScreen) { selectVerb(kVerbTalk); } else if (key == Common::KEYCODE_F6 && !_menuScreen) { selectVerb(kVerbMove); } else if (key == Common::KEYCODE_F7) { // ScummVM load screen if (!scummVMSaveLoadDialog(false)) return true; } else if (key == Common::KEYCODE_F8) { selectVerb(kVerbNone); } else if (key == Common::KEYCODE_F9) { volumeControls(); } else if (key == Common::KEYCODE_F10) { if (!ConfMan.getBool("originalsaveload")) { // ScummVM save screen scummVMSaveLoadDialog(true); } else { // Original save/load screen if (!saveLoadScreen()) return true; } } else if (key == Common::KEYCODE_v) { _subtitlesDisabled = true; ConfMan.setBool("subtitles", !_subtitlesDisabled); print_abc(_textsys[2], 96, 86); updateScreen(); delay(1410); } else if (key == Common::KEYCODE_t) { _subtitlesDisabled = false; ConfMan.setBool("subtitles", !_subtitlesDisabled); print_abc(_textsys[3], 94, 86); updateScreen(); delay(1460); } else if (key == Common::KEYCODE_ESCAPE) { if (!confirmExit()) return false; } else if (key == Common::KEYCODE_TILDE || key == Common::KEYCODE_BACKQUOTE) { _console->attach(); _console->onFrame(); } else if (currentChapter == 6 && key == Common::KEYCODE_0 && _roomNumber == 61) { loadPic("alcbar.alg", bgSurface, 255); } if (_leftMouseButton != 0 || _rightMouseButton != 0 || key != 0) framesWithoutAction = 0; if (framesWithoutAction == 15000) { screenSaver(); framesWithoutAction = 0; } framesWithoutAction++; } return false; } bool DrasculaEngine::verify1() { int l; if (_menuScreen) removeObject(); else { for (l = 0; l < numRoomObjs; l++) { if (_mouseX >= _objectX1[l] && _mouseY >= _objectY1[l] && _mouseX <= _objectX2[l] && _mouseY <= _objectY2[l] && doBreak == 0) { if (exitRoom(l)) return true; if (doBreak == 1) break; } } if (_mouseX > curX && _mouseY > curY && _mouseX < curX + curWidth && _mouseY < curY + curHeight) doBreak = 1; for (l = 0; l < numRoomObjs; l++) { if (_mouseX > _objectX1[l] && _mouseY > _objectY1[l] && _mouseX < _objectX2[l] && _mouseY < _objectY2[l] && doBreak == 0) { roomX = roomObjX[l]; roomY = roomObjY[l]; trackFinal = trackObj[l]; doBreak = 1; walkToObject = 1; startWalking(); } } if (doBreak == 0) { roomX = CLIP(_mouseX, floorX1, floorX2); roomY = CLIP(_mouseY, floorY1 + feetHeight, floorY2); startWalking(); } doBreak = 0; } return false; }
void DemoApplication::mouseFunc(int button, int state, int x, int y) { if (state == 0) { m_mouseButtons |= 1 << button; } else { m_mouseButtons = 0; } m_mouseOldX = x; m_mouseOldY = y; updateModifierKeys(); if ((m_modifierKeys & BT_ACTIVE_ALT) && (state == 0)) { return; } // printf("button %i, state %i, x=%i,y=%i\n",button,state,x,y); // button 0, state 0 means left mouse down btVector3 rayTo = getRayTo(x, y); switch (button) { case 2: { if (state == 0) { shootBox(rayTo); } break; }; case 1: { if (state == 0) { #if 0 //apply an impulse if (m_dynamicsWorld) { btCollisionWorld::ClosestRayResultCallback rayCallback(m_cameraPosition,rayTo); m_dynamicsWorld->rayTest(m_cameraPosition,rayTo,rayCallback); if (rayCallback.hasHit()) { btRigidBody* body = btRigidBody::upcast(rayCallback.m_collisionObject); if (body) { body->setActivationState(ACTIVE_TAG); btVector3 impulse = rayTo; impulse.normalize(); float impulseStrength = 10.f; impulse *= impulseStrength; btVector3 relPos = rayCallback.m_hitPointWorld - body->getCenterOfMassPosition(); body->applyImpulse(impulse,relPos); } } } #endif } else { } break; } case 0: { if (state == 0) { // add a point to point constraint for picking if (m_dynamicsWorld) { btVector3 rayFrom; if (m_ortho) { rayFrom = rayTo; rayFrom.setZ(-100.f); } else { rayFrom = m_cameraPosition; } btCollisionWorld::ClosestRayResultCallback rayCallback( rayFrom, rayTo); m_dynamicsWorld->rayTest(rayFrom, rayTo, rayCallback); if (rayCallback.hasHit()) { btVector3 pickPos = rayCallback.m_hitPointWorld; pickObject(pickPos, rayCallback.m_collisionObject); gOldPickingPos = rayTo; gHitPos = pickPos; gOldPickingDist = (pickPos - rayFrom).length(); } } } else { removePickingConstraint(); } break; } default: {} } }
void DrasculaEngine::doTalkSequenceCommand(TalkSequenceCommand cmd) { switch (cmd.commandType) { case kPause: pause(cmd.action); break; case kSetFlag: flags[cmd.action] = 1; break; case kClearFlag: flags[cmd.action] = 0; break; case kPickObject: pickObject(cmd.action); break; case kAddObject: addObject(cmd.action); break; case kBreakOut: breakOut = 1; break; case kConverse: converse(cmd.action); break; case kPlaceVB: placeVonBraun(cmd.action); break; case kUpdateRoom: updateRoom(); break; case kUpdateScreen: updateScreen(); break; case kTrackProtagonist: trackProtagonist = cmd.action; break; case kPlaySound: playSound(cmd.action); break; case kFinishSound: finishSound(); break; case kTalkerGeneral: talk(cmd.action); break; case kTalkerDrunk: talk_drunk(cmd.action); break; case kTalkerPianist: talk_pianist(cmd.action); break; case kTalkerBJ: talk_bj(cmd.action); break; case kTalkerVBNormal: talk_vonBraun(cmd.action, kVonBraunNormal); break; case kTalkerVBDoor: talk_vonBraun(cmd.action, kVonBraunDoor); break; case kTalkerIgorSeated: talk_igor(cmd.action, kIgorSeated); break; case kTalkerWerewolf: talk_werewolf(cmd.action); break; case kTalkerMus: talk_mus(cmd.action); break; case kTalkerDrascula: talk_drascula(cmd.action, 1); break; case kTalkerBartender0: talk_bartender(cmd.action, 0); break; case kTalkerBartender1: talk_bartender(cmd.action, 1); break; default: error("doTalkSequenceCommand: Unknown command: %d", cmd.commandType); } }
BumpObject* TouchPoint::getPickedObject() { return pickObject().get<1>(); }