2013-08-24 19:12:00 +00:00
|
|
|
/* 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.
|
|
|
|
*
|
2021-12-26 17:47:58 +00:00
|
|
|
* 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 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
2014-02-18 01:34:20 +00:00
|
|
|
*
|
2013-08-24 19:12:00 +00:00
|
|
|
* 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.
|
2014-02-18 01:34:20 +00:00
|
|
|
*
|
2013-08-24 19:12:00 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
2021-12-26 17:47:58 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2013-08-24 19:12:00 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2020-10-03 21:50:25 +00:00
|
|
|
#include "ngi/ngi.h"
|
2013-08-24 19:12:00 +00:00
|
|
|
|
2020-10-03 21:47:47 +00:00
|
|
|
#include "ngi/objects.h"
|
|
|
|
#include "ngi/objectnames.h"
|
|
|
|
#include "ngi/constants.h"
|
2014-01-26 14:52:33 +00:00
|
|
|
|
2020-10-03 21:47:47 +00:00
|
|
|
#include "ngi/scene.h"
|
|
|
|
#include "ngi/statics.h"
|
|
|
|
#include "ngi/messages.h"
|
|
|
|
#include "ngi/gameloader.h"
|
|
|
|
#include "ngi/motion.h"
|
2013-08-24 19:12:00 +00:00
|
|
|
|
2020-10-03 21:55:39 +00:00
|
|
|
namespace NGI {
|
2013-08-24 19:12:00 +00:00
|
|
|
|
2020-10-03 22:00:50 +00:00
|
|
|
int NGIEngine::lift_getButtonIdP(int objid) {
|
2013-08-24 19:12:00 +00:00
|
|
|
switch (objid) {
|
|
|
|
case ST_LBN_0N:
|
|
|
|
return ST_LBN_0P;
|
2014-01-26 14:23:49 +00:00
|
|
|
|
2013-08-24 19:12:00 +00:00
|
|
|
case ST_LBN_1N:
|
|
|
|
return ST_LBN_1P;
|
2014-01-26 14:23:49 +00:00
|
|
|
|
2013-08-24 19:12:00 +00:00
|
|
|
case ST_LBN_2N:
|
|
|
|
return ST_LBN_2P;
|
2014-01-26 14:23:49 +00:00
|
|
|
|
2013-08-24 19:12:00 +00:00
|
|
|
case ST_LBN_3N:
|
|
|
|
return ST_LBN_3P;
|
2014-01-26 14:23:49 +00:00
|
|
|
|
2013-08-24 19:12:00 +00:00
|
|
|
case ST_LBN_4N:
|
|
|
|
return ST_LBN_4P;
|
2014-01-26 14:23:49 +00:00
|
|
|
|
2013-08-24 19:12:00 +00:00
|
|
|
case ST_LBN_5N:
|
|
|
|
return ST_LBN_5P;
|
2014-01-26 14:23:49 +00:00
|
|
|
|
2013-08-24 19:12:00 +00:00
|
|
|
case ST_LBN_6N:
|
|
|
|
return ST_LBN_6P;
|
2014-01-26 14:23:49 +00:00
|
|
|
|
2013-08-24 19:12:00 +00:00
|
|
|
case ST_LBN_7N:
|
|
|
|
return ST_LBN_7P;
|
2014-01-26 14:23:49 +00:00
|
|
|
|
2013-08-24 19:12:00 +00:00
|
|
|
case ST_LBN_8N:
|
|
|
|
return ST_LBN_8P;
|
2014-01-26 14:23:49 +00:00
|
|
|
|
2013-08-24 19:12:00 +00:00
|
|
|
case ST_LBN_9N:
|
|
|
|
return ST_LBN_9P;
|
2014-01-26 14:23:49 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-03 22:00:50 +00:00
|
|
|
int NGIEngine::lift_getButtonIdH(int objid) {
|
2014-01-26 14:23:49 +00:00
|
|
|
switch (objid) {
|
|
|
|
case ST_LBN_0P:
|
|
|
|
return ST_LBN_0H;
|
|
|
|
|
|
|
|
case ST_LBN_1P:
|
|
|
|
return ST_LBN_1H;
|
|
|
|
|
|
|
|
case ST_LBN_2P:
|
|
|
|
return ST_LBN_2H;
|
|
|
|
|
|
|
|
case ST_LBN_3P:
|
|
|
|
return ST_LBN_3H;
|
|
|
|
|
|
|
|
case ST_LBN_4P:
|
|
|
|
return ST_LBN_4H;
|
|
|
|
|
|
|
|
case ST_LBN_5P:
|
|
|
|
return ST_LBN_5H;
|
|
|
|
|
|
|
|
case ST_LBN_6P:
|
|
|
|
return ST_LBN_6H;
|
|
|
|
|
|
|
|
case ST_LBN_7P:
|
|
|
|
return ST_LBN_7H;
|
|
|
|
|
|
|
|
case ST_LBN_8P:
|
|
|
|
return ST_LBN_8H;
|
|
|
|
|
|
|
|
case ST_LBN_9P:
|
|
|
|
return ST_LBN_9H;
|
|
|
|
|
2013-08-24 19:12:00 +00:00
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-03 22:00:50 +00:00
|
|
|
int NGIEngine::lift_getButtonIdN(int objid) {
|
2014-01-26 14:27:32 +00:00
|
|
|
switch (objid) {
|
|
|
|
case ST_LBN_0H:
|
|
|
|
case ST_LBN_0N:
|
|
|
|
case ST_LBN_0P:
|
|
|
|
return ST_LBN_0N;
|
|
|
|
|
|
|
|
case ST_LBN_1H:
|
|
|
|
case ST_LBN_1N:
|
|
|
|
case ST_LBN_1P:
|
|
|
|
return ST_LBN_1N;
|
|
|
|
|
|
|
|
case ST_LBN_2H:
|
|
|
|
case ST_LBN_2N:
|
|
|
|
case ST_LBN_2P:
|
|
|
|
return ST_LBN_2N;
|
|
|
|
|
|
|
|
case ST_LBN_3H:
|
|
|
|
case ST_LBN_3N:
|
|
|
|
case ST_LBN_3P:
|
|
|
|
return ST_LBN_3N;
|
|
|
|
|
|
|
|
case ST_LBN_4H:
|
|
|
|
case ST_LBN_4N:
|
|
|
|
case ST_LBN_4P:
|
|
|
|
return ST_LBN_4N;
|
|
|
|
|
|
|
|
case ST_LBN_5H:
|
|
|
|
case ST_LBN_5N:
|
|
|
|
case ST_LBN_5P:
|
|
|
|
return ST_LBN_5N;
|
|
|
|
|
|
|
|
case ST_LBN_6H:
|
|
|
|
case ST_LBN_6N:
|
|
|
|
case ST_LBN_6P:
|
|
|
|
return ST_LBN_6N;
|
|
|
|
|
|
|
|
case ST_LBN_7H:
|
|
|
|
case ST_LBN_7N:
|
|
|
|
case ST_LBN_7P:
|
|
|
|
return ST_LBN_7N;
|
|
|
|
|
|
|
|
case ST_LBN_8H:
|
|
|
|
case ST_LBN_8N:
|
|
|
|
case ST_LBN_8P:
|
|
|
|
return ST_LBN_8N;
|
|
|
|
|
|
|
|
case ST_LBN_9H:
|
|
|
|
case ST_LBN_9N:
|
|
|
|
case ST_LBN_9P:
|
|
|
|
return ST_LBN_9N;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-03 22:00:50 +00:00
|
|
|
void NGIEngine::lift_setButton(const char *name, int state) {
|
2020-10-04 20:25:19 +00:00
|
|
|
GameVar *var = g_nmi->getGameLoaderGameVar()->getSubVarByName("OBJSTATES")->getSubVarByName(sO_LiftButtons);
|
2013-11-20 20:02:42 +00:00
|
|
|
|
|
|
|
if (var)
|
|
|
|
var->setSubVarAsInt(name, state);
|
|
|
|
}
|
|
|
|
|
2020-10-03 22:00:50 +00:00
|
|
|
void NGIEngine::lift_init(Scene *sc, int enterSeq, int exitSeq) {
|
2021-11-13 21:40:34 +00:00
|
|
|
_lastLiftButton = nullptr;
|
2014-01-26 14:52:33 +00:00
|
|
|
|
|
|
|
_liftEnterMQ = sc->getMessageQueueById(enterSeq);
|
|
|
|
if (!_liftEnterMQ)
|
|
|
|
return;
|
|
|
|
|
|
|
|
_liftExitMQ = sc->getMessageQueueById(exitSeq);
|
|
|
|
|
|
|
|
if (!_liftExitMQ)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ExCommand *ex = _liftEnterMQ->getExCommandByIndex(0);
|
|
|
|
|
|
|
|
if (!ex)
|
|
|
|
return;
|
|
|
|
|
|
|
|
_liftX = ex->_x;
|
|
|
|
_liftY = ex->_y;
|
|
|
|
|
|
|
|
_lift = sc->getStaticANIObject1ById(ANI_LIFT, -1);
|
|
|
|
|
|
|
|
for (uint i = 0; i < sc->_staticANIObjectList1.size(); i++) {
|
2017-11-15 04:30:35 +00:00
|
|
|
StaticANIObject *ani = sc->_staticANIObjectList1[i];
|
2014-01-26 14:52:33 +00:00
|
|
|
|
|
|
|
if (ani->_id == ANI_LIFTBUTTON)
|
|
|
|
ani->_statics = ani->getStaticsById(lift_getButtonIdP(ani->_statics->_staticsId));
|
|
|
|
}
|
|
|
|
|
|
|
|
GameVar *var = getGameLoaderGameVar()->getSubVarByName("OBJSTATES")->getSubVarByName(sO_LiftButtons);
|
|
|
|
if (var) {
|
|
|
|
for (var = var->_subVars; var; var = var->_nextVarObj) {
|
|
|
|
for (uint i = 0; i < sc->_staticANIObjectList1.size(); i++) {
|
2017-11-15 04:30:35 +00:00
|
|
|
StaticANIObject *ani = sc->_staticANIObjectList1[i];
|
2014-01-26 14:52:33 +00:00
|
|
|
|
|
|
|
if (ani->_id == ANI_LIFTBUTTON) {
|
|
|
|
int id = lift_getButtonIdN(ani->_statics->_staticsId);
|
|
|
|
|
|
|
|
if (id == var->_value.intValue)
|
|
|
|
ani->_statics = ani->getStaticsById(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-11-03 22:28:13 +00:00
|
|
|
}
|
|
|
|
|
2020-10-03 22:00:50 +00:00
|
|
|
void NGIEngine::lift_exitSeq(ExCommand *cmd) {
|
2014-02-01 18:21:07 +00:00
|
|
|
if (cmd) {
|
|
|
|
MessageQueue *mq = _globalMessageQueueList->getMessageQueueById(cmd->_parId);
|
|
|
|
|
|
|
|
if (mq)
|
|
|
|
mq->activateExCommandsByKind(34);
|
|
|
|
}
|
2014-01-29 21:48:06 +00:00
|
|
|
|
|
|
|
_lift->changeStatics2(ST_LFT_CLOSED);
|
|
|
|
|
|
|
|
MessageQueue *mq = new MessageQueue(_globalMessageQueueList->compact());
|
|
|
|
|
|
|
|
ExCommand *ex = new ExCommand(_aniMan->_id, 34, 256, 0, 0, 0, 1, 0, 0, 0);
|
|
|
|
|
2017-12-03 19:07:35 +00:00
|
|
|
ex->_z = 256;
|
2014-01-29 21:48:06 +00:00
|
|
|
ex->_messageNum = 256;
|
|
|
|
ex->_excFlags |= 3;
|
|
|
|
mq->addExCommandToEnd(ex);
|
|
|
|
|
2014-02-01 18:22:46 +00:00
|
|
|
if (!cmd) {
|
2014-01-29 21:48:06 +00:00
|
|
|
ex = new ExCommand(_aniMan->_id, 2, 40, 0, 0, 0, 1, 0, 0, 0);
|
2016-09-04 22:11:07 +00:00
|
|
|
ex->_param = _aniMan->_odelay;
|
2014-01-29 21:48:06 +00:00
|
|
|
ex->_excFlags |= 2;
|
|
|
|
mq->addExCommandToEnd(ex);
|
|
|
|
}
|
|
|
|
|
|
|
|
ex = new ExCommand(_lift->_id, 1, MV_LFT_OPEN, 0, 0, 0, 1, 0, 0, 0);
|
2016-09-04 22:11:07 +00:00
|
|
|
ex->_param = _lift->_odelay;
|
2014-01-29 21:48:06 +00:00
|
|
|
ex->_excFlags |= 2;
|
|
|
|
mq->addExCommandToEnd(ex);
|
|
|
|
|
|
|
|
ex = new ExCommand(_aniMan->_id, 1, MV_MAN_STARTD, 0, 0, 0, 1, 0, 0, 0);
|
2016-09-04 22:11:07 +00:00
|
|
|
ex->_param = _aniMan->_odelay;
|
2014-01-29 21:48:06 +00:00
|
|
|
ex->_excFlags |= 2;
|
|
|
|
mq->addExCommandToEnd(ex);
|
|
|
|
|
|
|
|
ex = new ExCommand(_aniMan->_id, 5, -1, 0, 0, 0, 1, 0, 0, 0);
|
2016-09-04 22:11:07 +00:00
|
|
|
ex->_param = _aniMan->_odelay;
|
2017-12-03 19:07:35 +00:00
|
|
|
ex->_z = 10;
|
2014-01-29 21:48:06 +00:00
|
|
|
ex->_x = -1;
|
|
|
|
ex->_y = -1;
|
|
|
|
ex->_excFlags |= 3;
|
|
|
|
mq->addExCommandToEnd(ex);
|
|
|
|
|
|
|
|
ex = new ExCommand(_aniMan->_id, 34, 256, 0, 0, 0, 1, 0, 0, 0);
|
|
|
|
ex->_excFlags |= 3;
|
2017-12-03 19:07:35 +00:00
|
|
|
ex->_z = 256;
|
2014-01-29 21:48:06 +00:00
|
|
|
ex->_messageNum = 0;
|
|
|
|
mq->addExCommandToEnd(ex);
|
|
|
|
|
|
|
|
ex = new ExCommand(0, 17, MSG_LIFT_STARTEXITQUEUE, 0, 0, 0, 1, 0, 0, 0);
|
|
|
|
ex->_excFlags |= 3;
|
|
|
|
mq->addExCommandToEnd(ex);
|
|
|
|
|
|
|
|
ex = new ExCommand(_lift->_id, 1, MV_LFT_CLOSE, 0, 0, 0, 1, 0, 0, 0);
|
2016-09-04 22:11:07 +00:00
|
|
|
ex->_param = _lift->_odelay;
|
2014-01-29 21:48:06 +00:00
|
|
|
ex->_excFlags |= 2;
|
|
|
|
|
|
|
|
mq->addExCommandToEnd(ex);
|
|
|
|
|
2021-11-13 21:40:34 +00:00
|
|
|
mq->chain(nullptr);
|
2013-11-05 22:40:09 +00:00
|
|
|
}
|
|
|
|
|
2020-10-03 22:00:50 +00:00
|
|
|
void NGIEngine::lift_closedoorSeq() {
|
2014-02-01 11:20:30 +00:00
|
|
|
if (_lift->_movement) {
|
|
|
|
if (_lift->_movement->_id == MV_LFT_CLOSE) {
|
2021-11-13 21:40:34 +00:00
|
|
|
_lift->queueMessageQueue(nullptr);
|
2014-02-01 11:20:30 +00:00
|
|
|
} else if (_lift->_movement->_id == MV_LFT_OPEN) {
|
|
|
|
int ph = _lift->_movement->_currDynamicPhaseIndex;
|
|
|
|
|
|
|
|
_lift->changeStatics2(ST_LFT_OPEN_NEW);
|
|
|
|
_lift->startAnim(MV_LFT_CLOSE, 0, -1);
|
|
|
|
|
|
|
|
if (_lift->_movement->_currMovement)
|
|
|
|
_lift->_movement->setDynamicPhaseIndex(_lift->_movement->_currMovement->_dynamicPhases.size() - ph);
|
|
|
|
else
|
|
|
|
_lift->_movement->setDynamicPhaseIndex(_lift->_movement->_dynamicPhases.size() - ph);
|
|
|
|
} else {
|
|
|
|
_lift->changeStatics2(ST_LFT_OPEN_NEW);
|
|
|
|
|
|
|
|
_lift->startAnim(MV_LFT_CLOSE, 0, -1);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (_lift->_statics->_staticsId == ST_LFT_CLOSED ) {
|
|
|
|
_lift->changeStatics2(ST_LFT_CLOSED);
|
|
|
|
} else {
|
|
|
|
_lift->startAnim(MV_LFT_CLOSE, 0, -1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MessageQueue *mq = new MessageQueue(_globalMessageQueueList->compact());
|
|
|
|
ExCommand *ex = new ExCommand(0, 17, MSG_LIFT_GO, 0, 0, 0, 1, 0, 0, 0);
|
|
|
|
|
|
|
|
ex->_excFlags |= 3;
|
|
|
|
mq->addExCommandToEnd(ex);
|
|
|
|
|
|
|
|
if (!mq->chain(_lift))
|
|
|
|
delete mq;
|
2013-11-05 22:40:09 +00:00
|
|
|
}
|
|
|
|
|
2020-10-03 22:00:50 +00:00
|
|
|
void NGIEngine::lift_walkAndGo() {
|
2014-02-01 11:34:31 +00:00
|
|
|
MessageQueue *mq;
|
|
|
|
ExCommand *ex;
|
|
|
|
|
|
|
|
if (abs(_liftX - _aniMan->_ox) > 1 || abs(_liftY - _aniMan->_oy) > 1 || _aniMan->_movement || _aniMan->_statics->_staticsId != ST_MAN_UP) {
|
2015-09-19 22:39:53 +00:00
|
|
|
mq = getCurrSceneSc2MotionController()->startMove(_aniMan, _liftX, _liftY, 1, ST_MAN_UP);
|
2014-02-01 11:34:31 +00:00
|
|
|
|
|
|
|
if (mq) {
|
|
|
|
ex = new ExCommand(0, 17, MSG_LIFT_CLICKBUTTON, 0, 0, 0, 1, 0, 0, 0);
|
|
|
|
ex->_excFlags |= 3;
|
|
|
|
|
|
|
|
mq->addExCommandToEnd(ex);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
lift_openLift();
|
|
|
|
|
|
|
|
mq = new MessageQueue(_liftEnterMQ, 0, 0);
|
|
|
|
|
|
|
|
mq->setFlags(mq->getFlags() | 1);
|
|
|
|
|
|
|
|
ex = new ExCommand(_aniMan->_id, 2, 15, 0, 0, 0, 1, 0, 0, 0);
|
2016-09-04 22:11:07 +00:00
|
|
|
ex->_param = _aniMan->_odelay;
|
2014-02-01 11:34:31 +00:00
|
|
|
ex->_excFlags |= 2;
|
|
|
|
mq->addExCommand(ex);
|
|
|
|
|
|
|
|
ex = new ExCommand(_aniMan->_id, 5, -1, 0, 0, 0, 1, 0, 0, 0);
|
2016-09-04 22:11:07 +00:00
|
|
|
ex->_param = _aniMan->_odelay;
|
2017-12-03 19:07:35 +00:00
|
|
|
ex->_z = _lift->_priority + 1;
|
2014-02-01 11:34:31 +00:00
|
|
|
ex->_x = -1;
|
|
|
|
ex->_y = -1;
|
|
|
|
ex->_excFlags |= 3;
|
|
|
|
mq->addExCommandToEnd(ex);
|
|
|
|
|
|
|
|
ex = new ExCommand(0, 17, MSG_LIFT_CLOSEDOOR, 0, 0, 0, 1, 0, 0, 0);
|
|
|
|
ex->_excFlags |= 3;
|
|
|
|
mq->addExCommandToEnd(ex);
|
|
|
|
|
2021-11-13 21:40:34 +00:00
|
|
|
mq->chain(nullptr);
|
2014-02-01 11:34:31 +00:00
|
|
|
|
2016-09-17 18:36:57 +00:00
|
|
|
_aniMan->_flags |= 0x100;
|
2014-02-01 11:34:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-03 22:00:50 +00:00
|
|
|
void NGIEngine::lift_openLift() {
|
2014-02-01 11:40:36 +00:00
|
|
|
if (_lift->_movement) {
|
|
|
|
if (_lift->_movement->_id == MV_LFT_OPEN) {
|
2021-11-13 21:40:34 +00:00
|
|
|
_lift->queueMessageQueue(nullptr);
|
2014-02-01 11:40:36 +00:00
|
|
|
} else if (_lift->_movement->_id == MV_LFT_CLOSE) {
|
|
|
|
int idx = _lift->_movement->_currDynamicPhaseIndex;
|
|
|
|
|
|
|
|
_lift->changeStatics2(ST_LFT_CLOSED);
|
|
|
|
_lift->startAnim(MV_LFT_OPEN, 0, -1);
|
|
|
|
|
|
|
|
if (_lift->_movement->_currMovement)
|
|
|
|
_lift->_movement->setDynamicPhaseIndex(_lift->_movement->_currMovement->_dynamicPhases.size() - idx);
|
|
|
|
else
|
|
|
|
_lift->_movement->setDynamicPhaseIndex(_lift->_movement->_dynamicPhases.size() - idx);
|
|
|
|
} else {
|
|
|
|
_lift->changeStatics2(ST_LFT_CLOSED);
|
|
|
|
_lift->startAnim(MV_LFT_OPEN, 0, -1);
|
|
|
|
}
|
|
|
|
} else if (_lift->_statics->_staticsId == ST_LFT_OPEN_NEW) {
|
|
|
|
_lift->changeStatics2(ST_LFT_OPEN_NEW);
|
|
|
|
} else {
|
|
|
|
_lift->startAnim(MV_LFT_OPEN, 0, -1);
|
|
|
|
}
|
2014-01-26 14:18:03 +00:00
|
|
|
}
|
|
|
|
|
2020-10-03 22:00:50 +00:00
|
|
|
void NGIEngine::lift_clickButton() {
|
2014-01-26 14:18:03 +00:00
|
|
|
if (_lastLiftButton)
|
|
|
|
lift_walkAndGo();
|
2013-11-05 22:40:09 +00:00
|
|
|
}
|
|
|
|
|
2020-10-03 22:00:50 +00:00
|
|
|
void NGIEngine::lift_goAnimation() {
|
2016-08-26 18:40:02 +00:00
|
|
|
if (_lastLiftButton) {
|
2014-01-28 19:30:08 +00:00
|
|
|
int parentId = _currentScene->_sceneId;
|
|
|
|
int buttonId = lift_getButtonIdN(_lastLiftButton->_statics->_staticsId);
|
|
|
|
|
|
|
|
if (!buttonId)
|
|
|
|
return;
|
|
|
|
|
|
|
|
int numItems = _gameLoader->_preloadItems.size();
|
|
|
|
|
|
|
|
for (int i = 0; i < numItems; i++) {
|
2017-11-17 05:47:57 +00:00
|
|
|
PreloadItem &pre = _gameLoader->_preloadItems[i];
|
2014-01-28 19:30:08 +00:00
|
|
|
|
2017-11-17 05:47:57 +00:00
|
|
|
if (pre.preloadId2 == buttonId && pre.preloadId1 == _currentScene->_sceneId) {
|
2014-01-28 19:30:08 +00:00
|
|
|
MessageQueue *mq = new MessageQueue(_globalMessageQueueList->compact());
|
|
|
|
|
2017-11-17 05:47:57 +00:00
|
|
|
ExCommand *ex = new ExCommand(ANI_MAN, 1, (pre.param != LiftDown ? MV_MAN_LIFTDOWN : MV_MAN_LIFTUP), 0, 0, 0, 1, 0, 0, 0);
|
2014-01-28 19:30:08 +00:00
|
|
|
|
2016-09-04 21:54:43 +00:00
|
|
|
ex->_param = -1;
|
2014-01-28 19:30:08 +00:00
|
|
|
ex->_field_24 = 1;
|
|
|
|
ex->_excFlags |= 2;
|
|
|
|
|
|
|
|
mq->addExCommandToEnd(ex);
|
|
|
|
|
|
|
|
ex = new ExCommand(parentId, 17, 61, 0, 0, 0, 1, 0, 0, 0);
|
|
|
|
|
2016-09-04 21:54:43 +00:00
|
|
|
ex->_param = buttonId;
|
2014-01-28 19:30:08 +00:00
|
|
|
ex->_excFlags |= 3;
|
|
|
|
|
|
|
|
mq->addExCommandToEnd(ex);
|
|
|
|
|
2016-09-17 18:36:57 +00:00
|
|
|
_aniMan->_flags &= ~0x100;
|
2014-01-28 19:30:08 +00:00
|
|
|
|
|
|
|
if (!mq->chain(_aniMan))
|
|
|
|
delete mq;
|
|
|
|
|
2016-09-17 18:36:57 +00:00
|
|
|
_aniMan->_flags |= 0x100;
|
2016-08-26 18:40:02 +00:00
|
|
|
|
|
|
|
return;
|
2014-01-28 19:30:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-13 21:40:34 +00:00
|
|
|
lift_exitSeq(nullptr);
|
2014-01-28 19:30:08 +00:00
|
|
|
|
|
|
|
if (_lastLiftButton) {
|
|
|
|
_lastLiftButton->_statics = _lastLiftButton->getStaticsById(lift_getButtonIdN(_lastLiftButton->_statics->_staticsId));
|
2021-11-13 21:40:34 +00:00
|
|
|
_lastLiftButton = nullptr;
|
2014-01-28 19:30:08 +00:00
|
|
|
}
|
2013-11-05 22:40:09 +00:00
|
|
|
}
|
|
|
|
|
2020-10-03 22:00:50 +00:00
|
|
|
void NGIEngine::lift_animateButton(StaticANIObject *button) {
|
2014-02-01 11:09:55 +00:00
|
|
|
int butId = lift_getButtonIdP(button->_statics->_staticsId);
|
|
|
|
|
|
|
|
if (butId && butId != button->_statics->_staticsId) {
|
|
|
|
if (button == _lastLiftButton) {
|
|
|
|
playSound(SND_CMN_032, 0);
|
|
|
|
} else {
|
|
|
|
if (_lastLiftButton) {
|
|
|
|
int id = lift_getButtonIdN(_lastLiftButton->_statics->_staticsId);
|
|
|
|
|
|
|
|
if (id)
|
|
|
|
_lastLiftButton->_statics = _lastLiftButton->getStaticsById(id);
|
|
|
|
|
2021-11-13 21:40:34 +00:00
|
|
|
_lastLiftButton = nullptr;
|
2014-02-01 11:09:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (_aniMan->isIdle() && !(_aniMan->_flags & 0x100)) {
|
|
|
|
_lastLiftButton = button;
|
|
|
|
button->_statics = button->getStaticsById(butId);
|
|
|
|
|
|
|
|
ExCommand *ex = new ExCommand(0, 35, SND_CMN_032, 0, 0, 0, 1, 0, 0, 0);
|
|
|
|
ex->_excFlags |= 3;
|
2017-12-03 19:07:35 +00:00
|
|
|
ex->_z = 1;
|
2014-02-01 11:09:55 +00:00
|
|
|
ex->postMessage();
|
|
|
|
|
|
|
|
int id = lift_getButtonIdH(_lastLiftButton->_statics->_staticsId);
|
|
|
|
|
|
|
|
if (id) {
|
|
|
|
_lastLiftButton->_statics = _lastLiftButton->getStaticsById(id);
|
|
|
|
|
|
|
|
lift_walkAndGo();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-11-05 22:40:09 +00:00
|
|
|
}
|
|
|
|
|
2020-10-03 22:00:50 +00:00
|
|
|
void NGIEngine::lift_startExitQueue() {
|
2014-01-27 19:25:22 +00:00
|
|
|
MessageQueue *mq = new MessageQueue(_liftExitMQ, 0, 0);
|
|
|
|
|
2021-11-13 21:40:34 +00:00
|
|
|
mq->chain(nullptr);
|
2013-11-05 22:40:09 +00:00
|
|
|
}
|
|
|
|
|
2020-10-03 22:00:50 +00:00
|
|
|
void NGIEngine::lift_hoverButton(ExCommand *cmd) {
|
2014-02-01 11:45:22 +00:00
|
|
|
if (_lastLiftButton) {
|
2016-09-04 21:54:43 +00:00
|
|
|
if (!(cmd->_param & 2) || _liftX != cmd->_x || _liftY != cmd->_y) {
|
2014-02-01 11:45:22 +00:00
|
|
|
_lastLiftButton->_statics = _lastLiftButton->getStaticsById(lift_getButtonIdN(_lastLiftButton->_statics->_staticsId));
|
2021-11-13 21:40:34 +00:00
|
|
|
_lastLiftButton = nullptr;
|
2014-02-01 11:45:22 +00:00
|
|
|
}
|
|
|
|
}
|
2013-11-05 22:40:09 +00:00
|
|
|
}
|
|
|
|
|
2020-10-03 22:00:50 +00:00
|
|
|
bool NGIEngine::lift_checkButton(const char *varName) {
|
2020-10-04 20:25:19 +00:00
|
|
|
GameVar *var = g_nmi->getGameLoaderGameVar()->getSubVarByName("OBJSTATES")->getSubVarByName(sO_LiftButtons);
|
2014-01-30 18:30:21 +00:00
|
|
|
|
|
|
|
if (var)
|
|
|
|
return lift_getButtonIdP(var->getSubVarByName(varName)->_value.intValue) > 0;
|
2014-01-07 11:15:42 +00:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-10-03 22:00:50 +00:00
|
|
|
void NGIEngine::lift_setButtonStatics(Scene *sc, int buttonId) {
|
2014-01-26 14:33:19 +00:00
|
|
|
for (uint i = 0; i < sc->_staticANIObjectList1.size(); i++) {
|
2017-11-15 04:30:35 +00:00
|
|
|
StaticANIObject *ani = sc->_staticANIObjectList1[i];
|
2014-01-26 14:33:19 +00:00
|
|
|
|
|
|
|
if (ani->_id == ANI_LIFTBUTTON) {
|
|
|
|
int id = lift_getButtonIdN(ani->_statics->_staticsId);
|
|
|
|
|
|
|
|
if (id == buttonId)
|
|
|
|
ani->_statics = ani->getStaticsById(id);
|
|
|
|
}
|
|
|
|
}
|
2014-01-19 12:28:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-03 21:55:39 +00:00
|
|
|
} // End of namespace NGI
|