2013-06-27 10:13: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.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This code is based on the original source code of Lord Avalot d'Argent version 1.3.
|
|
|
|
* Copyright (c) 1994-1995 Mike, Mark and Thomas Thurman.
|
|
|
|
*/
|
|
|
|
|
2013-07-27 08:05:09 +00:00
|
|
|
/* TRIP5 Trippancy V - the sprite animation subsystem */
|
2013-06-27 10:13:00 +00:00
|
|
|
|
2013-06-29 08:13:02 +00:00
|
|
|
#include "avalanche/avalanche.h"
|
2013-09-07 17:09:06 +00:00
|
|
|
#include "avalanche/animation.h"
|
2013-06-29 14:36:40 +00:00
|
|
|
|
2013-06-27 10:13:00 +00:00
|
|
|
namespace Avalanche {
|
2013-09-07 07:00:34 +00:00
|
|
|
|
2013-10-02 05:25:20 +00:00
|
|
|
/**
|
|
|
|
* Loads & sets up the sprite.
|
|
|
|
*/
|
2013-09-08 10:53:19 +00:00
|
|
|
void AnimationType::init(byte spritenum, bool doCheck, Animation *anim) {
|
|
|
|
_anim = anim;
|
2013-07-19 21:36:00 +00:00
|
|
|
|
2013-07-09 15:20:42 +00:00
|
|
|
const int32 idshould = -1317732048;
|
|
|
|
|
|
|
|
if (spritenum == 177)
|
2013-09-05 00:29:09 +00:00
|
|
|
return; // Already running!
|
2013-07-09 15:20:42 +00:00
|
|
|
|
2013-09-07 21:42:34 +00:00
|
|
|
Common::File inf;
|
2013-09-08 20:23:58 +00:00
|
|
|
Common::String filename = Common::String::format("sprite%d.avd", spritenum);
|
2013-09-13 06:29:19 +00:00
|
|
|
if (!inf.open(filename))
|
|
|
|
error("AVALANCHE: Trip: File not found: %s", filename.c_str());
|
2013-07-09 15:20:42 +00:00
|
|
|
|
|
|
|
inf.seek(177);
|
|
|
|
|
2013-09-07 21:42:34 +00:00
|
|
|
int32 id = inf.readSint32LE();
|
2013-07-09 15:20:42 +00:00
|
|
|
if (id != idshould) {
|
|
|
|
inf.close();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-09-21 13:36:13 +00:00
|
|
|
// Replace variable named 'soa' in the original code.
|
|
|
|
inf.skip(2);
|
2013-09-07 07:00:34 +00:00
|
|
|
|
2013-09-07 17:09:06 +00:00
|
|
|
if (!_stat._name.empty())
|
|
|
|
_stat._name.clear();
|
2013-07-19 21:36:00 +00:00
|
|
|
byte nameSize = inf.readByte();
|
2013-09-16 20:57:38 +00:00
|
|
|
for (int i = 0; i < nameSize; i++)
|
2013-09-07 17:09:06 +00:00
|
|
|
_stat._name += inf.readByte();
|
2013-07-19 21:36:00 +00:00
|
|
|
inf.skip(12 - nameSize);
|
2013-09-07 07:00:34 +00:00
|
|
|
|
2013-07-19 21:36:00 +00:00
|
|
|
byte commentSize = inf.readByte();
|
2013-09-16 20:57:38 +00:00
|
|
|
for (int i = 0; i < commentSize; i++)
|
2013-09-07 17:09:06 +00:00
|
|
|
_stat._comment += inf.readByte();
|
2013-07-19 21:36:00 +00:00
|
|
|
inf.skip(16 - commentSize);
|
2013-07-09 15:20:42 +00:00
|
|
|
|
2013-09-07 17:09:06 +00:00
|
|
|
_stat._frameNum = inf.readByte();
|
2013-09-05 11:20:03 +00:00
|
|
|
_info._xLength = inf.readByte();
|
|
|
|
_info._yLength = inf.readByte();
|
2013-09-08 09:40:35 +00:00
|
|
|
_stat._seq = inf.readByte();
|
2013-09-05 11:20:03 +00:00
|
|
|
_info._size = inf.readUint16LE();
|
2013-09-27 19:57:24 +00:00
|
|
|
_stat._fgBubbleCol = (Color)inf.readByte();
|
|
|
|
_stat._bgBubbleCol = (Color)inf.readByte();
|
2013-09-08 09:40:35 +00:00
|
|
|
_stat._acciNum = inf.readByte();
|
2013-07-09 15:20:42 +00:00
|
|
|
|
2013-09-07 21:03:27 +00:00
|
|
|
_animCount = 0; // = 1;
|
2013-09-05 11:20:03 +00:00
|
|
|
_info._xWidth = _info._xLength / 8;
|
|
|
|
if ((_info._xLength % 8) > 0)
|
|
|
|
_info._xWidth++;
|
2013-09-16 20:57:38 +00:00
|
|
|
for (int i = 0; i < _stat._frameNum; i++) {
|
2013-09-07 21:03:27 +00:00
|
|
|
_info._sil[_animCount] = new SilType[11 * (_info._yLength + 1)];
|
|
|
|
_info._mani[_animCount] = new ManiType[_info._size - 6];
|
2013-09-16 20:57:38 +00:00
|
|
|
for (int j = 0; j <= _info._yLength; j++)
|
2013-09-07 21:42:34 +00:00
|
|
|
inf.read((*_info._sil[_animCount])[j], _info._xWidth);
|
2013-09-07 21:03:27 +00:00
|
|
|
inf.read(*_info._mani[_animCount], _info._size - 6);
|
2013-07-09 15:20:42 +00:00
|
|
|
|
2013-09-07 21:03:27 +00:00
|
|
|
_animCount++;
|
2013-07-09 15:20:42 +00:00
|
|
|
}
|
2013-09-07 21:03:27 +00:00
|
|
|
_animCount++;
|
2013-07-09 15:20:42 +00:00
|
|
|
|
2013-09-07 17:09:06 +00:00
|
|
|
_x = 0;
|
|
|
|
_y = 0;
|
2013-09-07 21:42:34 +00:00
|
|
|
_quick = true;
|
2013-09-07 17:09:06 +00:00
|
|
|
_visible = false;
|
2013-09-07 21:03:27 +00:00
|
|
|
_speedX = 3;
|
|
|
|
_speedY = 1;
|
2013-09-07 19:50:37 +00:00
|
|
|
_homing = false;
|
2013-09-07 21:03:27 +00:00
|
|
|
_moveX = 0;
|
|
|
|
_moveY = 0;
|
2013-09-07 21:42:34 +00:00
|
|
|
_stepNum = 0;
|
|
|
|
_doCheck = doCheck;
|
|
|
|
_count = 0;
|
2013-09-07 21:03:27 +00:00
|
|
|
_id = spritenum;
|
2013-09-07 21:42:34 +00:00
|
|
|
_vanishIfStill = false;
|
|
|
|
_callEachStepFl = false;
|
2013-07-19 21:36:00 +00:00
|
|
|
|
2013-07-09 15:20:42 +00:00
|
|
|
inf.close();
|
2013-06-29 08:13:02 +00:00
|
|
|
}
|
|
|
|
|
2013-10-02 05:25:20 +00:00
|
|
|
/**
|
|
|
|
* Just sets 'quick' to false.
|
|
|
|
* @remarks Originally called 'original'
|
|
|
|
*/
|
2013-09-24 16:25:53 +00:00
|
|
|
void AnimationType::reset() {
|
2013-09-07 21:42:34 +00:00
|
|
|
_quick = false;
|
2013-09-07 21:03:27 +00:00
|
|
|
_id = 177;
|
2013-06-29 08:13:02 +00:00
|
|
|
}
|
|
|
|
|
2013-10-02 05:25:20 +00:00
|
|
|
/**
|
|
|
|
* Drops sprite onto screen.
|
|
|
|
* @remarks Originally called 'andexor'
|
|
|
|
*/
|
2013-09-08 10:21:02 +00:00
|
|
|
void AnimationType::draw() {
|
2013-09-07 21:42:34 +00:00
|
|
|
if ((_vanishIfStill) && (_moveX == 0) && (_moveY == 0))
|
2013-07-18 13:51:46 +00:00
|
|
|
return;
|
2013-09-21 13:36:13 +00:00
|
|
|
|
|
|
|
byte picnum = _facingDir * _stat._seq + _stepNum;
|
2013-07-18 13:51:46 +00:00
|
|
|
|
2013-09-08 10:53:19 +00:00
|
|
|
_anim->_vm->_graphics->drawSprite(_info, picnum, _x, _y);
|
2013-06-29 08:13:02 +00:00
|
|
|
}
|
|
|
|
|
2013-10-02 05:25:20 +00:00
|
|
|
/**
|
|
|
|
* Turns character round.
|
|
|
|
*/
|
2013-09-23 21:16:57 +00:00
|
|
|
void AnimationType::turn(Direction whichway) {
|
2013-06-30 12:10:33 +00:00
|
|
|
if (whichway == 8)
|
2013-09-23 21:16:57 +00:00
|
|
|
_facingDir = kDirUp;
|
2013-06-30 12:10:33 +00:00
|
|
|
else
|
2013-09-07 21:03:27 +00:00
|
|
|
_facingDir = whichway;
|
2013-06-29 08:13:02 +00:00
|
|
|
}
|
|
|
|
|
2013-10-02 05:25:20 +00:00
|
|
|
/**
|
|
|
|
* Switches it on.
|
|
|
|
*/
|
2013-09-23 21:16:57 +00:00
|
|
|
void AnimationType::appear(int16 wx, int16 wy, Direction wf) {
|
2013-09-07 17:09:06 +00:00
|
|
|
_x = (wx / 8) * 8;
|
|
|
|
_y = wy;
|
2013-09-26 23:34:38 +00:00
|
|
|
_oldX[_anim->_vm->_cp] = wx;
|
|
|
|
_oldY[_anim->_vm->_cp] = wy;
|
2013-06-29 08:13:02 +00:00
|
|
|
turn(wf);
|
2013-09-07 17:09:06 +00:00
|
|
|
_visible = true;
|
2013-09-07 21:03:27 +00:00
|
|
|
_moveX = 0;
|
|
|
|
_moveY = 0;
|
2013-06-29 08:13:02 +00:00
|
|
|
}
|
|
|
|
|
2013-09-07 18:02:14 +00:00
|
|
|
/**
|
|
|
|
* Check collision
|
|
|
|
* @remarks Originally called 'collision_check'
|
|
|
|
*/
|
|
|
|
bool AnimationType::checkCollision() {
|
2013-09-16 20:57:38 +00:00
|
|
|
for (int i = 0; i < _anim->kSpriteNumbMax; i++) {
|
2013-09-15 08:50:43 +00:00
|
|
|
AnimationType *spr = &_anim->_sprites[i];
|
|
|
|
if (spr->_quick && (spr->_id != _id) && (_x + _info._xLength > spr->_x) && (_x < spr->_x + spr->_info._xLength) && (spr->_y == _y))
|
|
|
|
return true;
|
2013-09-07 18:02:14 +00:00
|
|
|
}
|
2013-07-03 12:05:06 +00:00
|
|
|
|
|
|
|
return false;
|
2013-06-29 08:13:02 +00:00
|
|
|
}
|
|
|
|
|
2013-10-02 05:25:20 +00:00
|
|
|
/**
|
|
|
|
* Prepares for draw(), etc.
|
|
|
|
*/
|
2013-09-07 17:09:06 +00:00
|
|
|
void AnimationType::walk() {
|
2013-09-26 23:34:38 +00:00
|
|
|
if (!_anim->_vm->_doingSpriteRun) {
|
|
|
|
_oldX[_anim->_vm->_cp] = _x;
|
|
|
|
_oldY[_anim->_vm->_cp] = _y;
|
2013-09-07 19:50:37 +00:00
|
|
|
if (_homing)
|
2013-09-08 09:34:21 +00:00
|
|
|
homeStep();
|
2013-09-08 08:29:38 +00:00
|
|
|
_x += _moveX;
|
|
|
|
_y += _moveY;
|
2013-07-24 15:02:38 +00:00
|
|
|
}
|
|
|
|
|
2013-09-07 21:42:34 +00:00
|
|
|
if (_doCheck) {
|
2013-09-07 18:02:14 +00:00
|
|
|
if (checkCollision()) {
|
2013-07-24 15:02:38 +00:00
|
|
|
bounce();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-09-26 23:34:38 +00:00
|
|
|
byte magicColor = _anim->checkFeet(_x, _x + _info._xLength, _oldY[_anim->_vm->_cp], _y, _info._yLength) - 1;
|
2013-09-04 23:36:10 +00:00
|
|
|
// -1 is because the modified array indexes of magics[] compared to Pascal .
|
2013-07-24 15:02:38 +00:00
|
|
|
|
2013-09-26 23:34:38 +00:00
|
|
|
if ((magicColor != 255) & (!_anim->_vm->_doingSpriteRun)) {
|
|
|
|
MagicType *magic = &_anim->_vm->_magics[magicColor];
|
2013-09-14 23:10:10 +00:00
|
|
|
switch (magic->_operation) {
|
2013-10-01 21:15:53 +00:00
|
|
|
case kMagicExclaim:
|
2013-07-24 15:02:38 +00:00
|
|
|
bounce();
|
2013-09-08 10:53:19 +00:00
|
|
|
_anim->_mustExclaim = true;
|
2013-09-14 23:10:10 +00:00
|
|
|
_anim->_sayWhat = magic->_data;
|
2013-07-24 15:02:38 +00:00
|
|
|
break;
|
2013-10-01 21:15:53 +00:00
|
|
|
case kMagicBounce:
|
2013-07-24 15:02:38 +00:00
|
|
|
bounce();
|
|
|
|
break;
|
2013-10-01 21:15:53 +00:00
|
|
|
case kMagicTransport:
|
2013-09-26 23:34:38 +00:00
|
|
|
_anim->_vm->flipRoom((Room)(magic->_data >> 8), magic->_data & 0xff);
|
2013-07-24 15:02:38 +00:00
|
|
|
break;
|
2013-10-01 21:15:53 +00:00
|
|
|
case kMagicUnfinished: {
|
2013-07-24 15:02:38 +00:00
|
|
|
bounce();
|
2013-10-02 05:48:45 +00:00
|
|
|
Common::String tmpStr = Common::String::format("%c%cSorry.%cThis place is not available yet!",
|
|
|
|
kControlBell, kControlCenter, kControlRoman);
|
2013-09-21 16:06:37 +00:00
|
|
|
_anim->_vm->_dialogs->displayText(tmpStr);
|
2013-07-24 15:02:38 +00:00
|
|
|
}
|
|
|
|
break;
|
2013-10-01 21:15:53 +00:00
|
|
|
case kMagicSpecial:
|
2013-09-14 23:10:10 +00:00
|
|
|
_anim->callSpecial(magic->_data);
|
2013-07-24 15:02:38 +00:00
|
|
|
break;
|
2013-10-01 21:15:53 +00:00
|
|
|
case kMagicOpenDoor:
|
2013-09-26 23:34:38 +00:00
|
|
|
_anim->_vm->openDoor((Room)(magic->_data >> 8), magic->_data & 0xff, magicColor);
|
2013-07-24 15:02:38 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-26 23:34:38 +00:00
|
|
|
if (!_anim->_vm->_doingSpriteRun) {
|
2013-09-07 21:42:34 +00:00
|
|
|
_count++;
|
|
|
|
if (((_moveX != 0) || (_moveY != 0)) && (_count > 1)) {
|
|
|
|
_stepNum++;
|
2013-09-08 09:40:35 +00:00
|
|
|
if (_stepNum == _stat._seq)
|
2013-09-07 21:42:34 +00:00
|
|
|
_stepNum = 0;
|
|
|
|
_count = 0;
|
2013-07-24 15:02:38 +00:00
|
|
|
}
|
|
|
|
}
|
2013-06-29 08:13:02 +00:00
|
|
|
}
|
|
|
|
|
2013-10-02 05:25:20 +00:00
|
|
|
/**
|
|
|
|
* Bounces off walls
|
|
|
|
*/
|
2013-09-07 17:09:06 +00:00
|
|
|
void AnimationType::bounce() {
|
2013-09-26 23:34:38 +00:00
|
|
|
_x = _oldX[_anim->_vm->_cp];
|
|
|
|
_y = _oldY[_anim->_vm->_cp];
|
2013-09-07 21:42:34 +00:00
|
|
|
if (_doCheck)
|
2013-09-08 10:53:19 +00:00
|
|
|
_anim->stopWalking();
|
2013-06-30 12:10:33 +00:00
|
|
|
else
|
2013-09-07 21:03:27 +00:00
|
|
|
stopWalk();
|
2013-09-26 23:34:38 +00:00
|
|
|
_anim->_vm->drawDirection();
|
2013-06-29 08:13:02 +00:00
|
|
|
}
|
|
|
|
|
2013-09-08 10:23:48 +00:00
|
|
|
int8 AnimationType::getSign(int16 val) {
|
2013-09-04 15:54:08 +00:00
|
|
|
if (val > 0)
|
2013-08-26 07:47:39 +00:00
|
|
|
return 1;
|
2013-09-04 15:54:08 +00:00
|
|
|
else if (val < 0)
|
2013-08-26 07:47:39 +00:00
|
|
|
return -1;
|
2013-06-29 08:13:02 +00:00
|
|
|
else
|
2013-08-26 07:47:39 +00:00
|
|
|
return 0;
|
2013-06-29 08:13:02 +00:00
|
|
|
}
|
|
|
|
|
2013-10-02 05:25:20 +00:00
|
|
|
/**
|
|
|
|
* Home in on a point.
|
|
|
|
*/
|
2013-09-15 08:50:43 +00:00
|
|
|
void AnimationType::walkTo(byte pedNum) {
|
2013-09-26 23:34:38 +00:00
|
|
|
PedType *curPed = &_anim->_vm->_peds[pedNum];
|
2013-09-15 08:50:43 +00:00
|
|
|
|
|
|
|
setSpeed(getSign(curPed->_x - _x) * 4, getSign(curPed->_y - _y));
|
|
|
|
_homingX = curPed->_x - _info._xLength / 2;
|
|
|
|
_homingY = curPed->_y - _info._yLength;
|
2013-09-07 19:50:37 +00:00
|
|
|
_homing = true;
|
2013-06-29 08:13:02 +00:00
|
|
|
}
|
|
|
|
|
2013-09-08 10:23:48 +00:00
|
|
|
void AnimationType::stopHoming() {
|
2013-09-07 19:50:37 +00:00
|
|
|
_homing = false;
|
2013-06-29 08:13:02 +00:00
|
|
|
}
|
|
|
|
|
2013-10-02 05:25:20 +00:00
|
|
|
/**
|
|
|
|
* Calculates ix & iy for one homing step.
|
|
|
|
*/
|
2013-09-08 09:34:21 +00:00
|
|
|
void AnimationType::homeStep() {
|
2013-06-29 08:13:02 +00:00
|
|
|
int16 temp;
|
|
|
|
|
2013-09-07 19:50:37 +00:00
|
|
|
if ((_homingX == _x) && (_homingY == _y)) {
|
2013-09-05 00:29:09 +00:00
|
|
|
// touching the target
|
2013-09-07 21:03:27 +00:00
|
|
|
stopWalk();
|
2013-06-29 08:13:02 +00:00
|
|
|
return;
|
2013-06-27 10:13:00 +00:00
|
|
|
}
|
2013-09-07 21:03:27 +00:00
|
|
|
_moveX = 0;
|
|
|
|
_moveY = 0;
|
2013-09-07 19:50:37 +00:00
|
|
|
if (_homingY != _y) {
|
|
|
|
temp = _homingY - _y;
|
2013-06-30 12:10:33 +00:00
|
|
|
if (temp > 4)
|
2013-09-07 21:03:27 +00:00
|
|
|
_moveY = 4;
|
2013-06-30 12:10:33 +00:00
|
|
|
else if (temp < -4)
|
2013-09-07 21:03:27 +00:00
|
|
|
_moveY = -4;
|
2013-06-30 12:10:33 +00:00
|
|
|
else
|
2013-09-07 21:03:27 +00:00
|
|
|
_moveY = temp;
|
2013-06-27 10:13:00 +00:00
|
|
|
}
|
2013-09-07 19:50:37 +00:00
|
|
|
if (_homingX != _x) {
|
|
|
|
temp = _homingX - _x;
|
2013-06-30 12:10:33 +00:00
|
|
|
if (temp > 4)
|
2013-09-07 21:03:27 +00:00
|
|
|
_moveX = 4;
|
2013-06-30 12:10:33 +00:00
|
|
|
else if (temp < -4)
|
2013-09-07 21:03:27 +00:00
|
|
|
_moveX = -4;
|
2013-06-30 12:10:33 +00:00
|
|
|
else
|
2013-09-07 21:03:27 +00:00
|
|
|
_moveX = temp;
|
2013-06-29 08:13:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-02 05:25:20 +00:00
|
|
|
/**
|
|
|
|
* Sets ix & iy, non-homing, etc.
|
|
|
|
*/
|
2013-09-08 10:23:48 +00:00
|
|
|
void AnimationType::setSpeed(int8 xx, int8 yy) {
|
2013-09-07 21:03:27 +00:00
|
|
|
_moveX = xx;
|
|
|
|
_moveY = yy;
|
|
|
|
if ((_moveX == 0) && (_moveY == 0))
|
2013-09-05 00:29:09 +00:00
|
|
|
return; // no movement
|
2013-09-07 21:03:27 +00:00
|
|
|
if (_moveX == 0) {
|
2013-09-05 00:29:09 +00:00
|
|
|
// No horz movement
|
2013-09-07 21:03:27 +00:00
|
|
|
if (_moveY < 0)
|
2013-09-23 21:16:57 +00:00
|
|
|
turn(kDirUp);
|
2013-06-30 12:10:33 +00:00
|
|
|
else
|
2013-09-23 21:16:57 +00:00
|
|
|
turn(kDirDown);
|
2013-06-29 08:13:02 +00:00
|
|
|
} else {
|
2013-09-07 21:03:27 +00:00
|
|
|
if (_moveX < 0)
|
2013-09-23 21:16:57 +00:00
|
|
|
turn(kDirLeft);
|
2013-06-30 12:10:33 +00:00
|
|
|
else
|
2013-09-23 21:16:57 +00:00
|
|
|
turn(kDirRight);
|
2013-06-29 08:13:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-02 05:25:20 +00:00
|
|
|
/**
|
|
|
|
* Stops the sprite from moving.
|
|
|
|
*/
|
2013-09-07 21:03:27 +00:00
|
|
|
void AnimationType::stopWalk() {
|
|
|
|
_moveX = 0;
|
|
|
|
_moveY = 0;
|
2013-09-07 19:50:37 +00:00
|
|
|
_homing = false;
|
2013-06-29 08:13:02 +00:00
|
|
|
}
|
|
|
|
|
2013-10-02 05:25:20 +00:00
|
|
|
/**
|
|
|
|
* Sets up talk vars.
|
|
|
|
*/
|
2013-09-07 17:09:06 +00:00
|
|
|
void AnimationType::chatter() {
|
2013-09-26 23:34:38 +00:00
|
|
|
_anim->_vm->_talkX = _x + _info._xLength / 2;
|
|
|
|
_anim->_vm->_talkY = _y;
|
2013-10-01 05:43:21 +00:00
|
|
|
_anim->_vm->_graphics->setDialogColor(_stat._bgBubbleCol, _stat._fgBubbleCol);
|
2013-06-29 08:13:02 +00:00
|
|
|
}
|
|
|
|
|
2013-09-08 10:23:48 +00:00
|
|
|
void AnimationType::remove() {
|
2013-09-07 21:03:27 +00:00
|
|
|
_animCount--;
|
2013-09-05 11:20:03 +00:00
|
|
|
_info._xWidth = _info._xLength / 8;
|
|
|
|
if ((_info._xLength % 8) > 0)
|
|
|
|
_info._xWidth++;
|
2013-09-16 20:57:38 +00:00
|
|
|
for (int i = 0; i < _stat._frameNum; i++) {
|
2013-09-12 19:44:36 +00:00
|
|
|
assert(_animCount > 0);
|
2013-09-07 21:03:27 +00:00
|
|
|
_animCount--;
|
|
|
|
delete[] _info._mani[_animCount];
|
|
|
|
delete[] _info._sil[_animCount];
|
2013-06-27 10:13:00 +00:00
|
|
|
}
|
|
|
|
|
2013-09-07 21:42:34 +00:00
|
|
|
_quick = false;
|
2013-09-07 21:03:27 +00:00
|
|
|
_id = 177;
|
2013-06-29 08:13:02 +00:00
|
|
|
}
|
2013-06-27 10:13:00 +00:00
|
|
|
|
2013-09-07 17:09:06 +00:00
|
|
|
Animation::Animation(AvalancheEngine *vm) {
|
2013-07-24 17:43:10 +00:00
|
|
|
_vm = vm;
|
|
|
|
|
2013-09-08 10:06:08 +00:00
|
|
|
_mustExclaim = false;
|
2013-06-29 08:13:02 +00:00
|
|
|
}
|
2013-06-27 10:13:00 +00:00
|
|
|
|
2013-09-07 17:09:06 +00:00
|
|
|
Animation::~Animation() {
|
2013-09-07 21:03:27 +00:00
|
|
|
for (int16 i = 0; i < kSpriteNumbMax; i++) {
|
2013-09-08 10:06:08 +00:00
|
|
|
if (_sprites[i]._quick)
|
2013-09-08 10:23:48 +00:00
|
|
|
_sprites[i].remove();
|
2013-09-05 13:48:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-02 05:25:20 +00:00
|
|
|
/**
|
|
|
|
* Resets Animation variables.
|
|
|
|
* @remarks Originally called 'loadtrip'
|
|
|
|
*/
|
2013-09-24 16:25:53 +00:00
|
|
|
void Animation::resetAnims() {
|
2013-09-27 06:21:04 +00:00
|
|
|
setDirection(kDirStopped);
|
2013-09-07 21:03:27 +00:00
|
|
|
for (int16 i = 0; i < kSpriteNumbMax; i++)
|
2013-09-24 16:25:53 +00:00
|
|
|
_sprites[i].reset();
|
2013-06-29 08:13:02 +00:00
|
|
|
}
|
2013-06-27 10:13:00 +00:00
|
|
|
|
2013-09-08 10:06:08 +00:00
|
|
|
byte Animation::checkFeet(int16 x1, int16 x2, int16 oy, int16 y, byte yl) {
|
2013-09-26 23:34:38 +00:00
|
|
|
if (!_vm->_alive)
|
2013-09-21 13:36:13 +00:00
|
|
|
return 0;
|
2013-06-29 08:13:02 +00:00
|
|
|
|
2013-07-30 17:05:05 +00:00
|
|
|
if (x1 < 0)
|
|
|
|
x1 = 0;
|
|
|
|
if (x2 > 639)
|
|
|
|
x2 = 639;
|
2013-09-21 13:36:13 +00:00
|
|
|
|
|
|
|
int16 minY = MIN(oy, y) + yl;
|
|
|
|
int16 maxY = MAX(oy, y) + yl;
|
|
|
|
|
2013-09-28 12:31:54 +00:00
|
|
|
return _vm->_graphics->getAlsoColor(x1, minY, x2, maxY);
|
2013-06-29 08:13:02 +00:00
|
|
|
}
|
|
|
|
|
2013-09-21 13:36:13 +00:00
|
|
|
byte Animation::geidaPed(byte ped) {
|
|
|
|
switch (ped) {
|
2013-06-29 08:13:02 +00:00
|
|
|
case 1:
|
2013-09-21 13:36:13 +00:00
|
|
|
return 6;
|
2013-06-29 08:13:02 +00:00
|
|
|
case 2:
|
|
|
|
case 6:
|
2013-09-21 13:36:13 +00:00
|
|
|
return 7;
|
2013-06-29 08:13:02 +00:00
|
|
|
case 3:
|
|
|
|
case 5:
|
2013-09-21 13:36:13 +00:00
|
|
|
return 8;
|
2013-06-29 08:13:02 +00:00
|
|
|
case 4:
|
2013-09-21 13:36:13 +00:00
|
|
|
return 9;
|
2013-09-04 10:02:01 +00:00
|
|
|
default:
|
2013-09-21 13:36:13 +00:00
|
|
|
error("geidaPed(): Unhandled ped value %d", ped);
|
2013-06-29 08:13:02 +00:00
|
|
|
}
|
|
|
|
}
|
2013-06-27 10:13:00 +00:00
|
|
|
|
2013-10-02 05:25:20 +00:00
|
|
|
/**
|
|
|
|
* When you enter a new position in the catacombs, this procedure should be
|
|
|
|
* called. It changes the 'also' codes so that they may match the picture
|
|
|
|
* on the screen.
|
|
|
|
*/
|
2013-09-08 10:06:08 +00:00
|
|
|
void Animation::catacombMove(byte ped) {
|
2013-10-04 15:12:35 +00:00
|
|
|
// XY_uint16 is _catacombX+_catacombY*256. Thus, every room in the
|
2013-09-05 00:29:09 +00:00
|
|
|
// catacombs has a different number for it.
|
2013-10-04 15:12:35 +00:00
|
|
|
uint16 xy = _vm->_catacombX + _vm->_catacombY * 256;
|
2013-09-25 21:54:35 +00:00
|
|
|
_geidaSpin = 0;
|
2013-09-07 07:00:34 +00:00
|
|
|
|
2013-10-04 15:12:35 +00:00
|
|
|
switch (xy) {
|
2013-09-05 00:29:09 +00:00
|
|
|
case 1801: // Exit catacombs
|
2013-09-26 23:34:38 +00:00
|
|
|
_vm->flipRoom(kRoomLustiesRoom, 4);
|
2013-09-21 16:06:37 +00:00
|
|
|
_vm->_dialogs->displayText("Phew! Nice to be out of there!");
|
2013-06-29 08:13:02 +00:00
|
|
|
return;
|
2013-09-08 21:13:58 +00:00
|
|
|
case 1033:{ // Oubliette
|
2013-09-26 23:34:38 +00:00
|
|
|
_vm->flipRoom(kRoomOubliette, 1);
|
2013-10-02 05:48:45 +00:00
|
|
|
Common::String tmpStr = Common::String::format("Oh, NO!%c1%c", kControlRegister, kControlSpeechBubble);
|
2013-09-21 16:06:37 +00:00
|
|
|
_vm->_dialogs->displayText(tmpStr);
|
2013-09-08 21:13:58 +00:00
|
|
|
}
|
2013-06-29 08:13:02 +00:00
|
|
|
return;
|
2013-06-30 12:10:33 +00:00
|
|
|
case 4:
|
2013-09-26 23:34:38 +00:00
|
|
|
_vm->flipRoom(kRoomGeidas, 1);
|
2013-06-29 08:13:02 +00:00
|
|
|
return;
|
2013-06-30 12:10:33 +00:00
|
|
|
case 2307:
|
2013-09-26 23:34:38 +00:00
|
|
|
_vm->flipRoom(kRoomLusties, 5);
|
2013-09-21 16:06:37 +00:00
|
|
|
_vm->_dialogs->displayText("Oh no... here we go again...");
|
2013-09-26 23:34:38 +00:00
|
|
|
_vm->_userMovesAvvy = false;
|
2013-09-08 10:06:08 +00:00
|
|
|
_sprites[0]._moveY = 1;
|
|
|
|
_sprites[0]._moveX = 0;
|
2013-06-29 08:13:02 +00:00
|
|
|
return;
|
|
|
|
}
|
2013-06-27 10:13:00 +00:00
|
|
|
|
2013-09-26 23:34:38 +00:00
|
|
|
if (!_vm->_enterCatacombsFromLustiesRoom)
|
|
|
|
_vm->loadRoom(29);
|
2013-10-04 15:12:35 +00:00
|
|
|
int32 here = _vm->kCatacombMap[_vm->_catacombY - 1][_vm->_catacombX - 1];
|
2013-06-27 10:13:00 +00:00
|
|
|
|
2013-09-05 00:29:09 +00:00
|
|
|
switch (here & 0xf) { // West.
|
|
|
|
case 0: // no connection (wall)
|
2013-10-01 21:15:53 +00:00
|
|
|
_vm->_magics[1]._operation = kMagicBounce; // Sloping wall.
|
|
|
|
_vm->_magics[2]._operation = kMagicNothing; // Straight wall.
|
|
|
|
_vm->_portals[4]._operation = kMagicNothing; // Door.
|
2013-09-25 05:18:08 +00:00
|
|
|
_vm->_background->draw(-1, -1, 27);
|
2013-06-30 12:10:33 +00:00
|
|
|
break;
|
2013-09-05 00:29:09 +00:00
|
|
|
case 0x1: // no connection (wall + shield),
|
2013-10-01 21:15:53 +00:00
|
|
|
_vm->_magics[1]._operation = kMagicBounce; // Sloping wall.
|
|
|
|
_vm->_magics[2]._operation = kMagicNothing; // Straight wall.
|
|
|
|
_vm->_portals[4]._operation = kMagicNothing; // Door.
|
2013-09-25 05:18:08 +00:00
|
|
|
_vm->_background->draw(-1, -1, 27); // Wall, plus...
|
|
|
|
_vm->_background->draw(-1, -1, 28); // ...shield.
|
2013-06-30 12:10:33 +00:00
|
|
|
break;
|
2013-09-05 00:29:09 +00:00
|
|
|
case 0x2: // wall with door
|
2013-10-01 21:15:53 +00:00
|
|
|
_vm->_magics[1]._operation = kMagicBounce; // Sloping wall.
|
|
|
|
_vm->_magics[2]._operation = kMagicNothing; // Straight wall.
|
|
|
|
_vm->_portals[4]._operation = kMagicSpecial; // Door.
|
2013-09-25 05:18:08 +00:00
|
|
|
_vm->_background->draw(-1, -1, 27); // Wall, plus...
|
|
|
|
_vm->_background->draw(-1, -1, 29); // ...door.
|
2013-06-30 12:10:33 +00:00
|
|
|
break;
|
2013-09-05 00:29:09 +00:00
|
|
|
case 0x3: // wall with door and shield
|
2013-10-01 21:15:53 +00:00
|
|
|
_vm->_magics[1]._operation = kMagicBounce; // Sloping wall.
|
|
|
|
_vm->_magics[2]._operation = kMagicNothing; // Straight wall.
|
|
|
|
_vm->_portals[4]._operation = kMagicSpecial; // Door.
|
2013-09-25 05:18:08 +00:00
|
|
|
_vm->_background->draw(-1, -1, 27); // Wall, plus...
|
|
|
|
_vm->_background->draw(-1, -1, 29); // ...door, and...
|
|
|
|
_vm->_background->draw(-1, -1, 28); // ...shield.
|
2013-06-30 12:10:33 +00:00
|
|
|
break;
|
2013-09-05 00:29:09 +00:00
|
|
|
case 0x4: // no connection (wall + window),
|
2013-10-01 21:15:53 +00:00
|
|
|
_vm->_magics[1]._operation = kMagicBounce; // Sloping wall.
|
|
|
|
_vm->_magics[2]._operation = kMagicNothing; // Straight wall.
|
|
|
|
_vm->_portals[4]._operation = kMagicNothing; // Door.
|
2013-09-25 05:18:08 +00:00
|
|
|
_vm->_background->draw(-1, -1, 27); // Wall, plus...
|
|
|
|
_vm->_background->draw(-1, -1, 4); // ...window.
|
2013-06-30 12:10:33 +00:00
|
|
|
break;
|
2013-09-05 00:29:09 +00:00
|
|
|
case 0x5: // wall with door and window
|
2013-10-01 21:15:53 +00:00
|
|
|
_vm->_magics[1]._operation = kMagicBounce; // Sloping wall.
|
|
|
|
_vm->_magics[2]._operation = kMagicNothing; // Straight wall.
|
|
|
|
_vm->_portals[4]._operation = kMagicSpecial; // Door.
|
2013-09-25 05:18:08 +00:00
|
|
|
_vm->_background->draw(-1, -1, 27); // Wall, plus...
|
|
|
|
_vm->_background->draw(-1, -1, 29); // ...door, and...
|
|
|
|
_vm->_background->draw(-1, -1, 4); // ...window.
|
2013-06-30 12:10:33 +00:00
|
|
|
break;
|
2013-09-05 00:29:09 +00:00
|
|
|
case 0x6: // no connection (wall + torches),
|
2013-10-01 21:15:53 +00:00
|
|
|
_vm->_magics[1]._operation = kMagicBounce; // Sloping wall.
|
|
|
|
_vm->_magics[2]._operation = kMagicNothing; // Straight wall.
|
|
|
|
_vm->_portals[4]._operation = kMagicNothing; // No door.
|
2013-09-25 05:18:08 +00:00
|
|
|
_vm->_background->draw(-1, -1, 27); // Wall, plus...
|
|
|
|
_vm->_background->draw(-1, -1, 6); // ...torches.
|
2013-06-30 12:10:33 +00:00
|
|
|
break;
|
2013-09-05 00:29:09 +00:00
|
|
|
case 0x7: // wall with door and torches
|
2013-10-01 21:15:53 +00:00
|
|
|
_vm->_magics[1]._operation = kMagicBounce; // Sloping wall.
|
|
|
|
_vm->_magics[2]._operation = kMagicNothing; // Straight wall.
|
|
|
|
_vm->_portals[4]._operation = kMagicSpecial; // Door.
|
2013-09-25 05:18:08 +00:00
|
|
|
_vm->_background->draw(-1, -1, 27); // Wall, plus...
|
|
|
|
_vm->_background->draw(-1, -1, 29); // ...door, and...
|
|
|
|
_vm->_background->draw(-1, -1, 6); // ...torches.
|
2013-06-30 12:10:33 +00:00
|
|
|
break;
|
2013-09-05 00:29:09 +00:00
|
|
|
case 0xf: // straight-through corridor.
|
2013-10-01 21:15:53 +00:00
|
|
|
_vm->_magics[1]._operation = kMagicNothing; // Sloping wall.
|
|
|
|
_vm->_magics[2]._operation = kMagicSpecial; // Straight wall.
|
2013-06-30 12:10:33 +00:00
|
|
|
break;
|
2013-06-27 10:13:00 +00:00
|
|
|
}
|
|
|
|
|
2013-06-29 08:13:02 +00:00
|
|
|
/* ---- */
|
2013-06-27 10:13:00 +00:00
|
|
|
|
2013-09-05 00:29:09 +00:00
|
|
|
switch ((here & 0xf0) >> 4) { // East
|
|
|
|
case 0: // no connection (wall)
|
2013-10-01 21:15:53 +00:00
|
|
|
_vm->_magics[4]._operation = kMagicBounce; // Sloping wall.
|
|
|
|
_vm->_magics[5]._operation = kMagicNothing; // Straight wall.
|
|
|
|
_vm->_portals[6]._operation = kMagicNothing; // Door.
|
2013-09-25 05:18:08 +00:00
|
|
|
_vm->_background->draw(-1, -1, 18);
|
2013-06-30 12:10:33 +00:00
|
|
|
break;
|
2013-09-05 00:29:09 +00:00
|
|
|
case 0x1: // no connection (wall + window),
|
2013-10-01 21:15:53 +00:00
|
|
|
_vm->_magics[4]._operation = kMagicBounce; // Sloping wall.
|
|
|
|
_vm->_magics[5]._operation = kMagicNothing; // Straight wall.
|
|
|
|
_vm->_portals[6]._operation = kMagicNothing; // Door.
|
2013-09-25 05:18:08 +00:00
|
|
|
_vm->_background->draw(-1, -1, 18); // Wall, plus...
|
|
|
|
_vm->_background->draw(-1, -1, 19); // ...window.
|
2013-06-30 12:10:33 +00:00
|
|
|
break;
|
2013-09-05 00:29:09 +00:00
|
|
|
case 0x2: // wall with door
|
2013-10-01 21:15:53 +00:00
|
|
|
_vm->_magics[4]._operation = kMagicBounce; // Sloping wall.
|
|
|
|
_vm->_magics[5]._operation = kMagicNothing; // Straight wall.
|
|
|
|
_vm->_portals[6]._operation = kMagicSpecial; // Door.
|
2013-09-25 05:18:08 +00:00
|
|
|
_vm->_background->draw(-1, -1, 18); // Wall, plus...
|
|
|
|
_vm->_background->draw(-1, -1, 20); // ...door.
|
2013-06-30 12:10:33 +00:00
|
|
|
break;
|
2013-09-05 00:29:09 +00:00
|
|
|
case 0x3: // wall with door and window
|
2013-10-01 21:15:53 +00:00
|
|
|
_vm->_magics[4]._operation = kMagicBounce; // Sloping wall.
|
|
|
|
_vm->_magics[5]._operation = kMagicNothing; // Straight wall.
|
|
|
|
_vm->_portals[6]._operation = kMagicSpecial; // Door.
|
2013-09-25 05:18:08 +00:00
|
|
|
_vm->_background->draw(-1, -1, 18); // Wall, plus...
|
|
|
|
_vm->_background->draw(-1, -1, 19); // ...door, and...
|
|
|
|
_vm->_background->draw(-1, -1, 20); // ...window.
|
2013-06-30 12:10:33 +00:00
|
|
|
break;
|
2013-09-05 00:29:09 +00:00
|
|
|
case 0x6: // no connection (wall + torches),
|
2013-10-01 21:15:53 +00:00
|
|
|
_vm->_magics[4]._operation = kMagicBounce; // Sloping wall.
|
|
|
|
_vm->_magics[5]._operation = kMagicNothing; // Straight wall.
|
|
|
|
_vm->_portals[6]._operation = kMagicNothing; // No door.
|
2013-09-25 05:18:08 +00:00
|
|
|
_vm->_background->draw(-1, -1, 18); // Wall, plus...
|
|
|
|
_vm->_background->draw(-1, -1, 17); // ...torches.
|
2013-06-30 12:10:33 +00:00
|
|
|
break;
|
2013-09-05 00:29:09 +00:00
|
|
|
case 0x7: // wall with door and torches
|
2013-10-01 21:15:53 +00:00
|
|
|
_vm->_magics[4]._operation = kMagicBounce; // Sloping wall.
|
|
|
|
_vm->_magics[5]._operation = kMagicNothing; // Straight wall.
|
|
|
|
_vm->_portals[6]._operation = kMagicSpecial; // Door.
|
2013-09-25 05:18:08 +00:00
|
|
|
_vm->_background->draw(-1, -1, 18); // Wall, plus...
|
|
|
|
_vm->_background->draw(-1, -1, 20); // ...door, and...
|
|
|
|
_vm->_background->draw(-1, -1, 17); // ...torches.
|
2013-06-30 12:10:33 +00:00
|
|
|
break;
|
2013-09-05 00:29:09 +00:00
|
|
|
case 0xf: // straight-through corridor.
|
2013-10-01 21:15:53 +00:00
|
|
|
_vm->_magics[4]._operation = kMagicNothing; // Sloping wall.
|
|
|
|
_vm->_magics[5]._operation = kMagicSpecial; // Straight wall.
|
|
|
|
_vm->_portals[6]._operation = kMagicNothing; // Door.
|
2013-06-30 12:10:33 +00:00
|
|
|
break;
|
2013-06-29 08:13:02 +00:00
|
|
|
}
|
2013-06-27 10:13:00 +00:00
|
|
|
|
2013-09-05 00:29:09 +00:00
|
|
|
switch ((here & 0xf00) >> 8) { // South
|
|
|
|
case 0: // No connection.
|
2013-10-01 21:15:53 +00:00
|
|
|
_vm->_magics[6]._operation = kMagicBounce;
|
|
|
|
_vm->_magics[11]._operation = kMagicBounce;
|
|
|
|
_vm->_magics[12]._operation = kMagicBounce;
|
2013-06-30 12:10:33 +00:00
|
|
|
break;
|
|
|
|
case 0x1:
|
2013-09-25 05:18:08 +00:00
|
|
|
_vm->_background->draw(-1, -1, 21);
|
2013-09-07 07:00:34 +00:00
|
|
|
|
2013-10-04 15:12:35 +00:00
|
|
|
if ((xy == 2051) && (_vm->_geidaFollows))
|
2013-10-01 21:15:53 +00:00
|
|
|
_vm->_magics[12]._operation = kMagicExclaim;
|
2013-06-30 20:01:05 +00:00
|
|
|
else
|
2013-10-01 21:15:53 +00:00
|
|
|
_vm->_magics[12]._operation = kMagicSpecial; // Right exit south.
|
2013-06-27 10:13:00 +00:00
|
|
|
|
2013-10-01 21:15:53 +00:00
|
|
|
_vm->_magics[6]._operation = kMagicBounce;
|
|
|
|
_vm->_magics[11]._operation = kMagicBounce;
|
2013-06-30 12:10:33 +00:00
|
|
|
break;
|
|
|
|
case 0x2:
|
2013-09-25 05:18:08 +00:00
|
|
|
_vm->_background->draw(-1, -1, 22);
|
2013-10-01 21:15:53 +00:00
|
|
|
_vm->_magics[6]._operation = kMagicSpecial; // Middle exit south.
|
|
|
|
_vm->_magics[11]._operation = kMagicBounce;
|
|
|
|
_vm->_magics[12]._operation = kMagicBounce;
|
2013-06-30 12:10:33 +00:00
|
|
|
break;
|
|
|
|
case 0x3:
|
2013-09-25 05:18:08 +00:00
|
|
|
_vm->_background->draw(-1, -1, 23);
|
2013-10-01 21:15:53 +00:00
|
|
|
_vm->_magics[11]._operation = kMagicSpecial; // Left exit south.
|
|
|
|
_vm->_magics[6]._operation = kMagicBounce;
|
|
|
|
_vm->_magics[12]._operation = kMagicBounce;
|
2013-06-30 12:10:33 +00:00
|
|
|
break;
|
2013-06-27 10:13:00 +00:00
|
|
|
}
|
|
|
|
|
2013-09-05 00:29:09 +00:00
|
|
|
switch ((here & 0xf000) >> 12) { // North
|
|
|
|
case 0: // No connection
|
2013-10-01 21:15:53 +00:00
|
|
|
_vm->_magics[0]._operation = kMagicBounce;
|
|
|
|
_vm->_portals[3]._operation = kMagicNothing; // Door.
|
2013-06-30 12:10:33 +00:00
|
|
|
break;
|
2013-09-07 07:00:34 +00:00
|
|
|
// LEFT handles:
|
2013-09-05 00:29:09 +00:00
|
|
|
#if 0
|
2013-06-30 12:10:33 +00:00
|
|
|
case 0x1:
|
2013-08-30 09:56:16 +00:00
|
|
|
_vm->_celer->show_one(-1, -1, 4);
|
2013-09-26 23:34:38 +00:00
|
|
|
_vm->magics[1].op = _vm->bounces; // { Left exit north. } { Change magic number! }
|
|
|
|
_vm->portals[12].op = _vm->special; // { Door. }
|
2013-06-30 12:10:33 +00:00
|
|
|
break;
|
2013-09-05 00:29:09 +00:00
|
|
|
#endif
|
2013-06-30 12:10:33 +00:00
|
|
|
case 0x2:
|
2013-09-25 05:18:08 +00:00
|
|
|
_vm->_background->draw(-1, -1, 3);
|
2013-10-01 21:15:53 +00:00
|
|
|
_vm->_magics[0]._operation = kMagicBounce; // Middle exit north.
|
|
|
|
_vm->_portals[3]._operation = kMagicSpecial; // Door.
|
2013-06-30 12:10:33 +00:00
|
|
|
break;
|
2013-09-05 00:29:09 +00:00
|
|
|
#if 0
|
|
|
|
case 0x3:
|
2013-08-30 09:56:16 +00:00
|
|
|
_vm->_celer->show_one(-1, -1, 4);
|
2013-09-26 23:34:38 +00:00
|
|
|
_vm->magics[1].op = _vm->bounces; // { Right exit north. } { Change magic number! }
|
|
|
|
_vm->portals[12].op = _vm->special; // { Door. }
|
2013-06-30 12:10:33 +00:00
|
|
|
break;
|
|
|
|
// RIGHT handles:
|
|
|
|
case 0x4:
|
2013-08-30 09:56:16 +00:00
|
|
|
_vm->_celer->show_one(-1, -1, 3);
|
2013-09-26 23:34:38 +00:00
|
|
|
_vm->magics[1].op = _vm->bounces; // { Left exit north. } { Change magic number! }
|
|
|
|
_vm->portals[12].op = _vm->special; // { Door. }
|
2013-06-30 12:10:33 +00:00
|
|
|
break;
|
2013-09-05 00:29:09 +00:00
|
|
|
#endif
|
2013-06-30 12:10:33 +00:00
|
|
|
case 0x5:
|
2013-09-25 05:18:08 +00:00
|
|
|
_vm->_background->draw(-1, -1, 2);
|
2013-10-01 21:15:53 +00:00
|
|
|
_vm->_magics[0]._operation = kMagicBounce; // Middle exit north.
|
|
|
|
_vm->_portals[3]._operation = kMagicSpecial; // Door.
|
2013-06-30 12:10:33 +00:00
|
|
|
break;
|
2013-09-05 00:29:09 +00:00
|
|
|
#if 0
|
2013-06-30 12:10:33 +00:00
|
|
|
case 0x6:
|
2013-08-30 09:56:16 +00:00
|
|
|
_vm->_celer->show_one(-1, -1, 3);
|
2013-09-26 23:34:38 +00:00
|
|
|
_vm->magics[1].op = _vm->bounces; // { Right exit north. }
|
|
|
|
_vm->portals[12].op = _vm->special; // { Door. }
|
2013-06-30 12:10:33 +00:00
|
|
|
break;
|
2013-09-05 00:29:09 +00:00
|
|
|
#endif
|
2013-06-30 12:10:33 +00:00
|
|
|
// ARCHWAYS:
|
2013-06-29 08:13:02 +00:00
|
|
|
case 0x7:
|
|
|
|
case 0x8:
|
2013-09-15 23:15:47 +00:00
|
|
|
case 0x9:
|
2013-09-25 05:18:08 +00:00
|
|
|
_vm->_background->draw(-1, -1, 5);
|
2013-06-29 08:13:02 +00:00
|
|
|
|
2013-06-30 12:10:33 +00:00
|
|
|
if (((here & 0xf000) >> 12) > 0x7)
|
2013-09-25 05:18:08 +00:00
|
|
|
_vm->_background->draw(-1, -1, 30);
|
2013-06-30 12:10:33 +00:00
|
|
|
if (((here & 0xf000) >> 12) == 0x9)
|
2013-09-25 05:18:08 +00:00
|
|
|
_vm->_background->draw(-1, -1, 31);
|
2013-06-29 08:13:02 +00:00
|
|
|
|
2013-10-01 21:15:53 +00:00
|
|
|
_vm->_magics[0]._operation = kMagicSpecial; // Middle arch north.
|
|
|
|
_vm->_portals[3]._operation = kMagicNothing; // Door.
|
2013-09-15 23:15:47 +00:00
|
|
|
break;
|
2013-09-05 00:29:09 +00:00
|
|
|
// DECORATIONS:
|
|
|
|
case 0xd: // No connection + WINDOW
|
2013-10-01 21:15:53 +00:00
|
|
|
_vm->_magics[0]._operation = kMagicBounce;
|
|
|
|
_vm->_portals[3]._operation = kMagicNothing; // Door.
|
2013-09-25 05:18:08 +00:00
|
|
|
_vm->_background->draw(-1, -1, 13);
|
2013-06-30 12:10:33 +00:00
|
|
|
break;
|
2013-09-05 00:29:09 +00:00
|
|
|
case 0xe: // No connection + TORCH
|
2013-10-01 21:15:53 +00:00
|
|
|
_vm->_magics[0]._operation = kMagicBounce;
|
|
|
|
_vm->_portals[3]._operation = kMagicNothing; // Door.
|
2013-09-25 05:18:08 +00:00
|
|
|
_vm->_background->draw(-1, -1, 7);
|
2013-06-30 12:10:33 +00:00
|
|
|
break;
|
2013-09-05 00:29:09 +00:00
|
|
|
// Recessed door:
|
2013-06-30 12:10:33 +00:00
|
|
|
case 0xf:
|
2013-10-01 21:15:53 +00:00
|
|
|
_vm->_magics[0]._operation = kMagicNothing; // Door to Geida's room.
|
2013-09-25 05:18:08 +00:00
|
|
|
_vm->_background->draw(-1, -1, 0);
|
2013-10-01 21:15:53 +00:00
|
|
|
_vm->_portals[3]._operation = kMagicSpecial; // Door.
|
2013-06-30 12:10:33 +00:00
|
|
|
break;
|
2013-06-27 10:13:00 +00:00
|
|
|
}
|
|
|
|
|
2013-10-04 15:12:35 +00:00
|
|
|
switch (xy) {
|
2013-06-29 08:13:02 +00:00
|
|
|
case 514:
|
2013-09-25 05:18:08 +00:00
|
|
|
_vm->_background->draw(-1, -1, 16);
|
2013-09-05 00:29:09 +00:00
|
|
|
break; // [2,2] : "Art Gallery" sign over door.
|
2013-06-29 08:13:02 +00:00
|
|
|
case 264:
|
2013-09-25 05:18:08 +00:00
|
|
|
_vm->_background->draw(-1, -1, 8);
|
2013-09-05 00:29:09 +00:00
|
|
|
break; // [8,1] : "The Wrong Way!" sign.
|
2013-06-29 08:13:02 +00:00
|
|
|
case 1797:
|
2013-09-25 05:18:08 +00:00
|
|
|
_vm->_background->draw(-1, -1, 1);
|
2013-09-05 00:29:09 +00:00
|
|
|
break; // [5,7] : "Ite Mingite" sign.
|
2013-06-29 08:13:02 +00:00
|
|
|
case 258:
|
2013-09-15 16:27:40 +00:00
|
|
|
for (int i = 0; i <= 2; i++) { // [2,1] : Art gallery - pictures
|
2013-09-25 05:18:08 +00:00
|
|
|
_vm->_background->draw(130 + i * 120, 70, 14);
|
|
|
|
_vm->_background->draw(184 + i * 120, 78, 15);
|
2013-06-29 08:13:02 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1287:
|
2013-09-15 16:27:40 +00:00
|
|
|
for (int i = 10; i <= 13; i++)
|
2013-09-25 05:18:08 +00:00
|
|
|
_vm->_background->draw(-1, -1, i - 1);
|
2013-09-05 00:29:09 +00:00
|
|
|
break; // [7,5] : 4 candles.
|
2013-06-29 08:13:02 +00:00
|
|
|
case 776:
|
2013-09-25 05:18:08 +00:00
|
|
|
_vm->_background->draw(-1, -1, 9);
|
2013-09-05 00:29:09 +00:00
|
|
|
break; // [8,3] : 1 candle.
|
2013-06-29 08:13:02 +00:00
|
|
|
case 2049:
|
2013-09-25 05:18:08 +00:00
|
|
|
_vm->_background->draw(-1, -1, 10);
|
2013-09-05 00:29:09 +00:00
|
|
|
break; // [1,8] : another candle.
|
2013-06-30 12:10:33 +00:00
|
|
|
case 257:
|
2013-09-25 05:18:08 +00:00
|
|
|
_vm->_background->draw(-1, -1, 11);
|
|
|
|
_vm->_background->draw(-1, -1, 12);
|
2013-09-05 00:29:09 +00:00
|
|
|
break; // [1,1] : the other two.
|
2013-06-27 10:13:00 +00:00
|
|
|
}
|
|
|
|
|
2013-09-26 23:34:38 +00:00
|
|
|
if ((_vm->_geidaFollows) && (ped > 0)) {
|
2013-09-08 10:06:08 +00:00
|
|
|
if (!_sprites[1]._quick) // If we don't already have her...
|
|
|
|
_sprites[1].init(5, true, this); // ...Load Geida.
|
2013-09-21 13:36:13 +00:00
|
|
|
appearPed(1, geidaPed(ped));
|
2013-09-08 10:06:08 +00:00
|
|
|
_sprites[1]._callEachStepFl = true;
|
|
|
|
_sprites[1]._eachStepProc = kProcGeida;
|
2013-06-29 08:13:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-02 05:25:20 +00:00
|
|
|
/**
|
|
|
|
* This proc gets called whenever you touch a line defined as _vm->special.
|
|
|
|
*/
|
2013-09-08 10:21:02 +00:00
|
|
|
void Animation::dawnDelay() {
|
2013-09-09 21:34:12 +00:00
|
|
|
_vm->_timer->addTimer(2, Timer::kProcDawnDelay, Timer::kReasonDawndelay);
|
2013-06-29 08:13:02 +00:00
|
|
|
}
|
|
|
|
|
2013-09-08 10:06:08 +00:00
|
|
|
void Animation::callSpecial(uint16 which) {
|
2013-06-29 08:13:02 +00:00
|
|
|
switch (which) {
|
2013-09-26 23:34:38 +00:00
|
|
|
case 1: // _vm->special 1: Room 22: top of stairs.
|
2013-09-25 05:18:08 +00:00
|
|
|
_vm->_background->draw(-1, -1, 0);
|
2013-09-26 23:34:38 +00:00
|
|
|
_vm->_brummieStairs = 1;
|
2013-10-01 21:15:53 +00:00
|
|
|
_vm->_magics[9]._operation = kMagicNothing;
|
2013-09-09 21:34:12 +00:00
|
|
|
_vm->_timer->addTimer(10, Timer::kProcStairs, Timer::kReasonBrummieStairs);
|
2013-09-07 21:03:27 +00:00
|
|
|
stopWalking();
|
2013-09-26 23:34:38 +00:00
|
|
|
_vm->_userMovesAvvy = false;
|
2013-07-24 16:25:07 +00:00
|
|
|
break;
|
2013-09-26 23:34:38 +00:00
|
|
|
case 2: // _vm->special 2: Room 22: bottom of stairs.
|
|
|
|
_vm->_brummieStairs = 3;
|
2013-10-01 21:15:53 +00:00
|
|
|
_vm->_magics[10]._operation = kMagicNothing;
|
|
|
|
_vm->_magics[11]._operation = kMagicExclaim;
|
2013-09-26 23:34:38 +00:00
|
|
|
_vm->_magics[11]._data = 5;
|
2013-10-01 21:15:53 +00:00
|
|
|
_vm->_magics[3]._operation = kMagicBounce; // Now works as planned!
|
2013-09-07 21:03:27 +00:00
|
|
|
stopWalking();
|
2013-09-21 16:06:37 +00:00
|
|
|
_vm->_dialogs->displayScrollChain('q', 26);
|
2013-09-26 23:34:38 +00:00
|
|
|
_vm->_userMovesAvvy = true;
|
2013-06-30 12:10:33 +00:00
|
|
|
break;
|
2013-09-26 23:34:38 +00:00
|
|
|
case 3: // _vm->special 3: Room 71: triggers dart.
|
2013-09-08 10:06:08 +00:00
|
|
|
_sprites[0].bounce(); // Must include that.
|
2013-06-29 08:13:02 +00:00
|
|
|
|
2013-09-30 22:12:28 +00:00
|
|
|
if (!_arrowTriggered) {
|
|
|
|
_arrowTriggered = true;
|
2013-09-15 22:05:35 +00:00
|
|
|
appearPed(1, 3); // The dart starts at ped 4, and...
|
2013-09-15 13:50:05 +00:00
|
|
|
_sprites[1].walkTo(4); // flies to ped 5 (- 1 for pascal to C conversion).
|
2013-09-08 10:06:08 +00:00
|
|
|
_sprites[1]._facingDir = kDirUp; // Only face.
|
2013-09-05 00:29:09 +00:00
|
|
|
// Should call some kind of Eachstep procedure which will deallocate
|
|
|
|
// the sprite when it hits the wall, and replace it with the chunk
|
|
|
|
// graphic of the arrow buried in the plaster. */
|
2013-09-07 07:00:34 +00:00
|
|
|
|
2013-09-05 00:29:09 +00:00
|
|
|
// OK!
|
2013-09-08 10:06:08 +00:00
|
|
|
_sprites[1]._callEachStepFl = true;
|
|
|
|
_sprites[1]._eachStepProc = kProcArrow;
|
2013-06-27 10:13:00 +00:00
|
|
|
}
|
2013-06-30 12:10:33 +00:00
|
|
|
break;
|
2013-09-05 00:29:09 +00:00
|
|
|
case 4: // This is the ghost room link.
|
2013-10-08 22:39:16 +00:00
|
|
|
_vm->fadeOut();
|
2013-09-08 10:06:08 +00:00
|
|
|
_sprites[0].turn(kDirRight); // you'll see this after we get back from bootstrap
|
2013-09-09 21:34:12 +00:00
|
|
|
_vm->_timer->addTimer(1, Timer::kProcGhostRoomPhew, Timer::kReasonGhostRoomPhew);
|
2013-09-15 11:21:03 +00:00
|
|
|
//_vm->_enid->backToBootstrap(3); TODO: Replace it with proper ScummVM-friendly function(s)! Do not remove until then!
|
2013-06-30 12:10:33 +00:00
|
|
|
break;
|
2013-06-29 08:13:02 +00:00
|
|
|
case 5:
|
2013-09-26 23:34:38 +00:00
|
|
|
if (_vm->_friarWillTieYouUp) {
|
|
|
|
// _vm->special 5: Room 42: touched tree, and get tied up.
|
2013-10-01 21:15:53 +00:00
|
|
|
_vm->_magics[4]._operation = kMagicBounce; // Boundary effect is now working again.
|
2013-09-21 16:06:37 +00:00
|
|
|
_vm->_dialogs->displayScrollChain('q', 35);
|
2013-09-08 10:23:48 +00:00
|
|
|
_sprites[0].remove();
|
2013-09-05 00:29:09 +00:00
|
|
|
//tr[1].vanishifstill:=true;
|
2013-09-25 05:18:08 +00:00
|
|
|
_vm->_background->draw(-1, -1, 1);
|
2013-09-21 16:06:37 +00:00
|
|
|
_vm->_dialogs->displayScrollChain('q', 36);
|
2013-09-26 23:34:38 +00:00
|
|
|
_vm->_tiedUp = true;
|
|
|
|
_vm->_friarWillTieYouUp = false;
|
2013-09-15 13:50:05 +00:00
|
|
|
_sprites[1].walkTo(2);
|
2013-09-08 10:06:08 +00:00
|
|
|
_sprites[1]._vanishIfStill = true;
|
|
|
|
_sprites[1]._doCheck = true; // One of them must have Check_Me switched on.
|
2013-09-26 23:34:38 +00:00
|
|
|
_vm->setRoom(kPeopleFriarTuck, kRoomDummy); // Not here, then.
|
2013-09-09 21:34:12 +00:00
|
|
|
_vm->_timer->addTimer(364, Timer::kProcHangAround, Timer::kReasonHangingAround);
|
2013-06-27 10:13:00 +00:00
|
|
|
}
|
2013-06-29 08:13:02 +00:00
|
|
|
break;
|
2013-09-26 23:34:38 +00:00
|
|
|
case 6: // _vm->special 6: fall down oubliette.
|
|
|
|
_vm->_userMovesAvvy = false;
|
2013-09-08 10:06:08 +00:00
|
|
|
_sprites[0]._moveX = 3;
|
|
|
|
_sprites[0]._moveY = 0;
|
|
|
|
_sprites[0]._facingDir = kDirRight;
|
2013-09-09 21:34:12 +00:00
|
|
|
_vm->_timer->addTimer(1, Timer::kProcFallDownOubliette, Timer::kReasonFallingDownOubliette);
|
2013-06-30 12:10:33 +00:00
|
|
|
break;
|
2013-09-26 23:34:38 +00:00
|
|
|
case 7: // _vm->special 7: stop falling down oubliette.
|
2013-09-08 10:06:08 +00:00
|
|
|
_sprites[0]._visible = false;
|
2013-10-01 21:15:53 +00:00
|
|
|
_vm->_magics[9]._operation = kMagicNothing;
|
2013-09-07 21:03:27 +00:00
|
|
|
stopWalking();
|
2013-09-09 21:34:12 +00:00
|
|
|
_vm->_timer->loseTimer(Timer::kReasonFallingDownOubliette);
|
2013-09-26 23:34:38 +00:00
|
|
|
//_vm->mblit(12, 80, 38, 160, 3, 0);
|
|
|
|
//_vm->mblit(12, 80, 38, 160, 3, 1);
|
2013-09-21 16:06:37 +00:00
|
|
|
_vm->_dialogs->displayText("Oh dear, you seem to be down the bottom of an oubliette.");
|
2013-09-09 21:34:12 +00:00
|
|
|
_vm->_timer->addTimer(200, Timer::kProcMeetAvaroid, Timer::kReasonMeetingAvaroid);
|
2013-06-30 12:10:33 +00:00
|
|
|
break;
|
2013-09-26 23:34:38 +00:00
|
|
|
case 8: // _vm->special 8: leave du Lustie's room.
|
|
|
|
if ((_vm->_geidaFollows) && (!_vm->_lustieIsAsleep)) {
|
2013-09-21 16:06:37 +00:00
|
|
|
_vm->_dialogs->displayScrollChain('q', 63);
|
2013-09-08 10:06:08 +00:00
|
|
|
_sprites[1].turn(kDirDown);
|
|
|
|
_sprites[1].stopWalk();
|
|
|
|
_sprites[1]._callEachStepFl = false; // Geida
|
2013-09-26 23:34:38 +00:00
|
|
|
_vm->gameOver();
|
2013-06-27 10:13:00 +00:00
|
|
|
}
|
2013-06-29 08:13:02 +00:00
|
|
|
break;
|
2013-09-26 23:34:38 +00:00
|
|
|
case 9: // _vm->special 9: lose Geida to Robin Hood...
|
|
|
|
if (!_vm->_geidaFollows)
|
2013-09-05 00:29:09 +00:00
|
|
|
return; // DOESN'T COUNT: no Geida.
|
2013-09-08 10:06:08 +00:00
|
|
|
_sprites[1]._callEachStepFl = false; // She no longer follows Avvy around.
|
2013-09-15 13:50:05 +00:00
|
|
|
_sprites[1].walkTo(3); // She walks to somewhere...
|
2013-09-08 10:23:48 +00:00
|
|
|
_sprites[0].remove(); // Lose Avvy.
|
2013-09-26 23:34:38 +00:00
|
|
|
_vm->_userMovesAvvy = false;
|
2013-09-09 21:34:12 +00:00
|
|
|
_vm->_timer->addTimer(40, Timer::kProcRobinHoodAndGeida, Timer::kReasonRobinHoodAndGeida);
|
2013-06-30 12:10:33 +00:00
|
|
|
break;
|
2013-09-26 23:34:38 +00:00
|
|
|
case 10: // _vm->special 10: transfer north in catacombs.
|
|
|
|
if ((_vm->_catacombX == 4) && (_vm->_catacombY == 1)) {
|
2013-09-05 00:29:09 +00:00
|
|
|
// Into Geida's room.
|
2013-09-26 23:34:38 +00:00
|
|
|
if (_vm->_objects[kObjectKey - 1])
|
2013-09-21 16:06:37 +00:00
|
|
|
_vm->_dialogs->displayScrollChain('q', 62);
|
2013-06-29 08:13:02 +00:00
|
|
|
else {
|
2013-09-21 16:06:37 +00:00
|
|
|
_vm->_dialogs->displayScrollChain('q', 61);
|
2013-06-29 08:13:02 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2013-10-08 22:39:16 +00:00
|
|
|
_vm->fadeOut();
|
2013-09-26 23:34:38 +00:00
|
|
|
_vm->_catacombY--;
|
2013-09-08 10:06:08 +00:00
|
|
|
catacombMove(4);
|
2013-09-26 23:34:38 +00:00
|
|
|
if (_vm->_room != kRoomCatacombs)
|
2013-06-30 12:10:33 +00:00
|
|
|
return;
|
2013-09-26 23:34:38 +00:00
|
|
|
switch ((_vm->kCatacombMap[_vm->_catacombY - 1][_vm->_catacombX - 1] & 0xf00) >> 8) {
|
2013-06-29 08:13:02 +00:00
|
|
|
case 0x1:
|
2013-09-15 22:05:35 +00:00
|
|
|
appearPed(0, 11);
|
2013-06-29 08:13:02 +00:00
|
|
|
break;
|
|
|
|
case 0x3:
|
2013-09-15 22:05:35 +00:00
|
|
|
appearPed(0, 10);
|
2013-06-29 08:13:02 +00:00
|
|
|
break;
|
|
|
|
default:
|
2013-09-15 22:05:35 +00:00
|
|
|
appearPed(0, 3);
|
2013-06-29 08:13:02 +00:00
|
|
|
}
|
2013-09-08 10:21:02 +00:00
|
|
|
dawnDelay();
|
2013-06-30 12:10:33 +00:00
|
|
|
break;
|
2013-09-26 23:34:38 +00:00
|
|
|
case 11: // _vm->special 11: transfer east in catacombs.
|
2013-10-08 22:39:16 +00:00
|
|
|
_vm->fadeOut();
|
2013-09-26 23:34:38 +00:00
|
|
|
_vm->_catacombX++;
|
2013-09-08 10:06:08 +00:00
|
|
|
catacombMove(1);
|
2013-09-26 23:34:38 +00:00
|
|
|
if (_vm->_room != kRoomCatacombs)
|
2013-06-30 12:10:33 +00:00
|
|
|
return;
|
2013-09-15 22:05:35 +00:00
|
|
|
appearPed(0, 0);
|
2013-09-08 10:21:02 +00:00
|
|
|
dawnDelay();
|
2013-06-30 12:10:33 +00:00
|
|
|
break;
|
2013-09-26 23:34:38 +00:00
|
|
|
case 12: // _vm->special 12: transfer south in catacombs.
|
2013-10-08 22:39:16 +00:00
|
|
|
_vm->fadeOut();
|
2013-09-26 23:34:38 +00:00
|
|
|
_vm->_catacombY++;
|
2013-09-08 10:06:08 +00:00
|
|
|
catacombMove(2);
|
2013-09-26 23:34:38 +00:00
|
|
|
if (_vm->_room != kRoomCatacombs)
|
2013-06-30 12:10:33 +00:00
|
|
|
return;
|
2013-09-15 22:05:35 +00:00
|
|
|
appearPed(0, 1);
|
2013-09-08 10:21:02 +00:00
|
|
|
dawnDelay();
|
2013-06-30 12:10:33 +00:00
|
|
|
break;
|
2013-09-26 23:34:38 +00:00
|
|
|
case 13: // _vm->special 13: transfer west in catacombs.
|
2013-10-08 22:39:16 +00:00
|
|
|
_vm->fadeOut();
|
2013-09-26 23:34:38 +00:00
|
|
|
_vm->_catacombX--;
|
2013-09-08 10:06:08 +00:00
|
|
|
catacombMove(3);
|
2013-09-26 23:34:38 +00:00
|
|
|
if (_vm->_room != kRoomCatacombs)
|
2013-06-30 12:10:33 +00:00
|
|
|
return;
|
2013-09-15 22:05:35 +00:00
|
|
|
appearPed(0, 2);
|
2013-09-08 10:21:02 +00:00
|
|
|
dawnDelay();
|
2013-06-30 12:10:33 +00:00
|
|
|
break;
|
2013-06-29 08:13:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-08 10:06:08 +00:00
|
|
|
void Animation::updateSpeed() {
|
2013-09-29 09:26:21 +00:00
|
|
|
// Given that you've just changed the speed in _speedX, this adjusts _moveX.
|
2013-09-08 10:06:08 +00:00
|
|
|
_sprites[0]._moveX = (_sprites[0]._moveX / 3) * _sprites[0]._speedX;
|
2013-09-29 09:26:21 +00:00
|
|
|
_vm->_graphics->drawSpeedBar(_sprites[0]._speedX);
|
2013-06-29 08:13:02 +00:00
|
|
|
}
|
2013-06-27 10:13:00 +00:00
|
|
|
|
2013-09-23 21:16:57 +00:00
|
|
|
void Animation::setMoveSpeed(byte t, Direction dir) {
|
2013-09-04 15:54:08 +00:00
|
|
|
switch (dir) {
|
2013-09-07 07:14:14 +00:00
|
|
|
case kDirUp:
|
2013-09-08 10:23:48 +00:00
|
|
|
_sprites[t].setSpeed(0, -_sprites[t]._speedY);
|
2013-06-30 12:10:33 +00:00
|
|
|
break;
|
2013-09-07 07:14:14 +00:00
|
|
|
case kDirDown:
|
2013-09-08 10:23:48 +00:00
|
|
|
_sprites[t].setSpeed(0, _sprites[t]._speedY);
|
2013-06-30 12:10:33 +00:00
|
|
|
break;
|
2013-09-07 07:14:14 +00:00
|
|
|
case kDirLeft:
|
2013-09-08 10:23:48 +00:00
|
|
|
_sprites[t].setSpeed(-_sprites[t]._speedX, 0);
|
2013-06-30 12:10:33 +00:00
|
|
|
break;
|
2013-09-07 07:14:14 +00:00
|
|
|
case kDirRight:
|
2013-09-08 10:23:48 +00:00
|
|
|
_sprites[t].setSpeed(_sprites[t]._speedX, 0);
|
2013-06-30 12:10:33 +00:00
|
|
|
break;
|
2013-09-07 07:14:14 +00:00
|
|
|
case kDirUpLeft:
|
2013-09-08 10:23:48 +00:00
|
|
|
_sprites[t].setSpeed(-_sprites[t]._speedX, -_sprites[t]._speedY);
|
2013-06-30 12:10:33 +00:00
|
|
|
break;
|
2013-09-07 07:14:14 +00:00
|
|
|
case kDirUpRight:
|
2013-09-08 10:23:48 +00:00
|
|
|
_sprites[t].setSpeed(_sprites[t]._speedX, -_sprites[t]._speedY);
|
2013-06-30 12:10:33 +00:00
|
|
|
break;
|
2013-09-07 07:14:14 +00:00
|
|
|
case kDirDownLeft:
|
2013-09-08 10:23:48 +00:00
|
|
|
_sprites[t].setSpeed(-_sprites[t]._speedX, _sprites[t]._speedY);
|
2013-06-30 12:10:33 +00:00
|
|
|
break;
|
2013-09-07 07:14:14 +00:00
|
|
|
case kDirDownRight:
|
2013-09-08 10:23:48 +00:00
|
|
|
_sprites[t].setSpeed(_sprites[t]._speedX, _sprites[t]._speedY);
|
2013-06-30 12:10:33 +00:00
|
|
|
break;
|
2013-09-29 21:59:01 +00:00
|
|
|
default:
|
|
|
|
break;
|
2013-06-29 08:13:02 +00:00
|
|
|
}
|
|
|
|
}
|
2013-06-27 10:13:00 +00:00
|
|
|
|
2013-09-15 08:50:43 +00:00
|
|
|
void Animation::appearPed(byte sprNum, byte pedNum) {
|
2013-09-15 22:05:35 +00:00
|
|
|
AnimationType *curSpr = &_sprites[sprNum];
|
2013-09-26 23:34:38 +00:00
|
|
|
PedType *curPed = &_vm->_peds[pedNum];
|
2013-09-15 08:50:43 +00:00
|
|
|
curSpr->appear(curPed->_x - curSpr->_info._xLength / 2, curPed->_y - curSpr->_info._yLength, curPed->_direction);
|
2013-09-23 21:16:57 +00:00
|
|
|
setMoveSpeed(sprNum, curPed->_direction);
|
2013-06-29 08:13:02 +00:00
|
|
|
}
|
|
|
|
|
2013-10-02 05:25:20 +00:00
|
|
|
/**
|
|
|
|
* @remarks Originally called 'follow_avvy_y'
|
|
|
|
*/
|
2013-09-08 10:21:02 +00:00
|
|
|
void Animation::followAvalotY(byte tripnum) {
|
2013-09-08 10:06:08 +00:00
|
|
|
if (_sprites[0]._facingDir == kDirLeft)
|
2013-06-29 08:13:02 +00:00
|
|
|
return;
|
2013-09-08 10:06:08 +00:00
|
|
|
if (_sprites[tripnum]._homing)
|
|
|
|
_sprites[tripnum]._homingY = _sprites[1]._y;
|
2013-06-29 08:13:02 +00:00
|
|
|
else {
|
2013-09-08 10:06:08 +00:00
|
|
|
if (_sprites[tripnum]._y < _sprites[1]._y)
|
2013-09-25 21:57:08 +00:00
|
|
|
_sprites[tripnum]._y++;
|
2013-09-08 10:06:08 +00:00
|
|
|
else if (_sprites[tripnum]._y > _sprites[1]._y)
|
2013-09-25 21:57:08 +00:00
|
|
|
_sprites[tripnum]._y--;
|
2013-06-29 08:13:02 +00:00
|
|
|
else
|
2013-06-27 10:13:00 +00:00
|
|
|
return;
|
2013-09-08 10:06:08 +00:00
|
|
|
if (_sprites[tripnum]._moveX == 0) {
|
2013-09-25 21:57:08 +00:00
|
|
|
_sprites[tripnum]._stepNum++;
|
2013-09-08 10:06:08 +00:00
|
|
|
if (_sprites[tripnum]._stepNum == _sprites[tripnum]._stat._seq)
|
|
|
|
_sprites[tripnum]._stepNum = 0;
|
|
|
|
_sprites[tripnum]._count = 0;
|
2013-06-27 10:13:00 +00:00
|
|
|
}
|
|
|
|
}
|
2013-06-29 08:13:02 +00:00
|
|
|
}
|
2013-06-27 10:13:00 +00:00
|
|
|
|
2013-09-08 10:21:02 +00:00
|
|
|
void Animation::backAndForth(byte tripnum) {
|
2013-09-08 10:06:08 +00:00
|
|
|
if (!_sprites[tripnum]._homing) {
|
|
|
|
if (_sprites[tripnum]._facingDir == kDirRight)
|
2013-09-15 13:50:05 +00:00
|
|
|
_sprites[tripnum].walkTo(3);
|
2013-06-29 08:13:02 +00:00
|
|
|
else
|
2013-09-15 13:50:05 +00:00
|
|
|
_sprites[tripnum].walkTo(4);
|
2013-06-27 10:13:00 +00:00
|
|
|
}
|
2013-06-29 08:13:02 +00:00
|
|
|
}
|
2013-06-27 10:13:00 +00:00
|
|
|
|
2013-09-08 10:21:02 +00:00
|
|
|
void Animation::faceAvvy(byte tripnum) {
|
2013-09-08 10:06:08 +00:00
|
|
|
if (!_sprites[tripnum]._homing) {
|
|
|
|
if (_sprites[0]._x >= _sprites[tripnum]._x)
|
|
|
|
_sprites[tripnum]._facingDir = kDirRight;
|
2013-06-30 12:10:33 +00:00
|
|
|
else
|
2013-09-08 10:06:08 +00:00
|
|
|
_sprites[tripnum]._facingDir = kDirLeft;
|
2013-06-27 10:13:00 +00:00
|
|
|
}
|
2013-06-29 08:13:02 +00:00
|
|
|
}
|
2013-06-27 10:13:00 +00:00
|
|
|
|
2013-09-08 10:21:02 +00:00
|
|
|
void Animation::arrowProcs(byte tripnum) {
|
2013-09-08 10:06:08 +00:00
|
|
|
if (_sprites[tripnum]._homing) {
|
2013-09-05 00:29:09 +00:00
|
|
|
// Arrow is still in flight.
|
|
|
|
// We must check whether or not the arrow has collided tr[tripnum] Avvy's head.
|
|
|
|
// This is so if: a) the bottom of the arrow is below Avvy's head,
|
|
|
|
// b) the left of the arrow is left of the right of Avvy's head, and
|
|
|
|
// c) the right of the arrow is right of the left of Avvy's head.
|
2013-09-08 10:06:08 +00:00
|
|
|
if (((_sprites[tripnum]._y + _sprites[tripnum]._info._yLength) >= _sprites[0]._y) // A
|
|
|
|
&& (_sprites[tripnum]._x <= (_sprites[0]._x + _sprites[0]._info._xLength)) // B
|
|
|
|
&& ((_sprites[tripnum]._x + _sprites[tripnum]._info._xLength) >= _sprites[0]._x)) { // C
|
2013-09-05 00:29:09 +00:00
|
|
|
// OK, it's hit him... what now?
|
|
|
|
|
2013-09-08 10:06:08 +00:00
|
|
|
_sprites[1]._callEachStepFl = false; // prevent recursion.
|
2013-09-21 16:06:37 +00:00
|
|
|
_vm->_dialogs->displayScrollChain('Q', 47); // Complaint!
|
2013-09-08 10:23:48 +00:00
|
|
|
_sprites[tripnum].remove(); // Deallocate the arrow.
|
2013-09-21 10:10:16 +00:00
|
|
|
|
2013-09-26 23:34:38 +00:00
|
|
|
_vm->gameOver();
|
2013-06-29 08:13:02 +00:00
|
|
|
|
2013-09-26 23:34:38 +00:00
|
|
|
_vm->_userMovesAvvy = false; // Stop the user from moving him.
|
2013-09-09 21:34:12 +00:00
|
|
|
_vm->_timer->addTimer(55, Timer::kProcNaughtyDuke, Timer::kReasonNaughtyDuke);
|
2013-06-27 10:13:00 +00:00
|
|
|
}
|
2013-09-05 00:29:09 +00:00
|
|
|
} else { // Arrow has hit the wall!
|
2013-09-08 10:23:48 +00:00
|
|
|
_sprites[tripnum].remove(); // Deallocate the arrow.
|
2013-09-25 05:18:08 +00:00
|
|
|
_vm->_background->draw(-1, -1, 2); // Show pic of arrow stuck into the door.
|
2013-09-26 23:34:38 +00:00
|
|
|
_vm->_arrowInTheDoor = true; // So that we can pick it up.
|
2013-06-27 10:13:00 +00:00
|
|
|
}
|
2013-09-07 07:00:34 +00:00
|
|
|
|
2013-06-29 08:13:02 +00:00
|
|
|
}
|
|
|
|
|
2013-09-08 10:21:02 +00:00
|
|
|
void Animation::grabAvvy(byte tripnum) { // For Friar Tuck, in Nottingham.
|
2013-09-08 10:06:08 +00:00
|
|
|
int16 tox = _sprites[0]._x + 17;
|
|
|
|
int16 toy = _sprites[0]._y - 1;
|
|
|
|
if ((_sprites[tripnum]._x == tox) && (_sprites[tripnum]._y == toy)) {
|
|
|
|
_sprites[tripnum]._callEachStepFl = false;
|
|
|
|
_sprites[tripnum]._facingDir = kDirLeft;
|
|
|
|
_sprites[tripnum].stopWalk();
|
2013-09-05 00:29:09 +00:00
|
|
|
// ... whatever ...
|
2013-06-29 08:13:02 +00:00
|
|
|
} else {
|
2013-09-05 00:29:09 +00:00
|
|
|
// Still some way to go.
|
2013-09-08 10:06:08 +00:00
|
|
|
if (_sprites[tripnum]._x < tox) {
|
|
|
|
_sprites[tripnum]._x += 5;
|
|
|
|
if (_sprites[tripnum]._x > tox)
|
|
|
|
_sprites[tripnum]._x = tox;
|
2013-06-29 08:13:02 +00:00
|
|
|
}
|
2013-09-08 10:06:08 +00:00
|
|
|
if (_sprites[tripnum]._y < toy)
|
|
|
|
_sprites[tripnum]._y++;
|
|
|
|
_sprites[tripnum]._stepNum++;
|
|
|
|
if (_sprites[tripnum]._stepNum == _sprites[tripnum]._stat._seq)
|
|
|
|
_sprites[tripnum]._stepNum = 0;
|
2013-06-27 10:13:00 +00:00
|
|
|
}
|
2013-06-29 08:13:02 +00:00
|
|
|
}
|
2013-06-27 10:13:00 +00:00
|
|
|
|
2013-09-08 10:06:08 +00:00
|
|
|
void Animation::takeAStep(byte &tripnum) {
|
|
|
|
if (_sprites[tripnum]._moveX == 0) {
|
|
|
|
_sprites[tripnum]._stepNum++;
|
|
|
|
if (_sprites[tripnum]._stepNum == _sprites[tripnum]._stat._seq)
|
|
|
|
_sprites[tripnum]._stepNum = 0;
|
|
|
|
_sprites[tripnum]._count = 0;
|
2013-06-27 10:13:00 +00:00
|
|
|
}
|
2013-06-29 08:13:02 +00:00
|
|
|
}
|
2013-06-27 10:13:00 +00:00
|
|
|
|
2013-09-23 21:16:57 +00:00
|
|
|
void Animation::spin(Direction dir, byte &tripnum) {
|
|
|
|
if (_sprites[tripnum]._facingDir == dir)
|
|
|
|
return;
|
2013-06-27 10:13:00 +00:00
|
|
|
|
2013-09-23 21:16:57 +00:00
|
|
|
_sprites[tripnum]._facingDir = dir;
|
|
|
|
if (_sprites[tripnum]._id == 2)
|
|
|
|
return; // Not for Spludwick
|
|
|
|
|
2013-09-25 21:54:35 +00:00
|
|
|
_geidaSpin++;
|
|
|
|
_geidaTime = 20;
|
|
|
|
if (_geidaSpin == 5) {
|
2013-09-23 21:16:57 +00:00
|
|
|
_vm->_dialogs->displayText("Steady on, Avvy, you'll make the poor girl dizzy!");
|
2013-09-25 21:54:35 +00:00
|
|
|
_geidaSpin = 0;
|
|
|
|
_geidaTime = 0; // knock out records
|
2013-06-27 10:13:00 +00:00
|
|
|
}
|
2013-06-29 08:13:02 +00:00
|
|
|
}
|
2013-06-27 10:13:00 +00:00
|
|
|
|
2013-09-08 10:21:02 +00:00
|
|
|
void Animation::geidaProcs(byte tripnum) {
|
2013-09-25 21:54:35 +00:00
|
|
|
if (_geidaTime > 0) {
|
|
|
|
_geidaTime--;
|
|
|
|
if (_geidaTime == 0)
|
|
|
|
_geidaSpin = 0;
|
2013-06-29 08:13:02 +00:00
|
|
|
}
|
2013-06-27 10:13:00 +00:00
|
|
|
|
2013-09-08 10:06:08 +00:00
|
|
|
if (_sprites[tripnum]._y < (_sprites[0]._y - 2)) {
|
2013-09-05 00:29:09 +00:00
|
|
|
// Geida is further from the screen than Avvy.
|
2013-09-07 07:14:14 +00:00
|
|
|
spin(kDirDown, tripnum);
|
2013-09-08 10:06:08 +00:00
|
|
|
_sprites[tripnum]._moveY = 1;
|
|
|
|
_sprites[tripnum]._moveX = 0;
|
|
|
|
takeAStep(tripnum);
|
2013-06-29 08:13:02 +00:00
|
|
|
return;
|
2013-09-08 10:06:08 +00:00
|
|
|
} else if (_sprites[tripnum]._y > (_sprites[0]._y + 2)) {
|
2013-09-05 00:29:09 +00:00
|
|
|
// Avvy is further from the screen than Geida.
|
2013-09-07 07:14:14 +00:00
|
|
|
spin(kDirUp, tripnum);
|
2013-09-08 10:06:08 +00:00
|
|
|
_sprites[tripnum]._moveY = -1;
|
|
|
|
_sprites[tripnum]._moveX = 0;
|
|
|
|
takeAStep(tripnum);
|
2013-06-29 08:13:02 +00:00
|
|
|
return;
|
2013-06-27 10:13:00 +00:00
|
|
|
}
|
|
|
|
|
2013-09-08 10:06:08 +00:00
|
|
|
_sprites[tripnum]._moveY = 0;
|
2013-08-12 15:23:39 +00:00
|
|
|
// These 12-s are not in the original, I added them to make the following method more "smooth".
|
|
|
|
// Now the NPC which is following Avvy won't block his way and will walk next to him properly.
|
2013-09-08 10:06:08 +00:00
|
|
|
if (_sprites[tripnum]._x < _sprites[0]._x - _sprites[0]._speedX * 8 - 12) {
|
|
|
|
_sprites[tripnum]._moveX = _sprites[0]._speedX;
|
2013-09-07 07:14:14 +00:00
|
|
|
spin(kDirRight, tripnum);
|
2013-09-08 10:06:08 +00:00
|
|
|
takeAStep(tripnum);
|
|
|
|
} else if (_sprites[tripnum]._x > _sprites[0]._x + _sprites[0]._speedX * 8 + 12) {
|
|
|
|
_sprites[tripnum]._moveX = -_sprites[0]._speedX;
|
2013-09-07 07:14:14 +00:00
|
|
|
spin(kDirLeft, tripnum);
|
2013-09-08 10:06:08 +00:00
|
|
|
takeAStep(tripnum);
|
2013-06-30 12:10:33 +00:00
|
|
|
} else
|
2013-09-08 10:06:08 +00:00
|
|
|
_sprites[tripnum]._moveX = 0;
|
2013-06-29 08:13:02 +00:00
|
|
|
}
|
|
|
|
|
2013-10-02 05:25:20 +00:00
|
|
|
/**
|
|
|
|
* @remarks Originally called 'call_andexors'
|
|
|
|
*/
|
2013-09-08 10:21:02 +00:00
|
|
|
void Animation::drawSprites() {
|
2013-07-18 20:35:55 +00:00
|
|
|
int8 order[5];
|
2013-09-07 21:03:27 +00:00
|
|
|
byte temp;
|
2013-06-29 08:13:02 +00:00
|
|
|
bool ok;
|
|
|
|
|
|
|
|
for (int i = 0; i < 5; i++)
|
2013-07-18 20:35:55 +00:00
|
|
|
order[i] = -1;
|
2013-06-29 08:13:02 +00:00
|
|
|
|
2013-09-07 21:03:27 +00:00
|
|
|
for (int16 i = 0; i < kSpriteNumbMax; i++) {
|
2013-09-08 10:06:08 +00:00
|
|
|
if (_sprites[i]._quick && _sprites[i]._visible)
|
2013-09-07 21:03:27 +00:00
|
|
|
order[i] = i;
|
2013-06-29 08:13:02 +00:00
|
|
|
}
|
2013-06-27 10:13:00 +00:00
|
|
|
|
2013-06-29 08:13:02 +00:00
|
|
|
do {
|
|
|
|
ok = true;
|
2013-09-16 20:57:38 +00:00
|
|
|
for (int i = 0; i < 4; i++) {
|
2013-09-07 21:03:27 +00:00
|
|
|
if (((order[i] != -1) && (order[i + 1] != -1))
|
2013-09-08 10:06:08 +00:00
|
|
|
&& (_sprites[order[i]]._y > _sprites[order[i + 1]]._y)) {
|
2013-09-05 00:29:09 +00:00
|
|
|
// Swap them!
|
2013-09-07 21:03:27 +00:00
|
|
|
temp = order[i];
|
|
|
|
order[i] = order[i + 1];
|
|
|
|
order[i + 1] = temp;
|
2013-06-29 08:13:02 +00:00
|
|
|
ok = false;
|
|
|
|
}
|
2013-06-30 12:10:33 +00:00
|
|
|
}
|
2013-06-29 08:13:02 +00:00
|
|
|
} while (!ok);
|
2013-06-27 10:13:00 +00:00
|
|
|
|
2013-08-23 09:33:37 +00:00
|
|
|
_vm->_graphics->refreshBackground();
|
2013-08-09 01:02:28 +00:00
|
|
|
|
2013-09-16 20:57:38 +00:00
|
|
|
for (int i = 0; i < 5; i++) {
|
2013-09-07 21:03:27 +00:00
|
|
|
if (order[i] > -1)
|
2013-09-08 10:21:02 +00:00
|
|
|
_sprites[order[i]].draw();
|
2013-06-30 12:10:33 +00:00
|
|
|
}
|
2013-06-29 08:13:02 +00:00
|
|
|
}
|
2013-06-27 10:13:00 +00:00
|
|
|
|
2013-09-07 18:02:14 +00:00
|
|
|
/**
|
|
|
|
* Animation links
|
|
|
|
* @remarks Originally called 'trippancy_link'
|
|
|
|
*/
|
|
|
|
void Animation::animLink() {
|
2013-10-04 15:15:24 +00:00
|
|
|
if (_vm->_menu->isActive() || _vm->_seeScroll)
|
2013-06-30 12:10:33 +00:00
|
|
|
return;
|
2013-09-07 21:03:27 +00:00
|
|
|
for (int16 i = 0; i < kSpriteNumbMax; i++) {
|
2013-09-08 10:06:08 +00:00
|
|
|
if (_sprites[i]._quick && _sprites[i]._visible)
|
|
|
|
_sprites[i].walk();
|
2013-06-29 08:13:02 +00:00
|
|
|
}
|
2013-06-27 10:13:00 +00:00
|
|
|
|
2013-09-08 10:21:02 +00:00
|
|
|
drawSprites();
|
2013-07-27 08:05:09 +00:00
|
|
|
|
2013-09-07 21:03:27 +00:00
|
|
|
for (int16 i = 0; i < kSpriteNumbMax; i++) {
|
2013-09-08 10:06:08 +00:00
|
|
|
if (_sprites[i]._quick && _sprites[i]._callEachStepFl) {
|
|
|
|
switch (_sprites[i]._eachStepProc) {
|
2013-09-07 18:02:14 +00:00
|
|
|
case kProcFollowAvvyY :
|
2013-09-08 10:21:02 +00:00
|
|
|
followAvalotY(i);
|
2013-06-29 08:13:02 +00:00
|
|
|
break;
|
2013-09-07 18:02:14 +00:00
|
|
|
case kProcBackAndForth :
|
2013-09-08 10:21:02 +00:00
|
|
|
backAndForth(i);
|
2013-06-29 08:13:02 +00:00
|
|
|
break;
|
2013-09-07 18:02:14 +00:00
|
|
|
case kProcFaceAvvy :
|
2013-09-08 10:21:02 +00:00
|
|
|
faceAvvy(i);
|
2013-06-29 08:13:02 +00:00
|
|
|
break;
|
2013-09-07 18:02:14 +00:00
|
|
|
case kProcArrow :
|
2013-09-08 10:21:02 +00:00
|
|
|
arrowProcs(i);
|
2013-06-29 08:13:02 +00:00
|
|
|
break;
|
2013-09-05 00:29:09 +00:00
|
|
|
// PROCSpludwick_procs : spludwick_procs(fv);
|
2013-09-07 18:02:14 +00:00
|
|
|
case kProcGrabAvvy :
|
2013-09-08 10:21:02 +00:00
|
|
|
grabAvvy(i);
|
2013-06-29 08:13:02 +00:00
|
|
|
break;
|
2013-09-07 18:02:14 +00:00
|
|
|
case kProcGeida :
|
2013-09-08 10:21:02 +00:00
|
|
|
geidaProcs(i);
|
2013-06-29 08:13:02 +00:00
|
|
|
break;
|
2013-06-27 10:13:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-07-27 08:05:09 +00:00
|
|
|
|
2013-09-08 10:06:08 +00:00
|
|
|
if (_mustExclaim) {
|
|
|
|
_mustExclaim = false;
|
2013-09-21 16:06:37 +00:00
|
|
|
_vm->_dialogs->displayScrollChain('x', _sayWhat);
|
2013-06-30 12:10:33 +00:00
|
|
|
}
|
2013-06-29 08:13:02 +00:00
|
|
|
}
|
|
|
|
|
2013-09-07 21:03:27 +00:00
|
|
|
void Animation::stopWalking() {
|
2013-09-08 10:06:08 +00:00
|
|
|
_sprites[0].stopWalk();
|
2013-09-13 20:58:24 +00:00
|
|
|
_direction = kDirStopped;
|
2013-09-26 23:34:38 +00:00
|
|
|
if (_vm->_alive)
|
2013-09-08 10:06:08 +00:00
|
|
|
_sprites[0]._stepNum = 1;
|
2013-06-29 08:13:02 +00:00
|
|
|
}
|
2013-06-27 10:13:00 +00:00
|
|
|
|
2013-09-07 21:03:27 +00:00
|
|
|
/**
|
|
|
|
* Hide in the cupboard
|
|
|
|
* @remarks Originally called 'hide_in_the_cupboard'
|
|
|
|
*/
|
|
|
|
void Animation::hideInCupboard() {
|
2013-09-26 23:34:38 +00:00
|
|
|
if (_vm->_avvysInTheCupboard) {
|
2013-09-24 05:31:43 +00:00
|
|
|
if (_vm->_parser->_wearing == kObjectDummy) {
|
2013-10-02 05:48:45 +00:00
|
|
|
Common::String tmpStr = Common::String::format("%cAVVY!%cGet dressed first!", kControlItalic, kControlRoman);
|
2013-09-21 16:06:37 +00:00
|
|
|
_vm->_dialogs->displayText(tmpStr);
|
2013-09-08 21:13:58 +00:00
|
|
|
} else {
|
2013-09-08 10:06:08 +00:00
|
|
|
_sprites[0]._visible = true;
|
2013-09-26 23:34:38 +00:00
|
|
|
_vm->_userMovesAvvy = true;
|
2013-09-15 22:05:35 +00:00
|
|
|
appearPed(0, 2); // Walk out of the cupboard.
|
2013-09-21 16:06:37 +00:00
|
|
|
_vm->_dialogs->displayText("You leave the cupboard. Nice to be out of there!");
|
2013-09-26 23:34:38 +00:00
|
|
|
_vm->_avvysInTheCupboard = false;
|
2013-09-26 18:16:33 +00:00
|
|
|
_vm->_sequence->startCupboardSeq();
|
2013-06-29 08:13:02 +00:00
|
|
|
}
|
|
|
|
} else {
|
2013-09-05 00:29:09 +00:00
|
|
|
// Not hiding in the cupboard
|
2013-09-08 10:06:08 +00:00
|
|
|
_sprites[0]._visible = false;
|
2013-09-26 23:34:38 +00:00
|
|
|
_vm->_userMovesAvvy = false;
|
2013-09-08 21:13:58 +00:00
|
|
|
Common::String tmpStr = Common::String::format("You walk into the room...%cIt seems to be an empty, " \
|
2013-10-02 05:48:45 +00:00
|
|
|
"but dusty, cupboard. Hmmmm... you leave the door slightly open to avoid suffocation.", kControlParagraph);
|
2013-09-21 16:06:37 +00:00
|
|
|
_vm->_dialogs->displayText(tmpStr);
|
2013-09-26 23:34:38 +00:00
|
|
|
_vm->_avvysInTheCupboard = true;
|
2013-09-25 05:18:08 +00:00
|
|
|
_vm->_background->draw(-1, -1, 7);
|
2013-06-27 10:13:00 +00:00
|
|
|
}
|
2013-06-29 08:13:02 +00:00
|
|
|
}
|
2013-06-27 10:13:00 +00:00
|
|
|
|
2013-10-02 05:25:20 +00:00
|
|
|
/**
|
|
|
|
* Returns true if you're within field "which".
|
|
|
|
*/
|
2013-09-08 10:06:08 +00:00
|
|
|
bool Animation::inField(byte which) {
|
2013-09-26 23:34:38 +00:00
|
|
|
FieldType *curField = &_vm->_fields[which];
|
2013-09-08 10:06:08 +00:00
|
|
|
int16 yy = _sprites[0]._y + _sprites[0]._info._yLength;
|
2013-06-27 10:13:00 +00:00
|
|
|
|
2013-09-15 08:50:43 +00:00
|
|
|
return (_sprites[0]._x >= curField->_x1) && (_sprites[0]._x <= curField->_x2) && (yy >= curField->_y1) && (yy <= curField->_y2);
|
2013-06-29 08:13:02 +00:00
|
|
|
}
|
|
|
|
|
2013-10-02 05:25:20 +00:00
|
|
|
/**
|
|
|
|
* Returns True if you're near a door.
|
|
|
|
*/
|
2013-09-08 10:06:08 +00:00
|
|
|
bool Animation::nearDoor() {
|
2013-09-26 23:34:38 +00:00
|
|
|
if (_vm->_fieldNum < 8) {
|
2013-09-05 00:29:09 +00:00
|
|
|
// there ARE no doors here!
|
2013-08-23 14:58:22 +00:00
|
|
|
return false;
|
2013-06-27 10:13:00 +00:00
|
|
|
}
|
2013-09-07 07:00:34 +00:00
|
|
|
|
2013-09-08 10:06:08 +00:00
|
|
|
int16 ux = _sprites[0]._x;
|
|
|
|
int16 uy = _sprites[0]._y + _sprites[0]._info._yLength;
|
2013-09-15 08:50:43 +00:00
|
|
|
|
2013-09-26 23:34:38 +00:00
|
|
|
for (int i = 8; i < _vm->_fieldNum; i++) {
|
|
|
|
FieldType *curField = &_vm->_fields[i];
|
2013-09-15 08:50:43 +00:00
|
|
|
if ((ux >= curField->_x1) && (ux <= curField->_x2) && (uy >= curField->_y1) && (uy <= curField->_y2))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2013-06-29 08:13:02 +00:00
|
|
|
}
|
2013-06-27 10:13:00 +00:00
|
|
|
|
2013-10-02 05:25:20 +00:00
|
|
|
/**
|
|
|
|
* @remarks Originally called 'tripkey'
|
|
|
|
*/
|
2013-09-07 17:09:06 +00:00
|
|
|
void Animation::handleMoveKey(const Common::Event &event) {
|
2013-09-26 23:34:38 +00:00
|
|
|
if (!_vm->_userMovesAvvy)
|
2013-08-26 14:10:17 +00:00
|
|
|
return;
|
|
|
|
|
2013-09-18 05:47:52 +00:00
|
|
|
if (_vm->_menu->_activeMenuItem._activeNow)
|
2013-07-28 08:46:46 +00:00
|
|
|
_vm->_parser->tryDropdown();
|
2013-09-05 06:02:25 +00:00
|
|
|
else {
|
2013-07-28 08:46:46 +00:00
|
|
|
switch (event.kbd.keycode) {
|
|
|
|
case Common::KEYCODE_UP:
|
2013-09-13 20:58:24 +00:00
|
|
|
if (_direction != kDirUp) {
|
|
|
|
_direction = kDirUp;
|
2013-09-23 21:16:57 +00:00
|
|
|
setMoveSpeed(0, _direction);
|
2013-07-28 08:46:46 +00:00
|
|
|
} else
|
2013-09-07 21:03:27 +00:00
|
|
|
stopWalking();
|
2013-07-28 08:46:46 +00:00
|
|
|
break;
|
|
|
|
case Common::KEYCODE_DOWN:
|
2013-09-13 20:58:24 +00:00
|
|
|
if (_direction != kDirDown) {
|
|
|
|
_direction = kDirDown;
|
2013-09-23 21:16:57 +00:00
|
|
|
setMoveSpeed(0, _direction);
|
2013-07-28 08:46:46 +00:00
|
|
|
} else
|
2013-09-07 21:03:27 +00:00
|
|
|
stopWalking();
|
2013-07-28 08:46:46 +00:00
|
|
|
break;
|
|
|
|
case Common::KEYCODE_LEFT:
|
2013-09-13 20:58:24 +00:00
|
|
|
if (_direction != kDirLeft) {
|
|
|
|
_direction = kDirLeft;
|
2013-09-23 21:16:57 +00:00
|
|
|
setMoveSpeed(0, _direction);
|
2013-07-28 08:46:46 +00:00
|
|
|
} else
|
2013-09-07 21:03:27 +00:00
|
|
|
stopWalking();
|
2013-07-28 08:46:46 +00:00
|
|
|
break;
|
|
|
|
case Common::KEYCODE_RIGHT:
|
2013-09-13 20:58:24 +00:00
|
|
|
if (_direction != kDirRight) {
|
|
|
|
_direction = kDirRight;
|
2013-09-23 21:16:57 +00:00
|
|
|
setMoveSpeed(0, _direction);
|
2013-07-28 08:46:46 +00:00
|
|
|
} else
|
2013-09-07 21:03:27 +00:00
|
|
|
stopWalking();
|
2013-07-28 08:46:46 +00:00
|
|
|
break;
|
|
|
|
case Common::KEYCODE_PAGEUP:
|
2013-09-13 20:58:24 +00:00
|
|
|
if (_direction != kDirUpRight) {
|
|
|
|
_direction = kDirUpRight;
|
2013-09-23 21:16:57 +00:00
|
|
|
setMoveSpeed(0, _direction);
|
2013-07-28 08:46:46 +00:00
|
|
|
} else
|
2013-09-07 21:03:27 +00:00
|
|
|
stopWalking();
|
2013-07-28 08:46:46 +00:00
|
|
|
break;
|
|
|
|
case Common::KEYCODE_PAGEDOWN:
|
2013-09-13 20:58:24 +00:00
|
|
|
if (_direction != kDirDownRight) {
|
|
|
|
_direction = kDirDownRight;
|
2013-09-23 21:16:57 +00:00
|
|
|
setMoveSpeed(0, _direction);
|
2013-07-28 08:46:46 +00:00
|
|
|
} else
|
2013-09-07 21:03:27 +00:00
|
|
|
stopWalking();
|
2013-07-28 08:46:46 +00:00
|
|
|
break;
|
|
|
|
case Common::KEYCODE_END:
|
2013-09-13 20:58:24 +00:00
|
|
|
if (_direction != kDirDownLeft) {
|
|
|
|
_direction = kDirDownLeft;
|
2013-09-23 21:16:57 +00:00
|
|
|
setMoveSpeed(0, _direction);
|
2013-07-28 08:46:46 +00:00
|
|
|
} else
|
2013-09-07 21:03:27 +00:00
|
|
|
stopWalking();
|
2013-07-28 08:46:46 +00:00
|
|
|
break;
|
|
|
|
case Common::KEYCODE_HOME:
|
2013-09-13 20:58:24 +00:00
|
|
|
if (_direction != kDirUpLeft) {
|
|
|
|
_direction = kDirUpLeft;
|
2013-09-23 21:16:57 +00:00
|
|
|
setMoveSpeed(0, _direction);
|
2013-07-28 08:46:46 +00:00
|
|
|
} else
|
2013-09-07 21:03:27 +00:00
|
|
|
stopWalking();
|
2013-07-28 08:46:46 +00:00
|
|
|
break;
|
|
|
|
case Common::KEYCODE_KP5:
|
2013-09-07 21:03:27 +00:00
|
|
|
stopWalking();
|
2013-07-28 08:46:46 +00:00
|
|
|
break;
|
2013-09-04 15:15:33 +00:00
|
|
|
default:
|
|
|
|
break;
|
2013-07-28 08:46:46 +00:00
|
|
|
}
|
2013-09-05 06:02:25 +00:00
|
|
|
}
|
2013-07-24 11:11:24 +00:00
|
|
|
}
|
|
|
|
|
2013-09-23 21:16:57 +00:00
|
|
|
void Animation::setDirection(Direction dir) {
|
|
|
|
_direction = dir;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Animation::setOldDirection(Direction dir) {
|
|
|
|
_oldDirection = dir;
|
|
|
|
}
|
|
|
|
|
|
|
|
Direction Animation::getDirection() {
|
|
|
|
return _direction;
|
|
|
|
}
|
|
|
|
|
|
|
|
Direction Animation::getOldDirection() {
|
|
|
|
return _oldDirection;
|
|
|
|
}
|
|
|
|
|
2013-09-25 21:54:35 +00:00
|
|
|
void Animation::resetVariables() {
|
|
|
|
_geidaSpin = 0;
|
|
|
|
_geidaTime = 0;
|
2013-09-30 22:12:28 +00:00
|
|
|
_arrowTriggered = false;
|
2013-09-25 21:54:35 +00:00
|
|
|
}
|
|
|
|
|
2013-09-23 21:16:57 +00:00
|
|
|
void Animation::synchronize(Common::Serializer &sz) {
|
|
|
|
sz.syncAsByte(_direction);
|
2013-09-25 21:54:35 +00:00
|
|
|
sz.syncAsByte(_geidaSpin);
|
|
|
|
sz.syncAsByte(_geidaTime);
|
|
|
|
|
|
|
|
byte spriteNum = 0;
|
|
|
|
if (sz.isSaving()) {
|
|
|
|
for (int i = 0; i < kSpriteNumbMax; i++) {
|
|
|
|
if (_sprites[i]._quick)
|
|
|
|
spriteNum++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sz.syncAsByte(spriteNum);
|
|
|
|
|
|
|
|
if (sz.isLoading()) {
|
|
|
|
for (int i = 0; i < kSpriteNumbMax; i++) { // Deallocate sprites.
|
|
|
|
AnimationType *spr = &_sprites[i];
|
|
|
|
if (spr->_quick)
|
|
|
|
spr->remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < spriteNum; i++) {
|
|
|
|
AnimationType *spr = &_sprites[i];
|
|
|
|
sz.syncAsByte(spr->_id);
|
|
|
|
sz.syncAsByte(spr->_doCheck);
|
|
|
|
|
|
|
|
if (sz.isLoading()) {
|
|
|
|
spr->_quick = true;
|
|
|
|
spr->init(spr->_id, spr->_doCheck, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
sz.syncAsByte(spr->_moveX);
|
|
|
|
sz.syncAsByte(spr->_moveY);
|
|
|
|
sz.syncAsByte(spr->_facingDir);
|
|
|
|
sz.syncAsByte(spr->_stepNum);
|
|
|
|
sz.syncAsByte(spr->_visible);
|
|
|
|
sz.syncAsByte(spr->_homing);
|
|
|
|
sz.syncAsByte(spr->_count);
|
|
|
|
sz.syncAsByte(spr->_info._xWidth);
|
|
|
|
sz.syncAsByte(spr->_speedX);
|
|
|
|
sz.syncAsByte(spr->_speedY);
|
|
|
|
sz.syncAsByte(spr->_animCount);
|
|
|
|
sz.syncAsSint16LE(spr->_homingX);
|
|
|
|
sz.syncAsSint16LE(spr->_homingY);
|
|
|
|
sz.syncAsByte(spr->_callEachStepFl);
|
|
|
|
sz.syncAsByte(spr->_eachStepProc);
|
|
|
|
sz.syncAsByte(spr->_vanishIfStill);
|
|
|
|
sz.syncAsSint16LE(spr->_x);
|
|
|
|
sz.syncAsSint16LE(spr->_y);
|
|
|
|
|
|
|
|
if (sz.isLoading() && spr->_visible)
|
|
|
|
spr->appear(spr->_x, spr->_y, spr->_facingDir);
|
|
|
|
}
|
|
|
|
|
2013-09-30 22:12:28 +00:00
|
|
|
sz.syncAsByte(_arrowTriggered);
|
2013-09-23 21:16:57 +00:00
|
|
|
}
|
|
|
|
|
2013-06-27 10:13:00 +00:00
|
|
|
} // End of namespace Avalanche.
|