2007-05-30 21:56:52 +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.
|
2006-02-11 12:54:56 +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 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
|
2008-01-05 12:45:14 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2006-02-11 12:54:56 +00:00
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "lure/hotspots.h"
|
|
|
|
#include "lure/decode.h"
|
|
|
|
#include "lure/palette.h"
|
|
|
|
#include "lure/disk.h"
|
|
|
|
#include "lure/res.h"
|
|
|
|
#include "lure/scripts.h"
|
|
|
|
#include "lure/room.h"
|
|
|
|
#include "lure/strings.h"
|
|
|
|
#include "lure/res_struct.h"
|
|
|
|
#include "lure/events.h"
|
2006-05-23 12:43:42 +00:00
|
|
|
#include "lure/game.h"
|
2007-06-22 12:36:04 +00:00
|
|
|
#include "lure/fights.h"
|
2007-08-12 11:19:01 +00:00
|
|
|
#include "lure/sound.h"
|
2007-09-23 22:17:57 +00:00
|
|
|
#include "lure/lure.h"
|
2006-09-09 09:09:19 +00:00
|
|
|
#include "common/endian.h"
|
2006-02-11 12:54:56 +00:00
|
|
|
|
|
|
|
namespace Lure {
|
|
|
|
|
2006-04-11 10:52:11 +00:00
|
|
|
Hotspot::Hotspot(HotspotData *res): _pathFinder(this) {
|
2006-05-23 12:43:42 +00:00
|
|
|
Resources &resources = Resources::getReference();
|
2008-01-02 07:14:02 +00:00
|
|
|
bool isEGA = LureEngine::getReference().isEGA();
|
2006-05-23 12:43:42 +00:00
|
|
|
|
2006-02-11 12:54:56 +00:00
|
|
|
_data = res;
|
|
|
|
_anim = NULL;
|
|
|
|
_frames = NULL;
|
|
|
|
_numFrames = 0;
|
|
|
|
_persistant = false;
|
2010-03-26 22:16:45 +00:00
|
|
|
_direction = NO_DIRECTION;
|
2006-02-11 12:54:56 +00:00
|
|
|
|
2006-02-19 04:25:28 +00:00
|
|
|
_hotspotId = res->hotspotId;
|
2006-10-02 12:48:56 +00:00
|
|
|
_originalId = res->hotspotId;
|
2006-02-19 04:25:28 +00:00
|
|
|
_roomNumber = res->roomNumber;
|
2006-02-11 12:54:56 +00:00
|
|
|
_startX = res->startX;
|
|
|
|
_startY = res->startY;
|
|
|
|
_destX = res->startX;
|
|
|
|
_destY = res->startY;
|
|
|
|
_destHotspotId = 0;
|
2006-07-08 08:42:58 +00:00
|
|
|
_frameWidth = res->width;
|
|
|
|
_frameStartsUsed = false;
|
2006-02-11 12:54:56 +00:00
|
|
|
_height = res->height;
|
2006-02-19 04:25:28 +00:00
|
|
|
_width = res->width;
|
|
|
|
_heightCopy = res->heightCopy;
|
|
|
|
_widthCopy = res->widthCopy;
|
2006-04-11 10:52:11 +00:00
|
|
|
_yCorrection = res->yCorrection;
|
2006-02-19 04:25:28 +00:00
|
|
|
_talkX = res->talkX;
|
|
|
|
_talkY = res->talkY;
|
|
|
|
_layer = res->layer;
|
2007-04-29 11:30:29 +00:00
|
|
|
_hotspotScriptOffset = res->hotspotScriptOffset;
|
2007-11-07 09:39:48 +00:00
|
|
|
_frameCtr = res->tickTimeout;
|
2007-09-16 04:31:15 +00:00
|
|
|
_tempDest.counter = 0;
|
2011-04-14 12:12:27 +00:00
|
|
|
_colorOffset = isEGA ? 0 : res->colorOffset;
|
2006-02-19 04:25:28 +00:00
|
|
|
|
2006-05-23 12:43:42 +00:00
|
|
|
_override = resources.getHotspotOverride(res->hotspotId);
|
2006-10-02 12:48:56 +00:00
|
|
|
setAnimation(_data->animRecordId);
|
2009-10-20 19:51:57 +00:00
|
|
|
_tickHandler = _tickHandlers.getHandler(_data->tickProcId);
|
2007-02-14 02:37:53 +00:00
|
|
|
_nameBuffer[0] = '\0';
|
2006-05-23 12:43:42 +00:00
|
|
|
|
2006-04-11 10:52:11 +00:00
|
|
|
_skipFlag = false;
|
|
|
|
_charRectY = 0;
|
2006-07-08 08:42:58 +00:00
|
|
|
_voiceCtr = 0;
|
2006-05-23 12:43:42 +00:00
|
|
|
_blockedOffset = 0;
|
|
|
|
_exitCtr = 0;
|
2007-11-17 08:42:23 +00:00
|
|
|
_walkFlag = false;
|
2006-08-27 11:48:41 +00:00
|
|
|
_startRoomNumber = 0;
|
2007-04-14 03:48:24 +00:00
|
|
|
_supportValue = 0;
|
2006-02-11 12:54:56 +00:00
|
|
|
}
|
|
|
|
|
2006-02-19 04:25:28 +00:00
|
|
|
// Special constructor used to create a voice hotspot
|
|
|
|
|
2006-04-11 10:52:11 +00:00
|
|
|
Hotspot::Hotspot(Hotspot *character, uint16 objType): _pathFinder(this) {
|
2006-10-02 12:48:56 +00:00
|
|
|
assert(character);
|
2007-09-23 22:17:57 +00:00
|
|
|
|
2006-10-02 12:48:56 +00:00
|
|
|
_originalId = objType;
|
2006-02-19 04:25:28 +00:00
|
|
|
_data = NULL;
|
|
|
|
_anim = NULL;
|
|
|
|
_frames = NULL;
|
|
|
|
_numFrames = 0;
|
|
|
|
_persistant = false;
|
|
|
|
_hotspotId = 0xffff;
|
|
|
|
_override = NULL;
|
2011-04-14 12:12:27 +00:00
|
|
|
_colorOffset = 0;
|
2006-02-19 04:25:28 +00:00
|
|
|
_destHotspotId = character->hotspotId();
|
2006-05-23 12:43:42 +00:00
|
|
|
_blockedOffset = 0;
|
|
|
|
_exitCtr = 0;
|
2006-07-08 08:42:58 +00:00
|
|
|
_voiceCtr = 0;
|
|
|
|
_walkFlag = false;
|
2007-06-22 12:36:04 +00:00
|
|
|
_skipFlag = false;
|
2010-03-26 22:16:45 +00:00
|
|
|
_direction = NO_DIRECTION;
|
2006-02-19 04:25:28 +00:00
|
|
|
|
|
|
|
switch (objType) {
|
2007-11-22 10:09:26 +00:00
|
|
|
case VOICE_ANIM_IDX:
|
2006-02-19 04:25:28 +00:00
|
|
|
_roomNumber = character->roomNumber();
|
|
|
|
_destHotspotId = character->hotspotId();
|
|
|
|
_startX = character->x() + character->talkX() + 12;
|
|
|
|
_startY = character->y() + character->talkY() - 18;
|
|
|
|
_destX = _startX;
|
|
|
|
_destY = _startY;
|
|
|
|
_layer = 1;
|
|
|
|
_height = 18;
|
|
|
|
_width = 32;
|
|
|
|
_heightCopy = character->height() + 14;
|
|
|
|
_widthCopy = 24;
|
2006-07-08 08:42:58 +00:00
|
|
|
_yCorrection = 1;
|
|
|
|
|
2007-11-07 09:39:48 +00:00
|
|
|
_frameCtr = 0;
|
2006-07-08 08:42:58 +00:00
|
|
|
_voiceCtr = 40;
|
|
|
|
|
2009-10-20 19:51:57 +00:00
|
|
|
_tickHandler = _tickHandlers.getHandler(VOICE_TICK_PROC_ID);
|
2007-11-22 10:09:26 +00:00
|
|
|
setAnimationIndex(VOICE_ANIM_INDEX);
|
2006-07-08 08:42:58 +00:00
|
|
|
break;
|
|
|
|
|
2007-11-22 10:09:26 +00:00
|
|
|
case PUZZLED_ANIM_IDX:
|
|
|
|
case EXCLAMATION_ANIM_IDX:
|
2006-07-08 08:42:58 +00:00
|
|
|
_roomNumber = character->roomNumber();
|
|
|
|
_hotspotId = 0xfffe;
|
2006-10-02 12:48:56 +00:00
|
|
|
_startX = character->x() + character->talkX() + 12;
|
|
|
|
_startY = character->y() + character->talkY() - 20;
|
2006-07-08 08:42:58 +00:00
|
|
|
_width = 32;
|
|
|
|
_height = 18;
|
|
|
|
_widthCopy = 19;
|
|
|
|
_heightCopy = 18 + character->heightCopy();
|
|
|
|
_layer = 1;
|
|
|
|
_persistant = false;
|
|
|
|
_yCorrection = 1;
|
|
|
|
_voiceCtr = CONVERSE_COUNTDOWN_SIZE;
|
2006-02-19 04:25:28 +00:00
|
|
|
|
2006-07-08 08:42:58 +00:00
|
|
|
_destHotspotId = character->hotspotId();
|
2009-10-20 19:51:57 +00:00
|
|
|
_tickHandler = _tickHandlers.getHandler(PUZZLED_TICK_PROC_ID);
|
2007-11-24 09:47:19 +00:00
|
|
|
setAnimationIndex(VOICE_ANIM_INDEX);
|
2007-11-22 10:09:26 +00:00
|
|
|
setFrameNumber(objType == PUZZLED_ANIM_IDX ? 1 : 2);
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2006-07-08 08:42:58 +00:00
|
|
|
character->setFrameCtr(_voiceCtr);
|
2006-02-19 04:25:28 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2006-07-08 08:42:58 +00:00
|
|
|
|
|
|
|
_frameWidth = _width;
|
|
|
|
_frameStartsUsed = false;
|
2007-02-14 02:37:53 +00:00
|
|
|
_nameBuffer[0] = '\0';
|
2006-02-19 04:25:28 +00:00
|
|
|
}
|
|
|
|
|
2007-08-12 11:19:01 +00:00
|
|
|
Hotspot::Hotspot(): _pathFinder(NULL) {
|
|
|
|
_data = NULL;
|
|
|
|
_anim = NULL;
|
|
|
|
_frames = NULL;
|
|
|
|
_numFrames = 0;
|
|
|
|
_persistant = false;
|
|
|
|
_hotspotId = 0xffff;
|
|
|
|
_override = NULL;
|
2011-04-14 12:12:27 +00:00
|
|
|
_colorOffset = 0;
|
2007-08-12 11:19:01 +00:00
|
|
|
_destHotspotId = 0;
|
|
|
|
_blockedOffset = 0;
|
|
|
|
_exitCtr = 0;
|
|
|
|
_voiceCtr = 0;
|
|
|
|
_walkFlag = false;
|
|
|
|
_skipFlag = false;
|
|
|
|
_roomNumber = 0;
|
|
|
|
_startX = 0;
|
|
|
|
_startY = 0;
|
|
|
|
_destX = 0;
|
|
|
|
_destY = 0;
|
|
|
|
_layer = 0;
|
|
|
|
_height = 0;
|
|
|
|
_width = 0;
|
|
|
|
_heightCopy = 0;
|
|
|
|
_widthCopy = 0;
|
|
|
|
_yCorrection = 0;
|
2007-11-07 09:39:48 +00:00
|
|
|
_frameCtr = 0;
|
2007-08-12 11:19:01 +00:00
|
|
|
_tickHandler = NULL;
|
|
|
|
_frameWidth = _width;
|
|
|
|
_frameStartsUsed = false;
|
2007-09-16 04:31:15 +00:00
|
|
|
_tempDest.counter = 0;
|
2010-03-26 22:16:45 +00:00
|
|
|
_direction = NO_DIRECTION;
|
2007-08-12 11:19:01 +00:00
|
|
|
}
|
|
|
|
|
2006-02-11 12:54:56 +00:00
|
|
|
Hotspot::~Hotspot() {
|
2010-01-03 19:37:43 +00:00
|
|
|
delete _frames;
|
2006-02-11 12:54:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Hotspot::setAnimation(uint16 newAnimId) {
|
|
|
|
Resources &r = Resources::getReference();
|
|
|
|
HotspotAnimData *tempAnim;
|
2006-10-02 12:48:56 +00:00
|
|
|
_animId = newAnimId;
|
2007-06-22 12:36:04 +00:00
|
|
|
if (_data)
|
|
|
|
_data->animRecordId = newAnimId;
|
|
|
|
|
2008-01-27 19:47:41 +00:00
|
|
|
if (newAnimId == 0)
|
2007-03-06 08:24:52 +00:00
|
|
|
tempAnim = NULL;
|
|
|
|
else {
|
2008-01-27 19:47:41 +00:00
|
|
|
tempAnim = r.getAnimation(newAnimId);
|
2007-12-01 23:57:22 +00:00
|
|
|
if (tempAnim == NULL)
|
|
|
|
error("Hotspot %xh tried to set non-existant Animation Id: %xh", _hotspotId, newAnimId);
|
2007-03-06 08:24:52 +00:00
|
|
|
}
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2006-02-11 12:54:56 +00:00
|
|
|
setAnimation(tempAnim);
|
|
|
|
}
|
|
|
|
|
2007-10-07 11:12:46 +00:00
|
|
|
void Hotspot::setAnimationIndex(int animIndex) {
|
|
|
|
Resources &r = Resources::getReference();
|
|
|
|
|
|
|
|
// Get the animation specified
|
2008-04-06 12:17:41 +00:00
|
|
|
HotspotAnimList::iterator a = r.animRecords().begin();
|
2008-04-06 12:00:37 +00:00
|
|
|
for (int i = 0; i < animIndex; i++)
|
2008-04-06 12:17:41 +00:00
|
|
|
++a;
|
|
|
|
HotspotAnimData *tempAnim = (*a).get();
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2007-10-07 11:12:46 +00:00
|
|
|
_animId = tempAnim->animRecordId;
|
|
|
|
if (_data)
|
|
|
|
_data->animRecordId = tempAnim->animRecordId;
|
|
|
|
|
|
|
|
setAnimation(tempAnim);
|
|
|
|
}
|
|
|
|
|
2007-03-06 08:24:52 +00:00
|
|
|
struct SizeOverrideEntry {
|
2007-10-07 11:12:46 +00:00
|
|
|
int animIndex;
|
2007-03-06 08:24:52 +00:00
|
|
|
uint16 width, height;
|
|
|
|
};
|
|
|
|
|
|
|
|
static const SizeOverrideEntry sizeOverrides[] = {
|
2007-10-07 11:12:46 +00:00
|
|
|
{BLACKSMITH_DEFAULT_ANIM_INDEX, 32, 48},
|
|
|
|
{BLACKSMITH_HAMMERING_ANIM_INDEX, 48, 47},
|
2007-03-06 08:24:52 +00:00
|
|
|
{0, 0, 0}
|
|
|
|
};
|
|
|
|
|
2006-02-11 12:54:56 +00:00
|
|
|
void Hotspot::setAnimation(HotspotAnimData *newRecord) {
|
2007-10-07 11:12:46 +00:00
|
|
|
Disk &disk = Disk::getReference();
|
|
|
|
Resources &res = Resources::getReference();
|
2006-07-08 08:42:58 +00:00
|
|
|
uint16 tempWidth, tempHeight;
|
|
|
|
int16 xStart;
|
2007-10-07 11:12:46 +00:00
|
|
|
int animIndex = res.getAnimationIndex(newRecord);
|
2006-07-08 08:42:58 +00:00
|
|
|
|
2006-02-11 12:54:56 +00:00
|
|
|
if (_frames) {
|
|
|
|
delete _frames;
|
|
|
|
_frames = NULL;
|
|
|
|
}
|
|
|
|
_anim = NULL;
|
|
|
|
_numFrames = 0;
|
|
|
|
_frameNumber = 0;
|
|
|
|
if (!newRecord) return;
|
2007-10-07 11:12:46 +00:00
|
|
|
if (!disk.exists(newRecord->animId)) return;
|
2006-02-11 12:54:56 +00:00
|
|
|
|
2007-03-06 08:24:52 +00:00
|
|
|
// Scan for any size overrides - some animations get their size set after decoding, but
|
|
|
|
// we want it in advance so we can decode the animation straight to a graphic surface
|
|
|
|
const SizeOverrideEntry *p = &sizeOverrides[0];
|
2007-10-07 11:12:46 +00:00
|
|
|
while ((p->animIndex != 0) && (p->animIndex != animIndex)) ++p;
|
|
|
|
if (p->animIndex != 0)
|
2007-03-06 08:24:52 +00:00
|
|
|
setSize(p->width, p->height);
|
|
|
|
|
2006-02-11 12:54:56 +00:00
|
|
|
_anim = newRecord;
|
|
|
|
MemoryBlock *src = Disk::getReference().getEntry(_anim->animId);
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2007-06-22 12:36:04 +00:00
|
|
|
uint16 numEntries = READ_LE_UINT16(src->data());
|
2006-02-11 12:54:56 +00:00
|
|
|
uint16 *headerEntry = (uint16 *) (src->data() + 2);
|
2007-06-22 12:36:04 +00:00
|
|
|
assert((numEntries >= 1) && (numEntries < 100));
|
2006-02-11 12:54:56 +00:00
|
|
|
|
|
|
|
// Calculate total needed size for output and create memory block to hold it
|
|
|
|
uint32 totalSize = 0;
|
2007-06-22 12:36:04 +00:00
|
|
|
for (uint16 ctr = 0; ctr < numEntries; ++ctr, ++headerEntry) {
|
|
|
|
totalSize += (READ_LE_UINT16(headerEntry) + 31) / 32;
|
2006-02-11 12:54:56 +00:00
|
|
|
}
|
|
|
|
totalSize = (totalSize + 0x81) << 4;
|
|
|
|
MemoryBlock *dest = Memory::allocate(totalSize);
|
|
|
|
|
2007-06-22 12:36:04 +00:00
|
|
|
uint32 srcStart = (numEntries + 1) * sizeof(uint16) + 6;
|
2006-02-11 12:54:56 +00:00
|
|
|
AnimationDecoder::decode_data(src, dest, srcStart);
|
|
|
|
|
2007-06-22 12:36:04 +00:00
|
|
|
_numFrames = numEntries;
|
2006-02-11 12:54:56 +00:00
|
|
|
_frameNumber = 0;
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2007-03-06 08:24:52 +00:00
|
|
|
// Special handling need
|
2007-10-07 11:12:46 +00:00
|
|
|
if (_hotspotId == RACK_SERF_ID) {
|
2006-07-08 08:42:58 +00:00
|
|
|
_frameStartsUsed = true;
|
|
|
|
_frames = new Surface(416, 27);
|
2007-06-22 12:36:04 +00:00
|
|
|
} else {
|
2006-07-08 08:42:58 +00:00
|
|
|
_frames = new Surface(_width * _numFrames, _height);
|
|
|
|
_frameStartsUsed = false;
|
|
|
|
}
|
2011-04-14 12:12:27 +00:00
|
|
|
_frames->data().setBytes(_colorOffset, 0, _frames->data().size());
|
2006-02-11 12:54:56 +00:00
|
|
|
|
|
|
|
byte *pSrc = dest->data() + 0x40;
|
|
|
|
byte *pDest;
|
|
|
|
headerEntry = (uint16 *) (src->data() + 2);
|
|
|
|
MemoryBlock &mDest = _frames->data();
|
2008-01-27 19:47:41 +00:00
|
|
|
uint16 frameOffset = 0x40;
|
2006-07-08 08:42:58 +00:00
|
|
|
uint16 *offsetPtr = (uint16 *) src->data();
|
|
|
|
|
|
|
|
tempWidth = _width;
|
|
|
|
tempHeight = _height;
|
2006-02-11 12:54:56 +00:00
|
|
|
|
2006-04-11 10:52:11 +00:00
|
|
|
for (uint16 frameNumCtr = 0; frameNumCtr < _numFrames; ++frameNumCtr, ++headerEntry) {
|
2006-03-13 11:20:58 +00:00
|
|
|
|
|
|
|
if ((newRecord->flags & PIXELFLAG_HAS_TABLE) != 0) {
|
2006-07-08 08:42:58 +00:00
|
|
|
// For animations with an offset table, set the source pointer
|
2006-03-13 11:20:58 +00:00
|
|
|
pSrc = dest->data() + frameOffset;
|
|
|
|
}
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2007-10-07 11:12:46 +00:00
|
|
|
if (_hotspotId == RACK_SERF_ID) {
|
2008-01-27 19:47:41 +00:00
|
|
|
// Save the start of each frame for serf, since the size varies
|
2006-07-08 08:42:58 +00:00
|
|
|
xStart = (frameNumCtr == 0) ? 0 : _frameStarts[frameNumCtr - 1] + tempWidth;
|
|
|
|
_frameStarts[frameNumCtr] = xStart;
|
|
|
|
|
|
|
|
// Switch statement to handle varying size for different frames
|
|
|
|
switch (frameNumCtr) {
|
|
|
|
case 3:
|
|
|
|
tempWidth = 48;
|
|
|
|
tempHeight = 25;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
tempHeight = 26;
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
tempWidth = 32;
|
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
tempHeight = 27;
|
|
|
|
break;
|
|
|
|
case 7:
|
|
|
|
tempWidth = 16;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Set the X Start based on the frame size
|
|
|
|
xStart = frameNumCtr * _width;
|
|
|
|
}
|
2006-03-13 11:20:58 +00:00
|
|
|
|
2011-04-14 12:12:27 +00:00
|
|
|
// Copy over the frame, applying the color offset to each nibble
|
2006-07-08 08:42:58 +00:00
|
|
|
for (uint16 yPos = 0; yPos < tempHeight; ++yPos) {
|
|
|
|
pDest = mDest.data() + yPos * _frames->width() + xStart;
|
2006-02-11 12:54:56 +00:00
|
|
|
|
2006-07-08 08:42:58 +00:00
|
|
|
for (uint16 xPos = 0; xPos < tempWidth / 2; ++xPos) {
|
2011-04-14 12:12:27 +00:00
|
|
|
*pDest++ = _colorOffset + (*pSrc >> 4);
|
|
|
|
*pDest++ = _colorOffset + (*pSrc & 0xf);
|
2006-02-11 12:54:56 +00:00
|
|
|
++pSrc;
|
|
|
|
}
|
|
|
|
}
|
2006-07-08 08:42:58 +00:00
|
|
|
|
2008-01-27 19:47:41 +00:00
|
|
|
if ((newRecord->flags & PIXELFLAG_HAS_TABLE) != 0)
|
2007-11-16 22:59:40 +00:00
|
|
|
frameOffset += (READ_LE_UINT16(++offsetPtr) >> 1);
|
2006-02-11 12:54:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
delete src;
|
|
|
|
delete dest;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Hotspot::copyTo(Surface *dest) {
|
2006-02-19 04:25:28 +00:00
|
|
|
int16 xPos = _startX;
|
|
|
|
int16 yPos = _startY;
|
2006-07-08 08:42:58 +00:00
|
|
|
uint16 hWidth = _frameWidth;
|
2006-02-19 04:25:28 +00:00
|
|
|
uint16 hHeight = _height;
|
2006-02-11 12:54:56 +00:00
|
|
|
|
2010-01-19 23:48:55 +00:00
|
|
|
Common::Rect r(_frameNumber * hWidth, 0, (_frameNumber + 1) * hWidth - 1, hHeight - 1);
|
2006-07-08 08:42:58 +00:00
|
|
|
if (_frameStartsUsed) {
|
|
|
|
assert(_frameNumber < MAX_NUM_FRAMES);
|
|
|
|
r.left = _frameStarts[_frameNumber];
|
|
|
|
r.right = (_frameNumber == _numFrames - 1) ? _frames->width() - 1 :
|
|
|
|
_frameStarts[_frameNumber + 1] - 1;
|
|
|
|
r.bottom = _height - 1;
|
|
|
|
}
|
2006-02-11 12:54:56 +00:00
|
|
|
|
2006-05-23 12:43:42 +00:00
|
|
|
// Handle clipping for X position
|
|
|
|
if (xPos < 0) {
|
|
|
|
if (xPos + hWidth <= 0)
|
2006-02-11 12:54:56 +00:00
|
|
|
// Completely off screen, so don't display
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Reduce the source rectangle to only the on-screen portion
|
2006-05-23 12:43:42 +00:00
|
|
|
r.left += -xPos;
|
|
|
|
xPos = 0;
|
2006-02-11 12:54:56 +00:00
|
|
|
}
|
2008-01-27 19:47:41 +00:00
|
|
|
else if (xPos >= FULL_SCREEN_WIDTH)
|
2006-05-23 12:43:42 +00:00
|
|
|
return;
|
|
|
|
else if (xPos + hWidth > FULL_SCREEN_WIDTH)
|
|
|
|
r.right = r.left + (FULL_SCREEN_WIDTH - xPos - 1);
|
2006-02-11 12:54:56 +00:00
|
|
|
|
2006-05-23 12:43:42 +00:00
|
|
|
// Handle clipping for Y position
|
|
|
|
if (yPos < 0) {
|
2008-01-27 19:47:41 +00:00
|
|
|
if (yPos + hHeight <= MENUBAR_Y_SIZE)
|
2006-02-11 12:54:56 +00:00
|
|
|
// Completely off screen, so don't display
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Reduce the source rectangle to only the on-screen portion
|
2007-06-22 12:36:04 +00:00
|
|
|
r.top += -yPos + MENUBAR_Y_SIZE;
|
2007-02-10 03:45:06 +00:00
|
|
|
yPos = MENUBAR_Y_SIZE;
|
2006-02-11 12:54:56 +00:00
|
|
|
}
|
2006-05-23 12:43:42 +00:00
|
|
|
else if (yPos >= FULL_SCREEN_HEIGHT)
|
2006-02-11 12:54:56 +00:00
|
|
|
return;
|
|
|
|
else if (yPos + hHeight > FULL_SCREEN_HEIGHT)
|
2006-05-23 12:43:42 +00:00
|
|
|
r.bottom = r.top + (FULL_SCREEN_HEIGHT - yPos - 1);
|
|
|
|
|
|
|
|
// Final check to make sure there is anything to display
|
|
|
|
if ((r.top >= r.bottom) || (r.left >= r.right))
|
|
|
|
return;
|
2006-02-11 12:54:56 +00:00
|
|
|
|
2011-04-14 12:12:27 +00:00
|
|
|
_frames->copyTo(dest, r, (uint16) xPos, (uint16) yPos, _colorOffset);
|
2006-02-11 12:54:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Hotspot::incFrameNumber() {
|
|
|
|
++_frameNumber;
|
2008-01-27 19:47:41 +00:00
|
|
|
if (_frameNumber >= _numFrames)
|
2006-02-11 12:54:56 +00:00
|
|
|
_frameNumber = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Hotspot::isActiveAnimation() {
|
2006-02-19 04:25:28 +00:00
|
|
|
return ((_numFrames != 0) && (_layer != 0));
|
|
|
|
}
|
|
|
|
|
2012-03-13 09:25:04 +00:00
|
|
|
uint16 Hotspot::nameId() const {
|
2006-02-19 04:25:28 +00:00
|
|
|
if (_data == NULL)
|
|
|
|
return 0;
|
2008-01-27 19:47:41 +00:00
|
|
|
else
|
2006-02-19 04:25:28 +00:00
|
|
|
return _data->nameId;
|
2006-02-11 12:54:56 +00:00
|
|
|
}
|
|
|
|
|
2007-09-08 11:18:35 +00:00
|
|
|
const char *Hotspot::getName() {
|
2007-02-14 02:37:53 +00:00
|
|
|
// If name hasn't been loaded yet, then do so
|
|
|
|
if (!_nameBuffer[0] && (nameId() != 0))
|
|
|
|
StringData::getReference().getString(nameId(), _nameBuffer);
|
|
|
|
|
|
|
|
return &_nameBuffer[0];
|
|
|
|
}
|
|
|
|
|
2006-02-11 12:54:56 +00:00
|
|
|
void Hotspot::setPosition(int16 newX, int16 newY) {
|
|
|
|
_startX = newX;
|
|
|
|
_startY = newY;
|
2006-02-19 04:25:28 +00:00
|
|
|
if (_data) {
|
|
|
|
_data->startX = newX;
|
|
|
|
_data->startY = newY;
|
|
|
|
}
|
2006-02-11 12:54:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Hotspot::setSize(uint16 newWidth, uint16 newHeight) {
|
|
|
|
_width = newWidth;
|
2007-03-06 08:24:52 +00:00
|
|
|
_frameWidth = newWidth;
|
2006-02-11 12:54:56 +00:00
|
|
|
_height = newHeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Hotspot::executeScript() {
|
2007-04-29 11:30:29 +00:00
|
|
|
if (_data->hotspotScriptOffset == 0xffff)
|
2006-02-11 12:54:56 +00:00
|
|
|
return false;
|
|
|
|
else
|
|
|
|
return HotspotScript::execute(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Hotspot::tick() {
|
2007-06-22 12:36:04 +00:00
|
|
|
uint16 id = _hotspotId;
|
|
|
|
debugC(ERROR_BASIC, kLureDebugAnimations, "Hotspot %xh tick begin", id);
|
2009-10-20 19:51:57 +00:00
|
|
|
(_tickHandlers.*_tickHandler)(*this);
|
2007-06-22 12:36:04 +00:00
|
|
|
debugC(ERROR_BASIC, kLureDebugAnimations, "Hotspot %xh tick end", id);
|
2006-02-11 12:54:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Hotspot::setTickProc(uint16 newVal) {
|
2006-02-19 04:25:28 +00:00
|
|
|
if (_data)
|
2007-09-23 22:17:57 +00:00
|
|
|
_data->tickProcId = newVal;
|
|
|
|
|
2009-10-20 19:51:57 +00:00
|
|
|
_tickHandler = _tickHandlers.getHandler(newVal);
|
2006-02-11 12:54:56 +00:00
|
|
|
}
|
|
|
|
|
2006-04-11 10:52:11 +00:00
|
|
|
void Hotspot::walkTo(int16 endPosX, int16 endPosY, uint16 destHotspot) {
|
|
|
|
if ((hotspotId() == PLAYER_ID) && (PATHFIND_COUNTDOWN != 0)) {
|
|
|
|
// Show the clock cursor whilst pathfinding will be calculated
|
|
|
|
Mouse &mouse = Mouse::getReference();
|
|
|
|
mouse.setCursorNum(CURSOR_TIME_START, 0, 0);
|
|
|
|
}
|
2006-02-11 12:54:56 +00:00
|
|
|
|
|
|
|
_destX = endPosX;
|
2006-04-11 10:52:11 +00:00
|
|
|
_destY = endPosY;
|
2006-02-11 12:54:56 +00:00
|
|
|
_destHotspotId = destHotspot;
|
2008-01-24 08:14:48 +00:00
|
|
|
currentActions().addFront(START_WALKING, _roomNumber);
|
2006-02-11 12:54:56 +00:00
|
|
|
}
|
|
|
|
|
2006-04-29 11:22:05 +00:00
|
|
|
void Hotspot::stopWalking() {
|
2006-07-08 08:42:58 +00:00
|
|
|
_voiceCtr = 0;
|
|
|
|
setActionCtr(0);
|
2008-01-24 08:14:48 +00:00
|
|
|
currentActions().clear();
|
2006-04-29 11:22:05 +00:00
|
|
|
Room::getReference().setCursorState(CS_NONE);
|
2006-05-23 12:43:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Hotspot::endAction() {
|
2006-07-08 08:42:58 +00:00
|
|
|
Room &room = Room::getReference();
|
|
|
|
|
|
|
|
_voiceCtr = 0;
|
|
|
|
setActionCtr(0);
|
2006-05-23 12:43:42 +00:00
|
|
|
if (_hotspotId == PLAYER_ID)
|
2006-07-08 08:42:58 +00:00
|
|
|
room.setCursorState((CursorState) ((int) room.cursorState() & 2));
|
2006-05-23 12:43:42 +00:00
|
|
|
|
2008-01-24 08:14:48 +00:00
|
|
|
if (currentActions().top().hasSupportData()) {
|
|
|
|
CharacterScheduleEntry *rec = currentActions().top().supportData().next();
|
|
|
|
currentActions().top().setSupportData(rec);
|
2007-11-24 09:47:19 +00:00
|
|
|
}
|
2006-04-29 11:22:05 +00:00
|
|
|
}
|
|
|
|
|
2006-02-11 12:54:56 +00:00
|
|
|
void Hotspot::setDirection(Direction dir) {
|
2007-11-16 07:47:43 +00:00
|
|
|
if ((_numFrames == 0) || (_direction == dir)) return;
|
2006-07-08 08:42:58 +00:00
|
|
|
uint8 newFrameNumber = 0;
|
2006-04-11 10:52:11 +00:00
|
|
|
|
2006-02-11 12:54:56 +00:00
|
|
|
switch (dir) {
|
|
|
|
case UP:
|
2006-07-08 08:42:58 +00:00
|
|
|
newFrameNumber = _anim->upFrame;
|
2006-04-11 10:52:11 +00:00
|
|
|
_charRectY = 4;
|
2006-02-11 12:54:56 +00:00
|
|
|
break;
|
|
|
|
case DOWN:
|
2006-07-08 08:42:58 +00:00
|
|
|
newFrameNumber = _anim->downFrame;
|
2006-04-11 10:52:11 +00:00
|
|
|
_charRectY = 4;
|
2006-02-11 12:54:56 +00:00
|
|
|
break;
|
|
|
|
case LEFT:
|
2006-07-08 08:42:58 +00:00
|
|
|
newFrameNumber = _anim->leftFrame;
|
2006-04-11 10:52:11 +00:00
|
|
|
_charRectY = 0;
|
2006-02-11 12:54:56 +00:00
|
|
|
break;
|
|
|
|
case RIGHT:
|
2006-07-08 08:42:58 +00:00
|
|
|
newFrameNumber = _anim->rightFrame;
|
2006-04-11 10:52:11 +00:00
|
|
|
_charRectY = 0;
|
2006-02-11 12:54:56 +00:00
|
|
|
break;
|
|
|
|
default:
|
2007-05-20 12:39:15 +00:00
|
|
|
// No need to change
|
|
|
|
return;
|
2006-02-11 12:54:56 +00:00
|
|
|
}
|
2006-07-08 08:42:58 +00:00
|
|
|
|
|
|
|
setFrameNumber(newFrameNumber);
|
|
|
|
_direction = dir;
|
2006-02-11 12:54:56 +00:00
|
|
|
}
|
|
|
|
|
2006-04-11 10:52:11 +00:00
|
|
|
// Makes the character face the given hotspot
|
|
|
|
|
|
|
|
void Hotspot::faceHotspot(HotspotData *hotspot) {
|
2007-04-22 22:42:01 +00:00
|
|
|
Resources &res = Resources::getReference();
|
|
|
|
Room &room = Room::getReference();
|
|
|
|
Screen &screen = Screen::getReference();
|
|
|
|
|
2006-04-11 10:52:11 +00:00
|
|
|
if (hotspot->hotspotId >= START_NONVISUAL_HOTSPOT_ID) {
|
|
|
|
// Non visual hotspot
|
2006-04-29 11:22:05 +00:00
|
|
|
setDirection(hotspot->nonVisualDirection());
|
|
|
|
|
2006-04-11 10:52:11 +00:00
|
|
|
} else {
|
|
|
|
// Visual hotspot
|
2007-04-22 22:42:01 +00:00
|
|
|
int xp, yp;
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2007-04-22 22:42:01 +00:00
|
|
|
HotspotOverrideData *hsEntry = res.getHotspotOverride(hotspot->hotspotId);
|
|
|
|
if (hsEntry != NULL) {
|
|
|
|
xp = x() - hsEntry->xs;
|
|
|
|
yp = y() + heightCopy() - (hsEntry->ys + hotspot->heightCopy);
|
|
|
|
} else {
|
|
|
|
xp = x() - hotspot->startX;
|
|
|
|
yp = y() + heightCopy() - (hotspot->startY + hotspot->heightCopy);
|
|
|
|
}
|
2006-04-11 10:52:11 +00:00
|
|
|
|
2006-05-08 13:34:21 +00:00
|
|
|
if (ABS(yp) >= ABS(xp)) {
|
2006-04-11 10:52:11 +00:00
|
|
|
if (yp < 0) setDirection(DOWN);
|
|
|
|
else setDirection(UP);
|
|
|
|
} else {
|
2006-04-29 11:22:05 +00:00
|
|
|
if (xp < 0) setDirection(RIGHT);
|
|
|
|
else setDirection(LEFT);
|
2006-04-11 10:52:11 +00:00
|
|
|
}
|
|
|
|
}
|
2006-04-29 11:22:05 +00:00
|
|
|
|
|
|
|
if (hotspotId() == PLAYER_ID) {
|
2007-04-22 22:42:01 +00:00
|
|
|
room.update();
|
|
|
|
screen.update();
|
2006-04-29 11:22:05 +00:00
|
|
|
}
|
2006-04-11 10:52:11 +00:00
|
|
|
}
|
|
|
|
|
2006-07-08 08:42:58 +00:00
|
|
|
void Hotspot::faceHotspot(uint16 id) {
|
|
|
|
HotspotData *hotspot = Resources::getReference().getHotspot(id);
|
|
|
|
assert(hotspot != NULL);
|
|
|
|
faceHotspot(hotspot);
|
|
|
|
}
|
|
|
|
|
2006-05-29 08:12:07 +00:00
|
|
|
// Sets a character walking to a random destination position
|
|
|
|
|
|
|
|
void Hotspot::setRandomDest() {
|
|
|
|
Resources &res = Resources::getReference();
|
|
|
|
RoomData *roomData = res.getRoom(roomNumber());
|
|
|
|
Common::Rect &rect = roomData->walkBounds;
|
2009-08-24 23:04:25 +00:00
|
|
|
Common::RandomSource &rnd = LureEngine::getReference().rnd();
|
2006-05-29 08:12:07 +00:00
|
|
|
int16 xp, yp;
|
|
|
|
|
2008-01-24 08:14:48 +00:00
|
|
|
if (currentActions().isEmpty())
|
|
|
|
currentActions().addFront(START_WALKING, roomNumber());
|
2006-05-29 08:12:07 +00:00
|
|
|
else
|
2008-01-24 08:14:48 +00:00
|
|
|
currentActions().top().setAction(START_WALKING);
|
2006-07-08 08:42:58 +00:00
|
|
|
_walkFlag = true;
|
|
|
|
|
2008-01-27 19:47:41 +00:00
|
|
|
// Try up to 20 times to find an unoccupied destination
|
2007-05-05 01:00:01 +00:00
|
|
|
for (int tryCtr = 0; tryCtr < 20; ++tryCtr) {
|
2006-07-08 08:42:58 +00:00
|
|
|
xp = rect.left + rnd.getRandomNumber(rect.right - rect.left);
|
2007-05-20 12:39:15 +00:00
|
|
|
yp = rect.top + rnd.getRandomNumber(rect.bottom - rect.top);
|
2006-05-29 08:12:07 +00:00
|
|
|
setDestPosition(xp, yp);
|
2006-07-08 08:42:58 +00:00
|
|
|
setDestHotspot(0);
|
2006-05-29 08:12:07 +00:00
|
|
|
|
2007-05-05 01:00:01 +00:00
|
|
|
// Check if three sequential blocks at chosen destination are unoccupied
|
2008-01-27 19:47:41 +00:00
|
|
|
if (!roomData->paths.isOccupied(xp, yp, 3))
|
2006-05-29 08:12:07 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-05-11 08:04:41 +00:00
|
|
|
// Sets or clears the hotspot as occupying an area in its room's pathfinding data
|
2006-04-11 10:52:11 +00:00
|
|
|
|
|
|
|
void Hotspot::setOccupied(bool occupiedFlag) {
|
2007-01-31 02:33:20 +00:00
|
|
|
if ((coveredFlag() != VB_INITIAL) &&
|
|
|
|
(occupiedFlag == (coveredFlag() == VB_TRUE)))
|
|
|
|
return;
|
|
|
|
setCoveredFlag(occupiedFlag ? VB_TRUE : VB_FALSE);
|
2006-07-08 08:42:58 +00:00
|
|
|
|
2006-04-29 11:22:05 +00:00
|
|
|
int xp = x() >> 3;
|
2006-04-11 10:52:11 +00:00
|
|
|
int yp = (y() - 8 + heightCopy() - 4) >> 3;
|
2007-05-07 12:16:05 +00:00
|
|
|
int widthVal = MAX(widthCopy() >> 3, 1);
|
2006-04-11 10:52:11 +00:00
|
|
|
|
|
|
|
// Handle cropping for screen left
|
|
|
|
if (xp < 0) {
|
|
|
|
xp = -xp;
|
|
|
|
widthVal -= xp;
|
|
|
|
if (widthVal <= 0) return;
|
|
|
|
xp = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Handle cropping for screen right
|
2006-04-29 11:22:05 +00:00
|
|
|
int x2 = xp + widthVal - ROOM_PATHS_WIDTH - 1;
|
|
|
|
if (x2 >= 0) {
|
|
|
|
widthVal -= (x2 + 1);
|
2006-04-11 10:52:11 +00:00
|
|
|
if (widthVal <= 0) return;
|
|
|
|
}
|
|
|
|
|
|
|
|
RoomPathsData &paths = Resources::getReference().getRoom(_roomNumber)->paths;
|
|
|
|
if (occupiedFlag) {
|
|
|
|
paths.setOccupied(xp, yp, widthVal);
|
|
|
|
} else {
|
|
|
|
paths.clearOccupied(xp, yp, widthVal);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// walks the character a single step in a sequence defined by the walking list
|
|
|
|
|
|
|
|
bool Hotspot::walkingStep() {
|
|
|
|
if (_pathFinder.isEmpty()) return true;
|
|
|
|
|
|
|
|
// Check to see if the end of the next straight walking slice
|
|
|
|
if (_pathFinder.stepCtr() >= _pathFinder.top().numSteps()) {
|
|
|
|
// Move to next slice in walking sequence
|
|
|
|
_pathFinder.stepCtr() = 0;
|
|
|
|
_pathFinder.pop();
|
|
|
|
if (_pathFinder.isEmpty()) return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_pathFinder.stepCtr() == 0)
|
|
|
|
// At start of new slice, set the direction
|
|
|
|
setDirection(_pathFinder.top().direction());
|
|
|
|
|
|
|
|
MovementDataList *frameSet;
|
|
|
|
switch (_pathFinder.top().direction()) {
|
|
|
|
case UP:
|
|
|
|
frameSet = &_anim->upFrames;
|
|
|
|
break;
|
|
|
|
case DOWN:
|
|
|
|
frameSet = &_anim->downFrames;
|
|
|
|
break;
|
|
|
|
case LEFT:
|
|
|
|
frameSet = &_anim->leftFrames;
|
|
|
|
break;
|
|
|
|
case RIGHT:
|
|
|
|
frameSet = &_anim->rightFrames;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
int16 _xChange, _yChange;
|
|
|
|
uint16 nextFrame;
|
2008-01-09 11:14:15 +00:00
|
|
|
if (frameSet->getFrame(frameNumber(), _xChange, _yChange, nextFrame)) {
|
|
|
|
setFrameNumber(nextFrame);
|
|
|
|
setPosition(x() + _xChange, y() + _yChange);
|
|
|
|
|
|
|
|
++_pathFinder.stepCtr();
|
|
|
|
} else {
|
|
|
|
warning("Hotspot %xh dir frame not found: currentFrame=%d, dir=%s",
|
|
|
|
_hotspotId, frameNumber(), directionList[(int) _pathFinder.top().direction()]);
|
|
|
|
}
|
2006-04-11 10:52:11 +00:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-05-29 08:12:07 +00:00
|
|
|
void Hotspot::updateMovement() {
|
|
|
|
assert(_data != NULL);
|
2008-01-24 08:14:48 +00:00
|
|
|
if (currentActions().action() == EXEC_HOTSPOT_SCRIPT) {
|
2006-05-29 08:12:07 +00:00
|
|
|
if (_data->coveredFlag) {
|
|
|
|
// Reset position and direction
|
|
|
|
resetPosition();
|
|
|
|
} else {
|
|
|
|
// Make sure the cell occupied by character is covered
|
2007-01-31 02:33:20 +00:00
|
|
|
_data->coveredFlag = VB_TRUE;
|
2006-05-29 08:12:07 +00:00
|
|
|
setOccupied(true);
|
|
|
|
}
|
|
|
|
}
|
2007-09-16 08:03:18 +00:00
|
|
|
|
|
|
|
resetDirection();
|
2006-05-29 08:12:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Hotspot::updateMovement2(CharacterMode value) {
|
|
|
|
setCharacterMode(value);
|
|
|
|
updateMovement();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Hotspot::resetPosition() {
|
2008-11-29 18:01:16 +00:00
|
|
|
setPosition((x() & 0xf8) | 5, y());
|
2006-05-29 08:12:07 +00:00
|
|
|
setDirection(direction());
|
|
|
|
}
|
|
|
|
|
2008-01-27 19:47:41 +00:00
|
|
|
void Hotspot::converse(uint16 destCharacterId, uint16 messageId, bool srcStandStill,
|
2007-11-10 22:47:11 +00:00
|
|
|
bool destStandStill) {
|
2006-07-08 08:42:58 +00:00
|
|
|
assert(_data);
|
2006-08-07 13:24:45 +00:00
|
|
|
_data->talkDestCharacterId = destCharacterId;
|
2006-07-08 08:42:58 +00:00
|
|
|
_data->talkMessageId = messageId;
|
|
|
|
_data->talkCountdown = CONVERSE_COUNTDOWN_SIZE;
|
|
|
|
|
2006-08-07 13:24:45 +00:00
|
|
|
if ((destCharacterId != 0) && (destCharacterId != NOONE_ID)) {
|
2006-07-08 08:42:58 +00:00
|
|
|
// Talking to a destination - add in any talk countdown from the destination,
|
|
|
|
// in case the destination is already in process of talking
|
2006-08-07 13:24:45 +00:00
|
|
|
HotspotData *hotspot = Resources::getReference().getHotspot(destCharacterId);
|
2006-07-08 08:42:58 +00:00
|
|
|
_data->talkCountdown += hotspot->talkCountdown;
|
2007-11-08 10:50:26 +00:00
|
|
|
|
2007-11-10 22:47:11 +00:00
|
|
|
if (destStandStill) {
|
|
|
|
hotspot->talkerId = _hotspotId;
|
|
|
|
hotspot->talkGate = 0;
|
|
|
|
}
|
2006-07-08 08:42:58 +00:00
|
|
|
}
|
|
|
|
|
2007-11-10 22:47:11 +00:00
|
|
|
if (srcStandStill) {
|
2006-07-08 08:42:58 +00:00
|
|
|
setDelayCtr(_data->talkCountdown);
|
|
|
|
_data->characterMode = CHARMODE_CONVERSING;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-08-07 13:24:45 +00:00
|
|
|
void Hotspot::showMessage(uint16 messageId, uint16 destCharacterId) {
|
2007-12-09 05:59:01 +00:00
|
|
|
debugC(ERROR_DETAILED, kLureDebugStrings, "Hotspot::showMessage messageId=%xh srcChar=%xh, destChar=%xh",
|
|
|
|
messageId, _hotspotId, destCharacterId);
|
2006-08-07 13:24:45 +00:00
|
|
|
Resources &res = Resources::getReference();
|
2007-12-09 10:39:50 +00:00
|
|
|
char nameBuffer[MAX_HOTSPOT_NAME_SIZE];
|
2006-08-07 13:24:45 +00:00
|
|
|
MemoryBlock *data = res.messagesData();
|
|
|
|
Hotspot *hotspot;
|
2010-04-14 09:33:27 +00:00
|
|
|
uint8 *msgData = (uint8 *) data->data();
|
2011-06-30 21:47:10 +00:00
|
|
|
uint16 idVal;
|
2006-08-07 13:24:45 +00:00
|
|
|
messageId &= 0x7fff;
|
|
|
|
|
|
|
|
// Skip through header to find table for given character
|
2010-04-14 09:33:27 +00:00
|
|
|
uint headerEnd = READ_LE_UINT16(msgData + 2);
|
|
|
|
uint idx = 0;
|
|
|
|
while ((idx < headerEnd) && (READ_LE_UINT16(msgData + idx) != hotspotId()))
|
|
|
|
idx += 2 * sizeof(uint16);
|
|
|
|
|
|
|
|
if (idx == headerEnd) {
|
|
|
|
// Given character doesn't have a message set, so fall back on a simple puzzled animation
|
|
|
|
hotspot = new Hotspot(this, PUZZLED_ANIM_IDX);
|
|
|
|
res.addHotspot(hotspot);
|
|
|
|
return;
|
|
|
|
}
|
2006-08-07 13:24:45 +00:00
|
|
|
|
|
|
|
// Scan through secondary list
|
2010-04-14 09:33:27 +00:00
|
|
|
uint16 *v = (uint16 *) (msgData + READ_LE_UINT16(msgData + idx + sizeof(uint16)));
|
2006-08-07 13:24:45 +00:00
|
|
|
while ((idVal = READ_LE_UINT16(v)) != 0xffff) {
|
|
|
|
++v;
|
|
|
|
if (READ_LE_UINT16(v) == messageId) break;
|
|
|
|
++v;
|
|
|
|
}
|
|
|
|
|
|
|
|
// default response if a specific response not found
|
2007-12-09 05:59:01 +00:00
|
|
|
|
2008-01-27 19:47:41 +00:00
|
|
|
if (idVal == 0xffff) idVal = 0x8c4;
|
2007-12-09 05:59:01 +00:00
|
|
|
debugC(ERROR_DETAILED, kLureDebugStrings, "Hotspot::showMessage idVal=%xh", idVal);
|
2006-08-07 13:24:45 +00:00
|
|
|
|
|
|
|
if (idVal == 0x76) {
|
|
|
|
// Special code id for showing the puzzled talk bubble
|
2007-11-22 10:09:26 +00:00
|
|
|
hotspot = new Hotspot(this, PUZZLED_ANIM_IDX);
|
2006-08-07 13:24:45 +00:00
|
|
|
res.addHotspot(hotspot);
|
|
|
|
|
|
|
|
} else if (idVal == 0x120) {
|
|
|
|
// Special code id for showing the exclamation talk bubble
|
2007-11-22 10:09:26 +00:00
|
|
|
hotspot = new Hotspot(this, EXCLAMATION_ANIM_IDX);
|
2006-08-07 13:24:45 +00:00
|
|
|
res.addHotspot(hotspot);
|
|
|
|
|
|
|
|
} else if (idVal >= 0x8000) {
|
|
|
|
// Handle string display
|
|
|
|
idVal &= 0x7fff;
|
2007-12-09 10:39:50 +00:00
|
|
|
HotspotData *hotspotData = res.getHotspot(res.fieldList().getField(ACTIVE_HOTSPOT_ID));
|
|
|
|
const char *itemName = NULL;
|
|
|
|
if (hotspotData != NULL) {
|
|
|
|
StringData::getReference().getString(hotspotData->nameId, nameBuffer);
|
|
|
|
itemName = nameBuffer;
|
|
|
|
}
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2007-02-14 02:37:53 +00:00
|
|
|
Dialog::show(idVal, itemName, this->getName());
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2006-08-07 13:24:45 +00:00
|
|
|
} else if (idVal != 0) {
|
2008-01-27 19:47:41 +00:00
|
|
|
// Handle message as a talking dialog
|
2007-11-16 06:53:18 +00:00
|
|
|
converse(destCharacterId, idVal, true, false);
|
2006-08-07 13:24:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-07-08 08:42:58 +00:00
|
|
|
void Hotspot::handleTalkDialog() {
|
|
|
|
assert(_data);
|
|
|
|
Resources &res = Resources::getReference();
|
|
|
|
ValueTableData &fields = res.fieldList();
|
|
|
|
Room &room = Room::getReference();
|
|
|
|
|
|
|
|
// Return if no talk dialog is necessary
|
|
|
|
if (_data->talkCountdown == 0) return;
|
|
|
|
debugC(ERROR_DETAILED, kLureDebugAnimations, "Talk countdown = %d", _data->talkCountdown);
|
|
|
|
|
|
|
|
if (_data->talkCountdown == CONVERSE_COUNTDOWN_SIZE) {
|
2007-11-15 10:07:46 +00:00
|
|
|
// Check if there's already an active dialog - if so, wait until it's finished
|
2007-11-18 06:16:58 +00:00
|
|
|
if (room.isDialogShowing() && (res.getTalkingCharacter() != _hotspotId)) {
|
2007-11-15 10:07:46 +00:00
|
|
|
++_data->talkCountdown;
|
|
|
|
if (delayCtr() > 0)
|
|
|
|
setDelayCtr(delayCtr() + 2);
|
|
|
|
|
|
|
|
if ((_data->talkDestCharacterId != 0) && (_data->talkDestCharacterId != NOONE_ID)) {
|
|
|
|
Hotspot *destCharacter = res.getActiveHotspot(_data->talkDestCharacterId);
|
|
|
|
if (destCharacter->resource()->talkCountdown > CONVERSE_COUNTDOWN_SIZE) {
|
|
|
|
destCharacter->resource()->talkCountdown += 2;
|
|
|
|
if (destCharacter->delayCtr() > 0)
|
|
|
|
destCharacter->setDelayCtr(destCharacter->delayCtr() + 2);
|
|
|
|
}
|
|
|
|
}
|
2008-01-27 19:47:41 +00:00
|
|
|
return;
|
2007-11-15 10:07:46 +00:00
|
|
|
}
|
|
|
|
|
2006-07-08 08:42:58 +00:00
|
|
|
// Time to set up the dialog for the character
|
|
|
|
--_data->talkCountdown;
|
|
|
|
debugC(ERROR_DETAILED, kLureDebugAnimations, "Talk dialog opening");
|
|
|
|
startTalkDialog();
|
|
|
|
|
2006-08-07 13:24:45 +00:00
|
|
|
if ((_data->talkDestCharacterId != NOONE_ID) && (_data->talkDestCharacterId != 0) &&
|
2006-07-08 08:42:58 +00:00
|
|
|
(_hotspotId < FIRST_NONCHARACTER_ID)) {
|
|
|
|
// Speaking to a hotspot
|
2006-08-07 13:24:45 +00:00
|
|
|
fields.setField(ACTIVE_HOTSPOT_ID, _data->talkDestCharacterId);
|
2006-07-08 08:42:58 +00:00
|
|
|
|
|
|
|
// Face the character to the hotspot
|
2006-08-07 13:24:45 +00:00
|
|
|
HotspotData *destHotspot = res.getHotspot(_data->talkDestCharacterId);
|
2006-07-08 08:42:58 +00:00
|
|
|
assert(destHotspot != NULL);
|
|
|
|
faceHotspot(destHotspot);
|
|
|
|
|
|
|
|
// If the hotspot is also a character, then face it to the speaker
|
2006-08-07 13:24:45 +00:00
|
|
|
if (_data->talkDestCharacterId < FIRST_NONCHARACTER_ID) {
|
|
|
|
Hotspot *charHotspot = res.getActiveHotspot(_data->talkDestCharacterId);
|
2006-07-08 08:42:58 +00:00
|
|
|
if (charHotspot != NULL)
|
|
|
|
charHotspot->faceHotspot(resource());
|
|
|
|
}
|
|
|
|
}
|
2007-10-24 10:09:06 +00:00
|
|
|
/*
|
|
|
|
} else if (game.fastTextFlag()) {
|
2006-07-08 08:42:58 +00:00
|
|
|
// Fast text speed
|
|
|
|
--_data->talkCountdown;
|
2007-10-24 10:09:06 +00:00
|
|
|
} else if (fields.textCtr2() != 0) {
|
|
|
|
fields.textCtr2() = 1;
|
2006-07-08 08:42:58 +00:00
|
|
|
--_data->talkCountdown;
|
|
|
|
} else {
|
|
|
|
--_data->talkCountdown;
|
2007-10-24 10:09:06 +00:00
|
|
|
--fields.textCtr2();
|
|
|
|
}*/
|
2006-07-08 08:42:58 +00:00
|
|
|
|
2007-10-24 10:09:06 +00:00
|
|
|
} else if ((room.talkDialog() != NULL) && (room.talkDialog()->isBuilding())) {
|
|
|
|
return;
|
|
|
|
|
|
|
|
} else if (_data->talkCountdown > 0) {
|
|
|
|
--_data->talkCountdown;
|
|
|
|
|
|
|
|
if (_data->talkCountdown == 0) {
|
|
|
|
// Talking is finish - stop talking and free voice animation
|
|
|
|
debugC(ERROR_DETAILED, kLureDebugAnimations, "Talk dialog close");
|
|
|
|
room.setTalkDialog(0, 0, 0, 0);
|
2007-11-10 22:47:11 +00:00
|
|
|
/*
|
2007-10-25 10:37:23 +00:00
|
|
|
if ((_data->talkDestCharacterId != 0) && (_data->talkDestCharacterId != NOONE_ID)) {
|
2007-10-24 10:09:06 +00:00
|
|
|
HotspotData *destChar = res.getHotspot(_data->talkDestCharacterId);
|
|
|
|
destChar->talkerId = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
_data->talkerId = 0;
|
|
|
|
_data->talkGate = 0;
|
2007-11-10 22:47:11 +00:00
|
|
|
*/
|
2007-10-24 10:09:06 +00:00
|
|
|
}
|
2006-07-08 08:42:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
debugC(ERROR_DETAILED, kLureDebugAnimations, "Talk handler method end");
|
|
|
|
}
|
|
|
|
|
|
|
|
void Hotspot::startTalkDialog() {
|
2006-08-07 13:24:45 +00:00
|
|
|
assert(_data);
|
2006-07-08 08:42:58 +00:00
|
|
|
Room &room = Room::getReference();
|
|
|
|
|
2007-11-07 09:39:48 +00:00
|
|
|
if ((_data->talkDestCharacterId != 0) && (_data->talkDestCharacterId != NOONE_ID)) {
|
2007-11-11 20:17:13 +00:00
|
|
|
// HotspotData *hotspot = Resources::getReference().getHotspot(_data->talkDestCharacterId);
|
2007-11-10 22:47:11 +00:00
|
|
|
// hotspot->talkerId = _hotspotId;
|
2007-11-07 09:39:48 +00:00
|
|
|
}
|
|
|
|
|
2007-11-11 20:17:13 +00:00
|
|
|
if (room.roomNumber() != roomNumber())
|
|
|
|
return;
|
2007-11-13 09:49:43 +00:00
|
|
|
|
2008-01-27 19:47:41 +00:00
|
|
|
room.setTalkDialog(hotspotId(), _data->talkDestCharacterId, _data->useHotspotId,
|
2006-08-07 13:24:45 +00:00
|
|
|
_data->talkMessageId);
|
2006-07-08 08:42:58 +00:00
|
|
|
}
|
|
|
|
|
2006-02-11 12:54:56 +00:00
|
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
/* Hotspot action handling */
|
|
|
|
/* */
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
|
2007-09-08 11:18:35 +00:00
|
|
|
static const uint16 validRoomExitHotspots[] = {0x2711, 0x2712, 0x2714, 0x2715, 0x2716, 0x2717,
|
2006-02-11 12:54:56 +00:00
|
|
|
0x2718, 0x2719, 0x271A, 0x271E, 0x271F, 0x2720, 0x2721, 0x2722, 0x2725, 0x2726,
|
|
|
|
0x2729, 0x272A, 0x272B, 0x272C, 0x272D, 0x272E, 0x272F, 0};
|
|
|
|
|
|
|
|
bool Hotspot::isRoomExit(uint16 id) {
|
2008-01-27 19:47:41 +00:00
|
|
|
for (const uint16 *p = &validRoomExitHotspots[0]; *p != 0; ++p)
|
2006-02-11 12:54:56 +00:00
|
|
|
if (*p == id) return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-04-11 10:52:11 +00:00
|
|
|
HotspotPrecheckResult Hotspot::actionPrecheck(HotspotData *hotspot) {
|
2006-07-08 08:42:58 +00:00
|
|
|
Resources &res = Resources::getReference();
|
|
|
|
ValueTableData &fields = res.fieldList();
|
|
|
|
|
2007-04-14 03:48:24 +00:00
|
|
|
if ((hotspot->hotspotId == SID_ID) || (hotspot->hotspotId == EWAN_ID) ||
|
|
|
|
(hotspot->hotspotId == NELLIE_ID)) {
|
|
|
|
// Check for a bar place
|
|
|
|
if (getBarPlace() == BP_KEEP_TRYING)
|
2007-04-14 11:00:29 +00:00
|
|
|
return PC_WAIT;
|
2006-07-08 08:42:58 +00:00
|
|
|
} else if (hotspot->roomNumber != roomNumber()) {
|
2007-12-28 07:46:21 +00:00
|
|
|
// Object is not in the same room
|
|
|
|
if (actionCtr() == 0)
|
|
|
|
showMessage(0, hotspot->hotspotId);
|
2006-07-08 08:42:58 +00:00
|
|
|
setActionCtr(0);
|
2006-04-29 11:22:05 +00:00
|
|
|
return PC_NOT_IN_ROOM;
|
2006-07-08 08:42:58 +00:00
|
|
|
} else if (actionCtr() != 0) {
|
2006-04-29 11:22:05 +00:00
|
|
|
// loc_883
|
2006-07-08 08:42:58 +00:00
|
|
|
setActionCtr(actionCtr() + 1);
|
|
|
|
if (actionCtr() >= 6) {
|
2006-04-29 11:22:05 +00:00
|
|
|
warning("actionCtr exceeded");
|
2006-07-08 08:42:58 +00:00
|
|
|
setActionCtr(0);
|
2007-12-28 04:00:15 +00:00
|
|
|
showMessage(13, NOONE_ID);
|
2006-04-29 11:22:05 +00:00
|
|
|
return PC_EXCESS;
|
2008-01-27 19:47:41 +00:00
|
|
|
}
|
2006-07-08 08:42:58 +00:00
|
|
|
|
2008-01-27 19:47:41 +00:00
|
|
|
if ((hotspot->hotspotId >= FIRST_NONCHARACTER_ID) ||
|
2007-04-14 11:00:29 +00:00
|
|
|
(hotspot->characterMode == CHARMODE_INTERACTING) ||
|
|
|
|
(hotspot->characterMode == CHARMODE_WAIT_FOR_PLAYER) ||
|
|
|
|
(hotspot->characterMode == CHARMODE_WAIT_FOR_INTERACT)) {
|
2006-07-08 08:42:58 +00:00
|
|
|
// loc_880
|
2008-01-08 06:13:55 +00:00
|
|
|
if (characterWalkingCheck(hotspot->hotspotId))
|
2007-04-14 11:00:29 +00:00
|
|
|
return PC_WAIT;
|
2006-07-08 08:42:58 +00:00
|
|
|
} else {
|
|
|
|
// loc_886
|
|
|
|
setActionCtr(0);
|
2007-04-29 11:30:29 +00:00
|
|
|
showMessage(14, NOONE_ID);
|
2007-04-14 11:00:29 +00:00
|
|
|
return PC_FAILED;
|
2006-04-29 11:22:05 +00:00
|
|
|
}
|
|
|
|
} else {
|
2006-07-08 08:42:58 +00:00
|
|
|
setActionCtr(1);
|
2007-04-22 22:42:01 +00:00
|
|
|
|
2006-07-08 08:42:58 +00:00
|
|
|
if ((hotspot->hotspotId >= FIRST_NONCHARACTER_ID) ||
|
2008-01-27 19:47:41 +00:00
|
|
|
((hotspot->actionHotspotId != _hotspotId) &&
|
2007-04-14 11:00:29 +00:00
|
|
|
(hotspot->characterMode == CHARMODE_WAIT_FOR_PLAYER))) {
|
2006-07-08 08:42:58 +00:00
|
|
|
// loc_880
|
2008-01-08 06:13:55 +00:00
|
|
|
if (characterWalkingCheck(hotspot->hotspotId))
|
2007-04-14 11:00:29 +00:00
|
|
|
return PC_WAIT;
|
2006-08-27 11:48:41 +00:00
|
|
|
|
|
|
|
} else if (hotspot->actionHotspotId != _hotspotId) {
|
2007-08-12 11:19:01 +00:00
|
|
|
if (fields.getField(AREA_FLAG) != 2) {
|
2007-04-29 11:30:29 +00:00
|
|
|
showMessage(5, hotspot->hotspotId);
|
2006-07-08 08:42:58 +00:00
|
|
|
setDelayCtr(4);
|
|
|
|
}
|
2007-04-22 22:42:01 +00:00
|
|
|
|
2007-05-27 04:33:19 +00:00
|
|
|
hotspot->talkGate = GENERAL_MAGIC_ID;
|
2007-11-10 22:47:11 +00:00
|
|
|
hotspot->talkerId = _hotspotId;
|
2007-04-22 22:42:01 +00:00
|
|
|
return PC_WAIT;
|
2008-01-27 19:47:41 +00:00
|
|
|
}
|
2006-04-11 10:52:11 +00:00
|
|
|
}
|
|
|
|
|
2006-07-08 08:42:58 +00:00
|
|
|
// loc_888
|
|
|
|
setActionCtr(0);
|
2006-04-29 11:22:05 +00:00
|
|
|
if (hotspot->hotspotId < FIRST_NONCHARACTER_ID) {
|
2007-04-14 11:00:29 +00:00
|
|
|
hotspot->characterMode = CHARMODE_INTERACTING;
|
2006-07-08 08:42:58 +00:00
|
|
|
hotspot->delayCtr = 30;
|
2007-11-10 22:47:11 +00:00
|
|
|
hotspot->actionHotspotId = _hotspotId;
|
2006-04-11 10:52:11 +00:00
|
|
|
}
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2007-12-07 08:16:52 +00:00
|
|
|
// If the player had called out to someone to wait, close down that talk dialog
|
2008-01-27 19:47:41 +00:00
|
|
|
if ((_hotspotId == PLAYER_ID) && (res.getTalkingCharacter() == PLAYER_ID))
|
2007-12-07 08:16:52 +00:00
|
|
|
Room::getReference().setTalkDialog(0, 0, 0, 0);
|
|
|
|
|
2006-07-08 08:42:58 +00:00
|
|
|
return PC_EXECUTE;
|
2006-04-11 10:52:11 +00:00
|
|
|
}
|
|
|
|
|
2007-04-14 03:48:24 +00:00
|
|
|
BarPlaceResult Hotspot::getBarPlace() {
|
|
|
|
Resources &res = Resources::getReference();
|
|
|
|
BarEntry &barEntry = res.barmanLists().getDetails(roomNumber());
|
|
|
|
|
|
|
|
if (actionCtr() != 0) {
|
2008-01-27 19:47:41 +00:00
|
|
|
// Already at bar
|
2007-04-14 03:48:24 +00:00
|
|
|
// Find the character's slot in the bar entry list
|
|
|
|
for (int index = 0; index < NUM_SERVE_CUSTOMERS; ++index) {
|
2008-01-27 19:47:41 +00:00
|
|
|
if (barEntry.customers[index].hotspotId == hotspotId())
|
2007-04-14 03:48:24 +00:00
|
|
|
return ((barEntry.customers[index].serveFlags & 0x80) == 0) ? BP_GOT_THERE : BP_KEEP_TRYING;
|
|
|
|
}
|
|
|
|
|
|
|
|
setActionCtr(0);
|
|
|
|
return BP_KEEP_TRYING;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Try and find a bar place
|
|
|
|
if (!findClearBarPlace())
|
|
|
|
return BP_KEEP_TRYING;
|
|
|
|
|
|
|
|
// First scan for any existing entry for the character
|
|
|
|
int index = -1;
|
|
|
|
while (++index < NUM_SERVE_CUSTOMERS) {
|
2008-01-27 19:47:41 +00:00
|
|
|
if (barEntry.customers[index].hotspotId == hotspotId())
|
2007-04-14 03:48:24 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (index == NUM_SERVE_CUSTOMERS) {
|
|
|
|
// Not already present - so scan for an empty slot
|
|
|
|
index = -1;
|
|
|
|
while (++index < NUM_SERVE_CUSTOMERS) {
|
2008-01-27 19:47:41 +00:00
|
|
|
if (barEntry.customers[index].hotspotId == 0)
|
2007-04-14 03:48:24 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (index == NUM_SERVE_CUSTOMERS)
|
|
|
|
// No slots available, so flag to keep trying
|
|
|
|
return BP_KEEP_TRYING;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set up the slot entry for the character
|
|
|
|
barEntry.customers[index].hotspotId = hotspotId();
|
|
|
|
barEntry.customers[index].serveFlags = 0x82;
|
|
|
|
setActionCtr(1);
|
|
|
|
updateMovement();
|
|
|
|
setDirection(UP);
|
|
|
|
|
|
|
|
return BP_KEEP_TRYING;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Hotspot::findClearBarPlace() {
|
|
|
|
// Check if character has reached the bar
|
|
|
|
Resources &res = Resources::getReference();
|
|
|
|
BarEntry &barEntry = res.barmanLists().getDetails(roomNumber());
|
2008-01-27 19:47:41 +00:00
|
|
|
if ((y() + heightCopy()) < ((barEntry.gridLine << 3) + 24))
|
2007-04-14 03:48:24 +00:00
|
|
|
return true;
|
|
|
|
|
|
|
|
RoomPathsData &paths = res.getRoom(roomNumber())->paths;
|
2008-01-27 19:47:41 +00:00
|
|
|
|
|
|
|
// Scan backwards from the right side for 4 free blocks along the bar line block
|
2007-04-14 03:48:24 +00:00
|
|
|
int numFree = 0;
|
2007-04-14 05:02:12 +00:00
|
|
|
for (int xp = ROOM_PATHS_WIDTH - 1; xp >= 0; --xp) {
|
|
|
|
if (paths.isOccupied(xp, barEntry.gridLine))
|
2007-04-14 03:48:24 +00:00
|
|
|
numFree = 0;
|
|
|
|
else if (++numFree == 4) {
|
|
|
|
// Start character walking to the found position
|
2007-04-14 05:02:12 +00:00
|
|
|
walkTo(xp * 8, (barEntry.gridLine << 3) + 8);
|
2007-04-14 03:48:24 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-01-08 06:18:33 +00:00
|
|
|
bool Hotspot::characterWalkingCheck(uint16 id) {
|
2008-01-08 06:13:55 +00:00
|
|
|
Resources &res = Resources::getReference();
|
2006-04-11 10:52:11 +00:00
|
|
|
int16 xp, yp;
|
2008-01-08 06:13:55 +00:00
|
|
|
bool altFlag;
|
|
|
|
HotspotData *hotspot;
|
|
|
|
|
2008-01-27 19:47:41 +00:00
|
|
|
// Note that several invalid hotspot Ids are used to identify special walk to
|
2008-01-08 06:13:55 +00:00
|
|
|
// coordinates used throughout the game
|
|
|
|
|
|
|
|
_walkFlag = true;
|
|
|
|
altFlag = false;
|
|
|
|
|
2008-01-08 06:18:33 +00:00
|
|
|
switch (id) {
|
2008-01-08 06:13:55 +00:00
|
|
|
case 997:
|
|
|
|
xp = 169; yp = 146;
|
|
|
|
altFlag = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 998:
|
|
|
|
xp = 124; yp = 169;
|
|
|
|
break;
|
2006-04-11 10:52:11 +00:00
|
|
|
|
2008-01-08 06:13:55 +00:00
|
|
|
case 999:
|
2006-05-23 12:43:42 +00:00
|
|
|
xp = 78; yp = 162;
|
2008-01-08 06:13:55 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2008-01-08 06:18:33 +00:00
|
|
|
hotspot = res.getHotspot(id);
|
2008-01-08 06:13:55 +00:00
|
|
|
if (hotspot == NULL) {
|
|
|
|
// Should never come here, as all other constants are handled
|
2008-01-08 06:18:33 +00:00
|
|
|
warning("characterWalkingCheck done on unknown hotspot Id %xh", id);
|
2008-01-08 06:13:55 +00:00
|
|
|
xp = 78; yp = 162;
|
|
|
|
} else if ((hotspot->walkX == 0) && (hotspot->walkY == 0)) {
|
|
|
|
// The hotspot doesn't have any walk co-ordinates
|
|
|
|
xp = hotspot->startX;
|
|
|
|
yp = hotspot->startY + hotspot->heightCopy - 4;
|
|
|
|
_walkFlag = false;
|
|
|
|
} else {
|
|
|
|
xp = hotspot->walkX;
|
|
|
|
yp = hotspot->walkY & 0x7fff;
|
|
|
|
altFlag = (hotspot->walkY & 0x8000) != 0;
|
|
|
|
}
|
|
|
|
break;
|
2006-05-23 12:43:42 +00:00
|
|
|
}
|
2008-01-08 06:13:55 +00:00
|
|
|
|
|
|
|
if (altFlag) {
|
|
|
|
// Alternate walking check
|
2008-01-27 19:47:41 +00:00
|
|
|
if (((x() >> 3) != (xp >> 3)) ||
|
2008-01-08 06:13:55 +00:00
|
|
|
((((y() + heightCopy()) >> 3) - 1) != (yp >> 3))) {
|
|
|
|
// Walk to the specified destination
|
|
|
|
walkTo(xp, yp);
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
2006-04-29 11:22:05 +00:00
|
|
|
}
|
|
|
|
}
|
2006-04-11 10:52:11 +00:00
|
|
|
|
2006-04-29 11:22:05 +00:00
|
|
|
// Default walking handling
|
2006-05-08 13:34:21 +00:00
|
|
|
if ((ABS(x() - xp) >= 8) ||
|
|
|
|
(ABS(y() + heightCopy() - yp - 1) >= 19)) {
|
2006-04-29 11:22:05 +00:00
|
|
|
walkTo(xp, yp);
|
|
|
|
return true;
|
|
|
|
}
|
2006-04-11 10:52:11 +00:00
|
|
|
|
2006-04-29 11:22:05 +00:00
|
|
|
return false;
|
|
|
|
}
|
2006-04-11 10:52:11 +00:00
|
|
|
|
2006-04-29 11:22:05 +00:00
|
|
|
bool Hotspot::doorCloseCheck(uint16 doorId) {
|
|
|
|
Resources &res = Resources::getReference();
|
|
|
|
Hotspot *doorHotspot = res.getActiveHotspot(doorId);
|
|
|
|
if (!doorHotspot) {
|
|
|
|
warning("Hotspot %xh is not currently active", doorId);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-01-19 23:48:55 +00:00
|
|
|
Common::Rect bounds(doorHotspot->x(), doorHotspot->y() + doorHotspot->heightCopy()
|
2006-04-29 11:22:05 +00:00
|
|
|
- doorHotspot->yCorrection() - doorHotspot->charRectY(),
|
|
|
|
doorHotspot->x() + doorHotspot->widthCopy(),
|
|
|
|
doorHotspot->y() + doorHotspot->heightCopy() + doorHotspot->charRectY());
|
|
|
|
|
|
|
|
// Loop through active hotspots
|
|
|
|
HotspotList::iterator i;
|
|
|
|
HotspotList &lst = res.activeHotspots();
|
|
|
|
for (i = lst.begin(); i != lst.end(); ++i) {
|
2012-03-13 13:53:40 +00:00
|
|
|
Hotspot const &hsCurrent = **i;
|
2006-04-29 11:22:05 +00:00
|
|
|
|
|
|
|
// Skip entry if it's the door or the character
|
2012-03-13 13:53:40 +00:00
|
|
|
if ((hsCurrent.hotspotId() == hotspotId()) ||
|
|
|
|
(hsCurrent.hotspotId() == doorHotspot->hotspotId()))
|
2006-04-29 11:22:05 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
// Skip entry if it doesn't meet certain criteria
|
2012-03-13 13:53:40 +00:00
|
|
|
if ((hsCurrent.layer() == 0) ||
|
|
|
|
(hsCurrent.roomNumber() != doorHotspot->roomNumber()) ||
|
|
|
|
(hsCurrent.hotspotId() < PLAYER_ID) ||
|
|
|
|
((hsCurrent.hotspotId() >= 0x408) && (hsCurrent.hotspotId() < 0x2710)))
|
2006-04-29 11:22:05 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
// Also skip entry if special Id
|
2012-03-13 13:53:40 +00:00
|
|
|
if ((hsCurrent.hotspotId() == 0xfffe) || (hsCurrent.hotspotId() == 0xffff))
|
2006-04-29 11:22:05 +00:00
|
|
|
continue;
|
|
|
|
|
2007-05-20 12:39:15 +00:00
|
|
|
// Check to see if the character is intersecting the door area
|
2012-03-13 13:53:40 +00:00
|
|
|
int tempY = hsCurrent.y() + hsCurrent.heightCopy();
|
|
|
|
if ((hsCurrent.x() >= bounds.right) ||
|
|
|
|
(hsCurrent.x() + hsCurrent.widthCopy() <= bounds.left) ||
|
|
|
|
(tempY + hsCurrent.charRectY() < bounds.top) ||
|
|
|
|
(tempY - hsCurrent.yCorrection() - hsCurrent.charRectY() > bounds.bottom))
|
2007-05-20 12:39:15 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
// At this point we know a character is blocking door, so return false
|
|
|
|
return false;
|
2006-04-11 10:52:11 +00:00
|
|
|
}
|
|
|
|
|
2006-04-29 11:22:05 +00:00
|
|
|
// No blocking characters, so return true that the door can be closed
|
2006-04-11 10:52:11 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2007-09-16 08:03:18 +00:00
|
|
|
void Hotspot::resetDirection() {
|
|
|
|
uint16 newFrameNumber;
|
|
|
|
switch (_direction) {
|
|
|
|
case UP:
|
|
|
|
newFrameNumber = _anim->upFrame;
|
|
|
|
break;
|
|
|
|
case DOWN:
|
|
|
|
newFrameNumber = _anim->downFrame;
|
|
|
|
break;
|
|
|
|
case LEFT:
|
|
|
|
newFrameNumber = _anim->leftFrame;
|
|
|
|
break;
|
|
|
|
case RIGHT:
|
|
|
|
newFrameNumber = _anim->rightFrame;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
// No need to change
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
setFrameNumber(newFrameNumber);
|
|
|
|
}
|
|
|
|
|
2006-04-29 11:22:05 +00:00
|
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
|
2006-05-23 12:43:42 +00:00
|
|
|
typedef void (Hotspot::*ActionProcPtr)(HotspotData *hotspot);
|
|
|
|
|
|
|
|
void Hotspot::doAction() {
|
2008-01-24 08:14:48 +00:00
|
|
|
CurrentActionEntry &entry = currentActions().top();
|
2006-05-23 12:43:42 +00:00
|
|
|
HotspotData *hotspot = NULL;
|
|
|
|
|
|
|
|
if (!entry.hasSupportData() || (entry.supportData().action() == NONE)) {
|
|
|
|
doAction(NONE, NULL);
|
|
|
|
} else {
|
|
|
|
if (entry.supportData().numParams() > 0)
|
2007-12-11 09:20:24 +00:00
|
|
|
hotspot = Resources::getReference().getHotspot(entry.supportData().param(
|
|
|
|
(entry.supportData().action() == USE) ? 1 : 0));
|
2006-05-23 12:43:42 +00:00
|
|
|
doAction(entry.supportData().action(), hotspot);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-11 12:54:56 +00:00
|
|
|
void Hotspot::doAction(Action action, HotspotData *hotspot) {
|
2007-12-09 05:59:01 +00:00
|
|
|
StringList &stringList = Resources::getReference().stringList();
|
2010-04-21 05:30:38 +00:00
|
|
|
int charId = _hotspotId;
|
2008-01-27 19:47:41 +00:00
|
|
|
debugC(ERROR_INTERMEDIATE, kLureDebugHotspots, "Action charId=%xh Action=%d/%s",
|
2010-04-21 05:30:38 +00:00
|
|
|
charId, (int)action, (action > EXAMINE) ? NULL : stringList.getString((int)action));
|
2007-12-09 05:59:01 +00:00
|
|
|
|
2007-12-09 10:08:41 +00:00
|
|
|
// Set the ACTIVE_HOTSPOT_ID and USE_HOTSPOT_ID fields
|
|
|
|
if (hotspot != NULL) {
|
|
|
|
ValueTableData &fields = Resources::getReference().fieldList();
|
|
|
|
fields.setField(ACTIVE_HOTSPOT_ID, hotspot->hotspotId);
|
2007-12-11 09:20:24 +00:00
|
|
|
|
2008-01-27 19:47:41 +00:00
|
|
|
if (action == USE)
|
2008-01-24 08:14:48 +00:00
|
|
|
fields.setField(USE_HOTSPOT_ID, currentActions().top().supportData().param(0));
|
2008-01-27 19:47:41 +00:00
|
|
|
else if ((action == GIVE) || (action == ASK))
|
2008-01-24 08:14:48 +00:00
|
|
|
fields.setField(USE_HOTSPOT_ID, currentActions().top().supportData().param(1));
|
2008-01-27 19:47:41 +00:00
|
|
|
else
|
2007-12-09 10:08:41 +00:00
|
|
|
fields.setField(USE_HOTSPOT_ID, hotspot->hotspotId);
|
|
|
|
}
|
|
|
|
|
2008-01-28 11:28:49 +00:00
|
|
|
// Call the appropriate action method
|
|
|
|
switch (action) {
|
|
|
|
case GET:
|
|
|
|
doGet(hotspot);
|
|
|
|
break;
|
|
|
|
case PUSH:
|
|
|
|
case PULL:
|
|
|
|
case OPERATE:
|
|
|
|
doOperate(hotspot);
|
|
|
|
break;
|
|
|
|
case OPEN:
|
|
|
|
doOpen(hotspot);
|
|
|
|
break;
|
|
|
|
case CLOSE:
|
|
|
|
doClose(hotspot);
|
|
|
|
break;
|
|
|
|
case LOCK:
|
|
|
|
case UNLOCK:
|
|
|
|
doLockUnlock(hotspot);
|
|
|
|
break;
|
|
|
|
case USE:
|
|
|
|
doUse(hotspot);
|
|
|
|
break;
|
|
|
|
case GIVE:
|
|
|
|
doGive(hotspot);
|
|
|
|
break;
|
|
|
|
case TALK_TO:
|
|
|
|
doTalkTo(hotspot);
|
|
|
|
break;
|
|
|
|
case TELL:
|
|
|
|
doTell(hotspot);
|
|
|
|
break;
|
|
|
|
case LOOK:
|
|
|
|
doLook(hotspot);
|
|
|
|
break;
|
|
|
|
case LOOK_AT:
|
|
|
|
doLookAt(hotspot);
|
|
|
|
break;
|
|
|
|
case LOOK_THROUGH:
|
|
|
|
doLookThrough(hotspot);
|
|
|
|
break;
|
|
|
|
case ASK:
|
|
|
|
doAsk(hotspot);
|
|
|
|
break;
|
|
|
|
case DRINK:
|
|
|
|
doDrink(hotspot);
|
|
|
|
break;
|
|
|
|
case STATUS:
|
|
|
|
doStatus(hotspot);
|
|
|
|
break;
|
|
|
|
case GO_TO:
|
|
|
|
doGoto(hotspot);
|
|
|
|
break;
|
|
|
|
case RETURN:
|
|
|
|
doReturn(hotspot);
|
|
|
|
break;
|
|
|
|
case BRIBE:
|
|
|
|
doBribe(hotspot);
|
|
|
|
break;
|
|
|
|
case EXAMINE:
|
|
|
|
doExamine(hotspot);
|
|
|
|
break;
|
|
|
|
case NPC_SET_ROOM_AND_OFFSET:
|
|
|
|
npcSetRoomAndBlockedOffset(hotspot);
|
|
|
|
break;
|
|
|
|
case NPC_TALK_TO_PLAYER:
|
|
|
|
npcHeySir(hotspot);
|
|
|
|
break;
|
|
|
|
case NPC_EXEC_SCRIPT:
|
|
|
|
npcExecScript(hotspot);
|
|
|
|
break;
|
|
|
|
case NPC_RESET_PAUSED_LIST:
|
|
|
|
npcResetPausedList(hotspot);
|
|
|
|
break;
|
|
|
|
case NPC_SET_RAND_DEST:
|
|
|
|
npcSetRandomDest(hotspot);
|
|
|
|
break;
|
|
|
|
case NPC_WALKING_CHECK:
|
|
|
|
npcWalkingCheck(hotspot);
|
|
|
|
break;
|
|
|
|
case NPC_SET_SUPPORT_OFFSET:
|
|
|
|
npcSetSupportOffset(hotspot);
|
|
|
|
break;
|
|
|
|
case NPC_SUPPORT_OFFSET_COND:
|
|
|
|
npcSupportOffsetConditional(hotspot);
|
|
|
|
break;
|
|
|
|
case NPC_DISPATCH_ACTION:
|
|
|
|
npcDispatchAction(hotspot);
|
|
|
|
break;
|
|
|
|
case NPC_TALK_NPC_TO_NPC:
|
|
|
|
npcTalkNpcToNpc(hotspot);
|
|
|
|
break;
|
|
|
|
case NPC_PAUSE:
|
|
|
|
npcPause(hotspot);
|
|
|
|
break;
|
|
|
|
case NPC_START_TALKING:
|
|
|
|
npcStartTalking(hotspot);
|
|
|
|
break;
|
|
|
|
case NPC_JUMP_ADDRESS:
|
|
|
|
npcJumpAddress(hotspot);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
doNothing(hotspot);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-01-27 19:47:41 +00:00
|
|
|
debugC(ERROR_DETAILED, kLureDebugHotspots, "Action charId=%xh Action=%d/%s Complete",
|
2010-04-21 05:30:38 +00:00
|
|
|
charId, (int)action, (action > EXAMINE) ? NULL : stringList.getString((int)action));
|
2006-05-23 12:43:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Hotspot::doNothing(HotspotData *hotspot) {
|
2008-01-24 08:14:48 +00:00
|
|
|
if (!currentActions().isEmpty()) {
|
|
|
|
currentActions().pop();
|
|
|
|
if (!currentActions().isEmpty()) {
|
2007-12-02 04:52:01 +00:00
|
|
|
setBlockedFlag(false);
|
|
|
|
currentActions().top().setAction(DISPATCH_ACTION);
|
|
|
|
return;
|
|
|
|
}
|
2006-05-23 12:43:42 +00:00
|
|
|
}
|
2007-12-02 04:52:01 +00:00
|
|
|
|
2008-01-27 19:47:41 +00:00
|
|
|
if (hotspotId() == PLAYER_ID)
|
2007-12-02 04:52:01 +00:00
|
|
|
Room::getReference().setCursorState(CS_NONE);
|
2006-02-11 12:54:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Hotspot::doGet(HotspotData *hotspot) {
|
|
|
|
Resources &res = Resources::getReference();
|
2006-04-11 10:52:11 +00:00
|
|
|
HotspotPrecheckResult result = actionPrecheck(hotspot);
|
2006-04-29 11:22:05 +00:00
|
|
|
|
2007-04-14 11:00:29 +00:00
|
|
|
if (result == PC_WAIT) return;
|
2006-05-23 12:43:42 +00:00
|
|
|
else if (result != PC_EXECUTE) {
|
|
|
|
endAction();
|
2006-04-11 10:52:11 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
faceHotspot(hotspot);
|
2006-05-23 12:43:42 +00:00
|
|
|
endAction();
|
2006-04-11 10:52:11 +00:00
|
|
|
|
|
|
|
uint16 sequenceOffset = res.getHotspotAction(hotspot->actionsOffset, GET);
|
2006-02-11 12:54:56 +00:00
|
|
|
if (sequenceOffset >= 0x8000) {
|
2006-08-07 13:24:45 +00:00
|
|
|
showMessage(sequenceOffset);
|
2006-02-11 12:54:56 +00:00
|
|
|
return;
|
2008-01-27 19:47:41 +00:00
|
|
|
}
|
|
|
|
|
2006-02-11 12:54:56 +00:00
|
|
|
if (sequenceOffset != 0) {
|
2006-04-11 22:11:12 +00:00
|
|
|
uint16 execResult = Script::execute(sequenceOffset);
|
2006-02-11 12:54:56 +00:00
|
|
|
|
2006-04-11 22:11:12 +00:00
|
|
|
if (execResult == 1) return;
|
|
|
|
else if (execResult != 0) {
|
2006-08-07 13:24:45 +00:00
|
|
|
showMessage(execResult);
|
2006-02-11 12:54:56 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Move hotspot into characters's inventory
|
2008-01-27 19:47:41 +00:00
|
|
|
hotspot->roomNumber = hotspotId();
|
2006-02-11 12:54:56 +00:00
|
|
|
|
|
|
|
if (hotspot->hotspotId < START_NONVISUAL_HOTSPOT_ID) {
|
|
|
|
// Deactive hotspot animation
|
|
|
|
Resources::getReference().deactivateHotspot(hotspot->hotspotId);
|
|
|
|
// Remove any 'on the ground' description for the hotspot
|
|
|
|
hotspot->descId2 = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-05-23 12:43:42 +00:00
|
|
|
void Hotspot::doOperate(HotspotData *hotspot) {
|
2006-02-11 12:54:56 +00:00
|
|
|
Resources &res = Resources::getReference();
|
2008-01-24 08:14:48 +00:00
|
|
|
Action action = currentActions().top().supportData().action();
|
2006-04-29 11:22:05 +00:00
|
|
|
|
|
|
|
HotspotPrecheckResult result = actionPrecheck(hotspot);
|
2007-04-14 11:00:29 +00:00
|
|
|
if (result == PC_WAIT) return;
|
2006-04-29 11:22:05 +00:00
|
|
|
else if (result != PC_EXECUTE) {
|
2006-05-23 12:43:42 +00:00
|
|
|
endAction();
|
2006-04-29 11:22:05 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-07-08 08:42:58 +00:00
|
|
|
setActionCtr(0);
|
2006-04-29 11:22:05 +00:00
|
|
|
faceHotspot(hotspot);
|
2006-05-23 12:43:42 +00:00
|
|
|
endAction();
|
2006-04-29 11:22:05 +00:00
|
|
|
|
2006-02-11 12:54:56 +00:00
|
|
|
uint16 sequenceOffset = res.getHotspotAction(hotspot->actionsOffset, action);
|
|
|
|
if (sequenceOffset >= 0x8000) {
|
2006-08-07 13:24:45 +00:00
|
|
|
showMessage(sequenceOffset);
|
2006-04-29 11:22:05 +00:00
|
|
|
} else {
|
|
|
|
sequenceOffset = Script::execute(sequenceOffset);
|
|
|
|
if (sequenceOffset > 1)
|
2006-08-07 13:24:45 +00:00
|
|
|
showMessage(sequenceOffset);
|
2006-02-11 12:54:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Hotspot::doOpen(HotspotData *hotspot) {
|
|
|
|
Resources &res = Resources::getReference();
|
|
|
|
RoomExitJoinData *joinRec;
|
|
|
|
|
|
|
|
if (isRoomExit(hotspot->hotspotId)) {
|
|
|
|
joinRec = res.getExitJoin(hotspot->hotspotId);
|
|
|
|
if (!joinRec->blocked) {
|
|
|
|
// Room exit is already open
|
2006-08-07 13:24:45 +00:00
|
|
|
showMessage(4);
|
2006-05-23 12:43:42 +00:00
|
|
|
endAction();
|
2006-02-11 12:54:56 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-29 11:22:05 +00:00
|
|
|
HotspotPrecheckResult result = actionPrecheck(hotspot);
|
2007-04-14 11:00:29 +00:00
|
|
|
if (result == PC_WAIT) return;
|
2006-04-29 11:22:05 +00:00
|
|
|
else if (result != PC_EXECUTE) {
|
2006-05-23 12:43:42 +00:00
|
|
|
endAction();
|
2006-04-29 11:22:05 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
faceHotspot(hotspot);
|
2006-07-08 08:42:58 +00:00
|
|
|
setActionCtr(0);
|
2006-05-23 12:43:42 +00:00
|
|
|
endAction();
|
2006-02-11 12:54:56 +00:00
|
|
|
|
|
|
|
uint16 sequenceOffset = res.getHotspotAction(hotspot->actionsOffset, OPEN);
|
|
|
|
if (sequenceOffset >= 0x8000) {
|
|
|
|
// Message to display
|
2006-08-07 13:24:45 +00:00
|
|
|
showMessage(sequenceOffset);
|
2006-04-29 11:22:05 +00:00
|
|
|
return;
|
|
|
|
}
|
2006-02-11 12:54:56 +00:00
|
|
|
|
2006-04-29 11:22:05 +00:00
|
|
|
if (sequenceOffset != 0) {
|
|
|
|
sequenceOffset = Script::execute(sequenceOffset);
|
2006-02-11 12:54:56 +00:00
|
|
|
|
2006-04-29 11:22:05 +00:00
|
|
|
if (sequenceOffset == 1) return;
|
|
|
|
if (sequenceOffset != 0) {
|
2008-01-27 19:47:41 +00:00
|
|
|
if (_exitCtr != 0)
|
2006-05-23 12:43:42 +00:00
|
|
|
_exitCtr = 4;
|
2006-08-07 13:24:45 +00:00
|
|
|
showMessage(sequenceOffset);
|
2006-04-29 11:22:05 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
joinRec = res.getExitJoin(hotspot->hotspotId);
|
|
|
|
if (joinRec->blocked) {
|
|
|
|
joinRec->blocked = 0;
|
|
|
|
|
|
|
|
if (hotspotId() != PLAYER_ID) {
|
2007-06-22 12:36:04 +00:00
|
|
|
setCharacterMode(CHARMODE_PAUSED);
|
|
|
|
setDelayCtr(4);
|
2006-02-11 12:54:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Hotspot::doClose(HotspotData *hotspot) {
|
|
|
|
Resources &res = Resources::getReference();
|
|
|
|
RoomExitJoinData *joinRec;
|
|
|
|
|
|
|
|
if (isRoomExit(hotspot->hotspotId)) {
|
|
|
|
joinRec = res.getExitJoin(hotspot->hotspotId);
|
|
|
|
if (joinRec->blocked) {
|
|
|
|
// Room exit is already closed/blocked
|
2006-08-07 13:24:45 +00:00
|
|
|
showMessage(3);
|
2006-05-23 12:43:42 +00:00
|
|
|
endAction();
|
2006-02-11 12:54:56 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-29 11:22:05 +00:00
|
|
|
HotspotPrecheckResult result = actionPrecheck(hotspot);
|
2007-04-14 11:00:29 +00:00
|
|
|
if (result == PC_WAIT) return;
|
2006-04-29 11:22:05 +00:00
|
|
|
else if (result != PC_EXECUTE) {
|
2006-05-23 12:43:42 +00:00
|
|
|
endAction();
|
2006-04-29 11:22:05 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
faceHotspot(hotspot);
|
2006-07-08 08:42:58 +00:00
|
|
|
setActionCtr(0);
|
2006-05-23 12:43:42 +00:00
|
|
|
endAction();
|
2006-02-11 12:54:56 +00:00
|
|
|
|
|
|
|
uint16 sequenceOffset = res.getHotspotAction(hotspot->actionsOffset, CLOSE);
|
|
|
|
if (sequenceOffset >= 0x8000) {
|
|
|
|
// Message to display
|
2006-08-07 13:24:45 +00:00
|
|
|
showMessage(sequenceOffset);
|
2006-07-08 08:42:58 +00:00
|
|
|
return;
|
2006-02-11 12:54:56 +00:00
|
|
|
} else if (sequenceOffset != 0) {
|
|
|
|
// Otherwise handle script
|
2006-04-29 11:22:05 +00:00
|
|
|
sequenceOffset = Script::execute(sequenceOffset);
|
2006-02-11 12:54:56 +00:00
|
|
|
|
2006-04-29 11:22:05 +00:00
|
|
|
if (sequenceOffset != 0) {
|
2006-08-07 13:24:45 +00:00
|
|
|
showMessage(sequenceOffset);
|
2006-04-29 11:22:05 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
joinRec = res.getExitJoin(hotspot->hotspotId);
|
|
|
|
if (!joinRec->blocked) {
|
|
|
|
// Close the door
|
2007-08-12 11:19:01 +00:00
|
|
|
if (!doorCloseCheck(joinRec->hotspots[0].hotspotId) ||
|
|
|
|
!doorCloseCheck(joinRec->hotspots[1].hotspotId)) {
|
2006-04-29 11:22:05 +00:00
|
|
|
// A character is preventing the door from closing
|
2006-08-07 13:24:45 +00:00
|
|
|
showMessage(2);
|
2006-02-11 12:54:56 +00:00
|
|
|
} else {
|
2006-04-29 11:22:05 +00:00
|
|
|
// Flag the door as closed
|
|
|
|
joinRec->blocked = 1;
|
2006-02-11 12:54:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Hotspot::doUse(HotspotData *hotspot) {
|
|
|
|
Resources &res = Resources::getReference();
|
2008-01-24 08:14:48 +00:00
|
|
|
uint16 usedId = currentActions().top().supportData().param(0);
|
2006-04-29 11:22:05 +00:00
|
|
|
HotspotData *usedHotspot = res.getHotspot(usedId);
|
2006-08-07 13:24:45 +00:00
|
|
|
_data->useHotspotId = usedId;
|
2006-04-29 11:22:05 +00:00
|
|
|
|
|
|
|
if (usedHotspot->roomNumber != hotspotId()) {
|
|
|
|
// Item to be used is not in character's inventory - say "What???"
|
2006-05-23 12:43:42 +00:00
|
|
|
endAction();
|
2006-08-07 13:24:45 +00:00
|
|
|
showMessage(0xF);
|
2006-04-29 11:22:05 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
HotspotPrecheckResult result = actionPrecheck(hotspot);
|
2007-04-14 11:00:29 +00:00
|
|
|
if (result == PC_WAIT) return;
|
2006-04-29 11:22:05 +00:00
|
|
|
else if (result != PC_EXECUTE) {
|
2006-05-23 12:43:42 +00:00
|
|
|
endAction();
|
2006-04-29 11:22:05 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
faceHotspot(hotspot);
|
2006-05-23 12:43:42 +00:00
|
|
|
endAction();
|
2006-04-29 11:22:05 +00:00
|
|
|
|
2007-08-05 02:56:51 +00:00
|
|
|
if (hotspotId() == RATPOUCH_ID) {
|
|
|
|
_tempDest.position.x = 40;
|
|
|
|
setFrameCtr(80);
|
|
|
|
}
|
2006-04-29 11:22:05 +00:00
|
|
|
|
2006-02-11 12:54:56 +00:00
|
|
|
uint16 sequenceOffset = res.getHotspotAction(hotspot->actionsOffset, USE);
|
|
|
|
|
|
|
|
if (sequenceOffset >= 0x8000) {
|
2006-08-07 13:24:45 +00:00
|
|
|
showMessage(sequenceOffset);
|
2006-02-11 12:54:56 +00:00
|
|
|
} else if (sequenceOffset == 0) {
|
2006-08-07 13:24:45 +00:00
|
|
|
showMessage(17);
|
2006-02-11 12:54:56 +00:00
|
|
|
} else {
|
2006-04-29 11:22:05 +00:00
|
|
|
sequenceOffset = Script::execute(sequenceOffset);
|
2008-01-27 19:47:41 +00:00
|
|
|
if (sequenceOffset != 0)
|
2006-08-07 13:24:45 +00:00
|
|
|
showMessage(sequenceOffset);
|
2006-02-11 12:54:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Hotspot::doGive(HotspotData *hotspot) {
|
|
|
|
Resources &res = Resources::getReference();
|
2008-01-24 08:14:48 +00:00
|
|
|
uint16 usedId = currentActions().top().supportData().param(1);
|
2006-04-29 11:22:05 +00:00
|
|
|
HotspotData *usedHotspot = res.getHotspot(usedId);
|
2007-04-10 03:20:50 +00:00
|
|
|
_data->useHotspotId = usedId;
|
2006-04-29 11:22:05 +00:00
|
|
|
|
|
|
|
if (usedHotspot->roomNumber != hotspotId()) {
|
|
|
|
// Item to be used is not in character's inventory - say "What???"
|
2006-05-23 12:43:42 +00:00
|
|
|
endAction();
|
2006-08-07 13:24:45 +00:00
|
|
|
showMessage(0xF);
|
2006-04-29 11:22:05 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
HotspotPrecheckResult result = actionPrecheck(hotspot);
|
2007-04-14 11:00:29 +00:00
|
|
|
if (result == PC_WAIT) return;
|
2006-04-29 11:22:05 +00:00
|
|
|
else if (result != PC_EXECUTE) {
|
2006-05-23 12:43:42 +00:00
|
|
|
endAction();
|
2006-04-29 11:22:05 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
faceHotspot(hotspot);
|
2006-05-23 12:43:42 +00:00
|
|
|
endAction();
|
2006-04-29 11:22:05 +00:00
|
|
|
|
2008-01-27 19:47:41 +00:00
|
|
|
if ((hotspot->hotspotId != PRISONER_ID) || (usedId != BOTTLE_HOTSPOT_ID))
|
2007-04-19 06:46:56 +00:00
|
|
|
showMessage(7, hotspot->hotspotId);
|
2007-12-28 22:56:22 +00:00
|
|
|
|
2006-02-11 12:54:56 +00:00
|
|
|
uint16 sequenceOffset = res.getHotspotAction(hotspot->actionsOffset, GIVE);
|
|
|
|
|
|
|
|
if (sequenceOffset >= 0x8000) {
|
2006-08-07 13:24:45 +00:00
|
|
|
showMessage(sequenceOffset);
|
2006-04-29 11:22:05 +00:00
|
|
|
} else if (sequenceOffset != 0) {
|
|
|
|
sequenceOffset = Script::execute(sequenceOffset);
|
|
|
|
if (sequenceOffset == NOONE_ID) {
|
2006-07-08 08:42:58 +00:00
|
|
|
// Start a conversation based on the index of field #6
|
2007-12-09 10:08:41 +00:00
|
|
|
uint16 index = res.fieldList().getField(GIVE_TALK_INDEX);
|
2007-10-07 11:12:46 +00:00
|
|
|
uint16 id = res.getGiveTalkId(index);
|
|
|
|
startTalk(hotspot, id);
|
2006-07-08 08:42:58 +00:00
|
|
|
|
2006-04-29 11:22:05 +00:00
|
|
|
} else if (sequenceOffset == 0) {
|
2006-02-11 12:54:56 +00:00
|
|
|
// Move item into character's inventory
|
|
|
|
HotspotData *usedItem = res.getHotspot(usedId);
|
2007-04-22 22:42:01 +00:00
|
|
|
usedItem->roomNumber = hotspot->hotspotId;
|
2006-04-29 11:22:05 +00:00
|
|
|
} else if (sequenceOffset > 1) {
|
2007-12-28 22:56:22 +00:00
|
|
|
Hotspot *destCharacter = res.getActiveHotspot(hotspot->hotspotId);
|
|
|
|
if (destCharacter != NULL)
|
|
|
|
destCharacter->showMessage(sequenceOffset, hotspotId());
|
2006-02-11 12:54:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Hotspot::doTalkTo(HotspotData *hotspot) {
|
2006-04-29 11:22:05 +00:00
|
|
|
Resources &res = Resources::getReference();
|
|
|
|
ValueTableData &fields = res.fieldList();
|
|
|
|
fields.setField(ACTIVE_HOTSPOT_ID, hotspot->hotspotId);
|
2006-07-08 08:42:58 +00:00
|
|
|
fields.setField(USE_HOTSPOT_ID, hotspot->hotspotId);
|
2006-04-29 11:22:05 +00:00
|
|
|
|
2008-01-27 19:47:41 +00:00
|
|
|
if ((hotspot->hotspotId != SKORL_ID) && ((hotspot->roomNumber != 28) ||
|
2007-04-19 06:46:56 +00:00
|
|
|
(hotspot->hotspotId != BLACKSMITH_ID))) {
|
2006-04-29 11:22:05 +00:00
|
|
|
|
|
|
|
HotspotPrecheckResult result = actionPrecheck(hotspot);
|
2007-04-14 11:00:29 +00:00
|
|
|
if (result == PC_WAIT) return;
|
2006-04-29 11:22:05 +00:00
|
|
|
else if (result != PC_EXECUTE) {
|
2006-05-23 12:43:42 +00:00
|
|
|
endAction();
|
2006-04-29 11:22:05 +00:00
|
|
|
return;
|
|
|
|
}
|
2006-02-19 04:25:28 +00:00
|
|
|
}
|
|
|
|
|
2006-04-29 11:22:05 +00:00
|
|
|
faceHotspot(hotspot);
|
2006-05-23 12:43:42 +00:00
|
|
|
endAction();
|
2006-02-19 04:25:28 +00:00
|
|
|
|
2011-09-09 12:10:03 +00:00
|
|
|
// WORKAROUND: Fix crash when talking when an ask conversation is active
|
|
|
|
if (_data->talkDestCharacterId != 0) {
|
|
|
|
// Don't allow the talk to start
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-02-11 12:54:56 +00:00
|
|
|
uint16 sequenceOffset = res.getHotspotAction(hotspot->actionsOffset, TALK_TO);
|
|
|
|
if (sequenceOffset >= 0x8000) {
|
2006-08-07 13:24:45 +00:00
|
|
|
showMessage(sequenceOffset);
|
2006-04-29 11:22:05 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sequenceOffset != 0) {
|
2006-02-11 12:54:56 +00:00
|
|
|
uint16 result = Script::execute(sequenceOffset);
|
|
|
|
|
2006-04-29 11:22:05 +00:00
|
|
|
if (result != 0) {
|
2006-05-23 12:43:42 +00:00
|
|
|
endAction();
|
2006-04-29 11:22:05 +00:00
|
|
|
return;
|
2006-02-11 12:54:56 +00:00
|
|
|
}
|
|
|
|
}
|
2006-04-29 11:22:05 +00:00
|
|
|
|
|
|
|
// Start talking with character
|
2006-07-08 08:42:58 +00:00
|
|
|
startTalk(hotspot, getTalkId(hotspot));
|
2006-02-11 12:54:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Hotspot::doTell(HotspotData *hotspot) {
|
2006-08-27 11:48:41 +00:00
|
|
|
Resources &res = Resources::getReference();
|
|
|
|
ValueTableData &fields = res.fieldList();
|
|
|
|
fields.setField(ACTIVE_HOTSPOT_ID, hotspot->hotspotId);
|
|
|
|
fields.setField(USE_HOTSPOT_ID, hotspot->hotspotId);
|
|
|
|
Hotspot *character = res.getActiveHotspot(hotspot->hotspotId);
|
|
|
|
assert(character);
|
|
|
|
|
2006-08-30 12:19:05 +00:00
|
|
|
HotspotPrecheckResult hsResult = actionPrecheck(hotspot);
|
2007-04-14 11:00:29 +00:00
|
|
|
if (hsResult == PC_WAIT) return;
|
2006-08-30 12:19:05 +00:00
|
|
|
else if (hsResult != PC_EXECUTE) {
|
2006-08-27 11:48:41 +00:00
|
|
|
endAction();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-11-10 22:47:11 +00:00
|
|
|
converse(hotspot->hotspotId, 0x7C, true, false);
|
2006-08-27 11:48:41 +00:00
|
|
|
|
|
|
|
uint16 sequenceOffset = res.getHotspotAction(hotspot->actionsOffset, TELL);
|
|
|
|
if (sequenceOffset >= 0x8000) {
|
|
|
|
showMessage(sequenceOffset);
|
|
|
|
} else if (sequenceOffset != 0) {
|
|
|
|
uint16 result = Script::execute(sequenceOffset);
|
|
|
|
|
|
|
|
if (result == 0) {
|
2006-08-30 12:19:05 +00:00
|
|
|
// Build up sequence of commands for character to follow
|
2008-01-24 08:14:48 +00:00
|
|
|
CharacterScheduleEntry &cmdData = currentActions().top().supportData();
|
2006-08-27 11:48:41 +00:00
|
|
|
character->setStartRoomNumber(character->roomNumber());
|
|
|
|
character->currentActions().clear();
|
2007-02-09 10:56:31 +00:00
|
|
|
character->setBlockedFlag(false);
|
2006-08-30 12:19:05 +00:00
|
|
|
|
|
|
|
for (int index = 1; index < cmdData.numParams(); index += 3) {
|
2007-06-22 12:36:04 +00:00
|
|
|
character->currentActions().addBack((Action) cmdData.param(index), 0,
|
|
|
|
cmdData.param(index + 1), cmdData.param(index + 2));
|
2006-08-30 12:19:05 +00:00
|
|
|
}
|
2006-08-27 11:48:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
endAction();
|
2006-02-11 12:54:56 +00:00
|
|
|
}
|
|
|
|
|
2006-05-23 12:43:42 +00:00
|
|
|
void Hotspot::doLook(HotspotData *hotspot) {
|
|
|
|
endAction();
|
2006-02-11 12:54:56 +00:00
|
|
|
Dialog::show(Room::getReference().descId());
|
|
|
|
}
|
|
|
|
|
2008-01-27 19:47:41 +00:00
|
|
|
static const uint16 hotspotLookAtList[] = {0x411, 0x412, 0x41F, 0x420, 0x421, 0x422, 0x426,
|
2006-04-29 11:22:05 +00:00
|
|
|
0x427, 0x428, 0x429, 0x436, 0x437, 0};
|
|
|
|
|
2006-02-11 12:54:56 +00:00
|
|
|
void Hotspot::doLookAt(HotspotData *hotspot) {
|
2007-09-08 11:18:35 +00:00
|
|
|
doLookAction(hotspot, LOOK_AT);
|
2006-04-29 11:22:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Hotspot::doLookThrough(HotspotData *hotspot) {
|
2007-09-08 11:18:35 +00:00
|
|
|
doLookAction(hotspot, LOOK_THROUGH);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Hotspot::doLookAction(HotspotData *hotspot, Action action) {
|
2006-04-29 11:22:05 +00:00
|
|
|
Resources &res = Resources::getReference();
|
2007-09-08 11:18:35 +00:00
|
|
|
uint16 sequenceOffset = res.getHotspotAction(hotspot->actionsOffset, action);
|
2006-04-29 11:22:05 +00:00
|
|
|
|
|
|
|
if (hotspot->hotspotId >= FIRST_NONCHARACTER_ID) {
|
|
|
|
// Check if the hotspot appears in the list of hotspots that don't
|
|
|
|
// need to be walked to before being looked at
|
2007-09-08 11:18:35 +00:00
|
|
|
const uint16 *tempId = &hotspotLookAtList[0];
|
|
|
|
while ((*tempId != 0) && (*tempId != hotspot->hotspotId))
|
|
|
|
++tempId;
|
2006-04-29 11:22:05 +00:00
|
|
|
if (!*tempId) {
|
|
|
|
// Hotspot wasn't in the list
|
|
|
|
HotspotPrecheckResult result = actionPrecheck(hotspot);
|
2007-09-08 11:18:35 +00:00
|
|
|
if (result == PC_WAIT)
|
|
|
|
return;
|
2006-04-29 11:22:05 +00:00
|
|
|
else if (result != PC_EXECUTE) {
|
2006-05-23 12:43:42 +00:00
|
|
|
endAction();
|
2006-04-29 11:22:05 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
faceHotspot(hotspot);
|
2006-07-08 08:42:58 +00:00
|
|
|
setActionCtr(0);
|
2006-05-23 12:43:42 +00:00
|
|
|
endAction();
|
2006-04-29 11:22:05 +00:00
|
|
|
|
2006-02-11 12:54:56 +00:00
|
|
|
if (sequenceOffset >= 0x8000) {
|
2006-08-07 13:24:45 +00:00
|
|
|
showMessage(sequenceOffset);
|
2006-02-11 12:54:56 +00:00
|
|
|
} else {
|
2008-01-27 19:47:41 +00:00
|
|
|
if (sequenceOffset != 0)
|
2006-02-11 12:54:56 +00:00
|
|
|
sequenceOffset = Script::execute(sequenceOffset);
|
|
|
|
|
|
|
|
if (sequenceOffset == 0) {
|
|
|
|
uint16 descId = (hotspot->descId2 != 0) ? hotspot->descId2 : hotspot->descId;
|
|
|
|
Dialog::show(descId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Hotspot::doAsk(HotspotData *hotspot) {
|
2006-08-07 13:24:45 +00:00
|
|
|
Resources &res = Resources::getReference();
|
2008-01-24 08:14:48 +00:00
|
|
|
uint16 usedId = currentActions().top().supportData().param(1);
|
2006-08-07 13:24:45 +00:00
|
|
|
Hotspot *destCharacter = res.getActiveHotspot(hotspot->hotspotId);
|
|
|
|
HotspotData *usedHotspot = res.getHotspot(usedId);
|
|
|
|
_data->useHotspotId = usedId;
|
|
|
|
|
|
|
|
HotspotPrecheckResult result = actionPrecheck(hotspot);
|
2007-04-14 11:00:29 +00:00
|
|
|
if (result == PC_WAIT) return;
|
2006-08-07 13:24:45 +00:00
|
|
|
else if (result != PC_EXECUTE) {
|
|
|
|
endAction();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
faceHotspot(hotspot);
|
|
|
|
endAction();
|
|
|
|
showMessage(9, hotspot->hotspotId); // CHARACTER, DO YOU HAVE ITEM?
|
|
|
|
|
|
|
|
// Get the action and handle the reply
|
|
|
|
uint16 sequenceOffset = res.getHotspotAction(hotspot->actionsOffset, ASK);
|
|
|
|
|
|
|
|
if (sequenceOffset >= 0x8000) {
|
2007-12-16 03:47:24 +00:00
|
|
|
if (destCharacter != NULL)
|
|
|
|
destCharacter->showMessage(sequenceOffset, hotspotId());
|
2006-08-07 13:24:45 +00:00
|
|
|
} else if (sequenceOffset != 0) {
|
|
|
|
sequenceOffset = Script::execute(sequenceOffset);
|
|
|
|
|
|
|
|
if (sequenceOffset == 0) {
|
|
|
|
// Give item to character
|
|
|
|
usedHotspot->roomNumber = hotspotId();
|
2007-12-16 03:47:24 +00:00
|
|
|
if (destCharacter != NULL)
|
|
|
|
destCharacter->showMessage(32, hotspotId());
|
|
|
|
} else if ((sequenceOffset != 1) && (destCharacter != NULL)) {
|
2006-08-07 13:24:45 +00:00
|
|
|
destCharacter->showMessage(sequenceOffset, hotspotId());
|
|
|
|
}
|
|
|
|
}
|
2006-02-11 12:54:56 +00:00
|
|
|
}
|
|
|
|
|
2006-04-29 11:22:05 +00:00
|
|
|
void Hotspot::doDrink(HotspotData *hotspot) {
|
2006-02-11 12:54:56 +00:00
|
|
|
Resources &res = Resources::getReference();
|
2006-04-29 11:22:05 +00:00
|
|
|
ValueTableData &fields = res.fieldList();
|
|
|
|
fields.setField(ACTIVE_HOTSPOT_ID, hotspot->hotspotId);
|
|
|
|
fields.setField(USE_HOTSPOT_ID, hotspot->hotspotId);
|
|
|
|
|
2006-07-08 08:42:58 +00:00
|
|
|
endAction();
|
|
|
|
|
2006-04-29 11:22:05 +00:00
|
|
|
// Make sure item is in character's inventory
|
2006-07-08 08:42:58 +00:00
|
|
|
if (hotspot->roomNumber != hotspotId()) {
|
2006-08-07 13:24:45 +00:00
|
|
|
showMessage(0xF);
|
2006-04-29 11:22:05 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-02-11 12:54:56 +00:00
|
|
|
uint16 sequenceOffset = res.getHotspotAction(hotspot->actionsOffset, DRINK);
|
|
|
|
|
|
|
|
if (sequenceOffset >= 0x8000) {
|
2006-08-07 13:24:45 +00:00
|
|
|
showMessage(sequenceOffset);
|
2006-02-11 12:54:56 +00:00
|
|
|
} else if (sequenceOffset == 0) {
|
2006-08-07 13:24:45 +00:00
|
|
|
showMessage(22);
|
2006-02-11 12:54:56 +00:00
|
|
|
} else {
|
|
|
|
uint16 result = Script::execute(sequenceOffset);
|
|
|
|
if (result == 0) {
|
|
|
|
// Item has been drunk, so remove item from game
|
|
|
|
hotspot->roomNumber = 0;
|
|
|
|
} else if (result != 1) {
|
2006-08-07 13:24:45 +00:00
|
|
|
showMessage(result);
|
2006-02-11 12:54:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// doStatus
|
|
|
|
// Handle the status window
|
|
|
|
|
2006-05-23 12:43:42 +00:00
|
|
|
void Hotspot::doStatus(HotspotData *hotspot) {
|
2006-02-11 12:54:56 +00:00
|
|
|
char buffer[MAX_DESC_SIZE];
|
|
|
|
uint16 numItems = 0;
|
2007-10-07 11:12:46 +00:00
|
|
|
Resources &res = Resources::getReference();
|
|
|
|
StringList &stringList = res.stringList();
|
2006-02-11 12:54:56 +00:00
|
|
|
StringData &strings = StringData::getReference();
|
|
|
|
Room &room = Room::getReference();
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2006-04-29 11:22:05 +00:00
|
|
|
room.update();
|
2006-05-23 12:43:42 +00:00
|
|
|
endAction();
|
2006-02-11 12:54:56 +00:00
|
|
|
|
2006-08-07 13:24:45 +00:00
|
|
|
strings.getString(room.roomNumber(), buffer);
|
2007-10-07 11:12:46 +00:00
|
|
|
strcat(buffer, "\n\n");
|
|
|
|
strcat(buffer, stringList.getString(S_YOU_ARE_CARRYING));
|
2006-02-11 12:54:56 +00:00
|
|
|
|
|
|
|
// Scan through the list and add in any items assigned to the player
|
2007-10-07 11:12:46 +00:00
|
|
|
HotspotDataList &list = res.hotspotData();
|
2006-02-11 12:54:56 +00:00
|
|
|
HotspotDataList::iterator i;
|
|
|
|
for (i = list.begin(); i != list.end(); ++i) {
|
2012-03-13 13:53:40 +00:00
|
|
|
HotspotData const &rec = **i;
|
2006-02-11 12:54:56 +00:00
|
|
|
|
2012-03-13 13:53:40 +00:00
|
|
|
if (rec.roomNumber == PLAYER_ID) {
|
2006-02-11 12:54:56 +00:00
|
|
|
if (numItems++ == 0) strcat(buffer, ": ");
|
|
|
|
else strcat(buffer, ", ");
|
2012-03-13 13:53:40 +00:00
|
|
|
strings.getString(rec.nameId, buffer + strlen(buffer));
|
2006-02-11 12:54:56 +00:00
|
|
|
}
|
|
|
|
}
|
2006-05-23 12:43:42 +00:00
|
|
|
|
2006-02-11 12:54:56 +00:00
|
|
|
// If there were no items, add in the word 'nothing'
|
2007-10-07 11:12:46 +00:00
|
|
|
if (numItems == 0) strcat(buffer, stringList.getString(S_INV_NOTHING));
|
2006-02-11 12:54:56 +00:00
|
|
|
|
|
|
|
// If the player has money, add it in
|
2007-10-07 11:12:46 +00:00
|
|
|
uint16 numGroats = res.fieldList().numGroats();
|
2006-02-19 04:25:28 +00:00
|
|
|
if (numGroats > 0) {
|
2007-10-07 11:12:46 +00:00
|
|
|
strcat(buffer, "\n\n");
|
|
|
|
strcat(buffer, stringList.getString(S_YOU_HAVE));
|
|
|
|
sprintf(buffer + strlen(buffer), "%d", numGroats);
|
|
|
|
strcat(buffer, " ");
|
|
|
|
strcat(buffer, stringList.getString((numGroats == 1) ? S_GROAT : S_GROATS));
|
2006-02-19 04:25:28 +00:00
|
|
|
}
|
2006-02-11 12:54:56 +00:00
|
|
|
|
|
|
|
// Display the dialog
|
|
|
|
Screen &screen = Screen::getReference();
|
|
|
|
Mouse &mouse = Mouse::getReference();
|
|
|
|
mouse.cursorOff();
|
2006-05-23 12:43:42 +00:00
|
|
|
|
2006-02-11 12:54:56 +00:00
|
|
|
Surface *s = Surface::newDialog(INFO_DIALOG_WIDTH, buffer);
|
|
|
|
s->copyToScreen(INFO_DIALOG_X, (FULL_SCREEN_HEIGHT-s->height())/2);
|
2006-05-23 12:43:42 +00:00
|
|
|
|
2006-02-11 12:54:56 +00:00
|
|
|
Events::getReference().waitForPress();
|
|
|
|
screen.update();
|
|
|
|
mouse.cursorOn();
|
|
|
|
}
|
|
|
|
|
2006-05-23 12:43:42 +00:00
|
|
|
// doGoto
|
|
|
|
// Sets the room for the character to go to
|
|
|
|
|
|
|
|
void Hotspot::doGoto(HotspotData *hotspot) {
|
|
|
|
_exitCtr = 0;
|
|
|
|
_blockedOffset = 0;
|
2008-01-24 08:14:48 +00:00
|
|
|
currentActions().top().setRoomNumber(currentActions().top().supportData().param(0));
|
2006-05-23 12:43:42 +00:00
|
|
|
endAction();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Hotspot::doReturn(HotspotData *hotspot) {
|
2006-08-27 11:48:41 +00:00
|
|
|
currentActions().top().setRoomNumber(startRoomNumber());
|
|
|
|
endAction();
|
2006-05-23 12:43:42 +00:00
|
|
|
}
|
|
|
|
|
2007-09-08 11:18:35 +00:00
|
|
|
static const uint16 bribe_hotspot_list[] = {0x421, 0x879, 0x3E9, 0x8C7, 0x429, 0x8D1,
|
2006-04-29 11:22:05 +00:00
|
|
|
0x422, 0x8D4, 0x420, 0x8D6, 0x42B, 0x956, 0x3F2, 0xBE6, 0};
|
|
|
|
|
2006-02-11 12:54:56 +00:00
|
|
|
void Hotspot::doBribe(HotspotData *hotspot) {
|
2006-04-29 11:22:05 +00:00
|
|
|
Resources &res = Resources::getReference();
|
|
|
|
ValueTableData &fields = res.fieldList();
|
|
|
|
fields.setField(ACTIVE_HOTSPOT_ID, hotspot->hotspotId);
|
|
|
|
fields.setField(USE_HOTSPOT_ID, hotspot->hotspotId);
|
|
|
|
|
|
|
|
HotspotPrecheckResult result = actionPrecheck(hotspot);
|
2007-04-14 11:00:29 +00:00
|
|
|
if (result == PC_WAIT) return;
|
2006-04-29 11:22:05 +00:00
|
|
|
else if (result != PC_EXECUTE) {
|
2006-05-23 12:43:42 +00:00
|
|
|
endAction();
|
2006-04-29 11:22:05 +00:00
|
|
|
return;
|
|
|
|
}
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2007-09-08 11:18:35 +00:00
|
|
|
const uint16 *tempId = &bribe_hotspot_list[0];
|
2006-04-29 11:22:05 +00:00
|
|
|
uint16 sequenceOffset = 0x14B; // Default sequence offset
|
|
|
|
while (*tempId != 0) {
|
|
|
|
if (*tempId++ == hotspotId()) {
|
|
|
|
sequenceOffset = *tempId;
|
|
|
|
if ((sequenceOffset & 0x8000) != 0)
|
|
|
|
sequenceOffset = Script::execute(sequenceOffset & 0x7fff);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
++tempId; // Move over entry's sequence offset
|
|
|
|
}
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2006-04-29 11:22:05 +00:00
|
|
|
faceHotspot(hotspot);
|
2006-07-08 08:42:58 +00:00
|
|
|
setActionCtr(0);
|
2006-05-23 12:43:42 +00:00
|
|
|
endAction();
|
2006-04-29 11:22:05 +00:00
|
|
|
|
|
|
|
sequenceOffset = res.getHotspotAction(hotspot->actionsOffset, BRIBE);
|
|
|
|
if (sequenceOffset != 0) {
|
|
|
|
sequenceOffset = Script::execute(sequenceOffset);
|
|
|
|
if (sequenceOffset != 0) return;
|
|
|
|
}
|
|
|
|
|
2007-08-05 02:56:51 +00:00
|
|
|
uint16 talkIndex = res.fieldList().getField(TALK_INDEX);
|
|
|
|
showMessage((talkIndex == 6) ? 0x30 : 0x29);
|
2006-02-11 12:54:56 +00:00
|
|
|
}
|
|
|
|
|
2006-04-29 11:22:05 +00:00
|
|
|
void Hotspot::doExamine(HotspotData *hotspot) {
|
2006-02-11 12:54:56 +00:00
|
|
|
Resources &res = Resources::getReference();
|
2006-04-29 11:22:05 +00:00
|
|
|
ValueTableData &fields = res.fieldList();
|
|
|
|
fields.setField(ACTIVE_HOTSPOT_ID, hotspot->hotspotId);
|
|
|
|
fields.setField(USE_HOTSPOT_ID, hotspot->hotspotId);
|
|
|
|
|
2006-05-23 12:43:42 +00:00
|
|
|
endAction();
|
2006-02-11 12:54:56 +00:00
|
|
|
uint16 sequenceOffset = res.getHotspotAction(hotspot->actionsOffset, EXAMINE);
|
2006-04-29 11:22:05 +00:00
|
|
|
|
2006-02-11 12:54:56 +00:00
|
|
|
if (sequenceOffset >= 0x8000) {
|
2006-08-07 13:24:45 +00:00
|
|
|
showMessage(sequenceOffset);
|
2006-02-11 12:54:56 +00:00
|
|
|
} else {
|
2008-01-27 19:47:41 +00:00
|
|
|
if (sequenceOffset != 0)
|
2006-02-11 12:54:56 +00:00
|
|
|
sequenceOffset = Script::execute(sequenceOffset);
|
|
|
|
|
|
|
|
if (sequenceOffset == 0) {
|
|
|
|
Dialog::show(hotspot->descId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-29 11:22:05 +00:00
|
|
|
void Hotspot::doLockUnlock(HotspotData *hotspot) {
|
2008-01-24 08:14:48 +00:00
|
|
|
Action action = currentActions().top().supportData().action();
|
2006-04-29 11:22:05 +00:00
|
|
|
Resources &res = Resources::getReference();
|
|
|
|
ValueTableData &fields = res.fieldList();
|
|
|
|
fields.setField(ACTIVE_HOTSPOT_ID, hotspot->hotspotId);
|
|
|
|
fields.setField(USE_HOTSPOT_ID, hotspot->hotspotId);
|
|
|
|
|
|
|
|
HotspotPrecheckResult result = actionPrecheck(hotspot);
|
2007-04-14 11:00:29 +00:00
|
|
|
if (result == PC_WAIT) return;
|
2006-04-29 11:22:05 +00:00
|
|
|
else if (result != PC_EXECUTE) {
|
2006-05-23 12:43:42 +00:00
|
|
|
endAction();
|
2006-04-29 11:22:05 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
faceHotspot(hotspot);
|
2006-05-23 12:43:42 +00:00
|
|
|
endAction();
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2006-04-29 11:22:05 +00:00
|
|
|
uint16 sequenceOffset = res.getHotspotAction(hotspot->actionsOffset, action);
|
|
|
|
|
|
|
|
if (sequenceOffset >= 0x8000) {
|
2006-08-07 13:24:45 +00:00
|
|
|
showMessage(sequenceOffset);
|
2006-04-29 11:22:05 +00:00
|
|
|
} else {
|
2008-01-27 19:47:41 +00:00
|
|
|
if (sequenceOffset != 0)
|
2006-04-29 11:22:05 +00:00
|
|
|
Script::execute(sequenceOffset);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-05-23 12:43:42 +00:00
|
|
|
void Hotspot::npcSetRoomAndBlockedOffset(HotspotData *hotspot) {
|
2008-01-24 08:14:48 +00:00
|
|
|
CharacterScheduleEntry &entry = currentActions().top().supportData();
|
2006-05-23 12:43:42 +00:00
|
|
|
_exitCtr = 0;
|
|
|
|
|
|
|
|
_blockedOffset = entry.param(1);
|
2008-01-24 08:14:48 +00:00
|
|
|
currentActions().top().setRoomNumber(entry.param(0));
|
2006-05-23 12:43:42 +00:00
|
|
|
endAction();
|
|
|
|
}
|
|
|
|
|
2007-02-26 02:50:23 +00:00
|
|
|
void Hotspot::npcHeySir(HotspotData *hotspot) {
|
|
|
|
Resources &res = Resources::getReference();
|
|
|
|
|
|
|
|
// If player is performing an action, wait until it's done
|
|
|
|
Hotspot *playerHotspot = res.getActiveHotspot(PLAYER_ID);
|
|
|
|
if (!playerHotspot->currentActions().isEmpty()) {
|
|
|
|
setDelayCtr(12);
|
|
|
|
setCharacterMode(CHARMODE_PAUSED);
|
|
|
|
setActionCtr(0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-08-05 02:56:51 +00:00
|
|
|
// TODO: Check storage of hotspot Id in talk_first=player/talk_second=0
|
2007-02-26 02:50:23 +00:00
|
|
|
|
|
|
|
// Get the npc to say "Hey Sir" to player
|
|
|
|
showMessage(0x22, PLAYER_ID);
|
|
|
|
|
|
|
|
// Get the character to remain in place for a while
|
|
|
|
setDelayCtr(130);
|
2007-04-14 11:00:29 +00:00
|
|
|
setCharacterMode(CHARMODE_WAIT_FOR_PLAYER);
|
2007-02-26 02:50:23 +00:00
|
|
|
|
|
|
|
// Set the talk override to the specified Id
|
2008-01-24 08:14:48 +00:00
|
|
|
CharacterScheduleEntry &entry = currentActions().top().supportData();
|
2007-02-26 02:50:23 +00:00
|
|
|
_data->talkOverride = entry.param(0);
|
|
|
|
|
|
|
|
doNothing(hotspot);
|
2006-05-23 12:43:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Hotspot::npcExecScript(HotspotData *hotspot) {
|
2008-01-24 08:14:48 +00:00
|
|
|
CharacterScheduleEntry &entry = currentActions().top().supportData();
|
2006-05-23 12:43:42 +00:00
|
|
|
uint16 offset = entry.param(0);
|
|
|
|
endAction();
|
|
|
|
Script::execute(offset);
|
|
|
|
}
|
|
|
|
|
2006-07-08 08:42:58 +00:00
|
|
|
void Hotspot::npcResetPausedList(HotspotData *hotspot) {
|
|
|
|
Resources &res = Resources::getReference();
|
|
|
|
setCharacterMode(CHARMODE_HESITATE);
|
2006-11-12 04:39:10 +00:00
|
|
|
setDelayCtr(IDLE_COUNTDOWN_SIZE + 1);
|
2006-07-08 08:42:58 +00:00
|
|
|
|
|
|
|
res.pausedList().reset(hotspotId());
|
2006-05-23 12:43:42 +00:00
|
|
|
endAction();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Hotspot::npcSetRandomDest(HotspotData *hotspot) {
|
|
|
|
endAction();
|
2006-05-29 08:12:07 +00:00
|
|
|
setRandomDest();
|
2006-05-23 12:43:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Hotspot::npcWalkingCheck(HotspotData *hotspot) {
|
2006-02-11 12:54:56 +00:00
|
|
|
Resources &res = Resources::getReference();
|
2006-05-23 12:43:42 +00:00
|
|
|
ValueTableData &fields = res.fieldList();
|
2008-01-24 08:14:48 +00:00
|
|
|
CharacterScheduleEntry &entry = currentActions().top().supportData();
|
2006-05-23 12:43:42 +00:00
|
|
|
uint16 hId = entry.param(0);
|
2006-02-11 12:54:56 +00:00
|
|
|
|
2006-05-23 12:43:42 +00:00
|
|
|
endAction();
|
|
|
|
fields.setField(USE_HOTSPOT_ID, hId);
|
|
|
|
fields.setField(ACTIVE_HOTSPOT_ID, hId);
|
|
|
|
|
|
|
|
if ((hId < PLAYER_ID) || (hotspot->roomNumber == _roomNumber)) {
|
2008-01-08 06:13:55 +00:00
|
|
|
characterWalkingCheck(hId);
|
2006-02-11 12:54:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-05-23 12:43:42 +00:00
|
|
|
void Hotspot::npcSetSupportOffset(HotspotData *hotspot) {
|
2008-01-24 08:14:48 +00:00
|
|
|
CharacterScheduleEntry &entry = currentActions().top().supportData();
|
2006-05-23 12:43:42 +00:00
|
|
|
uint16 entryId = entry.param(0);
|
|
|
|
|
|
|
|
CharacterScheduleEntry *newEntry = Resources::getReference().
|
|
|
|
charSchedules().getEntry(entryId, entry.parent());
|
2008-01-24 08:14:48 +00:00
|
|
|
currentActions().top().setSupportData(newEntry);
|
2006-05-23 12:43:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Hotspot::npcSupportOffsetConditional(HotspotData *hotspot) {
|
|
|
|
Resources &res = Resources::getReference();
|
2008-01-24 08:14:48 +00:00
|
|
|
CharacterScheduleEntry &entry = currentActions().top().supportData();
|
2006-05-23 12:43:42 +00:00
|
|
|
CharacterScheduleEntry *newEntry;
|
|
|
|
uint16 scriptOffset = entry.param(0);
|
|
|
|
uint16 entryId = entry.param(1);
|
|
|
|
|
|
|
|
if (Script::execute(scriptOffset) == 0) {
|
|
|
|
// Not succeeded, get next entry
|
|
|
|
newEntry = entry.next();
|
|
|
|
} else {
|
|
|
|
// Get entry specified by parameter 1
|
|
|
|
newEntry = res.charSchedules().getEntry(entryId, entry.parent());
|
|
|
|
}
|
|
|
|
|
2008-01-24 08:14:48 +00:00
|
|
|
currentActions().top().setSupportData(newEntry);
|
2007-12-11 09:20:24 +00:00
|
|
|
HotspotData *hotspotData = (newEntry->numParams() == 0) ? NULL : res.getHotspot(
|
2008-01-08 03:09:00 +00:00
|
|
|
(newEntry->action() == USE) ? newEntry->param(1) : newEntry->param(0));
|
2006-05-23 12:43:42 +00:00
|
|
|
doAction(newEntry->action(), hotspotData);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Hotspot::npcDispatchAction(HotspotData *hotspot) {
|
|
|
|
Resources &res = Resources::getReference();
|
|
|
|
ValueTableData &fields = res.fieldList();
|
2008-01-24 08:14:48 +00:00
|
|
|
CharacterScheduleEntry &entry = currentActions().top().supportData();
|
2006-05-23 12:43:42 +00:00
|
|
|
|
|
|
|
fields.setField(USE_HOTSPOT_ID, entry.param(0));
|
|
|
|
fields.setField(ACTIVE_HOTSPOT_ID, entry.param(0));
|
|
|
|
|
|
|
|
HotspotPrecheckResult result = actionPrecheck(hotspot);
|
|
|
|
if (result == PC_EXECUTE) {
|
|
|
|
endAction();
|
2007-04-14 11:00:29 +00:00
|
|
|
} else if (result != PC_WAIT) {
|
2006-05-23 12:43:42 +00:00
|
|
|
CharacterScheduleEntry *newEntry = Resources::getReference().
|
|
|
|
charSchedules().getEntry(entry.param(0), entry.parent());
|
2008-01-24 08:14:48 +00:00
|
|
|
currentActions().top().setSupportData(newEntry);
|
2008-01-27 19:47:41 +00:00
|
|
|
|
|
|
|
HotspotData *hotspotData = (newEntry->numParams() == 0) ? NULL :
|
2007-12-11 09:20:24 +00:00
|
|
|
res.getHotspot(newEntry->param((newEntry->action() == USE) ? 1 : 0));
|
2006-05-23 12:43:42 +00:00
|
|
|
doAction(newEntry->action(), hotspotData);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-30 07:56:45 +00:00
|
|
|
void Hotspot::npcTalkNpcToNpc(HotspotData *hotspot) {
|
|
|
|
Resources &res = Resources::getReference();
|
|
|
|
ValueTableData &fields = res.fieldList();
|
2008-01-24 08:14:48 +00:00
|
|
|
CharacterScheduleEntry &entry = currentActions().top().supportData();
|
2007-04-30 07:56:45 +00:00
|
|
|
fields.setField(ACTIVE_HOTSPOT_ID, hotspot->hotspotId);
|
|
|
|
fields.setField(USE_HOTSPOT_ID, hotspot->hotspotId);
|
|
|
|
|
|
|
|
HotspotPrecheckResult result = actionPrecheck(hotspot);
|
|
|
|
if (result == PC_WAIT) return;
|
|
|
|
else if (result != PC_EXECUTE) {
|
|
|
|
endAction();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If dest is already talking, keep exiting until they're free
|
2008-01-27 19:47:41 +00:00
|
|
|
if (hotspot->talkCountdown != 0)
|
2007-04-30 07:56:45 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
// Handle the source's talk message
|
|
|
|
if (entry.param(1) != 0) {
|
2007-11-12 09:16:00 +00:00
|
|
|
converse(hotspot->hotspotId, entry.param(1), true, false);
|
|
|
|
_data->talkCountdown += entry.param(2);
|
|
|
|
setDelayCtr(delayCtr() + entry.param(2));
|
2007-04-30 07:56:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Handle the destination's response message
|
|
|
|
if (entry.param(3) != 0) {
|
|
|
|
Hotspot *destHotspot = res.getActiveHotspot(hotspot->hotspotId);
|
|
|
|
assert(destHotspot);
|
2007-11-12 09:16:00 +00:00
|
|
|
destHotspot->converse(this->hotspotId(), entry.param(3), true, false);
|
2007-04-30 07:56:45 +00:00
|
|
|
}
|
|
|
|
|
2006-05-29 08:12:07 +00:00
|
|
|
endAction();
|
2006-05-23 12:43:42 +00:00
|
|
|
}
|
|
|
|
|
2006-07-08 08:42:58 +00:00
|
|
|
void Hotspot::npcPause(HotspotData *hotspot) {
|
2008-01-24 08:14:48 +00:00
|
|
|
uint16 delayAmount = currentActions().top().supportData().param(0);
|
2006-05-29 08:12:07 +00:00
|
|
|
endAction();
|
2006-07-08 08:42:58 +00:00
|
|
|
|
|
|
|
setCharacterMode(CHARMODE_PAUSED);
|
|
|
|
setDelayCtr(delayAmount);
|
2006-05-23 12:43:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Hotspot::npcStartTalking(HotspotData *hotspot) {
|
2008-01-24 08:14:48 +00:00
|
|
|
CharacterScheduleEntry &entry = currentActions().top().supportData();
|
2006-07-08 08:42:58 +00:00
|
|
|
uint16 stringId = entry.param(0);
|
|
|
|
uint16 destHotspot = entry.param(1);
|
|
|
|
|
|
|
|
converse(destHotspot, stringId, false);
|
2006-05-29 08:12:07 +00:00
|
|
|
endAction();
|
2006-05-23 12:43:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Hotspot::npcJumpAddress(HotspotData *hotspot) {
|
2006-07-08 08:42:58 +00:00
|
|
|
Resources &res = Resources::getReference();
|
|
|
|
ValueTableData &fields = res.fieldList();
|
2008-01-24 08:14:48 +00:00
|
|
|
int procIndex = currentActions().top().supportData().param(0);
|
2007-06-22 12:36:04 +00:00
|
|
|
Hotspot *player;
|
|
|
|
CharacterScheduleEntry *entry;
|
2006-05-29 08:12:07 +00:00
|
|
|
endAction();
|
2006-07-08 08:42:58 +00:00
|
|
|
|
|
|
|
switch (procIndex) {
|
|
|
|
case 0:
|
|
|
|
if (fields.getField(OLD_ROOM_NUMBER) == 19) {
|
|
|
|
fields.setField(TALK_INDEX, 24);
|
|
|
|
res.getHotspot(0x3F1)->nameId = 0x154;
|
|
|
|
Dialog::show(0xAB9);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
2007-06-22 12:36:04 +00:00
|
|
|
player = res.getActiveHotspot(PLAYER_ID);
|
|
|
|
if (player->y() < 52) {
|
|
|
|
entry = res.charSchedules().getEntry(JUMP_ADDR_2_SUPPORT_ID, NULL);
|
|
|
|
assert(entry);
|
|
|
|
|
2008-01-24 08:14:48 +00:00
|
|
|
currentActions().clear();
|
|
|
|
currentActions().addFront(DISPATCH_ACTION, entry, ROOMNUM_CELLAR);
|
2007-06-22 12:36:04 +00:00
|
|
|
}
|
2006-07-08 08:42:58 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
error("Hotspot::npcJumpAddress - invalid method index %d", procIndex);
|
|
|
|
break;
|
|
|
|
}
|
2006-05-23 12:43:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*------------------------------------------------------------------------*/
|
|
|
|
|
2006-07-08 08:42:58 +00:00
|
|
|
uint16 Hotspot::getTalkId(HotspotData *charHotspot) {
|
2006-02-19 04:25:28 +00:00
|
|
|
Resources &res = Resources::getReference();
|
|
|
|
uint16 talkIndex;
|
2007-02-26 02:50:23 +00:00
|
|
|
TalkHeaderData *headerEntry;
|
2010-01-19 23:48:55 +00:00
|
|
|
bool isEnglish = LureEngine::getReference().getLanguage() == Common::EN_ANY;
|
2007-02-26 02:50:23 +00:00
|
|
|
|
|
|
|
// If the hotspot has a talk data override, return it
|
2007-09-08 11:18:35 +00:00
|
|
|
if (charHotspot->talkOverride != 0) {
|
2007-02-26 02:50:23 +00:00
|
|
|
// Has an override, so return it and reset back to zero
|
|
|
|
uint16 result = charHotspot->talkOverride;
|
|
|
|
charHotspot->talkOverride = 0;
|
|
|
|
return result;
|
|
|
|
}
|
2006-02-19 04:25:28 +00:00
|
|
|
|
|
|
|
// Get offset of talk set to use
|
2007-02-26 02:50:23 +00:00
|
|
|
headerEntry = res.getTalkHeader(charHotspot->hotspotId);
|
2006-02-19 04:25:28 +00:00
|
|
|
|
2008-01-27 19:47:41 +00:00
|
|
|
// Check whether character is a stranger
|
2007-09-30 10:53:40 +00:00
|
|
|
if ((isEnglish && (charHotspot->nameId == 378)) ||
|
|
|
|
(!isEnglish && ((charHotspot->nameId == 381) || (charHotspot->nameId == 382))))
|
|
|
|
// Is a stranger, so force talk Index to be 0 (initial talk)
|
2006-02-19 04:25:28 +00:00
|
|
|
talkIndex = 0;
|
|
|
|
else
|
2007-09-30 10:53:40 +00:00
|
|
|
// Set the talk index based on the current game-wide talk index
|
2006-02-19 04:25:28 +00:00
|
|
|
talkIndex = res.fieldList().getField(TALK_INDEX) + 1;
|
2006-07-08 08:42:58 +00:00
|
|
|
|
|
|
|
return headerEntry->getEntry(talkIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Hotspot::startTalk(HotspotData *charHotspot, uint16 id) {
|
|
|
|
Resources &res = Resources::getReference();
|
|
|
|
|
|
|
|
// Set for providing talk listing
|
2008-01-27 19:47:41 +00:00
|
|
|
setTickProc(TALK_TICK_PROC_ID);
|
|
|
|
|
2006-07-08 08:42:58 +00:00
|
|
|
// Signal the character that they're being talked to
|
2007-11-10 22:47:11 +00:00
|
|
|
charHotspot->talkerId = _hotspotId;
|
2007-05-27 04:33:19 +00:00
|
|
|
charHotspot->talkGate = 0;
|
2007-11-10 22:47:11 +00:00
|
|
|
charHotspot->talkDestCharacterId = _hotspotId;
|
2007-04-10 03:20:50 +00:00
|
|
|
_data->talkDestCharacterId = charHotspot->hotspotId;
|
2007-04-22 22:42:01 +00:00
|
|
|
_data->talkGate = 0;
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2006-02-19 04:25:28 +00:00
|
|
|
// Set the active talk data
|
|
|
|
res.setTalkStartEntry(0);
|
2006-07-08 08:42:58 +00:00
|
|
|
res.setTalkData(id);
|
2008-01-27 19:47:41 +00:00
|
|
|
if (!res.getTalkData())
|
2006-07-08 08:42:58 +00:00
|
|
|
error("Talk failed - invalid offset: Character=%xh, offset=%xh",
|
|
|
|
charHotspot->hotspotId, id);
|
2006-02-19 04:25:28 +00:00
|
|
|
}
|
|
|
|
|
2012-03-13 09:25:04 +00:00
|
|
|
void Hotspot::saveToStream(Common::WriteStream *stream) const {
|
2008-02-16 05:12:32 +00:00
|
|
|
if (_data)
|
|
|
|
_data->npcSchedule.saveToStream(stream);
|
2009-01-01 15:06:43 +00:00
|
|
|
else
|
2008-02-16 05:12:32 +00:00
|
|
|
// Hotspot doesn't have an underlying data object, so write out an empty actions list
|
|
|
|
stream->writeByte(0xff);
|
|
|
|
|
2006-10-02 12:48:56 +00:00
|
|
|
_pathFinder.saveToStream(stream);
|
|
|
|
|
|
|
|
stream->writeUint16LE(_roomNumber);
|
|
|
|
stream->writeSint16LE(_startX);
|
|
|
|
stream->writeSint16LE(_startY);
|
|
|
|
stream->writeSint16LE(_destX);
|
|
|
|
stream->writeSint16LE(_destY);
|
2007-05-20 13:07:44 +00:00
|
|
|
stream->writeUint16LE(_destHotspotId);
|
2007-08-05 02:56:51 +00:00
|
|
|
stream->writeByte(_tempDest.counter);
|
|
|
|
stream->writeSint16LE(_tempDest.position.x);
|
|
|
|
stream->writeSint16LE(_tempDest.position.y);
|
2006-10-02 12:48:56 +00:00
|
|
|
stream->writeUint16LE(_frameWidth);
|
|
|
|
stream->writeUint16LE(_height);
|
|
|
|
stream->writeUint16LE(_width);
|
|
|
|
stream->writeUint16LE(_heightCopy);
|
|
|
|
stream->writeUint16LE(_widthCopy);
|
|
|
|
stream->writeUint16LE(_yCorrection);
|
|
|
|
stream->writeUint16LE(_talkX);
|
|
|
|
stream->writeUint16LE(_talkY);
|
|
|
|
stream->writeByte(_layer);
|
2007-04-29 11:30:29 +00:00
|
|
|
stream->writeUint16LE(_hotspotScriptOffset);
|
2011-04-14 12:12:27 +00:00
|
|
|
stream->writeByte(_colorOffset);
|
2007-10-25 10:37:23 +00:00
|
|
|
stream->writeByte((byte)_direction);
|
2006-10-02 12:48:56 +00:00
|
|
|
stream->writeUint16LE(_animId);
|
|
|
|
stream->writeUint16LE(_frameNumber);
|
|
|
|
|
|
|
|
stream->writeUint16LE(_frameCtr);
|
|
|
|
stream->writeByte(_skipFlag);
|
|
|
|
stream->writeUint16LE(_charRectY);
|
|
|
|
stream->writeUint16LE(_voiceCtr);
|
|
|
|
stream->writeUint16LE(_blockedOffset);
|
|
|
|
stream->writeUint16LE(_exitCtr);
|
|
|
|
stream->writeByte(_walkFlag);
|
2007-05-27 04:33:19 +00:00
|
|
|
stream->writeByte(_persistant);
|
2006-10-02 12:48:56 +00:00
|
|
|
stream->writeUint16LE(_startRoomNumber);
|
2007-04-14 03:48:24 +00:00
|
|
|
stream->writeUint16LE(_supportValue);
|
2006-10-02 12:48:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Hotspot::loadFromStream(Common::ReadStream *stream) {
|
2008-02-16 05:12:32 +00:00
|
|
|
if (_data)
|
|
|
|
_data->npcSchedule.loadFromStream(stream);
|
2012-01-14 22:58:59 +00:00
|
|
|
else {
|
2008-02-16 05:12:32 +00:00
|
|
|
// Dummy read of terminator for empty actions list
|
2012-01-14 22:58:59 +00:00
|
|
|
byte dummy = stream->readByte();
|
|
|
|
assert(dummy == 0xff);
|
|
|
|
}
|
2008-02-16 05:12:32 +00:00
|
|
|
|
2006-10-02 12:48:56 +00:00
|
|
|
_pathFinder.loadFromStream(stream);
|
|
|
|
|
|
|
|
_roomNumber = stream->readUint16LE();
|
|
|
|
_startX = stream->readSint16LE();
|
|
|
|
_startY = stream->readSint16LE();
|
|
|
|
_destX = stream->readSint16LE();
|
|
|
|
_destY = stream->readSint16LE();
|
2007-05-20 13:07:44 +00:00
|
|
|
_destHotspotId = stream->readUint16LE();
|
2007-08-05 02:56:51 +00:00
|
|
|
_tempDest.counter = stream->readByte();
|
|
|
|
_tempDest.position.x = stream->readSint16LE();
|
|
|
|
_tempDest.position.y = stream->readSint16LE();
|
2006-10-02 12:48:56 +00:00
|
|
|
_frameWidth = stream->readUint16LE();
|
|
|
|
_height = stream->readUint16LE();
|
|
|
|
_width = stream->readUint16LE();
|
|
|
|
_heightCopy = stream->readUint16LE();
|
|
|
|
_widthCopy = stream->readUint16LE();
|
|
|
|
_yCorrection = stream->readUint16LE();
|
|
|
|
_talkX = stream->readUint16LE();
|
|
|
|
_talkY = stream->readUint16LE();
|
|
|
|
_layer = stream->readByte();
|
2007-04-29 11:30:29 +00:00
|
|
|
_hotspotScriptOffset = stream->readUint16LE();
|
2011-04-14 12:12:27 +00:00
|
|
|
_colorOffset = stream->readByte();
|
2007-10-25 10:37:23 +00:00
|
|
|
_direction = (Direction)stream->readByte();
|
2006-10-02 12:48:56 +00:00
|
|
|
setAnimation(stream->readUint16LE());
|
|
|
|
setFrameNumber(stream->readUint16LE());
|
|
|
|
|
|
|
|
_frameCtr = stream->readUint16LE();
|
|
|
|
_skipFlag = stream->readByte() != 0;
|
|
|
|
_charRectY = stream->readUint16LE();
|
|
|
|
_voiceCtr = stream->readUint16LE();
|
|
|
|
_blockedOffset = stream->readUint16LE();
|
|
|
|
_exitCtr = stream->readUint16LE();
|
|
|
|
_walkFlag = stream->readByte() != 0;
|
2007-05-27 04:33:19 +00:00
|
|
|
_persistant = stream->readByte() != 0;
|
2006-10-02 12:48:56 +00:00
|
|
|
_startRoomNumber = stream->readUint16LE();
|
2007-04-14 03:48:24 +00:00
|
|
|
_supportValue = stream->readUint16LE();
|
2006-10-02 12:48:56 +00:00
|
|
|
}
|
|
|
|
|
2006-02-11 12:54:56 +00:00
|
|
|
/*------------------------------------------------------------------------*/
|
|
|
|
|
2009-10-20 19:51:57 +00:00
|
|
|
HotspotTickHandlers::HotspotTickHandlers() {
|
|
|
|
countdownCtr = 0;
|
|
|
|
ewanXOffset = false;
|
|
|
|
}
|
|
|
|
|
2007-09-23 22:17:57 +00:00
|
|
|
HandlerMethodPtr HotspotTickHandlers::getHandler(uint16 procIndex) {
|
|
|
|
switch (procIndex) {
|
|
|
|
case 1:
|
2009-10-20 19:51:57 +00:00
|
|
|
return &HotspotTickHandlers::defaultHandler;
|
2007-04-02 06:03:47 +00:00
|
|
|
case STANDARD_CHARACTER_TICK_PROC:
|
2009-10-20 19:51:57 +00:00
|
|
|
return &HotspotTickHandlers::standardCharacterAnimHandler;
|
2007-09-23 22:17:57 +00:00
|
|
|
case PLAYER_TICK_PROC_ID:
|
2009-10-20 19:51:57 +00:00
|
|
|
return &HotspotTickHandlers::playerAnimHandler;
|
2006-07-08 08:42:58 +00:00
|
|
|
case VOICE_TICK_PROC_ID:
|
2009-10-20 19:51:57 +00:00
|
|
|
return &HotspotTickHandlers::voiceBubbleAnimHandler;
|
2006-07-08 08:42:58 +00:00
|
|
|
case PUZZLED_TICK_PROC_ID:
|
2009-10-20 19:51:57 +00:00
|
|
|
return &HotspotTickHandlers::puzzledAnimHandler;
|
2007-09-23 22:17:57 +00:00
|
|
|
case 6:
|
2009-10-20 19:51:57 +00:00
|
|
|
return &HotspotTickHandlers::roomExitAnimHandler;
|
2007-09-23 22:17:57 +00:00
|
|
|
case 7:
|
2007-06-22 12:36:04 +00:00
|
|
|
case FOLLOWER_TICK_PROC_2:
|
2009-10-20 19:51:57 +00:00
|
|
|
return &HotspotTickHandlers::followerAnimHandler;
|
2007-06-22 12:36:04 +00:00
|
|
|
case JAILOR_TICK_PROC_ID:
|
2007-09-23 22:17:57 +00:00
|
|
|
case 10:
|
2009-10-20 19:51:57 +00:00
|
|
|
return &HotspotTickHandlers::jailorAnimHandler;
|
2007-04-22 22:42:01 +00:00
|
|
|
case STANDARD_ANIM_2_TICK_PROC:
|
2009-10-20 19:51:57 +00:00
|
|
|
return &HotspotTickHandlers::standardAnimHandler2;
|
2007-04-22 22:42:01 +00:00
|
|
|
case STANDARD_ANIM_TICK_PROC:
|
2009-10-20 19:51:57 +00:00
|
|
|
return &HotspotTickHandlers::standardAnimHandler;
|
2007-09-23 22:17:57 +00:00
|
|
|
case 13:
|
2009-10-20 19:51:57 +00:00
|
|
|
return &HotspotTickHandlers::sonicRatAnimHandler;
|
2007-09-23 22:17:57 +00:00
|
|
|
case 14:
|
2009-10-20 19:51:57 +00:00
|
|
|
return &HotspotTickHandlers::droppingTorchAnimHandler;
|
2007-09-23 22:17:57 +00:00
|
|
|
case 15:
|
2009-10-20 19:51:57 +00:00
|
|
|
return &HotspotTickHandlers::playerSewerExitAnimHandler;
|
2007-09-23 22:17:57 +00:00
|
|
|
case 16:
|
2009-10-20 19:51:57 +00:00
|
|
|
return &HotspotTickHandlers::fireAnimHandler;
|
2007-09-23 22:17:57 +00:00
|
|
|
case 17:
|
2009-10-20 19:51:57 +00:00
|
|
|
return &HotspotTickHandlers::sparkleAnimHandler;
|
2007-09-23 22:17:57 +00:00
|
|
|
case 18:
|
2009-10-20 19:51:57 +00:00
|
|
|
return &HotspotTickHandlers::teaAnimHandler;
|
2007-09-23 22:17:57 +00:00
|
|
|
case 19:
|
2009-10-20 19:51:57 +00:00
|
|
|
return &HotspotTickHandlers::goewinCaptiveAnimHandler;
|
2007-09-23 22:17:57 +00:00
|
|
|
case 20:
|
2009-10-20 19:51:57 +00:00
|
|
|
return &HotspotTickHandlers::prisonerAnimHandler;
|
2007-09-23 22:17:57 +00:00
|
|
|
case 21:
|
2009-10-20 19:51:57 +00:00
|
|
|
return &HotspotTickHandlers::catrionaAnimHandler;
|
2007-09-23 22:17:57 +00:00
|
|
|
case 22:
|
2009-10-20 19:51:57 +00:00
|
|
|
return &HotspotTickHandlers::morkusAnimHandler;
|
2007-09-23 22:17:57 +00:00
|
|
|
case 23:
|
2009-10-20 19:51:57 +00:00
|
|
|
return &HotspotTickHandlers::grubAnimHandler;
|
2007-09-23 22:17:57 +00:00
|
|
|
case 24:
|
2009-10-20 19:51:57 +00:00
|
|
|
return &HotspotTickHandlers::barmanAnimHandler;
|
2007-09-23 22:17:57 +00:00
|
|
|
case 25:
|
2009-10-20 19:51:57 +00:00
|
|
|
return &HotspotTickHandlers::skorlAnimHandler;
|
2007-09-23 22:17:57 +00:00
|
|
|
case 26:
|
2009-10-20 19:51:57 +00:00
|
|
|
return &HotspotTickHandlers::gargoyleAnimHandler;
|
2007-06-22 12:36:04 +00:00
|
|
|
case GOEWIN_SHOP_TICK_PROC:
|
2009-10-20 19:51:57 +00:00
|
|
|
return &HotspotTickHandlers::goewinShopAnimHandler;
|
2007-09-23 22:17:57 +00:00
|
|
|
case 28:
|
|
|
|
case 29:
|
|
|
|
case 30:
|
|
|
|
case 31:
|
|
|
|
case 32:
|
|
|
|
case 33:
|
2009-10-20 19:51:57 +00:00
|
|
|
return &HotspotTickHandlers::skullAnimHandler;
|
2007-09-23 22:17:57 +00:00
|
|
|
case 34:
|
2009-10-20 19:51:57 +00:00
|
|
|
return &HotspotTickHandlers::dragonFireAnimHandler;
|
2007-09-23 22:17:57 +00:00
|
|
|
case 35:
|
2009-10-20 19:51:57 +00:00
|
|
|
return &HotspotTickHandlers::castleSkorlAnimHandler;
|
2007-09-23 22:17:57 +00:00
|
|
|
case 36:
|
2009-10-20 19:51:57 +00:00
|
|
|
return &HotspotTickHandlers::rackSerfAnimHandler;
|
2006-02-19 04:25:28 +00:00
|
|
|
case TALK_TICK_PROC_ID:
|
2009-10-20 19:51:57 +00:00
|
|
|
return &HotspotTickHandlers::talkAnimHandler;
|
2007-09-23 22:17:57 +00:00
|
|
|
case 38:
|
2009-10-20 19:51:57 +00:00
|
|
|
return &HotspotTickHandlers::fighterAnimHandler;
|
2007-06-22 12:36:04 +00:00
|
|
|
case PLAYER_FIGHT_TICK_PROC_ID:
|
2009-10-20 19:51:57 +00:00
|
|
|
return &HotspotTickHandlers::playerFightAnimHandler;
|
2006-02-11 12:54:56 +00:00
|
|
|
default:
|
2007-09-23 22:17:57 +00:00
|
|
|
error("Unknown tick proc Id %xh for hotspot", procIndex);
|
2006-02-11 12:54:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void HotspotTickHandlers::defaultHandler(Hotspot &h) {
|
|
|
|
// No handling done
|
|
|
|
}
|
|
|
|
|
|
|
|
void HotspotTickHandlers::standardAnimHandler(Hotspot &h) {
|
2007-11-17 10:49:14 +00:00
|
|
|
Resources &res = Resources::getReference();
|
|
|
|
|
2008-01-27 19:47:41 +00:00
|
|
|
if (h.frameCtr() > 0)
|
2007-11-07 09:39:48 +00:00
|
|
|
h.decrFrameCtr();
|
2007-11-17 10:49:14 +00:00
|
|
|
else {
|
|
|
|
if (h.executeScript()) {
|
|
|
|
// Script is finished - deactivate hotspot and move it to an out of range room
|
|
|
|
HotspotData *data = h.resource();
|
|
|
|
res.deactivateHotspot(&h);
|
|
|
|
data->roomNumber |= 0x8000;
|
|
|
|
}
|
|
|
|
}
|
2006-02-11 12:54:56 +00:00
|
|
|
}
|
|
|
|
|
2007-02-26 22:56:02 +00:00
|
|
|
void HotspotTickHandlers::standardAnimHandler2(Hotspot &h) {
|
|
|
|
h.handleTalkDialog();
|
2007-03-06 08:24:52 +00:00
|
|
|
standardAnimHandler(h);
|
2007-02-26 22:56:02 +00:00
|
|
|
}
|
|
|
|
|
2006-04-11 10:52:11 +00:00
|
|
|
void HotspotTickHandlers::standardCharacterAnimHandler(Hotspot &h) {
|
2006-05-23 12:43:42 +00:00
|
|
|
Resources &res = Resources::getReference();
|
2006-07-08 08:42:58 +00:00
|
|
|
ValueTableData &fields = res.fieldList();
|
2006-05-23 12:43:42 +00:00
|
|
|
RoomPathsData &paths = Resources::getReference().getRoom(h.roomNumber())->paths;
|
|
|
|
PathFinder &pathFinder = h.pathFinder();
|
|
|
|
CurrentActionStack &actions = h.currentActions();
|
2007-08-05 02:56:51 +00:00
|
|
|
Hotspot *player = res.getActiveHotspot(PLAYER_ID);
|
2006-05-23 12:43:42 +00:00
|
|
|
uint16 impingingList[MAX_NUM_IMPINGING];
|
|
|
|
int numImpinging;
|
2006-05-29 08:12:07 +00:00
|
|
|
bool bumpedPlayer;
|
2006-05-23 12:43:42 +00:00
|
|
|
|
2006-07-08 08:42:58 +00:00
|
|
|
if (h.currentActions().action() != WALKING) {
|
2010-11-07 01:03:03 +00:00
|
|
|
Common::String buffer = h.currentActions().getDebugInfo();
|
2008-01-27 19:47:41 +00:00
|
|
|
debugC(ERROR_DETAILED, kLureDebugAnimations, "Hotspot standard character p=(%d,%d,%d) bs=%d\n%s",
|
2010-11-07 01:03:03 +00:00
|
|
|
h.x(), h.y(), h.roomNumber(), h.blockedState(), buffer.c_str());
|
2006-07-08 08:42:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Handle any active talk dialog
|
|
|
|
h.handleTalkDialog();
|
|
|
|
|
2007-10-24 10:09:06 +00:00
|
|
|
// If someone is talking to the character, this stops them from moving for the duration)
|
|
|
|
if (h.resource()->talkerId != 0) {
|
|
|
|
debugC(ERROR_DETAILED, kLureDebugAnimations, "Talker Id = %xh, talk_gate = %d",
|
2007-11-10 22:47:11 +00:00
|
|
|
h.resource()->talkerId, h.talkGate());
|
2007-05-27 04:33:19 +00:00
|
|
|
if (h.talkGate() == GENERAL_MAGIC_ID) {
|
2007-04-19 06:46:56 +00:00
|
|
|
fields.setField(ACTIVE_HOTSPOT_ID, h.talkGate());
|
2007-10-24 10:09:06 +00:00
|
|
|
fields.setField(USE_HOTSPOT_ID, h.resource()->talkerId);
|
2007-04-29 11:30:29 +00:00
|
|
|
Script::execute(h.talkScript());
|
2007-10-24 10:09:06 +00:00
|
|
|
h.resource()->talkerId = 0;
|
2006-07-08 08:42:58 +00:00
|
|
|
} else {
|
|
|
|
h.updateMovement();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2006-05-23 12:43:42 +00:00
|
|
|
|
|
|
|
// If a frame countdown is in progress, then decrement and exit
|
|
|
|
if (h.frameCtr() > 0) {
|
2006-07-08 08:42:58 +00:00
|
|
|
debugC(ERROR_DETAILED, kLureDebugAnimations, "Frame ctr = %d", h.frameCtr());
|
2006-05-23 12:43:42 +00:00
|
|
|
h.decrFrameCtr();
|
|
|
|
return;
|
|
|
|
}
|
2006-04-11 10:52:11 +00:00
|
|
|
|
2006-07-08 08:42:58 +00:00
|
|
|
debugC(ERROR_DETAILED, kLureDebugAnimations, "Hotspot standard character point 2");
|
2006-05-23 12:43:42 +00:00
|
|
|
numImpinging = Support::findIntersectingCharacters(h, impingingList);
|
2006-05-29 08:12:07 +00:00
|
|
|
bumpedPlayer = (numImpinging == 0) ? false :
|
|
|
|
Support::isCharacterInList(impingingList, numImpinging, PLAYER_ID);
|
|
|
|
|
|
|
|
// Check for character having just changed room
|
2006-07-08 08:42:58 +00:00
|
|
|
debugC(ERROR_DETAILED, kLureDebugAnimations, "Hotspot standard character point 3");
|
2006-05-23 12:43:42 +00:00
|
|
|
if (h.skipFlag()) {
|
2006-07-08 08:42:58 +00:00
|
|
|
debugC(ERROR_DETAILED, kLureDebugAnimations, "Skip flag was set");
|
|
|
|
|
2006-05-23 12:43:42 +00:00
|
|
|
if (numImpinging > 0) {
|
2006-05-29 08:12:07 +00:00
|
|
|
// Scan to check if the character has bumped into player
|
|
|
|
if (bumpedPlayer && (player->characterMode() == CHARMODE_IDLE)) {
|
|
|
|
// Signal the player to move out of the way automatically
|
|
|
|
player->setBlockedState(BS_INITIAL);
|
|
|
|
player->setDestHotspot(0);
|
2006-07-08 08:42:58 +00:00
|
|
|
player->setRandomDest();
|
2006-05-29 08:12:07 +00:00
|
|
|
|
|
|
|
Room::getReference().setCursorState(CS_BUMPED);
|
2006-07-08 08:42:58 +00:00
|
|
|
debugC(ERROR_DETAILED, kLureDebugAnimations, "Player bumped code starting");
|
|
|
|
|
2006-05-29 08:12:07 +00:00
|
|
|
} else {
|
|
|
|
// Signal the character to pause briefly to allow bumped
|
|
|
|
// character time to start moving out of the way
|
|
|
|
h.setDelayCtr(10);
|
|
|
|
h.setCharacterMode(CHARMODE_PAUSED);
|
2006-07-08 08:42:58 +00:00
|
|
|
debugC(ERROR_DETAILED, kLureDebugAnimations, "Pausing after bumping into character");
|
2006-05-23 12:43:42 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2006-05-29 08:12:07 +00:00
|
|
|
|
2006-05-23 12:43:42 +00:00
|
|
|
h.setSkipFlag(false);
|
|
|
|
}
|
|
|
|
|
2007-08-05 02:56:51 +00:00
|
|
|
if (h.resource()->scriptHotspotId != 0) {
|
|
|
|
// Character bumped against another
|
|
|
|
fields.setField(USE_HOTSPOT_ID, h.resource()->scriptHotspotId);
|
|
|
|
Script::execute(h.resource()->tickScriptOffset);
|
|
|
|
h.resource()->scriptHotspotId = 0;
|
|
|
|
}
|
2006-05-23 12:43:42 +00:00
|
|
|
|
2006-07-08 08:42:58 +00:00
|
|
|
debugC(ERROR_DETAILED, kLureDebugAnimations, "Hotspot standard character point 4");
|
|
|
|
if (h.pauseCtr() != 0) {
|
|
|
|
debugC(ERROR_DETAILED, kLureDebugAnimations, "pause ctr = %d", h.pauseCtr());
|
|
|
|
h.updateMovement();
|
|
|
|
h.pathFinder().clear();
|
|
|
|
if (h.pauseCtr() > 1) {
|
|
|
|
res.pausedList().scan(h);
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
h.setPauseCtr(0);
|
|
|
|
if (h.characterMode() == CHARMODE_NONE) {
|
|
|
|
h.pathFinder().clear();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
debugC(ERROR_DETAILED, kLureDebugAnimations, "Hotspot standard character point 5");
|
2006-05-29 08:12:07 +00:00
|
|
|
if (h.characterMode() != CHARMODE_NONE) {
|
2008-01-27 19:47:41 +00:00
|
|
|
debugC(ERROR_DETAILED, kLureDebugAnimations, "char mode = %d, delay ctr = %d",
|
2006-07-08 08:42:58 +00:00
|
|
|
h.characterMode(), h.delayCtr());
|
|
|
|
|
2007-04-14 11:00:29 +00:00
|
|
|
if (h.characterMode() == CHARMODE_PLAYER_WAIT) {
|
2006-05-29 08:12:07 +00:00
|
|
|
h.updateMovement();
|
|
|
|
if (bumpedPlayer) return;
|
|
|
|
} else {
|
|
|
|
// All other character modes
|
|
|
|
if (h.delayCtr() > 0) {
|
|
|
|
// There is some countdown left to do
|
2007-08-05 02:56:51 +00:00
|
|
|
h.updateMovement();
|
2006-05-29 08:12:07 +00:00
|
|
|
|
2007-10-07 11:12:46 +00:00
|
|
|
bool decrementFlag = (h.resource()->actionHotspotId == 0);
|
|
|
|
if (!decrementFlag) {
|
2007-08-05 02:56:51 +00:00
|
|
|
HotspotData *hotspot = res.getHotspot(h.resource()->actionHotspotId);
|
2007-10-07 11:12:46 +00:00
|
|
|
assert(hotspot);
|
2007-11-10 22:47:11 +00:00
|
|
|
decrementFlag = (hotspot->roomNumber != h.roomNumber()) ? false :
|
2006-05-29 08:12:07 +00:00
|
|
|
Support::charactersIntersecting(hotspot, h.resource());
|
2007-08-05 02:56:51 +00:00
|
|
|
}
|
2006-05-29 08:12:07 +00:00
|
|
|
|
|
|
|
if (decrementFlag) {
|
|
|
|
h.setDelayCtr(h.delayCtr() - 1);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-08-27 11:48:41 +00:00
|
|
|
h.resource()->actionHotspotId = 0;
|
2006-05-29 08:12:07 +00:00
|
|
|
CharacterMode currentMode = h.characterMode();
|
|
|
|
h.setCharacterMode(CHARMODE_NONE);
|
|
|
|
h.pathFinder().clear();
|
|
|
|
|
2007-04-14 11:00:29 +00:00
|
|
|
if ((currentMode == CHARMODE_WAIT_FOR_PLAYER) || (currentMode == CHARMODE_WAIT_FOR_INTERACT)) {
|
2007-08-05 02:56:51 +00:00
|
|
|
h.resource()->talkOverride = 0;
|
2006-08-07 13:24:45 +00:00
|
|
|
h.showMessage(1);
|
2006-05-29 08:12:07 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2007-02-09 10:56:31 +00:00
|
|
|
|
2008-01-27 19:47:41 +00:00
|
|
|
/* interactHotspotId never seems to be set
|
2007-08-05 02:56:51 +00:00
|
|
|
if ((h.resource()->interactHotspotId != 0) && !player->currentActions().isEmpty()) {
|
|
|
|
h.setActionCtr(99);
|
2008-01-27 19:47:41 +00:00
|
|
|
if (!actions.isEmpty())
|
2007-08-05 02:56:51 +00:00
|
|
|
actions.top().setAction(DISPATCH_ACTION);
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
2006-07-08 08:42:58 +00:00
|
|
|
debugC(ERROR_DETAILED, kLureDebugAnimations, "Hotspot standard character point 6");
|
2006-05-23 12:43:42 +00:00
|
|
|
CurrentAction action = actions.action();
|
2007-05-07 12:16:05 +00:00
|
|
|
PathFinderResult pfResult;
|
2006-05-23 12:43:42 +00:00
|
|
|
|
|
|
|
switch (action) {
|
|
|
|
case NO_ACTION:
|
2007-09-16 08:03:18 +00:00
|
|
|
h.updateMovement2(CHARMODE_IDLE);
|
2006-05-23 12:43:42 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DISPATCH_ACTION:
|
|
|
|
// Dispatch an action
|
2006-07-08 08:42:58 +00:00
|
|
|
debugC(ERROR_DETAILED, kLureDebugAnimations, "Hotspot standard character dispatch action");
|
|
|
|
|
2006-05-23 12:43:42 +00:00
|
|
|
if (actions.top().roomNumber() == 0)
|
|
|
|
actions.top().setRoomNumber(h.roomNumber());
|
|
|
|
if (actions.top().roomNumber() == h.roomNumber()) {
|
|
|
|
// NPC in correct room for action
|
|
|
|
h.setSkipFlag(false);
|
|
|
|
h.doAction();
|
|
|
|
} else {
|
|
|
|
// NPC in wrong room for action
|
|
|
|
npcRoomChange(h);
|
2006-07-08 08:42:58 +00:00
|
|
|
debugC(ERROR_DETAILED, kLureDebugAnimations, "Hotspot standard character change room request");
|
2006-05-23 12:43:42 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EXEC_HOTSPOT_SCRIPT:
|
|
|
|
// A hotspot script is in progress for the player, so don't interrupt
|
2006-07-08 08:42:58 +00:00
|
|
|
debugC(ERROR_DETAILED, kLureDebugAnimations, "Hotspot standard character exec hotspot script");
|
2006-05-23 12:43:42 +00:00
|
|
|
if (h.executeScript()) {
|
|
|
|
// Script is finished
|
|
|
|
actions.top().setAction(DISPATCH_ACTION);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case START_WALKING:
|
2009-01-28 10:27:14 +00:00
|
|
|
// Start the character walking to the given destination
|
2008-01-27 19:47:41 +00:00
|
|
|
|
|
|
|
debugC(ERROR_DETAILED, kLureDebugAnimations,
|
2006-07-08 08:42:58 +00:00
|
|
|
"Hotspot standard character exec start walking => (%d,%d)",
|
|
|
|
h.destX(), h.destY());
|
2009-01-28 10:27:14 +00:00
|
|
|
|
|
|
|
h.setCoveredFlag(VB_INITIAL);
|
2008-01-27 19:47:41 +00:00
|
|
|
h.setOccupied(false);
|
2006-05-23 12:43:42 +00:00
|
|
|
pathFinder.reset(paths);
|
|
|
|
h.currentActions().top().setAction(PROCESSING_PATH);
|
|
|
|
|
|
|
|
// Deliberate fall through to processing walking path
|
|
|
|
|
|
|
|
case PROCESSING_PATH:
|
2006-07-08 08:42:58 +00:00
|
|
|
// Handle processing pathfinding
|
|
|
|
debugC(ERROR_DETAILED, kLureDebugAnimations, "Hotspot standard character processing path");
|
|
|
|
res.pausedList().scan(h);
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2007-05-07 12:16:05 +00:00
|
|
|
pfResult = pathFinder.process();
|
|
|
|
if (pfResult == PF_UNFINISHED) break;
|
2006-05-23 12:43:42 +00:00
|
|
|
|
2008-01-27 19:47:41 +00:00
|
|
|
debugC(ERROR_DETAILED, kLureDebugAnimations,
|
2007-05-07 12:16:05 +00:00
|
|
|
"pathFinder done: result = %d", pfResult);
|
2006-05-23 12:43:42 +00:00
|
|
|
|
2006-07-08 08:42:58 +00:00
|
|
|
// Post-processing checks
|
2008-01-27 19:47:41 +00:00
|
|
|
if ((pfResult == PF_OK) ||
|
2007-05-07 12:16:05 +00:00
|
|
|
((h.destHotspotId() == 0) && (pfResult == PF_DEST_OCCUPIED))) {
|
2006-07-08 08:42:58 +00:00
|
|
|
// Standard processing
|
|
|
|
debugC(ERROR_DETAILED, kLureDebugAnimations, "Standard result handling");
|
|
|
|
|
|
|
|
h.setBlockedState(BS_NONE);
|
|
|
|
if (h.pathFinder().isEmpty()) {
|
|
|
|
// No path was defined
|
|
|
|
h.currentActions().top().setAction(DISPATCH_ACTION);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
h.currentActions().top().setAction(WALKING);
|
2009-07-23 10:49:30 +00:00
|
|
|
|
|
|
|
// WORKAROUND: A character that had enteredg an exit area might have been blocked from entering the new room.
|
|
|
|
// The Y position adjust below could thus place a character further into the exit area. So don't do the
|
|
|
|
// position adjustment if the user is already in an exit area
|
|
|
|
int16 x = h.x() + (h.widthCopy() >> 1);
|
|
|
|
int16 y = h.y() + h.heightCopy() - (h.yCorrection() >> 1);
|
|
|
|
|
|
|
|
RoomData *roomData = Resources::getReference().getRoom(h.roomNumber());
|
|
|
|
RoomExitData *exitRec = roomData->exits.checkExits(x, y);
|
|
|
|
|
|
|
|
if (!exitRec)
|
|
|
|
h.setPosition(h.x(), h.y() & 0xfff8);
|
|
|
|
|
2006-07-08 08:42:58 +00:00
|
|
|
} else if (h.blockedState() == BS_FINAL) {
|
2007-02-09 10:56:31 +00:00
|
|
|
// If this point is reached, the character twice hasn't found a walking path
|
|
|
|
debugC(ERROR_DETAILED, kLureDebugAnimations, "Character is hopelessly blocked");
|
2006-07-08 08:42:58 +00:00
|
|
|
|
|
|
|
res.pausedList().reset(h.hotspotId());
|
|
|
|
h.updateMovement();
|
2007-02-09 10:56:31 +00:00
|
|
|
|
2006-07-08 08:42:58 +00:00
|
|
|
assert(!h.currentActions().isEmpty());
|
|
|
|
h.currentActions().pop();
|
|
|
|
|
2007-02-09 10:56:31 +00:00
|
|
|
h.setBlockedFlag(false);
|
2006-07-08 08:42:58 +00:00
|
|
|
h.setBlockedState(BS_NONE);
|
|
|
|
h.setCharacterMode(CHARMODE_PAUSED);
|
|
|
|
h.setDelayCtr(2);
|
|
|
|
|
2008-01-27 19:47:41 +00:00
|
|
|
if (h.currentActions().isEmpty() ||
|
2007-02-09 10:56:31 +00:00
|
|
|
(h.currentActions().top().roomNumber() != h.roomNumber()))
|
2006-07-08 08:42:58 +00:00
|
|
|
h.setDestHotspot(0xffff);
|
|
|
|
|
|
|
|
if (bumpedPlayer)
|
2007-04-14 11:00:29 +00:00
|
|
|
h.setCharacterMode(CHARMODE_PLAYER_WAIT);
|
2007-02-09 10:56:31 +00:00
|
|
|
|
2006-07-08 08:42:58 +00:00
|
|
|
} else {
|
2007-02-09 10:56:31 +00:00
|
|
|
debugC(ERROR_DETAILED, kLureDebugAnimations, "Character is blocked from moving");
|
2006-07-08 08:42:58 +00:00
|
|
|
CharacterScheduleEntry *newEntry = res.charSchedules().getEntry(RETURN_SUPPORT_ID);
|
|
|
|
assert(newEntry);
|
2008-01-27 19:47:41 +00:00
|
|
|
|
|
|
|
// Increment the blocked state
|
2006-07-08 08:42:58 +00:00
|
|
|
h.setBlockedState((BlockedState) ((int) h.blockedState() + 1));
|
2007-09-08 11:18:35 +00:00
|
|
|
if (!h.blockedFlag()) {
|
2007-02-09 10:56:31 +00:00
|
|
|
// Not already handling blocked, so add a new dummy action so that the new
|
|
|
|
// action set below will not replace the existing one
|
|
|
|
h.currentActions().addFront(DISPATCH_ACTION, 0);
|
|
|
|
h.setBlockedFlag(true);
|
|
|
|
}
|
2006-07-08 08:42:58 +00:00
|
|
|
|
2007-02-09 10:56:31 +00:00
|
|
|
// Set the current action
|
2006-07-08 08:42:58 +00:00
|
|
|
CurrentActionEntry &entry = h.currentActions().top();
|
|
|
|
entry.setAction(DISPATCH_ACTION);
|
|
|
|
entry.setSupportData(newEntry);
|
|
|
|
entry.setRoomNumber(h.roomNumber());
|
2008-01-27 19:47:41 +00:00
|
|
|
}
|
|
|
|
|
2006-07-08 08:42:58 +00:00
|
|
|
// If the top action is now walking, deliberately fall through to the case entry;
|
|
|
|
// otherwise break out to exit method
|
|
|
|
if (h.currentActions().isEmpty() || h.currentActions().top().action() != WALKING)
|
|
|
|
break;
|
2006-05-23 12:43:42 +00:00
|
|
|
|
|
|
|
case WALKING:
|
|
|
|
// The character is currently moving
|
2006-07-08 08:42:58 +00:00
|
|
|
debugC(ERROR_DETAILED, kLureDebugAnimations, "Hotspot standard character walking");
|
2008-01-27 19:47:41 +00:00
|
|
|
h.setOccupied(false);
|
2006-07-08 08:42:58 +00:00
|
|
|
|
2006-05-23 12:43:42 +00:00
|
|
|
// If the character is walking to an exit hotspot, make sure it's still open
|
|
|
|
if ((h.destHotspotId() != 0) && (h.destHotspotId() != 0xffff)) {
|
|
|
|
// Player is walking to a room exit hotspot
|
|
|
|
RoomExitJoinData *joinRec = res.getExitJoin(h.destHotspotId());
|
|
|
|
if (joinRec->blocked) {
|
|
|
|
// Exit now blocked, so stop walking
|
|
|
|
actions.top().setAction(DISPATCH_ACTION);
|
|
|
|
h.setOccupied(true);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-07-08 08:42:58 +00:00
|
|
|
if (res.pausedList().check(h.hotspotId(), numImpinging, impingingList) == 0) {
|
2008-01-27 19:47:41 +00:00
|
|
|
if (h.walkingStep())
|
2006-07-08 08:42:58 +00:00
|
|
|
// Walking done
|
|
|
|
h.currentActions().top().setAction(DISPATCH_ACTION);
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2008-10-04 11:10:25 +00:00
|
|
|
// if (h.destHotspotId() != 0) {
|
2006-07-08 08:42:58 +00:00
|
|
|
// Walking to an exit, check for any required room change
|
2007-12-07 12:01:44 +00:00
|
|
|
if (Support::checkRoomChange(h))
|
|
|
|
break;
|
2008-10-04 11:10:25 +00:00
|
|
|
// }
|
2006-05-23 12:43:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
h.setOccupied(true);
|
|
|
|
break;
|
|
|
|
}
|
2006-07-08 08:42:58 +00:00
|
|
|
debugC(ERROR_DETAILED, kLureDebugAnimations, "Hotspot standard character point 7");
|
|
|
|
}
|
|
|
|
|
|
|
|
void HotspotTickHandlers::voiceBubbleAnimHandler(Hotspot &h) {
|
|
|
|
Resources &res = Resources::getReference();
|
2008-01-27 19:47:41 +00:00
|
|
|
debugC(ERROR_DETAILED, kLureDebugAnimations,
|
|
|
|
"Voice Bubble anim handler: char = %xh, ctr = %d, char speaking ctr = %d",
|
|
|
|
h.hotspotId(), h.voiceCtr(),
|
2007-06-22 12:36:04 +00:00
|
|
|
res.getHotspot(res.getTalkingCharacter())->talkCountdown);
|
2006-07-08 08:42:58 +00:00
|
|
|
|
2008-01-27 19:47:41 +00:00
|
|
|
if (h.voiceCtr() != 0)
|
2006-07-08 08:42:58 +00:00
|
|
|
h.setVoiceCtr(h.voiceCtr() - 1);
|
|
|
|
|
|
|
|
if (h.voiceCtr() != 0) {
|
|
|
|
// Countdown not yet ended
|
2007-06-22 12:36:04 +00:00
|
|
|
HotspotData *charHotspot = res.getHotspot(res.getTalkingCharacter());
|
|
|
|
if (charHotspot->roomNumber == h.roomNumber()) {
|
2006-07-08 08:42:58 +00:00
|
|
|
// Character is still in the same room as when it began speaking
|
2007-06-22 12:36:04 +00:00
|
|
|
if (charHotspot->talkCountdown != 0) {
|
2006-07-08 08:42:58 +00:00
|
|
|
// Character still talking
|
2007-06-22 12:36:04 +00:00
|
|
|
if (!res.checkHotspotExtent(charHotspot)) {
|
2006-07-08 08:42:58 +00:00
|
|
|
// Set voice bubble off screen to hide it
|
|
|
|
h.setPosition(h.x(), -100);
|
|
|
|
} else {
|
|
|
|
// Keep voice bubble in track with character
|
2007-06-22 12:36:04 +00:00
|
|
|
h.setPosition(charHotspot->startX + charHotspot->talkX + 12,
|
|
|
|
charHotspot->startY + charHotspot->talkY - 18);
|
2006-07-08 08:42:58 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// End of voice time, so unload
|
|
|
|
res.deactivateHotspot(&h);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void HotspotTickHandlers::puzzledAnimHandler(Hotspot &h) {
|
|
|
|
Resources &res = Resources::getReference();
|
|
|
|
HotspotData *charHotspot = res.getHotspot(h.destHotspotId());
|
|
|
|
assert(charHotspot);
|
|
|
|
|
|
|
|
h.setVoiceCtr(h.voiceCtr() - 1);
|
|
|
|
if ((charHotspot->roomNumber != h.roomNumber()) || (h.voiceCtr() == 0) ||
|
|
|
|
!res.checkHotspotExtent(charHotspot)) {
|
|
|
|
// Remove the animation
|
|
|
|
res.deactivateHotspot(&h);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
h.setPosition(charHotspot->startX + charHotspot->talkX + 12,
|
|
|
|
charHotspot->startY + charHotspot->talkY - 20);
|
2006-04-11 10:52:11 +00:00
|
|
|
}
|
|
|
|
|
2006-02-11 12:54:56 +00:00
|
|
|
void HotspotTickHandlers::roomExitAnimHandler(Hotspot &h) {
|
2007-08-05 02:56:51 +00:00
|
|
|
Resources &res = Resources::getReference();
|
2007-08-12 11:19:01 +00:00
|
|
|
ValueTableData &fields = res.fieldList();
|
|
|
|
Room &room = Room::getReference();
|
|
|
|
|
2007-08-05 02:56:51 +00:00
|
|
|
RoomExitJoinData *rec = res.getExitJoin(h.hotspotId());
|
2006-02-11 12:54:56 +00:00
|
|
|
if (!rec) return;
|
2008-01-27 19:47:41 +00:00
|
|
|
RoomExitJoinStruct &rs = (rec->hotspots[0].hotspotId == h.hotspotId()) ?
|
2007-08-12 11:19:01 +00:00
|
|
|
rec->hotspots[0] : rec->hotspots[1];
|
2006-02-11 12:54:56 +00:00
|
|
|
|
2007-08-12 11:19:01 +00:00
|
|
|
if ((rec->blocked != 0) && (rs.currentFrame != rs.destFrame)) {
|
2006-04-29 11:22:05 +00:00
|
|
|
// Closing the door
|
|
|
|
h.setOccupied(true);
|
2006-02-11 12:54:56 +00:00
|
|
|
|
2007-08-12 11:19:01 +00:00
|
|
|
++rs.currentFrame;
|
|
|
|
if ((rs.currentFrame == rs.destFrame) && (h.hotspotId() == room.roomNumber()))
|
|
|
|
Sound.addSound(rs.closeSound);
|
|
|
|
|
|
|
|
} else if ((rec->blocked == 0) && (rs.currentFrame != 0)) {
|
2006-04-29 11:22:05 +00:00
|
|
|
// Opening the door
|
|
|
|
h.setOccupied(false);
|
|
|
|
|
2007-08-12 11:19:01 +00:00
|
|
|
--rs.currentFrame;
|
|
|
|
if ((rs.currentFrame == rs.destFrame) && (h.hotspotId() == room.roomNumber())) {
|
|
|
|
Sound.addSound(rs.openSound);
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2007-08-12 11:19:01 +00:00
|
|
|
// If in the outside village, trash reverb
|
|
|
|
if (fields.getField(AREA_FLAG) == 1)
|
|
|
|
Sound.musicInterface_TrashReverb();
|
2006-02-11 12:54:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-08-12 11:19:01 +00:00
|
|
|
h.setFrameNumber(rs.currentFrame);
|
2006-02-11 12:54:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void HotspotTickHandlers::playerAnimHandler(Hotspot &h) {
|
2006-04-11 10:52:11 +00:00
|
|
|
Resources &res = Resources::getReference();
|
2006-07-08 08:42:58 +00:00
|
|
|
Room &room = Room::getReference();
|
2006-04-11 10:52:11 +00:00
|
|
|
Mouse &mouse = Mouse::getReference();
|
|
|
|
RoomPathsData &paths = Resources::getReference().getRoom(h.roomNumber())->paths;
|
|
|
|
PathFinder &pathFinder = h.pathFinder();
|
|
|
|
CurrentActionStack &actions = h.currentActions();
|
|
|
|
uint16 impingingList[MAX_NUM_IMPINGING];
|
|
|
|
int numImpinging;
|
|
|
|
Action hsAction;
|
|
|
|
uint16 hotspotId;
|
|
|
|
HotspotData *hotspot;
|
2010-11-07 01:03:03 +00:00
|
|
|
Common::String buffer;
|
2006-07-08 08:42:58 +00:00
|
|
|
|
2010-11-07 01:03:03 +00:00
|
|
|
buffer = h.currentActions().getDebugInfo();
|
2008-01-27 19:47:41 +00:00
|
|
|
debugC(ERROR_DETAILED, kLureDebugAnimations,
|
|
|
|
"Hotspot player anim handler p=(%d,%d,%d) bs=%d\n%s",
|
2010-11-07 01:03:03 +00:00
|
|
|
h.x(), h.y(), h.roomNumber(), h.blockedState(), buffer.c_str());
|
2006-07-08 08:42:58 +00:00
|
|
|
|
|
|
|
h.handleTalkDialog();
|
|
|
|
|
|
|
|
// If a frame countdown is in progress, then decrement and exit
|
|
|
|
if (h.frameCtr() > 0) {
|
|
|
|
debugC(ERROR_DETAILED, kLureDebugAnimations, "Frame countdown = %d", h.frameCtr());
|
|
|
|
h.decrFrameCtr();
|
|
|
|
return;
|
|
|
|
}
|
2006-04-11 10:52:11 +00:00
|
|
|
|
|
|
|
numImpinging = Support::findIntersectingCharacters(h, impingingList);
|
2006-07-08 08:42:58 +00:00
|
|
|
|
2006-04-11 10:52:11 +00:00
|
|
|
if (h.skipFlag()) {
|
2006-07-08 08:42:58 +00:00
|
|
|
debugC(ERROR_DETAILED, kLureDebugAnimations, "Skip flag set: numImpinging = %d", numImpinging);
|
2008-01-27 19:47:41 +00:00
|
|
|
if (numImpinging > 0)
|
2006-04-11 10:52:11 +00:00
|
|
|
return;
|
|
|
|
h.setSkipFlag(false);
|
|
|
|
}
|
2007-08-05 02:56:51 +00:00
|
|
|
|
2008-01-27 19:47:41 +00:00
|
|
|
/* interactHotspotId never seems to be set
|
2007-08-05 02:56:51 +00:00
|
|
|
if (h.resource()->interactHotspotId != 0) {
|
|
|
|
h.resource()->interactHotspotId = 0;
|
|
|
|
Hotspot *hotspot = res.getActiveHotspot(h.resource()->interactHotspotId);
|
|
|
|
assert(hotspot);
|
|
|
|
if ((hotspot->characterMode() != CHARMODE_WAIT_FOR_INTERACT) &&
|
|
|
|
!actions.isEmpty())
|
|
|
|
actions.top().setAction(ACTION_NONE);
|
|
|
|
}
|
|
|
|
*/
|
2006-02-11 12:54:56 +00:00
|
|
|
|
2006-07-08 08:42:58 +00:00
|
|
|
if (h.pauseCtr() > 0) {
|
|
|
|
debugC(ERROR_DETAILED, kLureDebugAnimations, "Pause countdown = %d", h.pauseCtr());
|
|
|
|
h.updateMovement();
|
|
|
|
h.pathFinder().clear();
|
|
|
|
|
|
|
|
if (h.pauseCtr() == 1) {
|
|
|
|
h.setPauseCtr(0);
|
|
|
|
if (h.characterMode() == 0) {
|
|
|
|
h.setOccupied(false);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
res.pausedList().scan(h);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((h.characterMode() != CHARMODE_NONE) && (h.characterMode() != CHARMODE_IDLE)) {
|
|
|
|
if (h.delayCtr() != 0) {
|
|
|
|
debugC(ERROR_DETAILED, kLureDebugAnimations, "Delay countdown = %d", h.delayCtr());
|
|
|
|
h.updateMovement();
|
|
|
|
h.pathFinder().clear();
|
|
|
|
h.setDelayCtr(h.delayCtr() - 1);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
debugC(ERROR_DETAILED, kLureDebugAnimations, "Character mode = %d", h.characterMode());
|
|
|
|
h.setOccupied(false);
|
|
|
|
h.setCharacterMode(CHARMODE_NONE);
|
2007-08-05 02:56:51 +00:00
|
|
|
if (h.tempDest().counter != 0) {
|
2006-07-08 08:42:58 +00:00
|
|
|
// Start walking to the previously set destination
|
2007-08-05 02:56:51 +00:00
|
|
|
h.tempDest().counter = 0;
|
|
|
|
h.setDestPosition(h.tempDest().position.x, h.tempDest().position.y);
|
2006-07-08 08:42:58 +00:00
|
|
|
h.currentActions().addFront(START_WALKING, h.roomNumber());
|
|
|
|
h.setWalkFlag(false);
|
|
|
|
}
|
2006-04-11 10:52:11 +00:00
|
|
|
return;
|
|
|
|
}
|
2006-02-11 12:54:56 +00:00
|
|
|
|
2006-04-11 10:52:11 +00:00
|
|
|
CurrentAction action = actions.action();
|
2007-05-07 12:16:05 +00:00
|
|
|
PathFinderResult pfResult;
|
2006-02-11 12:54:56 +00:00
|
|
|
|
2006-04-11 10:52:11 +00:00
|
|
|
switch (action) {
|
|
|
|
case NO_ACTION:
|
|
|
|
// Make sure there is no longer any destination
|
|
|
|
h.setDestHotspot(0);
|
2006-05-29 08:12:07 +00:00
|
|
|
h.updateMovement2(CHARMODE_IDLE);
|
2007-12-02 04:52:01 +00:00
|
|
|
h.doNothing(NULL);
|
2006-07-08 08:42:58 +00:00
|
|
|
strcpy(room.statusLine(), "");
|
2006-04-11 10:52:11 +00:00
|
|
|
break;
|
2006-02-11 12:54:56 +00:00
|
|
|
|
2006-04-11 10:52:11 +00:00
|
|
|
case DISPATCH_ACTION:
|
|
|
|
// Dispatch an action
|
|
|
|
h.setDestHotspot(0);
|
2006-05-23 12:43:42 +00:00
|
|
|
|
2006-07-08 08:42:58 +00:00
|
|
|
hotspot = NULL;
|
2006-05-23 12:43:42 +00:00
|
|
|
if (actions.top().hasSupportData()) {
|
|
|
|
hsAction = actions.top().supportData().action();
|
2006-08-27 11:48:41 +00:00
|
|
|
|
2006-07-08 08:42:58 +00:00
|
|
|
if (actions.top().supportData().numParams() > 0) {
|
2007-12-11 09:20:24 +00:00
|
|
|
hotspotId = actions.top().supportData().param((hsAction == USE) ? 1 : 0);
|
2006-07-08 08:42:58 +00:00
|
|
|
hotspot = res.getHotspot(hotspotId);
|
2008-01-27 19:47:41 +00:00
|
|
|
}
|
2006-05-23 12:43:42 +00:00
|
|
|
} else {
|
|
|
|
hsAction = NONE;
|
|
|
|
}
|
|
|
|
|
2006-04-11 10:52:11 +00:00
|
|
|
h.doAction(hsAction, hotspot);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EXEC_HOTSPOT_SCRIPT:
|
|
|
|
// A hotspot script is in progress for the player, so don't interrupt
|
|
|
|
if (h.executeScript()) {
|
|
|
|
// Script is finished, so pop of the execution action
|
|
|
|
actions.pop();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case START_WALKING:
|
|
|
|
// Start the player walking to the given destination
|
2009-01-28 10:27:14 +00:00
|
|
|
h.setCoveredFlag(VB_INITIAL);
|
2008-01-27 19:47:41 +00:00
|
|
|
h.setOccupied(false);
|
2006-04-11 10:52:11 +00:00
|
|
|
|
|
|
|
// Reset the path finder / walking sequence
|
|
|
|
pathFinder.reset(paths);
|
|
|
|
|
|
|
|
// Set current action to processing walking path
|
|
|
|
actions.pop();
|
2006-05-23 12:43:42 +00:00
|
|
|
h.currentActions().addFront(PROCESSING_PATH, h.roomNumber());
|
2006-04-11 10:52:11 +00:00
|
|
|
// Deliberate fall through to processing walking path
|
|
|
|
|
|
|
|
case PROCESSING_PATH:
|
2006-05-29 08:12:07 +00:00
|
|
|
h.setCharacterMode(CHARMODE_NONE);
|
2006-07-08 08:42:58 +00:00
|
|
|
res.pausedList().scan(h);
|
|
|
|
|
2007-05-07 12:16:05 +00:00
|
|
|
pfResult = pathFinder.process();
|
|
|
|
if (pfResult == PF_UNFINISHED) break;
|
2006-04-11 10:52:11 +00:00
|
|
|
|
2008-01-27 19:47:41 +00:00
|
|
|
// Pathfinding is now complete
|
2010-11-07 01:03:03 +00:00
|
|
|
buffer = pathFinder.getDebugInfo();
|
2008-01-27 19:47:41 +00:00
|
|
|
debugC(ERROR_DETAILED, kLureDebugAnimations,
|
|
|
|
"Pathfind processing done; result=%d, walkFlag=%d\n%s",
|
2010-11-07 01:03:03 +00:00
|
|
|
pfResult, h.walkFlag(), buffer.c_str());
|
2006-07-08 08:42:58 +00:00
|
|
|
|
2008-01-27 19:47:41 +00:00
|
|
|
if ((pfResult != PF_OK) && (h.walkFlag() || (pfResult != PF_DEST_OCCUPIED))) {
|
|
|
|
|
2006-07-08 08:42:58 +00:00
|
|
|
debugC(ERROR_DETAILED, kLureDebugAnimations, "Blocked state checking");
|
|
|
|
if (h.blockedState() == BS_FINAL) {
|
|
|
|
res.pausedList().reset(h.hotspotId());
|
|
|
|
h.setBlockedState(BS_NONE);
|
|
|
|
h.currentActions().pop();
|
2007-04-14 11:00:29 +00:00
|
|
|
h.setCharacterMode(CHARMODE_PLAYER_WAIT);
|
2006-07-08 08:42:58 +00:00
|
|
|
h.setDelayCtr(7);
|
|
|
|
return;
|
|
|
|
|
|
|
|
} else if (h.blockedState() != BS_NONE) {
|
2007-08-05 02:56:51 +00:00
|
|
|
h.tempDest().position.x = h.destX();
|
|
|
|
h.tempDest().position.y = h.destY();
|
|
|
|
h.tempDest().counter = 1;
|
2006-07-08 08:42:58 +00:00
|
|
|
h.setBlockedState((BlockedState) ((int) h.blockedState() + 1));
|
|
|
|
h.setRandomDest();
|
|
|
|
return;
|
|
|
|
}
|
2006-05-29 08:12:07 +00:00
|
|
|
}
|
2006-07-08 08:42:58 +00:00
|
|
|
|
|
|
|
h.setCharacterMode(CHARMODE_NONE);
|
|
|
|
h.setPosition(h.x(), h.y() & 0xFFF8);
|
2006-04-11 10:52:11 +00:00
|
|
|
|
|
|
|
if (pathFinder.isEmpty()) {
|
2006-07-08 08:42:58 +00:00
|
|
|
mouse.setCursorNum(CURSOR_ARROW);
|
2007-11-07 09:39:48 +00:00
|
|
|
h.currentActions().top().setAction(DISPATCH_ACTION);
|
2006-04-11 10:52:11 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2006-07-08 08:42:58 +00:00
|
|
|
h.currentActions().top().setAction(WALKING);
|
2006-04-11 10:52:11 +00:00
|
|
|
if (mouse.getCursorNum() != CURSOR_CAMERA)
|
|
|
|
mouse.setCursorNum(CURSOR_ARROW);
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2006-04-11 10:52:11 +00:00
|
|
|
// Deliberate fall through to walking
|
|
|
|
|
|
|
|
case WALKING:
|
|
|
|
// The character is currently moving
|
2006-07-08 08:42:58 +00:00
|
|
|
h.setOccupied(false);
|
|
|
|
|
2007-04-15 10:49:59 +00:00
|
|
|
if (h.destHotspotId() != 0) {
|
2006-04-11 10:52:11 +00:00
|
|
|
RoomExitJoinData *joinRec = res.getExitJoin(h.destHotspotId());
|
2007-04-15 10:49:59 +00:00
|
|
|
if ((joinRec != NULL) && (joinRec->blocked)) {
|
|
|
|
// Player is walking to a blocked room exit, so stop walking
|
2006-04-11 10:52:11 +00:00
|
|
|
actions.pop();
|
2006-07-08 08:42:58 +00:00
|
|
|
h.setOccupied(true);
|
2006-04-11 10:52:11 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-07-08 08:42:58 +00:00
|
|
|
if (res.pausedList().check(PLAYER_ID, numImpinging, impingingList) == 0) {
|
|
|
|
if (h.walkingStep()) {
|
|
|
|
// Walking done
|
|
|
|
if (room.cursorState() == CS_BUMPED)
|
|
|
|
room.setCursorState(CS_NONE);
|
2007-08-05 02:56:51 +00:00
|
|
|
if (h.tempDest().counter != 0) {
|
2007-04-14 11:00:29 +00:00
|
|
|
h.setCharacterMode(CHARMODE_PLAYER_WAIT);
|
2006-11-12 04:39:10 +00:00
|
|
|
h.setDelayCtr(IDLE_COUNTDOWN_SIZE);
|
2006-07-08 08:42:58 +00:00
|
|
|
return;
|
|
|
|
}
|
2006-08-07 13:24:45 +00:00
|
|
|
|
2006-07-08 08:42:58 +00:00
|
|
|
h.currentActions().top().setAction(DISPATCH_ACTION);
|
|
|
|
}
|
2006-08-07 13:24:45 +00:00
|
|
|
|
2006-07-08 08:42:58 +00:00
|
|
|
// Check for whether need to change room
|
2006-09-03 08:39:06 +00:00
|
|
|
if (Support::checkRoomChange(h))
|
|
|
|
// Player changinge room - break now to avoid resetting occupied status
|
|
|
|
break;
|
2006-04-11 10:52:11 +00:00
|
|
|
}
|
2006-07-08 08:42:58 +00:00
|
|
|
h.setOccupied(true);
|
2006-04-11 10:52:11 +00:00
|
|
|
break;
|
2006-02-11 12:54:56 +00:00
|
|
|
}
|
2006-08-07 13:24:45 +00:00
|
|
|
|
|
|
|
debugC(ERROR_DETAILED, kLureDebugAnimations, "Hotspot player anim handler end");
|
2006-02-11 12:54:56 +00:00
|
|
|
}
|
|
|
|
|
2006-07-08 08:42:58 +00:00
|
|
|
void HotspotTickHandlers::followerAnimHandler(Hotspot &h) {
|
|
|
|
Resources &res = Resources::getReference();
|
|
|
|
ValueTableData &fields = res.fieldList();
|
|
|
|
Hotspot *player = res.getActiveHotspot(PLAYER_ID);
|
|
|
|
|
2007-09-23 22:17:57 +00:00
|
|
|
if ((h.resource()->tickProcId == FOLLOWER_TICK_PROC_2) || (fields.getField(37) == 0)) {
|
2007-06-22 12:36:04 +00:00
|
|
|
if (h.currentActions().isEmpty() && (h.roomNumber() != player->roomNumber())) {
|
2007-02-02 08:35:17 +00:00
|
|
|
// Character in different room than player
|
2008-01-27 19:47:41 +00:00
|
|
|
if (h.hotspotId() == GOEWIN_ID)
|
2006-07-08 08:42:58 +00:00
|
|
|
h.currentActions().addFront(DISPATCH_ACTION, player->roomNumber());
|
|
|
|
else {
|
|
|
|
// Scan through the translation list for an alternate destination room
|
2007-09-08 11:18:35 +00:00
|
|
|
const RoomTranslationRecord *p = &roomTranslations[0];
|
2006-07-08 08:42:58 +00:00
|
|
|
while ((p->srcRoom != 0) && (p->srcRoom != player->roomNumber()))
|
|
|
|
++p;
|
2010-10-06 09:55:41 +00:00
|
|
|
|
|
|
|
if (p->destRoom == h.roomNumber())
|
|
|
|
// Character is already in destination room, so set a random dest
|
|
|
|
h.setRandomDest();
|
|
|
|
else
|
|
|
|
// Move character to either the player's room, or found alternate destination
|
|
|
|
h.currentActions().addFront(DISPATCH_ACTION,
|
|
|
|
(p->srcRoom != 0) ? p->destRoom : player->roomNumber());
|
2006-07-08 08:42:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-02-22 06:29:09 +00:00
|
|
|
// If some action is in progress, do standard handling
|
|
|
|
if (h.characterMode() != CHARMODE_IDLE) {
|
2006-07-08 08:42:58 +00:00
|
|
|
standardCharacterAnimHandler(h);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-02-22 06:29:09 +00:00
|
|
|
// Handle any pause countdown
|
2007-02-22 08:17:41 +00:00
|
|
|
if (countdownCtr > 0) {
|
2007-02-22 06:29:09 +00:00
|
|
|
--countdownCtr;
|
|
|
|
standardCharacterAnimHandler(h);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Handle selecting a random action for the character to do
|
|
|
|
RandomActionSet *set = res.randomActions().getRoom(h.roomNumber());
|
2007-02-26 02:50:23 +00:00
|
|
|
if (!set) {
|
|
|
|
standardCharacterAnimHandler(h);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-08-24 23:04:25 +00:00
|
|
|
Common::RandomSource &rnd = LureEngine::getReference().rnd();
|
2007-02-22 06:29:09 +00:00
|
|
|
RandomActionType actionType;
|
|
|
|
uint16 scheduleId;
|
2007-09-19 13:55:05 +00:00
|
|
|
|
2007-02-22 06:29:09 +00:00
|
|
|
int actionIndex = rnd.getRandomNumber(set->numActions() - 1);
|
|
|
|
set->getEntry(actionIndex, actionType, scheduleId);
|
|
|
|
|
2007-02-22 08:17:41 +00:00
|
|
|
if (actionType == REPEAT_ONCE_DONE) {
|
2007-02-22 06:29:09 +00:00
|
|
|
// Repeat once random action that's already done, so don't repeat it
|
|
|
|
standardCharacterAnimHandler(h);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// For repeat once actions, make sure the character is in the same room as the player
|
2007-02-22 08:17:41 +00:00
|
|
|
if (actionType == REPEAT_ONCE) {
|
|
|
|
if (player->roomNumber() != h.roomNumber()) {
|
2007-02-22 06:29:09 +00:00
|
|
|
// Not in the same room, so don't do the action
|
|
|
|
standardCharacterAnimHandler(h);
|
|
|
|
return;
|
|
|
|
}
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2007-02-22 06:29:09 +00:00
|
|
|
// Flag the action as having been done, so it won't be repeated
|
|
|
|
set->setDone(actionIndex);
|
|
|
|
}
|
|
|
|
|
2007-02-22 08:17:41 +00:00
|
|
|
if (scheduleId == 0) {
|
2009-01-30 12:22:30 +00:00
|
|
|
// No special schedule to perform, so simply set a random destination
|
2007-02-22 06:29:09 +00:00
|
|
|
h.setRandomDest();
|
2007-02-22 08:17:41 +00:00
|
|
|
} else {
|
2007-02-22 06:29:09 +00:00
|
|
|
// Prepare the follower to standard the specified schedule
|
|
|
|
CharacterScheduleEntry *newEntry = res.charSchedules().getEntry(scheduleId);
|
|
|
|
assert(newEntry);
|
|
|
|
h.currentActions().addFront(DISPATCH_ACTION, newEntry, h.roomNumber());
|
|
|
|
|
|
|
|
// Set a random delay before beginning the action
|
|
|
|
countdownCtr = rnd.getRandomNumber(32);
|
|
|
|
}
|
|
|
|
|
2006-07-08 08:42:58 +00:00
|
|
|
standardCharacterAnimHandler(h);
|
|
|
|
}
|
|
|
|
|
2007-06-22 12:36:04 +00:00
|
|
|
void HotspotTickHandlers::jailorAnimHandler(Hotspot &h) {
|
2006-05-23 12:43:42 +00:00
|
|
|
Resources &res = Resources::getReference();
|
|
|
|
ValueTableData &fields = res.fieldList();
|
2007-08-12 11:19:01 +00:00
|
|
|
Game &game = Game::getReference();
|
2006-05-23 12:43:42 +00:00
|
|
|
HotspotData *player = res.getHotspot(PLAYER_ID);
|
|
|
|
|
2007-06-22 12:36:04 +00:00
|
|
|
if ((fields.getField(11) != 0) || (h.hotspotId() == CASTLE_SKORL_ID)) {
|
2007-08-12 11:19:01 +00:00
|
|
|
if (!h.skipFlag() && !game.preloadFlag() && (h.roomNumber() == player->roomNumber)) {
|
2007-06-22 12:36:04 +00:00
|
|
|
if (Support::charactersIntersecting(h.resource(), player)) {
|
|
|
|
// Skorl has caught the player
|
|
|
|
Game::getReference().setState(GS_RESTORE_RESTART | GS_CAUGHT);
|
|
|
|
}
|
2006-05-23 12:43:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
standardCharacterAnimHandler(h);
|
|
|
|
}
|
|
|
|
|
2007-04-15 10:49:59 +00:00
|
|
|
void HotspotTickHandlers::sonicRatAnimHandler(Hotspot &h) {
|
|
|
|
if (h.actionCtr() == 0) {
|
|
|
|
HotspotData *player = Resources::getReference().getHotspot(PLAYER_ID);
|
|
|
|
if (Support::charactersIntersecting(h.resource(), player))
|
|
|
|
h.setActionCtr(1);
|
|
|
|
} else {
|
|
|
|
standardAnimHandler(h);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-11 12:54:56 +00:00
|
|
|
void HotspotTickHandlers::droppingTorchAnimHandler(Hotspot &h) {
|
2008-01-27 19:47:41 +00:00
|
|
|
if (h.frameCtr() > 0)
|
2006-07-08 08:42:58 +00:00
|
|
|
h.setFrameCtr(h.frameCtr() - 1);
|
2006-02-11 12:54:56 +00:00
|
|
|
else {
|
|
|
|
bool result = h.executeScript();
|
|
|
|
if (result) {
|
|
|
|
// Changeover to the fire on the straw
|
|
|
|
Resources &res = Resources::getReference();
|
|
|
|
res.deactivateHotspot(h.hotspotId());
|
|
|
|
res.activateHotspot(0x41C);
|
|
|
|
|
2007-08-12 11:19:01 +00:00
|
|
|
// Add sound
|
2008-01-27 19:47:41 +00:00
|
|
|
Sound.addSound(8);
|
2007-08-12 11:19:01 +00:00
|
|
|
|
2006-05-11 08:04:41 +00:00
|
|
|
// Enable the fire and activate its animation
|
2006-02-11 12:54:56 +00:00
|
|
|
HotspotData *fire = res.getHotspot(0x418);
|
|
|
|
fire->flags |= 0x80;
|
2007-09-30 10:53:40 +00:00
|
|
|
fire->loadOffset = 4;
|
2006-02-11 12:54:56 +00:00
|
|
|
res.activateHotspot(0x418);
|
|
|
|
}
|
2008-01-28 00:14:17 +00:00
|
|
|
}
|
2006-02-11 12:54:56 +00:00
|
|
|
}
|
|
|
|
|
2007-01-31 02:33:20 +00:00
|
|
|
void HotspotTickHandlers::playerSewerExitAnimHandler(Hotspot &h) {
|
2007-09-08 11:18:35 +00:00
|
|
|
if (h.frameCtr() > 0) {
|
2007-01-31 02:33:20 +00:00
|
|
|
h.decrFrameCtr();
|
2007-09-08 11:18:35 +00:00
|
|
|
} else if (h.executeScript()) {
|
2007-01-31 02:33:20 +00:00
|
|
|
Resources &res = Resources::getReference();
|
|
|
|
|
|
|
|
// Deactive the dropping animation
|
|
|
|
h.setLayer(0);
|
|
|
|
res.deactivateHotspot(h.hotspotId());
|
|
|
|
|
|
|
|
// Position the player
|
|
|
|
Hotspot *playerHotspot = res.getActiveHotspot(PLAYER_ID);
|
|
|
|
playerHotspot->setPosition(FULL_SCREEN_WIDTH / 2, (FULL_SCREEN_HEIGHT - MENUBAR_Y_SIZE) / 2);
|
|
|
|
playerHotspot->setDirection(DOWN);
|
|
|
|
playerHotspot->setCharacterMode(CHARMODE_NONE);
|
|
|
|
|
|
|
|
// Setup Ratpouch
|
|
|
|
Hotspot *ratpouchHotspot = res.getActiveHotspot(RATPOUCH_ID);
|
2007-04-14 03:48:24 +00:00
|
|
|
assert(ratpouchHotspot);
|
2007-01-31 02:33:20 +00:00
|
|
|
ratpouchHotspot->setCharacterMode(CHARMODE_NONE);
|
|
|
|
ratpouchHotspot->setDelayCtr(0);
|
|
|
|
ratpouchHotspot->setActions(0x821C00);
|
2007-04-15 10:49:59 +00:00
|
|
|
|
|
|
|
// Ratpouch has previously been moved to room 8. Start him moving to room 7
|
|
|
|
ratpouchHotspot->currentActions().clear();
|
|
|
|
ratpouchHotspot->currentActions().addFront(DISPATCH_ACTION, 7);
|
2007-01-31 02:33:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-11 12:54:56 +00:00
|
|
|
void HotspotTickHandlers::fireAnimHandler(Hotspot &h) {
|
|
|
|
standardAnimHandler(h);
|
2006-04-11 10:52:11 +00:00
|
|
|
h.setOccupied(true);
|
2006-02-11 12:54:56 +00:00
|
|
|
}
|
|
|
|
|
2007-04-22 22:42:01 +00:00
|
|
|
void HotspotTickHandlers::sparkleAnimHandler(Hotspot &h) {
|
|
|
|
Resources &res = Resources::getReference();
|
|
|
|
Hotspot *player = res.getActiveHotspot(PLAYER_ID);
|
|
|
|
ValueTableData &fields = res.fieldList();
|
|
|
|
|
|
|
|
h.setRoomNumber(player->roomNumber());
|
|
|
|
h.setPosition(player->x() - 14, player->y() - 10);
|
|
|
|
h.setActionCtr(h.actionCtr() + 1);
|
|
|
|
if (h.actionCtr() == 6) {
|
2007-10-07 11:12:46 +00:00
|
|
|
int animIndex;
|
2007-04-22 22:42:01 +00:00
|
|
|
if ((fields.getField(11) == 2) || (fields.getField(28) != 0)) {
|
|
|
|
fields.setField(28, 0);
|
2007-10-07 11:12:46 +00:00
|
|
|
animIndex = PLAYER_ANIM_INDEX;
|
2007-04-22 22:42:01 +00:00
|
|
|
} else {
|
|
|
|
fields.setField(28, fields.getField(28) + 1);
|
2007-10-07 11:12:46 +00:00
|
|
|
animIndex = SELENA_ANIM_INDEX;
|
2007-04-22 22:42:01 +00:00
|
|
|
}
|
|
|
|
|
2007-10-07 11:12:46 +00:00
|
|
|
player->setAnimationIndex(animIndex);
|
2007-04-22 22:42:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (h.executeScript()) {
|
|
|
|
HotspotData *data = h.resource();
|
|
|
|
res.deactivateHotspot(&h);
|
|
|
|
data->roomNumber = 0x1A8;
|
|
|
|
|
|
|
|
if (fields.getField(28) != 0) {
|
|
|
|
Hotspot *ratpouch = res.getActiveHotspot(RATPOUCH_ID);
|
|
|
|
assert(ratpouch);
|
|
|
|
ratpouch->converse(NOONE_ID, 0x854, false);
|
|
|
|
|
|
|
|
uint16 dataId = res.getCharOffset(4);
|
|
|
|
CharacterScheduleEntry *entry = res.charSchedules().getEntry(dataId);
|
|
|
|
|
|
|
|
ratpouch->currentActions().addFront(DISPATCH_ACTION, entry, ratpouch->roomNumber());
|
|
|
|
ratpouch->setActionCtr(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-15 10:49:59 +00:00
|
|
|
void HotspotTickHandlers::teaAnimHandler(Hotspot &h) {
|
|
|
|
if (h.frameCtr() > 0) {
|
|
|
|
h.decrFrameCtr();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (h.executeScript()) {
|
|
|
|
// Signal that the tea is done
|
2007-04-29 11:30:29 +00:00
|
|
|
h.setHotspotScript(0xB82);
|
2007-04-15 10:49:59 +00:00
|
|
|
Resources::getReference().fieldList().setField(27, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-02 06:03:47 +00:00
|
|
|
void HotspotTickHandlers::goewinCaptiveAnimHandler(Hotspot &h) {
|
|
|
|
if (h.actionCtr() > 0) {
|
|
|
|
if (h.executeScript()) {
|
|
|
|
h.setTickProc(STANDARD_CHARACTER_TICK_PROC);
|
|
|
|
h.setActionCtr(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-07-08 08:42:58 +00:00
|
|
|
void HotspotTickHandlers::prisonerAnimHandler(Hotspot &h) {
|
|
|
|
ValueTableData &fields = Resources::getReference().fieldList();
|
2009-08-24 23:04:25 +00:00
|
|
|
Common::RandomSource &rnd = LureEngine::getReference().rnd();
|
2007-09-19 13:55:05 +00:00
|
|
|
|
2006-07-08 08:42:58 +00:00
|
|
|
h.handleTalkDialog();
|
|
|
|
if (h.frameCtr() > 0) {
|
|
|
|
h.setFrameCtr(h.frameCtr() - 1);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (h.actionCtr() != 0) {
|
|
|
|
if (h.executeScript() == 0) {
|
|
|
|
h.setActionCtr(0);
|
2007-04-29 11:30:29 +00:00
|
|
|
h.setHotspotScript(0x3E0);
|
2006-07-08 08:42:58 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((fields.getField(PRISONER_DEAD) == 0) && (rnd.getRandomNumber(65536) >= 6)) {
|
|
|
|
h.setActionCtr(1);
|
2007-04-29 11:30:29 +00:00
|
|
|
h.setHotspotScript(0x3F6);
|
2006-07-08 08:42:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-02-16 23:17:00 +00:00
|
|
|
void HotspotTickHandlers::catrionaAnimHandler(Hotspot &h) {
|
|
|
|
h.handleTalkDialog();
|
2007-03-06 08:24:52 +00:00
|
|
|
if (h.frameCtr() > 0) {
|
2007-02-16 23:17:00 +00:00
|
|
|
h.decrFrameCtr();
|
2007-03-06 08:24:52 +00:00
|
|
|
} else {
|
2007-02-16 23:17:00 +00:00
|
|
|
h.executeScript();
|
2007-11-12 10:30:23 +00:00
|
|
|
int delayVal = (h.actionCtr() == 0) ? 5 : h.actionCtr();
|
|
|
|
h.setFrameCtr(delayVal);
|
2007-02-16 23:17:00 +00:00
|
|
|
}
|
|
|
|
}
|
2006-07-08 08:42:58 +00:00
|
|
|
|
2007-03-06 08:24:52 +00:00
|
|
|
void HotspotTickHandlers::morkusAnimHandler(Hotspot &h) {
|
|
|
|
h.handleTalkDialog();
|
|
|
|
if (h.frameCtr() > 0) {
|
|
|
|
h.decrFrameCtr();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (h.executeScript()) {
|
|
|
|
// Script is done - set new script to one of two alternates randomly
|
2009-08-24 23:04:25 +00:00
|
|
|
Common::RandomSource &rnd = LureEngine::getReference().rnd();
|
2007-09-19 13:55:05 +00:00
|
|
|
|
2008-01-27 19:47:41 +00:00
|
|
|
h.setHotspotScript(rnd.getRandomNumber(100) >= 50 ? 0x54 : 0);
|
2007-03-06 08:24:52 +00:00
|
|
|
h.setFrameCtr(20 + rnd.getRandomNumber(63));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-19 04:25:28 +00:00
|
|
|
void HotspotTickHandlers::talkAnimHandler(Hotspot &h) {
|
|
|
|
// Talk handler
|
|
|
|
Resources &res = Resources::getReference();
|
|
|
|
StringData &strings = StringData::getReference();
|
|
|
|
Screen &screen = Screen::getReference();
|
2007-11-13 09:49:43 +00:00
|
|
|
Room &room = Room::getReference();
|
2006-02-19 04:25:28 +00:00
|
|
|
Mouse &mouse = Mouse::getReference();
|
|
|
|
TalkSelections &talkSelections = res.getTalkSelections();
|
|
|
|
TalkData *data = res.getTalkData();
|
2008-01-27 19:47:41 +00:00
|
|
|
TalkEntryList &entries = data->entries;
|
2006-07-08 08:42:58 +00:00
|
|
|
Hotspot *charHotspot;
|
2006-02-19 04:25:28 +00:00
|
|
|
char buffer[MAX_DESC_SIZE];
|
2010-01-19 23:48:55 +00:00
|
|
|
Common::Rect r;
|
2006-02-19 04:25:28 +00:00
|
|
|
int lineNum, numLines;
|
|
|
|
int selectedLine, responseNumber;
|
|
|
|
bool showSelections, keepTalkingFlag;
|
|
|
|
TalkEntryList::iterator i;
|
|
|
|
TalkEntryData *entry;
|
2006-07-08 08:42:58 +00:00
|
|
|
uint16 result, descId;
|
2006-02-19 04:25:28 +00:00
|
|
|
|
2006-07-08 08:42:58 +00:00
|
|
|
debugC(ERROR_DETAILED, kLureDebugAnimations, "Player talk anim handler state = %d", res.getTalkState());
|
2006-02-19 04:25:28 +00:00
|
|
|
switch (res.getTalkState()) {
|
|
|
|
case TALK_NONE:
|
2007-04-10 03:20:50 +00:00
|
|
|
talkDestCharacter = h.resource()->talkDestCharacterId;
|
2006-07-08 08:42:58 +00:00
|
|
|
assert(talkDestCharacter != 0);
|
2007-11-13 09:49:43 +00:00
|
|
|
|
|
|
|
// Make sure any other dialog is finished before we start talking
|
2007-11-16 08:59:18 +00:00
|
|
|
if (room.isDialogShowing())
|
2007-11-13 09:49:43 +00:00
|
|
|
return;
|
|
|
|
|
2006-07-08 08:42:58 +00:00
|
|
|
// Fall through to TALK_START
|
|
|
|
|
|
|
|
case TALK_START:
|
2006-02-19 04:25:28 +00:00
|
|
|
// Handle initial setup of talking options
|
|
|
|
// Reset talk entry pointer list
|
|
|
|
for (lineNum = 0; lineNum < MAX_TALK_SELECTIONS; ++lineNum)
|
|
|
|
talkSelections[lineNum] = NULL;
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2006-02-19 04:25:28 +00:00
|
|
|
// Loop through list to find entries to display
|
|
|
|
_talkResponse = NULL;
|
|
|
|
numLines = 0;
|
|
|
|
showSelections = false;
|
|
|
|
|
|
|
|
i = entries.begin();
|
|
|
|
for (lineNum = 0; lineNum < res.getTalkStartEntry(); ++lineNum)
|
|
|
|
if (i != entries.end()) ++i;
|
|
|
|
|
|
|
|
for (; i != entries.end(); ++i) {
|
2008-04-06 12:00:37 +00:00
|
|
|
entry = (*i).get();
|
2006-02-19 04:25:28 +00:00
|
|
|
uint8 flags = (uint8) (entry->descId >> 14);
|
2008-01-27 19:47:41 +00:00
|
|
|
if (flags == 3)
|
2006-02-19 04:25:28 +00:00
|
|
|
// Skip the entry
|
|
|
|
continue;
|
|
|
|
|
|
|
|
uint16 sequenceOffset = entry->preSequenceId & 0x3fff;
|
|
|
|
bool showLine = sequenceOffset == 0;
|
2006-07-08 08:42:58 +00:00
|
|
|
if (!showLine) {
|
2008-01-27 19:47:41 +00:00
|
|
|
debugC(ERROR_DETAILED, kLureDebugAnimations,
|
2006-07-08 08:42:58 +00:00
|
|
|
"Checking whether to display line: script=%xh, descId=%d",
|
|
|
|
sequenceOffset, entry->descId);
|
2006-02-19 04:25:28 +00:00
|
|
|
showLine = Script::execute(sequenceOffset) != 0;
|
2006-07-08 08:42:58 +00:00
|
|
|
}
|
2006-02-19 04:25:28 +00:00
|
|
|
|
|
|
|
if (showLine) {
|
|
|
|
talkSelections[numLines++] = entry;
|
|
|
|
showSelections |= (entry->descId & 0x3fff) != TALK_MAGIC_ID;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((entry->preSequenceId & 0x8000) != 0) break;
|
|
|
|
}
|
|
|
|
|
2007-05-27 04:33:19 +00:00
|
|
|
if (showSelections && (numLines > 1)) {
|
2006-02-19 04:25:28 +00:00
|
|
|
res.setTalkState(TALK_SELECT);
|
2007-05-27 04:33:19 +00:00
|
|
|
|
|
|
|
// Make sure the dest character holds still while an option is selected
|
2007-11-11 20:17:13 +00:00
|
|
|
//HotspotData *destHotspot = res.getHotspot(talkDestCharacter);
|
2007-11-10 22:47:11 +00:00
|
|
|
//destHotspot->talkerId = h.hotspotId();
|
2007-05-27 04:33:19 +00:00
|
|
|
} else {
|
2006-02-19 04:25:28 +00:00
|
|
|
res.setTalkState(TALK_RESPOND);
|
|
|
|
res.setTalkSelection(1);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TALK_SELECT:
|
|
|
|
r.left = 0; r.right = FULL_SCREEN_WIDTH - 1;
|
|
|
|
selectedLine = mouse.y() / MENUBAR_Y_SIZE;
|
2008-01-27 19:47:41 +00:00
|
|
|
if ((selectedLine > MAX_TALK_SELECTIONS) || ((selectedLine != 0) &&
|
2006-02-19 04:25:28 +00:00
|
|
|
!talkSelections[selectedLine-1]))
|
|
|
|
selectedLine = 0;
|
|
|
|
|
|
|
|
for (lineNum = 0; lineNum < MAX_TALK_SELECTIONS; ++lineNum) {
|
|
|
|
if (!talkSelections[lineNum]) break;
|
|
|
|
entry = talkSelections[lineNum];
|
|
|
|
|
2006-08-07 13:24:45 +00:00
|
|
|
strings.getString(entry->descId & 0x3fff, buffer);
|
2006-02-19 04:25:28 +00:00
|
|
|
|
|
|
|
// Clear line
|
|
|
|
r.top = (lineNum + 1) * MENUBAR_Y_SIZE;
|
|
|
|
r.bottom = r.top + MENUBAR_Y_SIZE - 1;
|
|
|
|
screen.screen().fillRect(r, 0);
|
|
|
|
|
|
|
|
// Display line
|
2011-04-14 12:12:27 +00:00
|
|
|
byte color = LureEngine::getReference().isEGA() ?
|
|
|
|
((lineNum + 1 == selectedLine) ? EGA_DIALOG_WHITE_COLOR : EGA_DIALOG_TEXT_COLOR) :
|
|
|
|
((lineNum + 1 == selectedLine) ? VGA_DIALOG_WHITE_COLOR : VGA_DIALOG_TEXT_COLOR);
|
|
|
|
screen.screen().writeString(r.left, r.top, buffer, false, color);
|
2006-02-19 04:25:28 +00:00
|
|
|
}
|
|
|
|
|
2007-12-29 10:38:30 +00:00
|
|
|
if (mouse.mButton() || mouse.rButton()) {
|
|
|
|
// Abort the conversation
|
|
|
|
talkEndConversation();
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2007-12-29 10:38:30 +00:00
|
|
|
// Have destination character show question speech bubble
|
|
|
|
charHotspot = res.getActiveHotspot(talkDestCharacter);
|
|
|
|
if (charHotspot != NULL)
|
|
|
|
charHotspot->showMessage(13, NOONE_ID);
|
2006-02-19 04:25:28 +00:00
|
|
|
|
2007-12-29 10:38:30 +00:00
|
|
|
} else if (mouse.lButton() && (selectedLine != 0)) {
|
|
|
|
// Set the talk response index to use
|
|
|
|
res.setTalkSelection(selectedLine);
|
|
|
|
res.setTalkState(TALK_RESPOND);
|
|
|
|
}
|
2006-02-19 04:25:28 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TALK_RESPOND:
|
|
|
|
// Handle initial response to show the question in a talk dialog if needed
|
2006-07-08 08:42:58 +00:00
|
|
|
|
2007-11-12 09:53:10 +00:00
|
|
|
if (h.resource()->talkCountdown != 0) {
|
|
|
|
// Current talk dialog already pending needs to finish
|
|
|
|
h.handleTalkDialog();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-07-08 08:42:58 +00:00
|
|
|
// Get the original question for display
|
2006-02-19 04:25:28 +00:00
|
|
|
selectedLine = res.getTalkSelection();
|
|
|
|
entry = talkSelections[selectedLine-1];
|
|
|
|
descId = entry->descId & 0x3fff;
|
|
|
|
entry->descId |= 0x4000;
|
2006-07-08 08:42:58 +00:00
|
|
|
debugC(ERROR_DETAILED, kLureDebugAnimations, "Talk line set: line=#%d, desc=%xh",
|
|
|
|
selectedLine, descId);
|
|
|
|
|
|
|
|
// Get the response the destination character will say
|
2007-04-22 22:42:01 +00:00
|
|
|
if (descId != TALK_MAGIC_ID) {
|
2006-07-08 08:42:58 +00:00
|
|
|
// Set up to display the question and response in talk dialogs
|
2007-11-10 22:47:11 +00:00
|
|
|
h.converse(talkDestCharacter, descId);
|
2007-04-22 22:42:01 +00:00
|
|
|
res.setTalkState(TALK_RESPOND_2);
|
|
|
|
} else {
|
|
|
|
res.setTalkState(TALK_RESPOND_3);
|
|
|
|
}
|
2006-02-19 04:25:28 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TALK_RESPOND_2:
|
2006-07-08 08:42:58 +00:00
|
|
|
// Wait until the question dialog is no longer active
|
|
|
|
h.handleTalkDialog();
|
2008-01-27 19:47:41 +00:00
|
|
|
debugC(ERROR_DETAILED, kLureDebugAnimations, "Player talk dialog countdown %d",
|
2006-07-08 08:42:58 +00:00
|
|
|
h.resource()->talkCountdown);
|
|
|
|
|
|
|
|
if (res.getTalkingCharacter() != 0)
|
|
|
|
return;
|
|
|
|
|
2007-04-22 22:42:01 +00:00
|
|
|
case TALK_RESPOND_3:
|
|
|
|
// Respond
|
2006-07-08 08:42:58 +00:00
|
|
|
selectedLine = res.getTalkSelection();
|
|
|
|
entry = talkSelections[selectedLine-1];
|
|
|
|
|
|
|
|
responseNumber = entry->postSequenceId;
|
|
|
|
debugC(ERROR_DETAILED, kLureDebugAnimations, "Post sequence Id = %xh", responseNumber);
|
|
|
|
|
|
|
|
if ((responseNumber & 0x8000) != 0) {
|
|
|
|
responseNumber = Script::execute(responseNumber & 0x7fff);
|
|
|
|
debugC(ERROR_DETAILED, kLureDebugAnimations, "Post sequence Id = %xh", responseNumber);
|
2006-02-19 04:25:28 +00:00
|
|
|
}
|
|
|
|
|
2006-07-08 08:42:58 +00:00
|
|
|
do {
|
|
|
|
_talkResponse = res.getTalkData()->getResponse(responseNumber);
|
|
|
|
debugC(ERROR_DETAILED, kLureDebugAnimations, "Character response pre id = %xh",
|
|
|
|
_talkResponse->preSequenceId);
|
|
|
|
|
|
|
|
if (!_talkResponse->preSequenceId) break;
|
|
|
|
responseNumber = Script::execute(_talkResponse->preSequenceId);
|
|
|
|
debugC(ERROR_DETAILED, kLureDebugAnimations, "Character response new response = %d",
|
|
|
|
responseNumber);
|
|
|
|
} while (responseNumber != TALK_RESPONSE_MAGIC_ID);
|
|
|
|
|
|
|
|
descId = _talkResponse->descId;
|
|
|
|
if ((descId & 0x8000) != 0)
|
|
|
|
descId = Script::execute(descId & 0x7fff);
|
|
|
|
|
|
|
|
if (descId != TALK_MAGIC_ID) {
|
|
|
|
charHotspot = res.getActiveHotspot(talkDestCharacter);
|
|
|
|
|
|
|
|
if (charHotspot != NULL)
|
|
|
|
charHotspot->converse(PLAYER_ID, descId, true);
|
2008-01-27 19:47:41 +00:00
|
|
|
}
|
2006-07-08 08:42:58 +00:00
|
|
|
res.setTalkState(TALK_RESPONSE_WAIT);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TALK_RESPONSE_WAIT:
|
|
|
|
// Wait until the character's response has finished being displayed
|
2007-11-15 10:07:46 +00:00
|
|
|
h.handleTalkDialog();
|
|
|
|
|
2006-07-08 08:42:58 +00:00
|
|
|
charHotspot = res.getActiveHotspot(talkDestCharacter);
|
2007-11-12 09:53:10 +00:00
|
|
|
assert(charHotspot);
|
2008-01-27 19:47:41 +00:00
|
|
|
debugC(ERROR_DETAILED, kLureDebugAnimations, "Player talk dialog countdown %d",
|
2006-07-08 08:42:58 +00:00
|
|
|
(charHotspot) ? charHotspot->resource()->talkCountdown : 0);
|
|
|
|
|
2007-11-12 09:53:10 +00:00
|
|
|
if ((charHotspot->resource()->talkCountdown > 0) || (res.getTalkingCharacter() != 0))
|
2006-07-08 08:42:58 +00:00
|
|
|
return;
|
|
|
|
|
2006-02-19 04:25:28 +00:00
|
|
|
result = _talkResponse->postSequenceId;
|
2006-07-08 08:42:58 +00:00
|
|
|
debugC(ERROR_DETAILED, kLureDebugAnimations, "Character response post id = %xh", result);
|
|
|
|
|
2006-02-19 04:25:28 +00:00
|
|
|
if (result == 0xffff)
|
|
|
|
keepTalkingFlag = false;
|
|
|
|
else {
|
2008-01-27 19:47:41 +00:00
|
|
|
if ((result & 0x8000) == 0)
|
2006-02-19 04:25:28 +00:00
|
|
|
keepTalkingFlag = true;
|
|
|
|
else {
|
|
|
|
result = Script::execute(result & 0x7fff);
|
|
|
|
keepTalkingFlag = result != 0xffff;
|
|
|
|
}
|
|
|
|
}
|
2006-07-08 08:42:58 +00:00
|
|
|
|
|
|
|
debugC(ERROR_DETAILED, kLureDebugAnimations, "Keep Talking flag = %d", keepTalkingFlag);
|
|
|
|
|
2006-02-19 04:25:28 +00:00
|
|
|
if (keepTalkingFlag) {
|
|
|
|
// Reset for loading the next set of talking options
|
|
|
|
res.setTalkStartEntry(result);
|
2006-07-08 08:42:58 +00:00
|
|
|
res.setTalkState(TALK_START);
|
2006-02-19 04:25:28 +00:00
|
|
|
} else {
|
|
|
|
// End the conversation
|
2007-12-29 10:38:30 +00:00
|
|
|
talkEndConversation();
|
2006-02-19 04:25:28 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-12-29 10:38:30 +00:00
|
|
|
void HotspotTickHandlers::talkEndConversation() {
|
|
|
|
Resources &res = Resources::getReference();
|
|
|
|
Hotspot *charHotspot = res.getActiveHotspot(talkDestCharacter);
|
|
|
|
assert(charHotspot);
|
|
|
|
|
|
|
|
res.getActiveHotspot(PLAYER_ID)->setTickProc(PLAYER_TICK_PROC_ID);
|
|
|
|
charHotspot->setUseHotspotId(0);
|
|
|
|
charHotspot->resource()->talkerId = 0;
|
|
|
|
charHotspot->setDelayCtr(24);
|
|
|
|
|
|
|
|
res.setTalkData(0);
|
|
|
|
res.setCurrentAction(NONE);
|
|
|
|
res.setTalkState(TALK_NONE);
|
|
|
|
}
|
|
|
|
|
2007-06-22 12:36:04 +00:00
|
|
|
void HotspotTickHandlers::fighterAnimHandler(Hotspot &h) {
|
|
|
|
Fights.fighterAnimHandler(h);
|
|
|
|
}
|
|
|
|
|
|
|
|
void HotspotTickHandlers::playerFightAnimHandler(Hotspot &h) {
|
|
|
|
Fights.playerAnimHandler(h);
|
|
|
|
}
|
|
|
|
|
2007-04-17 03:48:51 +00:00
|
|
|
void HotspotTickHandlers::grubAnimHandler(Hotspot &h) {
|
2006-02-11 12:54:56 +00:00
|
|
|
Resources &res = Resources::getReference();
|
2007-04-17 03:48:51 +00:00
|
|
|
h.handleTalkDialog();
|
|
|
|
|
2006-02-11 12:54:56 +00:00
|
|
|
Hotspot *character = res.getActiveHotspot(PLAYER_ID);
|
|
|
|
uint16 frameNumber = 0;
|
|
|
|
|
|
|
|
if (character->y() < 79) {
|
2007-04-17 03:48:51 +00:00
|
|
|
// If player is behind Grub, use Ratpouch if possible
|
|
|
|
Hotspot *ratpouch = res.getActiveHotspot(RATPOUCH_ID);
|
|
|
|
if ((ratpouch != NULL) && (ratpouch->roomNumber() == h.roomNumber()))
|
|
|
|
character = ratpouch;
|
2006-02-11 12:54:56 +00:00
|
|
|
}
|
|
|
|
|
2007-04-17 03:48:51 +00:00
|
|
|
if (character->x() < 72) frameNumber = 0;
|
|
|
|
else if (character->x() < 172) frameNumber = 1;
|
|
|
|
else frameNumber = 2;
|
|
|
|
|
|
|
|
h.setActionCtr(frameNumber);
|
2006-02-11 12:54:56 +00:00
|
|
|
h.setFrameNumber(frameNumber);
|
|
|
|
}
|
|
|
|
|
2007-04-14 03:48:24 +00:00
|
|
|
void HotspotTickHandlers::barmanAnimHandler(Hotspot &h) {
|
|
|
|
Resources &res = Resources::getReference();
|
|
|
|
Room &room = Room::getReference();
|
|
|
|
BarEntry &barEntry = res.barmanLists().getDetails(h.roomNumber());
|
2009-08-24 23:04:25 +00:00
|
|
|
Common::RandomSource &rnd = LureEngine::getReference().rnd();
|
2007-04-14 03:48:24 +00:00
|
|
|
|
2007-04-02 06:03:47 +00:00
|
|
|
h.handleTalkDialog();
|
2007-04-14 03:48:24 +00:00
|
|
|
if (h.delayCtr() > 0) {
|
|
|
|
h.setDelayCtr(h.delayCtr() - 1);
|
2007-04-02 06:03:47 +00:00
|
|
|
return;
|
|
|
|
}
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2007-04-14 03:48:24 +00:00
|
|
|
if (h.frameCtr() == 0) {
|
|
|
|
// Barman not currently doing something
|
|
|
|
if (barEntry.currentCustomer != NULL) {
|
|
|
|
// A customer has been set to be served
|
|
|
|
Hotspot *servee = res.getActiveHotspot(barEntry.currentCustomer->hotspotId);
|
|
|
|
if (servee != NULL) {
|
|
|
|
// Check whether the character is still at the bar
|
|
|
|
if ((servee->y() + servee->heightCopy()) >= ((barEntry.gridLine << 3) + 24)) {
|
|
|
|
// Customer has left - nullify their entry
|
|
|
|
barEntry.currentCustomer->hotspotId = 0;
|
|
|
|
barEntry.currentCustomer->serveFlags = 0;
|
|
|
|
barEntry.currentCustomer = NULL;
|
|
|
|
}
|
|
|
|
else if (servee->hotspotId() != PLAYER_ID) {
|
|
|
|
// Any other NPC character, so serve them
|
|
|
|
barEntry.currentCustomer->serveFlags = 0;
|
|
|
|
} else {
|
|
|
|
// Servee is the player, flag to stop the barman until the player walks away
|
|
|
|
barEntry.currentCustomer->serveFlags &= 0x7f;
|
|
|
|
|
|
|
|
if ((barEntry.currentCustomer->serveFlags & 7) != 0) {
|
|
|
|
// Barman needs to do something
|
|
|
|
h.setFrameCtr(barEntry.currentCustomer->serveFlags);
|
|
|
|
barEntry.currentCustomer->serveFlags &= 0xf8;
|
|
|
|
|
2007-10-24 10:09:06 +00:00
|
|
|
} else if (h.resource()->talkerId == 0) {
|
|
|
|
// Barman is not currently being talked to
|
2007-04-14 03:48:24 +00:00
|
|
|
// Clear entry from list
|
|
|
|
barEntry.currentCustomer->hotspotId = 0;
|
|
|
|
barEntry.currentCustomer->serveFlags = 0;
|
|
|
|
barEntry.currentCustomer = NULL;
|
|
|
|
// Set the barman to polish the bar
|
|
|
|
h.setFrameCtr(2);
|
|
|
|
}
|
|
|
|
}
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2007-04-14 03:48:24 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check for any customer waiting to be served
|
|
|
|
for (int index = 0; index < NUM_SERVE_CUSTOMERS; ++index) {
|
|
|
|
if ((barEntry.customers[index].serveFlags & 0x80) != 0) {
|
|
|
|
// Found one to serve
|
|
|
|
barEntry.customers[index].serveFlags = 0;
|
|
|
|
barEntry.currentCustomer = &barEntry.customers[index];
|
|
|
|
Hotspot *hotspot = res.getActiveHotspot(barEntry.customers[index].hotspotId);
|
|
|
|
assert(hotspot);
|
|
|
|
h.setSupportValue(hotspot->x()); // Save the position to move to
|
|
|
|
h.setFrameCtr(0x80); // Flag for movement
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// At this point, no customers need servering. Empty the table
|
|
|
|
barEntry.currentCustomer = NULL;
|
|
|
|
for (int index = 0; index < NUM_SERVE_CUSTOMERS; ++index) {
|
|
|
|
barEntry.customers[index].hotspotId = 0;
|
|
|
|
barEntry.customers[index].serveFlags = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Choose a random action for the barman to do - walk around, polish the bar, or wait
|
|
|
|
h.setFrameCtr(rnd.getRandomNumber(2) + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// At this point the barman is known to be doing something
|
|
|
|
|
|
|
|
if ((h.frameCtr() & 0x80) != 0) {
|
|
|
|
// Bit 7 being set indicates the barman is moving to a destination
|
|
|
|
int16 xDiff = h.x() - h.supportValue();
|
|
|
|
if (ABS(xDiff) >= 2) {
|
|
|
|
// Keep the barman moving
|
|
|
|
if (xDiff > 0) {
|
|
|
|
// Moving left
|
|
|
|
h.setPosition(h.x() - 2, h.y());
|
|
|
|
h.setActionCtr(h.actionCtr() + 1);
|
|
|
|
if ((h.actionCtr() >= 12) || (h.actionCtr() < 6))
|
|
|
|
h.setActionCtr(6);
|
|
|
|
} else {
|
|
|
|
// Moving right
|
|
|
|
h.setPosition(h.x() + 2, h.y());
|
|
|
|
h.setActionCtr(h.actionCtr() + 1);
|
|
|
|
if (h.actionCtr() >= 6) h.setActionCtr(0);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Stop the barman moving
|
|
|
|
h.setActionCtr(12);
|
|
|
|
h.setFrameCtr(h.frameCtr() & 0x7f);
|
|
|
|
}
|
|
|
|
|
|
|
|
h.setFrameNumber(h.actionCtr());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// All other actions
|
|
|
|
uint16 xp, id;
|
2007-09-08 11:18:35 +00:00
|
|
|
const uint16 *frameList;
|
2007-04-14 03:48:24 +00:00
|
|
|
uint16 frameNumber;
|
|
|
|
|
|
|
|
BarmanAction action = (BarmanAction) (h.frameCtr() & 0x3F);
|
|
|
|
switch (action) {
|
|
|
|
case WALK_AROUND:
|
|
|
|
// Wander around between the ends of the bar
|
|
|
|
if (h.hotspotId() == EWAN_ID)
|
|
|
|
xp = rnd.getRandomNumber(51) + 94;
|
|
|
|
else
|
2008-01-27 19:47:41 +00:00
|
|
|
xp = rnd.getRandomNumber(85) + 117;
|
2007-04-14 03:48:24 +00:00
|
|
|
|
|
|
|
h.setSupportValue(xp);
|
|
|
|
h.setFrameCtr(0x83);
|
|
|
|
return;
|
|
|
|
|
|
|
|
case POLISH_BAR:
|
|
|
|
case SERVE_BEER:
|
|
|
|
if (action == SERVE_BEER) {
|
|
|
|
// Serving a beer
|
|
|
|
if ((h.frameCtr() & 0x40) == 0)
|
|
|
|
h.setSupportValue(h.resource()->flags2);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
// Polishing the bar
|
|
|
|
if ((h.frameCtr() & 0x40) == 0) {
|
|
|
|
// New polish beginning
|
|
|
|
id = BG_RANDOM << 8;
|
|
|
|
|
|
|
|
if (h.hotspotId() == EWAN_ID) {
|
|
|
|
HotspotData *player = res.getHotspot(PLAYER_ID);
|
2010-04-27 10:59:28 +00:00
|
|
|
HotspotData *gwyn = res.getHotspot(GWEN_ID);
|
2007-04-14 03:48:24 +00:00
|
|
|
HotspotData *wayne = res.getHotspot(WAYNE_ID);
|
|
|
|
|
2007-09-08 11:18:35 +00:00
|
|
|
if ((player->roomNumber != 35) && (gwyn->roomNumber != 35) && (wayne->roomNumber != 35)) {
|
2010-01-09 09:27:40 +00:00
|
|
|
h.setAnimationIndex(EWAN_ANIM_INDEX);
|
2007-04-14 03:48:24 +00:00
|
|
|
if (rnd.getRandomNumber(1) == 1)
|
|
|
|
id = BG_EXTRA1 << 8;
|
2007-09-08 11:18:35 +00:00
|
|
|
else {
|
2007-04-14 03:48:24 +00:00
|
|
|
// Set up alternate animation
|
|
|
|
h.setWidth(32);
|
2007-10-07 11:12:46 +00:00
|
|
|
h.setAnimationIndex(EWAN_ALT_ANIM_INDEX);
|
2007-04-14 03:48:24 +00:00
|
|
|
ewanXOffset = true;
|
|
|
|
h.setPosition(h.x() - 8, h.y());
|
|
|
|
id = BG_EXTRA2 << 8;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
h.setSupportValue(id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// At this point, either a polish or a beer serve is in progress
|
|
|
|
h.setFrameCtr(h.frameCtr() | 0x40);
|
|
|
|
h.setSupportValue(h.supportValue() + 1); // Move to next frame
|
|
|
|
frameList = barEntry.graphics[h.supportValue() >> 8];
|
|
|
|
frameNumber = frameList[h.supportValue() & 0xff];
|
|
|
|
|
2007-09-08 11:18:35 +00:00
|
|
|
if (frameNumber != 0) {
|
2007-04-14 03:48:24 +00:00
|
|
|
h.setActionCtr(frameNumber);
|
|
|
|
h.setFrameNumber(frameNumber);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-09-08 11:18:35 +00:00
|
|
|
if (h.hotspotId() == EWAN_ID) {
|
2007-04-14 03:48:24 +00:00
|
|
|
// Make sure Ewan is back to his standard animation
|
|
|
|
h.setWidth(16);
|
2007-10-07 11:12:46 +00:00
|
|
|
h.setAnimationIndex(EWAN_ANIM_INDEX);
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2007-04-14 03:48:24 +00:00
|
|
|
if (ewanXOffset) {
|
|
|
|
h.setPosition(h.x() + 8, h.y());
|
|
|
|
ewanXOffset = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WAIT_DIALOG:
|
|
|
|
if (room.isDialogActive()) {
|
|
|
|
h.setFrameNumber(h.actionCtr());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WAIT:
|
|
|
|
// Immediate break, since the code outside the switch handles stopping the barman
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If this point is reached, then the barman should stop whatever he's doing
|
|
|
|
if (action != WAIT_DIALOG)
|
|
|
|
h.setDelayCtr(10);
|
|
|
|
h.setFrameCtr(0);
|
|
|
|
h.setActionCtr(12);
|
|
|
|
h.setFrameNumber(h.actionCtr());
|
2007-04-02 06:03:47 +00:00
|
|
|
}
|
|
|
|
|
2007-06-22 12:36:04 +00:00
|
|
|
void HotspotTickHandlers::skorlAnimHandler(Hotspot &h) {
|
2007-04-02 06:03:47 +00:00
|
|
|
h.handleTalkDialog();
|
|
|
|
h.setFrameNumber(h.actionCtr());
|
|
|
|
}
|
|
|
|
|
2007-04-15 10:49:59 +00:00
|
|
|
void HotspotTickHandlers::gargoyleAnimHandler(Hotspot &h) {
|
|
|
|
h.handleTalkDialog();
|
|
|
|
}
|
|
|
|
|
2007-06-22 12:36:04 +00:00
|
|
|
void HotspotTickHandlers::goewinShopAnimHandler(Hotspot &h) {
|
|
|
|
Resources &res = Resources::getReference();
|
|
|
|
ValueTableData &fields = res.fieldList();
|
|
|
|
|
2007-11-16 07:32:03 +00:00
|
|
|
h.resource()->actionHotspotId = 0;
|
2007-06-22 12:36:04 +00:00
|
|
|
h.setCharacterMode(CHARMODE_WAIT_FOR_INTERACT);
|
|
|
|
|
|
|
|
h.handleTalkDialog();
|
|
|
|
if (h.frameCtr() > 0) {
|
|
|
|
h.decrFrameCtr();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
h.executeScript();
|
|
|
|
|
|
|
|
if (h.delayCtr() > 0) {
|
|
|
|
h.setDelayCtr(h.delayCtr() - 1);
|
|
|
|
|
|
|
|
if (h.delayCtr() == 0) {
|
|
|
|
Hotspot *playerHotspot = res.getActiveHotspot(PLAYER_ID);
|
|
|
|
uint16 talkIndex = fields.getField(TALK_INDEX);
|
|
|
|
|
|
|
|
if ((talkIndex == 12) || (talkIndex == 13) || (talkIndex == 14) ||
|
|
|
|
(playerHotspot->roomNumber() == 34))
|
|
|
|
h.setDelayCtr(1500);
|
2008-01-27 19:47:41 +00:00
|
|
|
else
|
2007-06-22 12:36:04 +00:00
|
|
|
Script::normalGoewin(0, 0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-15 10:49:59 +00:00
|
|
|
void HotspotTickHandlers::skullAnimHandler(Hotspot &h) {
|
|
|
|
Resources &res = Resources::getReference();
|
2007-06-22 12:36:04 +00:00
|
|
|
uint16 doorId = 0x272E;
|
|
|
|
if ((h.hotspotId() == 0x42E) || (h.hotspotId() == 0x431) || (h.hotspotId() == 0x432))
|
|
|
|
doorId = 0x272A;
|
|
|
|
else if ((h.hotspotId() == 0x42f) || (h.hotspotId() == 0x433))
|
|
|
|
doorId = 0x272C;
|
|
|
|
|
|
|
|
RoomExitJoinData *joinRec = res.getExitJoin(doorId);
|
|
|
|
if ((h.hotspotId() == 0x42E) || (h.hotspotId() == 0x42F)) {
|
|
|
|
h.setFrameNumber(joinRec->blocked ? 0 : 1);
|
|
|
|
} else {
|
|
|
|
h.setFrameNumber(joinRec->blocked ? 1 : 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void HotspotTickHandlers::dragonFireAnimHandler(Hotspot &h) {
|
2008-01-27 19:47:41 +00:00
|
|
|
if (h.executeScript())
|
2007-06-22 12:36:04 +00:00
|
|
|
// Script is finished - player is dead
|
|
|
|
Game::getReference().setState(GS_RESTORE_RESTART);
|
|
|
|
}
|
|
|
|
|
|
|
|
void HotspotTickHandlers::castleSkorlAnimHandler(Hotspot &h) {
|
|
|
|
Resources &res = Resources::getReference();
|
|
|
|
|
|
|
|
h.handleTalkDialog();
|
|
|
|
if (h.frameCtr() > 0) {
|
|
|
|
h.decrFrameCtr();
|
|
|
|
return;
|
|
|
|
}
|
2007-04-15 10:49:59 +00:00
|
|
|
|
2007-06-22 12:36:04 +00:00
|
|
|
if (h.executeScript()) {
|
|
|
|
HotspotData *hotspot = res.getHotspot(h.hotspotId());
|
|
|
|
assert(hotspot);
|
|
|
|
res.deactivateHotspot(hotspot->hotspotId);
|
2008-01-09 12:36:58 +00:00
|
|
|
hotspot->roomNumber = 0xffff;
|
2007-06-22 12:36:04 +00:00
|
|
|
hotspot->layer = 255;
|
|
|
|
hotspot->talkCountdown = 0;
|
|
|
|
hotspot->flags |= HOTSPOTFLAG_MENU_EXCLUSION;
|
|
|
|
|
|
|
|
hotspot = res.getHotspot(CASTLE_SKORL_ID);
|
|
|
|
hotspot->roomNumber = 45;
|
|
|
|
res.activateHotspot(CASTLE_SKORL_ID);
|
|
|
|
}
|
2007-04-15 10:49:59 +00:00
|
|
|
}
|
|
|
|
|
2006-07-08 08:42:58 +00:00
|
|
|
void HotspotTickHandlers::rackSerfAnimHandler(Hotspot &h) {
|
|
|
|
Resources &res = Resources::getReference();
|
|
|
|
|
|
|
|
// Handle any talking
|
|
|
|
h.handleTalkDialog();
|
|
|
|
|
|
|
|
if (h.frameCtr() > 0) {
|
|
|
|
h.decrFrameCtr();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (h.actionCtr()) {
|
|
|
|
case 1:
|
2007-04-29 11:30:29 +00:00
|
|
|
h.setHotspotScript(RACK_SERF_SCRIPT_ID_1);
|
2006-07-08 08:42:58 +00:00
|
|
|
h.setActionCtr(2);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
if (HotspotScript::execute(&h))
|
|
|
|
h.setActionCtr(0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
2007-04-29 11:30:29 +00:00
|
|
|
h.setHotspotScript(RACK_SERF_SCRIPT_ID_2);
|
2006-07-08 08:42:58 +00:00
|
|
|
h.setActionCtr(4);
|
|
|
|
h.setLayer(2);
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
if (HotspotScript::execute(&h)) {
|
|
|
|
h.setLayer(255);
|
|
|
|
res.deactivateHotspot(h.hotspotId());
|
2007-02-09 10:56:31 +00:00
|
|
|
|
|
|
|
HotspotData *ratpouchData = res.getHotspot(RATPOUCH_ID);
|
|
|
|
ratpouchData->roomNumber = 4;
|
2006-07-08 08:42:58 +00:00
|
|
|
Hotspot *newHotspot = res.activateHotspot(RATPOUCH_ID);
|
|
|
|
newHotspot->converse(PLAYER_ID, 0x9C, true);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-05-23 12:43:42 +00:00
|
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
// support method for the standard character tick proc routine - it gets called
|
|
|
|
// when the character is in the wrong room designated for an action, and is
|
|
|
|
// responsible for starting the character walking to the correct exit
|
|
|
|
|
|
|
|
void HotspotTickHandlers::npcRoomChange(Hotspot &h) {
|
|
|
|
Resources &res = Resources::getReference();
|
|
|
|
|
|
|
|
// Increment number of times an exit has been attempted
|
|
|
|
h.setExitCtr(h.exitCtr() + 1);
|
|
|
|
if (h.exitCtr() >= 5) {
|
|
|
|
// Failed to exit room too many times
|
|
|
|
h.setExitCtr(0);
|
2010-04-19 09:40:20 +00:00
|
|
|
|
|
|
|
if (!h.currentActions().isEmpty()) {
|
2006-08-27 11:48:41 +00:00
|
|
|
if (h.startRoomNumber() != 0) {
|
2010-10-05 09:14:18 +00:00
|
|
|
// If character isn't already returning to starting room, redirect them to the
|
|
|
|
// player's current room
|
2010-04-19 09:40:20 +00:00
|
|
|
if (!h.currentActions().bottom().hasSupportData() ||
|
2010-04-05 07:27:16 +00:00
|
|
|
(h.currentActions().bottom().supportData().action() != RETURN)) {
|
2010-04-19 09:40:20 +00:00
|
|
|
// Start follower returning
|
2010-10-05 09:14:18 +00:00
|
|
|
Hotspot *playerHotspot = res.getActiveHotspot(PLAYER_ID);
|
2010-04-05 06:07:14 +00:00
|
|
|
h.currentActions().clear();
|
2010-10-05 09:14:18 +00:00
|
|
|
h.currentActions().addFront(RETURN, playerHotspot->roomNumber(), 0, 0);
|
2006-08-27 11:48:41 +00:00
|
|
|
}
|
2006-05-23 12:43:42 +00:00
|
|
|
}
|
|
|
|
|
2008-01-12 06:34:11 +00:00
|
|
|
} else if ((h.blockedOffset() != 0) && (h.blockedOffset() != 0xffff)) {
|
2008-01-27 19:47:41 +00:00
|
|
|
// Only current action on stack - and there is a block handler
|
2006-05-23 12:43:42 +00:00
|
|
|
CharacterScheduleEntry *entry = res.charSchedules().getEntry(h.blockedOffset());
|
2010-04-19 09:40:20 +00:00
|
|
|
h.currentActions().addFront(DISPATCH_ACTION, entry, h.roomNumber());
|
2006-05-23 12:43:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get room exit coordinates
|
|
|
|
RoomExitCoordinateData &exitData = res.coordinateList().getEntry(
|
|
|
|
h.roomNumber()).getData(h.currentActions().top().roomNumber());
|
2007-02-16 04:49:15 +00:00
|
|
|
|
2006-05-23 12:43:42 +00:00
|
|
|
if (h.hotspotId() != RATPOUCH_ID) {
|
|
|
|
// Count up the number of characters in the room
|
|
|
|
HotspotList &list = res.activeHotspots();
|
|
|
|
HotspotList::iterator i;
|
|
|
|
int numCharacters = 0;
|
|
|
|
|
|
|
|
for (i = list.begin(); i != list.end(); ++i) {
|
|
|
|
if ((h.roomNumber() == (exitData.roomNumber & 0xff)) && (h.layer() != 0) &&
|
2008-01-27 19:47:41 +00:00
|
|
|
(h.hotspotId() >= PLAYER_ID) && (h.hotspotId() < FIRST_NONCHARACTER_ID))
|
2006-05-23 12:43:42 +00:00
|
|
|
++numCharacters;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (numCharacters >= 4) {
|
|
|
|
uint16 dataId = res.getCharOffset(0);
|
|
|
|
CharacterScheduleEntry *entry = res.charSchedules().getEntry(dataId);
|
|
|
|
h.currentActions().addFront(DISPATCH_ACTION, entry, h.roomNumber());
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2006-05-23 12:43:42 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
h.setDestPosition(exitData.x, exitData.y);
|
|
|
|
h.setDestHotspot(res.exitHotspots().getHotspot(h.roomNumber(), exitData.hotspotIndexId));
|
|
|
|
|
|
|
|
if (h.destHotspotId() != 0xffff) {
|
|
|
|
RoomExitJoinData *joinRec = res.getExitJoin(h.destHotspotId());
|
|
|
|
|
|
|
|
if (joinRec->blocked) {
|
|
|
|
// The room exit is blocked - so add an opening action
|
2007-02-09 10:56:31 +00:00
|
|
|
h.currentActions().addFront(OPEN, h.roomNumber(), h.destHotspotId(), 0);
|
|
|
|
h.setBlockedFlag(false);
|
2006-05-23 12:43:42 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// No exit hotspot, or it has one that's not blocked. So start the walking
|
2008-01-27 19:47:41 +00:00
|
|
|
h.currentActions().top().setAction(START_WALKING);
|
2006-07-08 08:42:58 +00:00
|
|
|
h.setWalkFlag(true);
|
2006-05-23 12:43:42 +00:00
|
|
|
}
|
|
|
|
|
2006-04-11 10:52:11 +00:00
|
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
/* Miscellaneous classes */
|
|
|
|
/* */
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
// WalkingActionEntry class
|
|
|
|
|
|
|
|
// This method performs rounding of the number of steps depending on direciton
|
|
|
|
|
2012-03-13 09:25:04 +00:00
|
|
|
int WalkingActionEntry::numSteps() const {
|
2006-04-11 10:52:11 +00:00
|
|
|
switch (_direction) {
|
|
|
|
case UP:
|
|
|
|
case DOWN:
|
|
|
|
return (_numSteps + 1) >> 1;
|
|
|
|
|
|
|
|
case LEFT:
|
|
|
|
case RIGHT:
|
|
|
|
return (_numSteps + 3) >> 2;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// PathFinder class
|
|
|
|
|
2008-01-27 19:47:41 +00:00
|
|
|
PathFinder::PathFinder(Hotspot *h) {
|
2006-04-11 10:52:11 +00:00
|
|
|
_hotspot = h;
|
2007-05-07 12:16:05 +00:00
|
|
|
_inUse = false;
|
2008-01-27 19:47:41 +00:00
|
|
|
_list.clear();
|
|
|
|
_stepCtr = 0;
|
2006-04-11 10:52:11 +00:00
|
|
|
}
|
|
|
|
|
2006-05-29 08:12:07 +00:00
|
|
|
void PathFinder::clear() {
|
2006-04-11 10:52:11 +00:00
|
|
|
_stepCtr = 0;
|
|
|
|
_list.clear();
|
|
|
|
_inProgress = false;
|
|
|
|
_countdownCtr = PATHFIND_COUNTDOWN;
|
|
|
|
}
|
|
|
|
|
2006-05-29 08:12:07 +00:00
|
|
|
void PathFinder::reset(RoomPathsData &src) {
|
|
|
|
clear();
|
|
|
|
src.decompress(_layer, _hotspot->widthCopy());
|
2007-05-07 12:16:05 +00:00
|
|
|
_inUse = true;
|
2006-05-29 08:12:07 +00:00
|
|
|
}
|
|
|
|
|
2006-04-11 10:52:11 +00:00
|
|
|
// Does the next stage of processing to figure out a path to take to a given
|
|
|
|
// destination. Returns true if the path finding has been completed
|
|
|
|
|
2007-05-07 12:16:05 +00:00
|
|
|
PathFinderResult PathFinder::process() {
|
2006-04-11 10:52:11 +00:00
|
|
|
bool returnFlag = _inProgress;
|
|
|
|
// Check whether the pathfinding can be broken by the countdown counter
|
|
|
|
bool breakFlag = (PATHFIND_COUNTDOWN != 0);
|
|
|
|
_countdownCtr = PATHFIND_COUNTDOWN;
|
|
|
|
int v;
|
|
|
|
uint16 *pTemp;
|
|
|
|
bool scanFlag = false;
|
|
|
|
Direction currDirection = NO_DIRECTION;
|
|
|
|
Direction newDirection;
|
|
|
|
uint16 numSteps = 0, savedSteps = 0;
|
|
|
|
bool altFlag;
|
|
|
|
uint16 *pCurrent;
|
2007-05-07 12:16:05 +00:00
|
|
|
PathFinderResult result = PF_UNFINISHED;
|
2011-12-08 23:21:40 +00:00
|
|
|
bool skipToFinalStep = false;
|
2006-04-11 10:52:11 +00:00
|
|
|
|
|
|
|
if (!_inProgress) {
|
|
|
|
// Following code only done during first call to method
|
|
|
|
_inProgress = true;
|
|
|
|
initVars();
|
|
|
|
|
2010-10-13 10:12:35 +00:00
|
|
|
Common::Point diff(_destX - _xCurrent, _destY - _yCurrent);
|
2006-04-11 10:52:11 +00:00
|
|
|
_xCurrent >>= 3; _yCurrent >>= 3;
|
|
|
|
_xDestCurrent >>= 3; _yDestCurrent >>= 3;
|
|
|
|
if ((_xCurrent == _xDestCurrent) && (_yCurrent == _yDestCurrent)) {
|
|
|
|
// Very close move
|
2008-01-27 19:47:41 +00:00
|
|
|
if (_xDestPos > 0)
|
2006-04-11 10:52:11 +00:00
|
|
|
add(RIGHT, _xDestPos);
|
2008-01-27 19:47:41 +00:00
|
|
|
else if (_xDestPos < 0)
|
2006-04-11 10:52:11 +00:00
|
|
|
add(LEFT, -_xDestPos);
|
2010-10-13 10:12:35 +00:00
|
|
|
else if (diff.y > 0)
|
|
|
|
add(DOWN, diff.y);
|
|
|
|
else
|
|
|
|
add(UP, -diff.y);
|
2006-04-11 10:52:11 +00:00
|
|
|
|
2006-11-12 04:39:10 +00:00
|
|
|
_inProgress = false;
|
2007-05-20 12:39:15 +00:00
|
|
|
result = PF_OK;
|
2011-12-08 23:21:40 +00:00
|
|
|
skipToFinalStep = true;
|
|
|
|
} else {
|
|
|
|
// Path finding
|
2006-04-11 10:52:11 +00:00
|
|
|
|
2011-12-08 23:21:40 +00:00
|
|
|
_destX >>= 3;
|
|
|
|
_destY >>= 3;
|
|
|
|
_pSrc = &_layer[(_yCurrent + 1) * DECODED_PATHS_WIDTH + 1 + _xCurrent];
|
|
|
|
_pDest = &_layer[(_yDestCurrent + 1) * DECODED_PATHS_WIDTH + 1 + _xDestCurrent];
|
2006-04-11 10:52:11 +00:00
|
|
|
|
2011-12-08 23:21:40 +00:00
|
|
|
// Flag starting/ending cells
|
|
|
|
*_pSrc = 1;
|
|
|
|
_destOccupied = *_pDest != 0;
|
|
|
|
result = _destOccupied ? PF_DEST_OCCUPIED : PF_OK;
|
|
|
|
*_pDest = 0;
|
2006-04-11 10:52:11 +00:00
|
|
|
|
2011-12-08 23:21:40 +00:00
|
|
|
// Set up the current pointer, adjusting away from edges if necessary
|
2006-04-11 10:52:11 +00:00
|
|
|
|
2011-12-08 23:21:40 +00:00
|
|
|
if (_xCurrent >= _xDestCurrent) {
|
|
|
|
_xChangeInc = -1;
|
|
|
|
_xChangeStart = ROOM_PATHS_WIDTH;
|
|
|
|
} else {
|
|
|
|
_xChangeInc = 1;
|
|
|
|
_xChangeStart = 1;
|
|
|
|
}
|
2006-04-11 10:52:11 +00:00
|
|
|
|
2011-12-08 23:21:40 +00:00
|
|
|
if (_yCurrent >= _yDestCurrent) {
|
|
|
|
_yChangeInc = -1;
|
|
|
|
_yChangeStart = ROOM_PATHS_HEIGHT;
|
|
|
|
} else {
|
|
|
|
_yChangeInc = 1;
|
|
|
|
_yChangeStart = 1;
|
|
|
|
}
|
2006-04-11 10:52:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-08 23:21:40 +00:00
|
|
|
if (!skipToFinalStep) {
|
|
|
|
// Major loop to populate data
|
|
|
|
_cellPopulated = false;
|
2006-04-11 10:52:11 +00:00
|
|
|
|
2011-12-08 23:21:40 +00:00
|
|
|
while (1) {
|
|
|
|
// Loop through to process cells in the given area
|
|
|
|
if (!returnFlag) _yCtr = 0;
|
|
|
|
while (returnFlag || (_yCtr < ROOM_PATHS_HEIGHT)) {
|
|
|
|
if (!returnFlag) _xCtr = 0;
|
|
|
|
|
|
|
|
while (returnFlag || (_xCtr < ROOM_PATHS_WIDTH)) {
|
|
|
|
if (!returnFlag) {
|
|
|
|
processCell(&_layer[(_yChangeStart + _yCtr * _yChangeInc) * DECODED_PATHS_WIDTH +
|
|
|
|
(_xChangeStart + _xCtr * _xChangeInc)]);
|
|
|
|
if (breakFlag && (_countdownCtr <= 0)) return PF_UNFINISHED;
|
|
|
|
} else {
|
|
|
|
returnFlag = false;
|
|
|
|
}
|
|
|
|
++_xCtr;
|
2006-04-11 10:52:11 +00:00
|
|
|
}
|
2011-12-08 23:21:40 +00:00
|
|
|
++_yCtr;
|
2006-04-11 10:52:11 +00:00
|
|
|
}
|
|
|
|
|
2011-12-08 23:21:40 +00:00
|
|
|
// If the destination cell has been filled in, then break out of loop
|
|
|
|
if (*_pDest != 0) break;
|
2006-04-11 10:52:11 +00:00
|
|
|
|
2011-12-08 23:21:40 +00:00
|
|
|
if (_cellPopulated) {
|
|
|
|
// At least one cell populated, so go repeat loop
|
|
|
|
_cellPopulated = false;
|
|
|
|
} else {
|
|
|
|
result = PF_PART_PATH;
|
|
|
|
scanFlag = true;
|
|
|
|
break;
|
|
|
|
}
|
2006-04-11 10:52:11 +00:00
|
|
|
}
|
2011-12-08 23:21:40 +00:00
|
|
|
_inProgress = false;
|
2006-04-11 10:52:11 +00:00
|
|
|
|
2011-12-08 23:21:40 +00:00
|
|
|
if (scanFlag || _destOccupied) {
|
|
|
|
// Adjust the end point if necessary to stop character walking into occupied area
|
2006-04-11 10:52:11 +00:00
|
|
|
|
2011-12-08 23:21:40 +00:00
|
|
|
// Restore destination's occupied state if necessary
|
|
|
|
if (_destOccupied) {
|
|
|
|
*_pDest = 0xffff;
|
|
|
|
_destOccupied = false;
|
|
|
|
}
|
2006-04-11 10:52:11 +00:00
|
|
|
|
2011-12-08 23:21:40 +00:00
|
|
|
// Scan through lines
|
|
|
|
v = 0xff;
|
|
|
|
pTemp = _pDest;
|
|
|
|
scanLine(_destX, -1, pTemp, v);
|
|
|
|
scanLine(ROOM_PATHS_WIDTH - _destX, 1, pTemp, v);
|
|
|
|
scanLine(_destY, -DECODED_PATHS_WIDTH, pTemp, v);
|
|
|
|
scanLine(ROOM_PATHS_HEIGHT - _destY, DECODED_PATHS_WIDTH, pTemp, v);
|
|
|
|
|
|
|
|
if (pTemp == _pDest) {
|
|
|
|
clear();
|
|
|
|
return PF_NO_WALK;
|
|
|
|
}
|
2006-04-11 10:52:11 +00:00
|
|
|
|
2011-12-08 23:21:40 +00:00
|
|
|
_pDest = pTemp;
|
2006-04-11 10:52:11 +00:00
|
|
|
}
|
|
|
|
|
2011-12-08 23:21:40 +00:00
|
|
|
// ****DEBUG****
|
|
|
|
if (_hotspot->hotspotId() == PLAYER_ID) {
|
|
|
|
for (int ctr = 0; ctr < DECODED_PATHS_WIDTH * DECODED_PATHS_HEIGHT; ++ctr)
|
|
|
|
Room::getReference().tempLayer[ctr] = _layer[ctr];
|
|
|
|
}
|
2006-04-11 10:52:11 +00:00
|
|
|
|
2011-12-08 23:21:40 +00:00
|
|
|
// Determine the walk path by working backwards from the destination, adding in the
|
|
|
|
// walking steps in reverse order until source is reached
|
|
|
|
int stageCtr;
|
|
|
|
for (stageCtr = 0; stageCtr < 3; ++stageCtr) {
|
|
|
|
// Clear out any previously determined directions
|
|
|
|
clear();
|
2006-04-11 10:52:11 +00:00
|
|
|
|
2011-12-08 23:21:40 +00:00
|
|
|
altFlag = stageCtr == 1;
|
|
|
|
pCurrent = _pDest;
|
|
|
|
|
|
|
|
numSteps = 0;
|
|
|
|
currDirection = NO_DIRECTION;
|
|
|
|
while (1) {
|
|
|
|
v = *pCurrent - 1;
|
|
|
|
if (v == 0) break;
|
|
|
|
|
|
|
|
newDirection = NO_DIRECTION;
|
|
|
|
if (!altFlag && (currDirection != LEFT) && (currDirection != RIGHT)) {
|
|
|
|
// Standard order direction checking
|
|
|
|
if (*(pCurrent - DECODED_PATHS_WIDTH) == v) newDirection = DOWN;
|
|
|
|
else if (*(pCurrent + DECODED_PATHS_WIDTH) == v) newDirection = UP;
|
|
|
|
else if (*(pCurrent + 1) == v) newDirection = LEFT;
|
|
|
|
else if (*(pCurrent - 1) == v) newDirection = RIGHT;
|
|
|
|
} else {
|
|
|
|
// Alternate order direction checking
|
|
|
|
if (*(pCurrent + 1) == v) newDirection = LEFT;
|
|
|
|
else if (*(pCurrent - 1) == v) newDirection = RIGHT;
|
|
|
|
else if (*(pCurrent - DECODED_PATHS_WIDTH) == v) newDirection = DOWN;
|
|
|
|
else if (*(pCurrent + DECODED_PATHS_WIDTH) == v) newDirection = UP;
|
|
|
|
}
|
|
|
|
if (newDirection == NO_DIRECTION)
|
|
|
|
error("Path finding process failed");
|
2007-05-07 12:16:05 +00:00
|
|
|
|
2011-12-08 23:21:40 +00:00
|
|
|
// Process for the specified direction
|
|
|
|
if (newDirection != currDirection) add(newDirection, 0);
|
2006-04-11 10:52:11 +00:00
|
|
|
|
2011-12-08 23:21:40 +00:00
|
|
|
switch (newDirection) {
|
|
|
|
case UP:
|
|
|
|
pCurrent += DECODED_PATHS_WIDTH;
|
|
|
|
break;
|
2006-04-11 10:52:11 +00:00
|
|
|
|
2011-12-08 23:21:40 +00:00
|
|
|
case DOWN:
|
|
|
|
pCurrent -= DECODED_PATHS_WIDTH;
|
|
|
|
break;
|
2006-04-11 10:52:11 +00:00
|
|
|
|
2011-12-08 23:21:40 +00:00
|
|
|
case LEFT:
|
|
|
|
++pCurrent;
|
|
|
|
break;
|
2006-04-11 10:52:11 +00:00
|
|
|
|
2011-12-08 23:21:40 +00:00
|
|
|
case RIGHT:
|
|
|
|
--pCurrent;
|
|
|
|
break;
|
2006-04-11 10:52:11 +00:00
|
|
|
|
2011-12-08 23:21:40 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2006-04-11 10:52:11 +00:00
|
|
|
|
2011-12-08 23:21:40 +00:00
|
|
|
++numSteps;
|
|
|
|
top().rawSteps() += 8;
|
|
|
|
currDirection = newDirection;
|
2006-04-11 10:52:11 +00:00
|
|
|
}
|
|
|
|
|
2011-12-08 23:21:40 +00:00
|
|
|
if (stageCtr == 0)
|
|
|
|
// Save the number of steps needed
|
|
|
|
savedSteps = numSteps;
|
|
|
|
if ((stageCtr == 1) && (numSteps <= savedSteps))
|
|
|
|
// Less steps were needed, so break out
|
|
|
|
break;
|
2006-04-11 10:52:11 +00:00
|
|
|
}
|
|
|
|
|
2011-12-08 23:21:40 +00:00
|
|
|
// Add final movement if necessary
|
2006-04-11 10:52:11 +00:00
|
|
|
|
2011-12-08 23:21:40 +00:00
|
|
|
if (result == PF_OK) {
|
|
|
|
if (_xDestPos < 0)
|
|
|
|
addBack(LEFT, -_xDestPos);
|
|
|
|
else if (_xDestPos > 0)
|
|
|
|
addBack(RIGHT, _xDestPos);
|
|
|
|
}
|
2006-04-11 10:52:11 +00:00
|
|
|
}
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2011-12-08 23:21:40 +00:00
|
|
|
// Final Step
|
2007-02-16 04:49:15 +00:00
|
|
|
if (_xPos < 0) add(RIGHT, -_xPos);
|
|
|
|
else if (_xPos > 0) add(LEFT, _xPos);
|
2006-04-11 10:52:11 +00:00
|
|
|
|
2007-05-07 12:16:05 +00:00
|
|
|
return result;
|
2006-04-11 10:52:11 +00:00
|
|
|
}
|
|
|
|
|
2010-11-07 01:03:03 +00:00
|
|
|
Common::String PathFinder::getDebugInfo() const {
|
|
|
|
Common::String buffer;
|
|
|
|
buffer += "Pathfinder::list(\n";
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2010-11-07 01:03:03 +00:00
|
|
|
WalkingActionList::const_iterator i;
|
2006-05-23 12:43:42 +00:00
|
|
|
for (i = _list.begin(); i != _list.end(); ++i) {
|
2012-03-13 13:53:40 +00:00
|
|
|
WalkingActionEntry const &e = **i;
|
|
|
|
buffer += Common::String::format("Direction=%d, numSteps=%d\n", e.direction(), e.numSteps());
|
2006-05-23 12:43:42 +00:00
|
|
|
}
|
2010-11-07 01:03:03 +00:00
|
|
|
|
|
|
|
return buffer;
|
2006-05-23 12:43:42 +00:00
|
|
|
}
|
|
|
|
|
2006-04-11 10:52:11 +00:00
|
|
|
void PathFinder::processCell(uint16 *p) {
|
|
|
|
// Only process cells that are still empty
|
|
|
|
if (*p == 0) {
|
|
|
|
uint16 vMax = 0xffff;
|
|
|
|
uint16 vTemp;
|
|
|
|
|
|
|
|
// Check the surrounding cells (up,down,left,right) for values
|
|
|
|
// Up
|
|
|
|
vTemp = *(p - DECODED_PATHS_WIDTH);
|
|
|
|
if ((vTemp != 0) && (vTemp < vMax)) vMax = vTemp;
|
|
|
|
// Down
|
|
|
|
vTemp = *(p + DECODED_PATHS_WIDTH);
|
|
|
|
if ((vTemp != 0) && (vTemp < vMax)) vMax = vTemp;
|
|
|
|
// Left
|
|
|
|
vTemp = *(p - 1);
|
|
|
|
if ((vTemp != 0) && (vTemp < vMax)) vMax = vTemp;
|
|
|
|
// Right
|
|
|
|
vTemp = *(p + 1);
|
|
|
|
if ((vTemp != 0) && (vTemp < vMax)) vMax = vTemp;
|
|
|
|
|
|
|
|
if (vMax != 0xffff) {
|
|
|
|
// A surrounding cell with a value was found
|
|
|
|
++vMax;
|
|
|
|
*p = vMax;
|
|
|
|
_cellPopulated = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
_countdownCtr -= 3;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
--_countdownCtr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void PathFinder::scanLine(int numScans, int changeAmount, uint16 *&pEnd, int &v) {
|
|
|
|
uint16 *pTemp = _pDest;
|
|
|
|
|
|
|
|
for (int ctr = 1; ctr <= numScans; ++ctr) {
|
|
|
|
pTemp += changeAmount;
|
|
|
|
if ((*pTemp != 0) && (*pTemp != 0xffff)) {
|
|
|
|
if ((v < ctr) || ((v == ctr) && (*pTemp >= *pEnd))) return;
|
|
|
|
pEnd = pTemp;
|
|
|
|
v = ctr;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void PathFinder::initVars() {
|
|
|
|
int16 xRight;
|
|
|
|
|
|
|
|
// Set up dest position, adjusting for walking off screen if necessary
|
|
|
|
_destX = _hotspot->destX();
|
|
|
|
_destY = _hotspot->destY();
|
|
|
|
|
|
|
|
if (_destX < 10) _destX -= 50;
|
|
|
|
if (_destX >= FULL_SCREEN_WIDTH-10) _destX += 50;
|
|
|
|
|
|
|
|
_xPos = 0; _yPos = 0;
|
|
|
|
_xDestPos = 0; _yDestPos = 0;
|
|
|
|
|
|
|
|
_xCurrent = _hotspot->x();
|
|
|
|
if (_xCurrent < 0) {
|
|
|
|
_xPos = _xCurrent;
|
|
|
|
_xCurrent = 0;
|
|
|
|
}
|
|
|
|
xRight = FULL_SCREEN_WIDTH - _hotspot->widthCopy() - 1;
|
|
|
|
if (_xCurrent >= xRight) {
|
|
|
|
_xPos = _xCurrent - xRight;
|
|
|
|
_xCurrent = xRight;
|
|
|
|
}
|
|
|
|
|
|
|
|
_yCurrent = (_hotspot->y() & 0xf8) + _hotspot->heightCopy() - MENUBAR_Y_SIZE - 4;
|
|
|
|
if (_yCurrent < 0) {
|
|
|
|
_yPos = _yCurrent;
|
|
|
|
_yCurrent = 0;
|
|
|
|
}
|
|
|
|
if (_yCurrent >= (FULL_SCREEN_HEIGHT - MENUBAR_Y_SIZE)) {
|
|
|
|
_yPos = _yCurrent - (FULL_SCREEN_HEIGHT - MENUBAR_Y_SIZE);
|
|
|
|
_yCurrent = FULL_SCREEN_HEIGHT - MENUBAR_Y_SIZE;
|
|
|
|
}
|
|
|
|
|
|
|
|
_xDestCurrent = _destX;
|
|
|
|
if (_xDestCurrent < 0) {
|
|
|
|
_xDestPos = _xDestCurrent;
|
|
|
|
_xDestCurrent = 0;
|
|
|
|
}
|
|
|
|
xRight = FULL_SCREEN_WIDTH - _hotspot->widthCopy();
|
|
|
|
if (_xDestCurrent >= xRight) {
|
|
|
|
_xDestPos = _xDestCurrent - xRight;
|
|
|
|
_xDestCurrent = xRight;
|
|
|
|
}
|
|
|
|
|
2007-11-17 08:42:23 +00:00
|
|
|
_yDestCurrent = _destY - MENUBAR_Y_SIZE;
|
2006-04-11 10:52:11 +00:00
|
|
|
if (_yDestCurrent < 0)
|
|
|
|
_yDestCurrent = 0;
|
|
|
|
if (_yDestCurrent >= (FULL_SCREEN_HEIGHT - MENUBAR_Y_SIZE))
|
|
|
|
_yDestCurrent = FULL_SCREEN_HEIGHT - MENUBAR_Y_SIZE - 1;
|
|
|
|
|
|
|
|
// Subtract an amount from the countdown counter to compensate for
|
|
|
|
// the time spent decompressing the walkable areas set for the room
|
|
|
|
_countdownCtr -= 700;
|
|
|
|
}
|
|
|
|
|
2012-03-13 09:25:04 +00:00
|
|
|
void PathFinder::saveToStream(Common::WriteStream *stream) const {
|
2007-05-07 12:16:05 +00:00
|
|
|
stream->writeByte(_inUse);
|
|
|
|
|
|
|
|
if (_inUse) {
|
|
|
|
// Save the path finding plane
|
|
|
|
stream->write(_layer, sizeof(RoomPathsDecompressedData));
|
|
|
|
|
|
|
|
// Save any active step sequence
|
2012-03-13 09:25:04 +00:00
|
|
|
for (WalkingActionList::const_iterator i = _list.begin(); i != _list.end(); ++i) {
|
2012-03-13 13:53:40 +00:00
|
|
|
WalkingActionEntry &entry = **i;
|
|
|
|
stream->writeByte(entry.direction());
|
|
|
|
stream->writeSint16LE(entry.rawSteps());
|
2007-05-07 12:16:05 +00:00
|
|
|
}
|
|
|
|
stream->writeByte(0xff);
|
|
|
|
stream->writeSint16LE(_stepCtr);
|
2006-10-02 12:48:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void PathFinder::loadFromStream(Common::ReadStream *stream) {
|
|
|
|
_inProgress = false;
|
2007-05-07 12:16:05 +00:00
|
|
|
_inUse = stream->readByte() != 0;
|
|
|
|
|
|
|
|
if (_inUse) {
|
|
|
|
stream->read(_layer, sizeof(RoomPathsDecompressedData));
|
|
|
|
|
|
|
|
_list.clear();
|
|
|
|
uint8 direction;
|
|
|
|
while ((direction = stream->readByte()) != 0xff) {
|
|
|
|
int steps = stream->readSint16LE();
|
2008-04-06 12:00:37 +00:00
|
|
|
_list.push_back(WalkingActionList::value_type(new WalkingActionEntry((Direction) direction, steps)));
|
2007-05-07 12:16:05 +00:00
|
|
|
}
|
|
|
|
_stepCtr = stream->readSint16LE();
|
2006-10-02 12:48:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-11 10:52:11 +00:00
|
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
/* Support methods */
|
|
|
|
/* */
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
|
2008-01-27 19:47:41 +00:00
|
|
|
// finds a list of character animations whose base area are impinging
|
2006-04-11 10:52:11 +00:00
|
|
|
// that of the specified character (ie. are bumping into them)
|
|
|
|
|
2009-01-30 12:22:30 +00:00
|
|
|
int Support::findIntersectingCharacters(Hotspot &h, uint16 *charList, int16 xp, int16 yp, int roomNumber) {
|
2006-04-11 10:52:11 +00:00
|
|
|
int numImpinging = 0;
|
|
|
|
Resources &res = Resources::getReference();
|
2010-01-19 23:48:55 +00:00
|
|
|
Common::Rect r;
|
2006-05-29 08:12:07 +00:00
|
|
|
uint16 hotspotY;
|
2006-04-11 10:52:11 +00:00
|
|
|
|
2009-01-30 12:22:30 +00:00
|
|
|
// If a specific x/y/room isn't provided, use the specified hotspot's current location
|
|
|
|
if (roomNumber == -1) {
|
|
|
|
xp = h.x();
|
|
|
|
yp = h.y();
|
|
|
|
roomNumber = h.roomNumber();
|
|
|
|
}
|
|
|
|
|
|
|
|
r.left = xp;
|
|
|
|
r.right = xp + h.widthCopy();
|
|
|
|
r.top = yp + h.heightCopy() - h.yCorrection() - h.charRectY();
|
|
|
|
r.bottom = yp + h.heightCopy() + h.charRectY();
|
2006-04-11 10:52:11 +00:00
|
|
|
|
|
|
|
HotspotList::iterator i;
|
|
|
|
for (i = res.activeHotspots().begin(); i != res.activeHotspots().end(); ++i) {
|
|
|
|
Hotspot &hotspot = **i;
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2006-04-11 10:52:11 +00:00
|
|
|
// Check for basic reasons to skip checking the animation
|
|
|
|
if ((h.hotspotId() == hotspot.hotspotId()) || (hotspot.layer() == 0) ||
|
2009-01-30 12:22:30 +00:00
|
|
|
(roomNumber != hotspot.roomNumber()) ||
|
2006-05-23 12:43:42 +00:00
|
|
|
(hotspot.hotspotId() >= FIRST_NONCHARACTER_ID) ||
|
|
|
|
hotspot.skipFlag()) continue;
|
2006-04-11 10:52:11 +00:00
|
|
|
// TODO: See why si+ANIM_HOTSPOT_OFFSET compared aganst di+ANIM_VOICE_CTR
|
|
|
|
|
2006-05-29 08:12:07 +00:00
|
|
|
hotspotY = hotspot.y() + hotspot.heightCopy();
|
2006-07-08 08:42:58 +00:00
|
|
|
if ((hotspot.x() >= r.right) || (hotspot.x() + hotspot.widthCopy() <= r.left) ||
|
|
|
|
(hotspotY + hotspot.charRectY() <= r.top) ||
|
2006-05-29 08:12:07 +00:00
|
|
|
(hotspotY - hotspot.charRectY() - hotspot.yCorrection() >= r.bottom))
|
2006-04-11 10:52:11 +00:00
|
|
|
continue;
|
2006-05-29 08:12:07 +00:00
|
|
|
|
2006-04-11 10:52:11 +00:00
|
|
|
// Add hotspot Id to list
|
|
|
|
if (numImpinging == MAX_NUM_IMPINGING)
|
|
|
|
error("Exceeded maximum allowable number of impinging characters");
|
|
|
|
*charList++ = hotspot.hotspotId();
|
|
|
|
++numImpinging;
|
|
|
|
}
|
|
|
|
|
|
|
|
return numImpinging;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Returns true if any other characters are intersecting the specified one
|
|
|
|
|
2009-01-30 12:22:30 +00:00
|
|
|
bool Support::checkForIntersectingCharacter(Hotspot &h, int16 xp, int16 yp, int roomNumber) {
|
2006-04-11 10:52:11 +00:00
|
|
|
uint16 tempList[MAX_NUM_IMPINGING];
|
2009-01-30 12:22:30 +00:00
|
|
|
return findIntersectingCharacters(h, tempList, xp, yp, roomNumber) != 0;
|
2006-04-11 10:52:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check whether a character needs to change the room they're in
|
|
|
|
|
2006-09-03 08:39:06 +00:00
|
|
|
bool Support::checkRoomChange(Hotspot &h) {
|
2006-04-11 10:52:11 +00:00
|
|
|
int16 x = h.x() + (h.widthCopy() >> 1);
|
|
|
|
int16 y = h.y() + h.heightCopy() - (h.yCorrection() >> 1);
|
|
|
|
|
|
|
|
RoomData *roomData = Resources::getReference().getRoom(h.roomNumber());
|
|
|
|
RoomExitData *exitRec = roomData->exits.checkExits(x, y);
|
|
|
|
|
|
|
|
if (exitRec) {
|
2007-02-09 10:56:31 +00:00
|
|
|
// End the current walking sequence
|
2006-04-11 10:52:11 +00:00
|
|
|
if (exitRec->sequenceOffset != 0xffff) {
|
|
|
|
Script::execute(exitRec->sequenceOffset);
|
|
|
|
} else {
|
2008-01-27 19:47:41 +00:00
|
|
|
Support::characterChangeRoom(h, exitRec->roomNumber,
|
2006-04-11 10:52:11 +00:00
|
|
|
exitRec->x, exitRec->y, exitRec->direction);
|
|
|
|
}
|
|
|
|
}
|
2006-09-03 08:39:06 +00:00
|
|
|
|
|
|
|
return (exitRec != NULL);
|
2006-04-11 10:52:11 +00:00
|
|
|
}
|
|
|
|
|
2008-01-27 19:47:41 +00:00
|
|
|
void Support::characterChangeRoom(Hotspot &h, uint16 roomNumber,
|
2006-04-11 10:52:11 +00:00
|
|
|
int16 newX, int16 newY, Direction dir) {
|
2006-05-23 12:43:42 +00:00
|
|
|
Resources &res = Resources::getReference();
|
2006-07-08 08:42:58 +00:00
|
|
|
Room &room = Room::getReference();
|
2006-05-23 12:43:42 +00:00
|
|
|
ValueTableData &fields = res.fieldList();
|
2006-04-11 10:52:11 +00:00
|
|
|
|
|
|
|
if (h.hotspotId() == PLAYER_ID) {
|
|
|
|
// Room change code for the player
|
2006-07-08 08:42:58 +00:00
|
|
|
if (room.cursorState() != CS_NONE) return;
|
2006-04-11 10:52:11 +00:00
|
|
|
PlayerNewPosition &p = fields.playerNewPos();
|
|
|
|
|
2009-01-30 12:22:30 +00:00
|
|
|
if (checkForIntersectingCharacter(h, newX, newY - 48, roomNumber)) {
|
|
|
|
// Another character is blocking the exit in the other room, so set the player to
|
|
|
|
// temporarily move to a random destination in the current room
|
2007-08-05 02:56:51 +00:00
|
|
|
h.tempDest().position.x = h.destX();
|
|
|
|
h.tempDest().position.y = h.destY();
|
|
|
|
h.tempDest().counter = 1;
|
2006-07-08 08:42:58 +00:00
|
|
|
Room::getReference().setCursorState(CS_BUMPED);
|
|
|
|
h.setActionCtr(0);
|
|
|
|
h.setBlockedState((BlockedState) ((int) h.blockedState() + 1));
|
|
|
|
h.setDestHotspot(0);
|
|
|
|
h.setRandomDest();
|
|
|
|
p.roomNumber = 0;
|
2009-01-30 12:22:30 +00:00
|
|
|
} else {
|
|
|
|
// Flag the new location to move the player to (which will be handled by the outer game loop)
|
|
|
|
h.setDirection(dir);
|
|
|
|
p.roomNumber = roomNumber;
|
|
|
|
p.position.x = newX;
|
|
|
|
p.position.y = newY - 48;
|
2006-07-08 08:42:58 +00:00
|
|
|
}
|
|
|
|
|
2006-04-11 10:52:11 +00:00
|
|
|
} else {
|
|
|
|
// Any other character changing room
|
2009-01-30 12:22:30 +00:00
|
|
|
newX = (newX & 0xfff8) | 5;
|
|
|
|
newY = (newY - h.heightCopy()) & 0xfff8;
|
2006-05-23 12:43:42 +00:00
|
|
|
|
2009-01-30 12:22:30 +00:00
|
|
|
if (checkForIntersectingCharacter(h, newX, newY, roomNumber)) {
|
2006-05-23 12:43:42 +00:00
|
|
|
// Character is blocked, so add a handler for handling it
|
|
|
|
uint16 dataId = res.getCharOffset(0);
|
|
|
|
CharacterScheduleEntry *entry = res.charSchedules().getEntry(dataId);
|
|
|
|
h.currentActions().addFront(DISPATCH_ACTION, entry, h.roomNumber());
|
2006-04-11 10:52:11 +00:00
|
|
|
} else {
|
|
|
|
// Handle character room change
|
|
|
|
h.setRoomNumber(roomNumber);
|
2009-01-30 12:22:30 +00:00
|
|
|
h.setPosition(newX, newY);
|
2006-04-11 10:52:11 +00:00
|
|
|
h.setSkipFlag(true);
|
|
|
|
h.setDirection(dir);
|
|
|
|
|
2006-05-23 12:43:42 +00:00
|
|
|
h.setExitCtr(0);
|
|
|
|
h.currentActions().top().setAction(DISPATCH_ACTION);
|
2006-04-11 10:52:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Support::charactersIntersecting(HotspotData *hotspot1, HotspotData *hotspot2) {
|
|
|
|
return !((hotspot1->startX + hotspot1->widthCopy + 4 < hotspot2->startX) ||
|
|
|
|
(hotspot2->startX + hotspot2->widthCopy + 4 < hotspot1->startX) ||
|
|
|
|
(hotspot2->startY + hotspot2->heightCopy - hotspot2->yCorrection - 2 >=
|
|
|
|
hotspot1->startY + hotspot1->heightCopy + 2) ||
|
2008-01-27 19:47:41 +00:00
|
|
|
(hotspot2->startY + hotspot2->heightCopy + 2 <
|
2006-04-11 10:52:11 +00:00
|
|
|
hotspot1->startY + hotspot1->heightCopy - hotspot1->yCorrection - 2));
|
|
|
|
}
|
|
|
|
|
2006-05-29 08:12:07 +00:00
|
|
|
bool Support::isCharacterInList(uint16 *lst, int numEntries, uint16 charId) {
|
2008-01-27 19:47:41 +00:00
|
|
|
while (numEntries-- > 0)
|
2006-05-29 08:12:07 +00:00
|
|
|
if (*lst++ == charId) return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-03-13 09:25:04 +00:00
|
|
|
void HotspotList::saveToStream(Common::WriteStream *stream) const {
|
|
|
|
for (HotspotList::const_iterator i = begin(); i != end(); ++i) {
|
2012-03-13 13:53:40 +00:00
|
|
|
Hotspot const &hotspot = **i;
|
|
|
|
debugC(ERROR_INTERMEDIATE, kLureDebugAnimations, "Saving hotspot %xh", hotspot.hotspotId());
|
|
|
|
bool dynamicObject = hotspot.hotspotId() != hotspot.originalId();
|
|
|
|
stream->writeUint16LE(hotspot.originalId());
|
2006-10-02 12:48:56 +00:00
|
|
|
stream->writeByte(dynamicObject);
|
2012-03-13 13:53:40 +00:00
|
|
|
stream->writeUint16LE(hotspot.destHotspotId());
|
|
|
|
hotspot.saveToStream(stream);
|
2006-10-02 12:48:56 +00:00
|
|
|
|
2012-03-13 13:53:40 +00:00
|
|
|
debugC(ERROR_DETAILED, kLureDebugAnimations, "Saved hotspot %xh", hotspot.hotspotId());
|
2006-10-02 12:48:56 +00:00
|
|
|
}
|
|
|
|
stream->writeUint16LE(0);
|
|
|
|
}
|
|
|
|
|
2010-01-19 23:48:55 +00:00
|
|
|
void HotspotList::loadFromStream(Common::ReadStream *stream) {
|
2006-10-02 12:48:56 +00:00
|
|
|
Resources &res = Resources::getReference();
|
|
|
|
Hotspot *hotspot;
|
|
|
|
|
|
|
|
clear();
|
|
|
|
uint16 hotspotId = stream->readUint16LE();
|
2007-09-08 11:18:35 +00:00
|
|
|
while (hotspotId != 0) {
|
2006-10-02 12:48:56 +00:00
|
|
|
debugC(ERROR_INTERMEDIATE, kLureDebugAnimations, "Loading hotspot %xh", hotspotId);
|
|
|
|
bool dynamicObject = stream->readByte() != 0;
|
|
|
|
uint16 destHotspotId = stream->readUint16LE();
|
|
|
|
|
|
|
|
if (dynamicObject) {
|
|
|
|
// Add in a dynamic object (such as a floating talk bubble)
|
|
|
|
Hotspot *destHotspot = res.getActiveHotspot(destHotspotId);
|
|
|
|
assert(destHotspot);
|
|
|
|
hotspot = new Hotspot(destHotspot, hotspotId);
|
2007-09-08 11:18:35 +00:00
|
|
|
} else {
|
2007-05-27 04:33:19 +00:00
|
|
|
HotspotData *hotspotData = res.getHotspot(hotspotId);
|
|
|
|
assert(hotspotData);
|
|
|
|
hotspot = new Hotspot(hotspotData);
|
2006-10-02 12:48:56 +00:00
|
|
|
}
|
|
|
|
|
2007-05-27 04:33:19 +00:00
|
|
|
res.addHotspot(hotspot);
|
|
|
|
assert(hotspot);
|
2006-10-02 12:48:56 +00:00
|
|
|
hotspot->loadFromStream(stream);
|
2007-05-27 04:33:19 +00:00
|
|
|
|
2006-10-02 12:48:56 +00:00
|
|
|
debugC(ERROR_DETAILED, kLureDebugAnimations, "Loaded hotspot %xh", hotspotId);
|
|
|
|
|
2007-05-27 04:33:19 +00:00
|
|
|
// Get the next hotspot
|
2006-10-02 12:48:56 +00:00
|
|
|
hotspotId = stream->readUint16LE();
|
|
|
|
}
|
|
|
|
}
|
2006-07-08 08:42:58 +00:00
|
|
|
|
2009-10-04 21:26:33 +00:00
|
|
|
} // End of namespace Lure
|