void sceneHandler29_animBearded() { MessageQueue *mq; for (uint i = 0; i < g_vars->scene29_bearders.size(); i++) { StaticANIObject *ani = g_vars->scene29_bearders[i]->ani; if (g_vars->scene29_bearders[i]->wbflag) { int x = ani->_ox; int y = ani->_oy; if (!ani->_movement && ani->_statics->_staticsId == (ST_BRDCMN_RIGHT | 0x4000)) { x -= 4; if (x - g_vars->scene29_manX < 100 || !g_vars->scene29_arcadeIsOn) { mq = new MessageQueue(g_fp->_currentScene->getMessageQueueById(QU_SC29_BRDOUT1), 0, 1); mq->replaceKeyCode(-1, ani->_okeyCode); mq->chain(0); g_vars->scene29_bearders[i]->wbflag = 0; g_vars->scene29_bearders[i]->wbcounter = 0; } } if (!ani->_movement && ani->_statics->_staticsId == ST_BRDCMN_GOR) ani->startAnim(MV_BRDCMN_GOR, 0, -1); if (ani->_movement) { if (ani->_movement->_id == MV_BRDCMN_GOR) { x -= 4; if (g_vars->scene29_manX - x < 60 || x - g_vars->scene29_manX < -260 || !g_vars->scene29_arcadeIsOn) { ani->changeStatics2(ST_BRDCMN_RIGHT); mq = new MessageQueue(g_fp->_currentScene->getMessageQueueById(QU_SC29_BRDOUT2), 0, 1); mq->replaceKeyCode(-1, ani->_okeyCode); mq->chain(0); g_vars->scene29_bearders[i]->wbflag = 0; g_vars->scene29_bearders[i]->wbcounter = 0; } } } ani->setOXY(x, y); continue; } if (g_vars->scene29_arcadeIsOn && g_vars->scene29_bearders[i]->wbcounter > 30) { int newx; if (g_fp->_rnd->getRandomNumber(1)) goto dostuff; if (g_vars->scene29_manX <= 700) { g_vars->scene29_bearders[i]->wbcounter++; continue; } if (g_vars->scene29_manX >= 1100) { dostuff: if (g_vars->scene29_manX <= 700 || g_vars->scene29_manX >= 1350) { g_vars->scene29_bearders[i]->wbcounter++; continue; } mq = new MessageQueue(g_fp->_currentScene->getMessageQueueById(QU_SC29_BRD2), 0, 1); newx = g_vars->scene29_manX - 200; } else { mq = new MessageQueue(g_fp->_currentScene->getMessageQueueById(QU_SC29_BRD1), 0, 1); newx = g_vars->scene29_manX + 350; } mq->getExCommandByIndex(0)->_x = newx; mq->replaceKeyCode(-1, ani->_okeyCode); mq->chain(0); g_vars->scene29_bearders[i]->wbflag = 1; g_vars->scene29_bearders[i]->wbcounter = 0; } g_vars->scene29_bearders[i]->wbcounter++; } }
bool GameLoader::gotoScene(int sceneId, int entranceId) { SceneTag *st; int sc2idx = getSceneTagBySceneId(sceneId, &st); if (sc2idx < 0) return false; if (!_sc2array[sc2idx]._isLoaded) return false; if (_sc2array[sc2idx]._entranceDataCount < 1) { g_fp->_currentScene = st->_scene; return true; } if (_sc2array[sc2idx]._entranceDataCount <= 0) return false; int entranceIdx = 0; if (sceneId != 726) // WORKAROUND for (entranceIdx = 0; _sc2array[sc2idx]._entranceData[entranceIdx]->_field_4 != entranceId; entranceIdx++) { if (entranceIdx >= _sc2array[sc2idx]._entranceDataCount) return false; } GameVar *sg = _gameVar->getSubVarByName("OBJSTATES")->getSubVarByName("SAVEGAME"); if (sg || (sg = _gameVar->getSubVarByName("OBJSTATES")->addSubVarAsInt("SAVEGAME", 0)) != 0) sg->setSubVarAsInt("Entrance", entranceId); if (!g_fp->sceneSwitcher(_sc2array[sc2idx]._entranceData[entranceIdx])) return false; g_fp->_msgObjectId2 = 0; g_fp->_msgY = -1; g_fp->_msgX = -1; g_fp->_currentScene = st->_scene; MessageQueue *mq1 = g_fp->_currentScene->getMessageQueueById(_sc2array[sc2idx]._entranceData[entranceIdx]->_messageQueueId); if (mq1) { MessageQueue *mq = new MessageQueue(mq1, 0, 0); StaticANIObject *stobj = g_fp->_currentScene->getStaticANIObject1ById(_field_FA, -1); if (stobj) { stobj->_flags &= 0x100; ExCommand *ex = new ExCommand(stobj->_id, 34, 256, 0, 0, 0, 1, 0, 0, 0); ex->_field_14 = 256; ex->_messageNum = 0; ex->_excFlags |= 3; mq->addExCommandToEnd(ex); } mq->setFlags(mq->getFlags() | 1); if (!mq->chain(0)) { delete mq; return false; } } else { StaticANIObject *stobj = g_fp->_currentScene->getStaticANIObject1ById(_field_FA, -1); if (stobj) stobj->_flags &= 0xfeff; } return true; }
void sceneHandler06_mumsyBallTake() { int momAni = 0; switch (g_vars->scene06_mumsyNumBalls) { case 1: momAni = MV_MOM_TAKE1; break; case 2: momAni = MV_MOM_TAKE2; break; case 3: momAni = MV_MOM_TAKE3; break; case 4: momAni = MV_MOM_TAKE4; break; case 5: momAni = MV_MOM_TAKE5; break; } MessageQueue *mq = new MessageQueue(g_fp->_globalMessageQueueList->compact()); ExCommand *ex = new ExCommand(ANI_MAMASHA, 2, 50, 0, 0, 0, 1, 0, 0, 0); ex->_excFlags = 2u; mq->addExCommandToEnd(ex); if (g_vars->scene06_mumsyNumBalls >= 5) { g_fp->setObjectState(sO_BigMumsy, g_fp->getObjectEnumState(sO_BigMumsy, sO_IsGone)); if (g_fp->getObjectState(sO_ClockAxis) == g_fp->getObjectEnumState(sO_ClockAxis, sO_IsNotAvailable)) g_fp->setObjectState(sO_ClockAxis, g_fp->getObjectEnumState(sO_ClockAxis, sO_WithoutHandle)); ex = new ExCommand(ANI_MAMASHA, 1, momAni, 0, 0, 0, 1, 0, 0, 0); ex->_excFlags |= 2; mq->addExCommandToEnd(ex); if (g_vars->scene06_mumsyPos + 3 >= 0) { ex = new ExCommand(ANI_MAMASHA, 1, MV_MOM_STARTBK, 0, 0, 0, 1, 0, 0, 0); ex->_excFlags |= 2u; mq->addExCommandToEnd(ex); for (int i = 0; i < g_vars->scene06_mumsyPos + 3; i++) { ex = new ExCommand(ANI_MAMASHA, 1, MV_MOM_CYCLEBK, 0, 0, 0, 1, 0, 0, 0); ex->_excFlags |= 2; mq->addExCommandToEnd(ex); } ex = new ExCommand(ANI_MAMASHA, 1, MV_MOM_STOPBK, 0, 0, 0, 1, 0, 0, 0); ex->_excFlags |= 2; mq->addExCommandToEnd(ex); } ex = new ExCommand(0, 18, QU_MOM_TOLIFT, 0, 0, 0, 1, 0, 0, 0); ex->_excFlags |= 3; mq->addExCommandToEnd(ex); } else { if (momAni) { ex = new ExCommand(ANI_MAMASHA, 1, momAni, 0, 0, 0, 1, 0, 0, 0); ex->_excFlags |= 2; mq->addExCommandToEnd(ex); } if (g_vars->scene06_mumsyPos < 0) { for (int i = 0; i > g_vars->scene06_mumsyPos; i--) { ex = new ExCommand(ANI_MAMASHA, 1, MV_MOM_JUMPFW, 0, 0, 0, 1, 0, 0, 0); ex->_excFlags |= 2; mq->addExCommandToEnd(ex); } } else if (g_vars->scene06_mumsyPos > 0) { for (int i = 0; i < g_vars->scene06_mumsyPos; i++) { ex = new ExCommand(ANI_MAMASHA, 1, MV_MOM_JUMPBK, 0, 0, 0, 1, 0, 0, 0); ex->_excFlags |= 2; mq->addExCommandToEnd(ex); } } ex = new ExCommand(0, 18, QU_MOM_SITDOWN, 0, 0, 0, 1, 0, 0, 0); ex->_excFlags |= 3u; mq->addExCommandToEnd(ex); } mq->setFlags(mq->getFlags() | 1); mq->chain(0); g_vars->scene06_mumsyNumBalls = 0; g_vars->scene06_arcadeEnabled = false; g_fp->_aniMan2 = 0; }
void sceneHandler16_fillMug() { if (g_vars->scene16_mug->_flags & 4) { g_vars->scene16_jettie->_priority = 2; g_vars->scene16_jettie->startAnim(MV_JTI_FLOWIN, 0, -1); if (g_fp->_aniMan->_movement) { if (g_fp->_aniMan->_movement->_id == MV_MAN16_TAKEMUG) { g_fp->_aniMan->changeStatics2(ST_MAN_RIGHT); g_vars->scene16_mug->show1(-1, -1, -1, 0); g_fp->setObjectState(sO_Cup, g_fp->getObjectEnumState(sO_Cup, sO_DudeHas)); } } return; } MessageQueue *mq; if (!(g_vars->scene16_boot->_flags & 4)) { g_vars->scene16_jettie->_priority = 15; g_vars->scene16_jettie->startAnim(MV_JTI_FLOWBY, 0, -1); if (g_vars->scene16_walkingBoy) { mq = new MessageQueue(g_fp->_currentScene->getMessageQueueById(QU_SC16_BOYOUT), 0, 1); mq->replaceKeyCode(-1, g_vars->scene16_walkingBoy->_okeyCode); if (mq->chain(g_vars->scene16_walkingBoy) || !mq) return; } else { if (!g_vars->scene16_walkingGirl) return; mq = new MessageQueue(g_fp->_currentScene->getMessageQueueById(QU_SC16_GIRLOUT), 0, 1); mq->replaceKeyCode(-1, g_vars->scene16_walkingGirl->_okeyCode); if (mq->chain(g_vars->scene16_walkingGirl)) return; } delete mq; return; } g_vars->scene16_jettie->_priority = 15; g_vars->scene16_boot->startAnim(MV_BT16_FILL, 0, -1); StaticANIObject *ani; if (g_vars->scene16_walkingBoy) { mq = new MessageQueue(g_fp->_currentScene->getMessageQueueById(QU_SC16_BOYOUT), 0, 1); mq->replaceKeyCode(-1, g_vars->scene16_walkingBoy->_okeyCode); ani = g_vars->scene16_walkingBoy; } else { if (!g_vars->scene16_walkingGirl) return; mq = new MessageQueue(g_fp->_currentScene->getMessageQueueById(QU_SC16_GIRLOUT), 0, 1); mq->replaceKeyCode(-1, g_vars->scene16_walkingGirl->_okeyCode); ani = g_vars->scene16_walkingGirl; } if (!mq->chain(ani)) delete mq; }
bool InteractionController::handleInteraction(StaticANIObject *subj, GameObject *obj, int invId) { if (subj) { if (!subj->isIdle() || (subj->_flags & 0x100)) return false; } if (!_interactions.size()) return false; Interaction *inter = 0; Interaction *previnter = 0; int dur = 0; int mindur = 0xFFFF; MessageQueue *mq; ExCommand *ex; for (ObList::iterator i = _interactions.begin(); i != _interactions.end(); ++i) { Interaction *cinter = (Interaction *)*i; if (!cinter->canInteract(subj, obj, invId)) continue; if ((inter || cinter->_objectId2) && (!obj || cinter->_objectId3 != obj->_id)) { if (cinter->_messageQueue) cinter->_messageQueue->calcDuration(subj); PicAniInfo aniInfo; obj->getPicAniInfo(&aniInfo); if (cinter->_staticsId1) { StaticANIObject *ani = (StaticANIObject *)obj; ani->_messageQueueId = 0; ani->changeStatics2(cinter->_staticsId1); } int xpos = cinter->_xOffs + obj->_ox; int ypos = cinter->_yOffs + obj->_oy; obj->setPicAniInfo(&aniInfo); if (abs(xpos - subj->_ox) > 1 || abs(ypos - subj->_oy) > 1) { debugC(0, kDebugPathfinding, "Calling doWalkTo() at [%d, %d]", xpos, ypos); mq = getSc2MctlCompoundBySceneId(g_fp->_currentScene->_sceneId)->doWalkTo(subj, xpos, ypos, 1, cinter->_staticsId2); if (mq) { dur = mq->calcDuration(subj); delete mq; } else { dur = 0x10000; } inter = previnter; } else { dur = 0; } if (dur < mindur) { inter = cinter; mindur = dur; previnter = cinter; } } else { inter = cinter; break; } } if (!inter) return false; if (!inter->_objectId2) { StaticANIObject *ani = (StaticANIObject *)obj; if (!ani->isIdle()) return false; if (ani->_flags & 0x100) return false; if (!inter->_staticsId1 || !(inter->_flags & 1)) goto LABEL_38; if (ani->_movement || ani->_statics == 0 || ani->_statics->_staticsId != inter->_staticsId1) { mq = ani->changeStatics1(inter->_staticsId1); if (!mq) return false; ex = new ExCommand((subj ? subj->_id : 0), 55, 0, 0, 0, 0, 1, 0, 0, 0); ex->_x = obj->_id; ex->_y = obj->_okeyCode; ex->_keyCode = subj ? subj->_okeyCode : 0; ex->_excFlags = 3; ex->_field_14 = (obj->_objtype != kObjTypePictureObject); ex->_field_20 = invId; mq->addExCommandToEnd(ex); if (mq->_isFinished) { mq->_isFinished = 0; ani->queueMessageQueue(mq); } } else { if (ani->getMessageQueue()) ani->queueMessageQueue(0); LABEL_38: if (inter->_messageQueue) { mq = new MessageQueue(inter->_messageQueue, 0, 1); mq->changeParam28ForObjectId(ani->_id, -1, ani->_okeyCode); if (!mq->chain(0)) return false; } } return true; } if (obj && !subj) return true; if (!obj || inter->_objectId3 == obj->_id) { if (subj) { if (inter->_messageQueue) { if (subj->isIdle()) { mq = new MessageQueue(inter->_messageQueue, 0, 1); if (!mq->chain(subj)) { delete mq; return false; } } } } return true; } if (inter->isOverlapping(subj, obj)) { if (obj->_objtype == kObjTypeStaticANIObject) { StaticANIObject *ani = (StaticANIObject *)obj; ani->queueMessageQueue(0); if (inter->_staticsId1) ani->changeStatics2(inter->_staticsId1); if (!(inter->_flags & 0x10000)) obj->_flags |= 0x80; } if (!inter->_messageQueue) return false; subj->setOXY(inter->_xOffs + obj->_ox, inter->_yOffs + obj->_oy); mq = new MessageQueue(inter->_messageQueue, 0, 1); mq->changeParam28ForObjectId(obj->_id, -1, obj->_okeyCode); mq->_flags |= 1; if (!(inter->_flags & 0x10000)) { ex = new ExCommand(obj->_id, 34, 0x80, 0, 0, 0, 1, 0, 0, 0); ex->_keyCode = obj->_okeyCode; ex->_field_14 = 0x100; ex->_messageNum = 0; ex->_excFlags = 3; mq->addExCommandToEnd(ex); } ex = new ExCommand(obj->_id, 34, 0x100, 0, 0, 0, 1, 0, 0, 0); ex->_keyCode = obj->_okeyCode; ex->_field_14 = 0x100; ex->_messageNum = 0; ex->_excFlags = 3; mq->addExCommandToEnd(ex); ex = new ExCommand(subj->_id, 34, 0x100, 0, 0, 0, 1, 0, 0, 0); ex->_keyCode = subj->_okeyCode; ex->_field_14 = 0x100; ex->_messageNum = 0; ex->_excFlags = 3; mq->addExCommandToEnd(ex); ex = new ExCommand(subj->_id, 17, 0x40, 0, 0, 0, 1, 0, 0, 0); ex->_excFlags |= 3; ex->_keyCode = 0; mq->addExCommandToEnd(ex); if (!mq->chain(subj)) { delete mq; return false; } subj->_flags |= 1; obj->_flags |= 1; } else { bool someFlag = false; PicAniInfo aniInfo; obj->getPicAniInfo(&aniInfo); if (obj->_objtype == kObjTypeStaticANIObject && inter->_staticsId1) { StaticANIObject *ani = (StaticANIObject *)obj; ani->_messageQueueId = 0; ani->changeStatics2(inter->_staticsId1); } int xpos = inter->_yOffs + obj->_ox; int ypos = inter->_yOffs + obj->_oy; obj->setPicAniInfo(&aniInfo); if (abs(xpos - subj->_ox) > 1 || abs(ypos - subj->_oy) > 1 || (inter->_staticsId2 != 0 && (subj->_statics == 0 || subj->_statics->_staticsId != inter->_staticsId2))) { mq = getSc2MctlCompoundBySceneId(g_fp->_currentScene->_sceneId)->startMove(subj, xpos, ypos, 1, inter->_staticsId2); if (!mq) return false; ex = new ExCommand(subj->_id, 55, 0, 0, 0, 0, 1, 0, 0, 0); ex->_x = obj->_id; ex->_y = obj->_okeyCode; ex->_keyCode = subj->_okeyCode; ex->_excFlags = 3; ex->_field_20 = invId; ex->_field_14 = (obj->_objtype != kObjTypePictureObject); mq->addExCommandToEnd(ex); someFlag = true; ex = new ExCommand(subj->_id, 17, 0x40, 0, 0, 0, 1, 0, 0, 0); ex->_x = xpos; ex->_y = ypos; ex->_excFlags |= 3; ex->_keyCode = 6; ex->_field_14 = obj->_id; ex->_field_20 = obj->_okeyCode; ex->postMessage(); } if (!inter->_staticsId1 || !(inter->_flags & 1)) return true; StaticANIObject *ani = (StaticANIObject *)obj; if (!ani->isIdle()) return false; if (ani->getMessageQueue()) ani->queueMessageQueue(0); if (!ani->_statics || ani->_statics->_staticsId != inter->_staticsId1 || ani->_movement) { mq = ani->changeStatics1(inter->_staticsId1); if (!mq) return false; if (someFlag) { if (!(inter->_flags & 0x10000)) { if (mq->_isFinished) { ani->_flags |= 0x80u; } else { ex = new ExCommand(ani->_id, 34, 0x80, 0, 0, 0, 1, 0, 0, 0); ex->_field_14 = 0x80; ex->_keyCode = ani->_okeyCode; ex->_excFlags = 3; mq->addExCommandToEnd(ex); } } ex = new ExCommand(ani->_id, 34, 0x100, 0, 0, 0, 1, 0, 0, 0); ex->_keyCode = ani->_okeyCode; ex->_field_14 = 0x100; ex->_excFlags = 3; mq->addExCommandToEnd(ex); } else { ex = new ExCommand(subj->_id, 55, 0, 0, 0, 0, 1, 0, 0, 0); ex->_x = ani->_id; ex->_y = ani->_okeyCode; ex->_keyCode = subj->_okeyCode; ex->_excFlags = 2; ex->_field_14 = (obj->_objtype != kObjTypePictureObject); ex->_field_20 = invId; mq->addExCommandToEnd(ex); if (!mq->_isFinished) return true; mq->_isFinished = 0; ani->queueMessageQueue(mq); } } else { obj->_flags |= 1; if (inter->_flags & 0x10000) return true; obj->_flags |= 0x80; } } return true; }
void sceneHandler28_trySecondaryPers() { MessageQueue *mq; int x; if (g_vars->scene28_headBeardedFlipper) { if (g_vars->scene28_beardedDirection) { mq = new MessageQueue(g_fp->_currentScene->getMessageQueueById(QU_BRD28_GOR), 0, 1); mq->getExCommandByIndex(0)->_x = g_fp->_sceneRect.left - 20; mq->getExCommandByIndex(0)->_param = 1; mq->setParamInt(-1, 1); mq->chain(0); mq = new MessageQueue(g_fp->_currentScene->getMessageQueueById(QU_BRD28_GOR), 0, 1); mq->getExCommandByIndex(0)->_x = g_fp->_sceneRect.left - 40; mq->getExCommandByIndex(0)->_y += 20; mq->getExCommandByIndex(0)->_param = 2; mq->setParamInt(-1, 2); mq->chain(0); mq = new MessageQueue(g_fp->_currentScene->getMessageQueueById(QU_BRD28_GOR), 0, 1); x = g_fp->_sceneRect.left - 60; } else { mq = new MessageQueue(g_fp->_currentScene->getMessageQueueById(QU_BRD28_GOL), 0, 1); mq->getExCommandByIndex(0)->_x = g_fp->_sceneRect.right + 20; mq->getExCommandByIndex(0)->_param = 1; mq->setParamInt(-1, 1); mq->chain(0); mq = new MessageQueue(g_fp->_currentScene->getMessageQueueById(QU_BRD28_GOL), 0, 1); mq->getExCommandByIndex(0)->_x = g_fp->_sceneRect.right + 40; mq->getExCommandByIndex(0)->_y += 20; mq->getExCommandByIndex(0)->_param = 2; mq->setParamInt(-1, 2); mq->chain(0); mq = new MessageQueue(g_fp->_currentScene->getMessageQueueById(QU_BRD28_GOL), 0, 1); x = g_fp->_sceneRect.right + 60; } mq->getExCommandByIndex(0)->_x = x; mq->getExCommandByIndex(0)->_y += 40; mq->getExCommandByIndex(0)->_param = 3; mq->setParamInt(-1, 3); mq->chain( 0); g_vars->scene28_beardedDirection = !g_vars->scene28_beardedDirection; } else { if (g_vars->scene28_headDirection) { mq = new MessageQueue(g_fp->_currentScene->getMessageQueueById(QU_GLV28_GOR), 0, 1); x = g_fp->_sceneRect.left - 40; } else { mq = new MessageQueue(g_fp->_currentScene->getMessageQueueById(QU_GLV28_GOL), 0, 1); x = g_fp->_sceneRect.right + 40; } mq->getExCommandByIndex(0)->_x = x; mq->chain(0); g_vars->scene28_headDirection = !g_vars->scene28_headDirection; } g_vars->scene28_headBeardedFlipper = !g_vars->scene28_headBeardedFlipper; }