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-05-11 19:43:30 +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-05-11 19:43:30 +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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2010-11-19 17:03:07 +00:00
|
|
|
#include "common/memstream.h"
|
2006-05-11 19:43:30 +00:00
|
|
|
|
|
|
|
#include "gob/gob.h"
|
|
|
|
#include "gob/map.h"
|
|
|
|
#include "gob/dataio.h"
|
|
|
|
#include "gob/goblin.h"
|
2006-05-29 18:24:52 +00:00
|
|
|
#include "gob/mult.h"
|
2008-05-08 00:47:23 +00:00
|
|
|
#include "gob/sound/sound.h"
|
2006-05-11 19:43:30 +00:00
|
|
|
|
|
|
|
namespace Gob {
|
|
|
|
|
|
|
|
Map_v1::Map_v1(GobEngine *vm) : Map(vm) {
|
2007-02-17 09:56:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Map_v1::~Map_v1() {
|
|
|
|
}
|
|
|
|
|
2009-11-02 21:54:57 +00:00
|
|
|
void Map_v1::init() {
|
2007-08-13 14:04:50 +00:00
|
|
|
if (_passMap || _itemsMap)
|
|
|
|
return;
|
|
|
|
|
2010-10-30 17:25:29 +00:00
|
|
|
_passWidth = 26;
|
|
|
|
_mapWidth = 26;
|
2006-05-29 18:24:52 +00:00
|
|
|
_mapHeight = 28;
|
|
|
|
|
|
|
|
_passMap = new int8[_mapHeight * _mapWidth];
|
2007-03-20 14:51:57 +00:00
|
|
|
memset(_passMap, 0, _mapHeight * _mapWidth * sizeof(int8));
|
|
|
|
|
2006-05-29 18:24:52 +00:00
|
|
|
_itemsMap = new int16*[_mapHeight];
|
2007-03-20 14:51:57 +00:00
|
|
|
for (int i = 0; i < _mapHeight; i++) {
|
2007-03-29 20:53:37 +00:00
|
|
|
_itemsMap[i] = new int16[_mapWidth];
|
2007-03-20 14:51:57 +00:00
|
|
|
memset(_itemsMap[i], 0, _mapWidth * sizeof(int16));
|
2007-03-29 20:53:37 +00:00
|
|
|
}
|
2006-05-29 18:24:52 +00:00
|
|
|
|
2010-10-30 17:26:06 +00:00
|
|
|
_wayPointCount = 40;
|
2010-10-30 17:26:49 +00:00
|
|
|
_wayPoints = new WayPoint[40];
|
|
|
|
memset(_wayPoints, 0, sizeof(WayPoint));
|
2006-05-29 18:24:52 +00:00
|
|
|
}
|
|
|
|
|
2007-04-02 11:05:09 +00:00
|
|
|
void Map_v1::loadMapObjects(const char *avjFile) {
|
2006-05-11 19:43:30 +00:00
|
|
|
char avoName[128];
|
2007-04-02 11:05:09 +00:00
|
|
|
byte *dataBuf;
|
2006-05-11 19:43:30 +00:00
|
|
|
int16 tmp;
|
|
|
|
int32 flag;
|
2007-03-20 14:51:57 +00:00
|
|
|
int16 gobDataCount;
|
|
|
|
int16 objDataCount;
|
|
|
|
uint32 gobsPos;
|
|
|
|
uint32 objsPos;
|
2006-05-11 19:43:30 +00:00
|
|
|
|
|
|
|
strcpy(avoName, _sourceFile);
|
|
|
|
strcat(avoName, ".avo");
|
|
|
|
|
2010-10-31 20:07:14 +00:00
|
|
|
int32 size;
|
|
|
|
dataBuf = _vm->_dataIO->getFile(avoName, size);
|
|
|
|
if (!dataBuf) {
|
|
|
|
dataBuf = _vm->_dataIO->getFile(avjFile, size);
|
2007-03-20 14:51:57 +00:00
|
|
|
_loadFromAvo = false;
|
2010-10-31 20:07:14 +00:00
|
|
|
} else
|
|
|
|
_loadFromAvo = true;
|
2009-06-22 10:12:33 +00:00
|
|
|
|
2007-04-02 11:05:09 +00:00
|
|
|
Common::MemoryReadStream mapData(dataBuf, 4294967295U);
|
2007-03-20 14:51:57 +00:00
|
|
|
|
2007-08-13 14:04:50 +00:00
|
|
|
init();
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if (_loadFromAvo) {
|
|
|
|
mapData.read(_passMap, _mapHeight * _mapWidth);
|
|
|
|
|
|
|
|
for (int y = 0; y < _mapHeight; y++)
|
|
|
|
for (int x = 0; x < _mapWidth; x++)
|
|
|
|
_itemsMap[y][x] = mapData.readSByte();
|
2006-05-11 19:43:30 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
for (int i = 0; i < 40; i++) {
|
|
|
|
_wayPoints[i].x = mapData.readUint16LE();
|
|
|
|
_wayPoints[i].y = mapData.readUint16LE();
|
2006-05-11 19:43:30 +00:00
|
|
|
}
|
2010-10-30 17:27:53 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < 20; i++) {
|
|
|
|
_itemPoses[i].x = mapData.readByte();
|
|
|
|
_itemPoses[i].y = mapData.readByte();
|
|
|
|
_itemPoses[i].orient = mapData.readByte();
|
|
|
|
}
|
2006-05-11 19:43:30 +00:00
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
mapData.skip(32 + 76 + 4 + 20);
|
2006-05-11 19:43:30 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
for (int i = 0; i < 3; i++) {
|
|
|
|
tmp = mapData.readUint16LE();
|
|
|
|
mapData.skip(tmp * 14);
|
2006-05-11 19:43:30 +00:00
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
loadSounds(mapData);
|
2006-05-11 19:43:30 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
mapData.skip(4 + 24);
|
2006-05-11 19:43:30 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
gobDataCount = mapData.readUint16LE();
|
|
|
|
objDataCount = mapData.readUint16LE();
|
2006-05-11 19:43:30 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
gobsPos = mapData.pos();
|
2007-04-02 11:05:09 +00:00
|
|
|
Common::MemoryReadStream gobsData(dataBuf + gobsPos, 4294967295U);
|
2007-03-20 14:51:57 +00:00
|
|
|
mapData.skip(gobDataCount * 8);
|
2006-05-11 19:43:30 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
objsPos = mapData.pos();
|
2007-04-02 11:05:09 +00:00
|
|
|
Common::MemoryReadStream objsData(dataBuf + objsPos, 4294967295U);
|
2007-03-20 14:51:57 +00:00
|
|
|
mapData.skip(objDataCount * 8);
|
2006-05-11 19:43:30 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
loadGoblins(mapData, gobsPos);
|
|
|
|
loadObjects(mapData, objsPos);
|
2006-05-11 19:43:30 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
tmp = mapData.readUint16LE();
|
|
|
|
for (int i = 0; i < tmp; i++) {
|
|
|
|
mapData.skip(30);
|
2006-05-11 19:43:30 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
flag = mapData.readSint32LE();
|
|
|
|
mapData.skip(56);
|
2006-05-11 19:43:30 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if (flag != 0)
|
|
|
|
mapData.skip(30);
|
|
|
|
}
|
2006-05-11 19:43:30 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
mapData.skip(50);
|
|
|
|
loadItemToObject(mapData);
|
2006-05-11 19:43:30 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
delete[] dataBuf;
|
|
|
|
}
|
2006-05-11 19:43:30 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
void Map_v1::loadSounds(Common::SeekableReadStream &data) {
|
|
|
|
int16 count;
|
2007-03-30 17:52:31 +00:00
|
|
|
char buf[19];
|
2013-04-15 16:35:33 +00:00
|
|
|
char sndNames[20][19];
|
2007-03-20 14:51:57 +00:00
|
|
|
|
|
|
|
count = data.readUint16LE();
|
|
|
|
|
|
|
|
for (int i = 0; i < count; i++) {
|
|
|
|
data.read(buf, 14);
|
2007-03-30 17:52:31 +00:00
|
|
|
buf[14] = 0;
|
2007-03-20 14:51:57 +00:00
|
|
|
strcat(buf, ".SND");
|
|
|
|
strcpy(sndNames[i], buf);
|
|
|
|
}
|
|
|
|
|
2008-12-14 03:44:39 +00:00
|
|
|
_vm->_sound->sampleLoad(&_vm->_goblin->_soundData[14], SOUND_SND, "diamant1.snd");
|
2007-03-20 14:51:57 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < count; i++) {
|
2010-10-31 20:07:14 +00:00
|
|
|
if (!_vm->_dataIO->hasFile(sndNames[i]))
|
2007-03-20 14:51:57 +00:00
|
|
|
continue;
|
|
|
|
|
2008-12-14 03:44:39 +00:00
|
|
|
_vm->_sound->sampleLoad(&_vm->_goblin->_soundData[i], SOUND_SND, sndNames[i]);
|
2007-03-20 14:51:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Map_v1::loadGoblins(Common::SeekableReadStream &data, uint32 gobsPos) {
|
|
|
|
Goblin::Gob_State *pState;
|
|
|
|
uint32 tmpStateData[40 * 6];
|
|
|
|
uint32 tmpPos;
|
|
|
|
|
|
|
|
_vm->_goblin->_gobsCount = data.readUint16LE();
|
|
|
|
for (int i = 0; i < _vm->_goblin->_gobsCount; i++) {
|
|
|
|
int linesCount = (i == 3) ? 70 : 40;
|
|
|
|
|
|
|
|
_vm->_goblin->_goblins[i] = new Goblin::Gob_Object;
|
|
|
|
memset(_vm->_goblin->_goblins[i], 0, sizeof(Goblin::Gob_Object));
|
|
|
|
|
|
|
|
tmpPos = data.pos();
|
|
|
|
data.seek(gobsPos);
|
|
|
|
_vm->_goblin->_goblins[i]->xPos = data.readUint16LE();
|
|
|
|
_vm->_goblin->_goblins[i]->yPos = data.readUint16LE();
|
|
|
|
_vm->_goblin->_goblins[i]->order = data.readUint16LE();
|
|
|
|
_vm->_goblin->_goblins[i]->state = data.readUint16LE();
|
|
|
|
gobsPos = data.pos();
|
|
|
|
data.seek(tmpPos);
|
|
|
|
|
|
|
|
_vm->_goblin->_goblins[i]->stateMach =
|
|
|
|
new Goblin::Gob_StateLine[linesCount];
|
|
|
|
for (int state = 0; state < linesCount; ++state)
|
|
|
|
for (int col = 0; col < 6; ++col)
|
|
|
|
_vm->_goblin->_goblins[i]->stateMach[state][col] = 0;
|
|
|
|
|
|
|
|
for (int state = 0; state < 40; ++state)
|
|
|
|
for (int col = 0; col < 6; ++col)
|
|
|
|
tmpStateData[state * 6 + col] = data.readUint32LE();
|
|
|
|
|
|
|
|
data.skip(160);
|
|
|
|
_vm->_goblin->_goblins[i]->multObjIndex = data.readByte();
|
|
|
|
data.skip(1);
|
|
|
|
|
|
|
|
_vm->_goblin->_goblins[i]->realStateMach =
|
|
|
|
_vm->_goblin->_goblins[i]->stateMach;
|
|
|
|
for (int state = 0; state < 40; state++) {
|
|
|
|
for (int col = 0; col < 6; col++) {
|
|
|
|
if (tmpStateData[state * 6 + col] == 0) {
|
2006-05-11 19:43:30 +00:00
|
|
|
_vm->_goblin->_goblins[i]->stateMach[state][col] = 0;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
Goblin::Gob_State *tmpState = new Goblin::Gob_State;
|
2007-03-20 14:51:57 +00:00
|
|
|
memset(tmpState, 0, sizeof(Goblin::Gob_State));
|
|
|
|
|
2006-05-11 19:43:30 +00:00
|
|
|
_vm->_goblin->_goblins[i]->stateMach[state][col] = tmpState;
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
tmpState->animation = data.readUint16LE();
|
|
|
|
tmpState->layer = data.readUint16LE();
|
|
|
|
data.skip(8);
|
|
|
|
tmpState->unk0 = data.readUint16LE();
|
|
|
|
tmpState->unk1 = data.readUint16LE();
|
|
|
|
|
|
|
|
data.skip(2);
|
|
|
|
if (data.readUint32LE() == 0) {
|
|
|
|
data.skip(2);
|
2006-05-11 19:43:30 +00:00
|
|
|
tmpState->sndItem = -1;
|
2007-03-20 14:51:57 +00:00
|
|
|
} else
|
|
|
|
tmpState->sndItem = data.readUint16LE();
|
|
|
|
|
|
|
|
tmpState->freq = data.readUint16LE();
|
|
|
|
tmpState->repCount = data.readUint16LE();
|
|
|
|
tmpState->sndFrame = data.readUint16LE();
|
2006-05-11 19:43:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pState = new Goblin::Gob_State;
|
2007-03-20 14:51:57 +00:00
|
|
|
memset(pState, 0, sizeof(Goblin::Gob_State));
|
2006-05-11 19:43:30 +00:00
|
|
|
_vm->_goblin->_goblins[0]->stateMach[39][0] = pState;
|
|
|
|
pState->layer = 98;
|
|
|
|
pState->sndItem = -1;
|
|
|
|
|
|
|
|
pState = new Goblin::Gob_State;
|
2007-03-20 14:51:57 +00:00
|
|
|
memset(pState, 0, sizeof(Goblin::Gob_State));
|
2006-05-11 19:43:30 +00:00
|
|
|
_vm->_goblin->_goblins[1]->stateMach[39][0] = pState;
|
|
|
|
pState->layer = 99;
|
|
|
|
pState->sndItem = -1;
|
|
|
|
|
|
|
|
pState = new Goblin::Gob_State;
|
2007-03-20 14:51:57 +00:00
|
|
|
memset(pState, 0, sizeof(Goblin::Gob_State));
|
2006-05-11 19:43:30 +00:00
|
|
|
_vm->_goblin->_goblins[2]->stateMach[39][0] = pState;
|
|
|
|
pState->layer = 100;
|
|
|
|
pState->sndItem = -1;
|
|
|
|
|
|
|
|
_vm->_goblin->_goblins[2]->stateMach[10][0]->sndFrame = 13;
|
|
|
|
_vm->_goblin->_goblins[2]->stateMach[11][0]->sndFrame = 13;
|
|
|
|
_vm->_goblin->_goblins[2]->stateMach[28][0]->sndFrame = 13;
|
|
|
|
_vm->_goblin->_goblins[2]->stateMach[29][0]->sndFrame = 13;
|
|
|
|
|
|
|
|
_vm->_goblin->_goblins[1]->stateMach[10][0]->sndFrame = 13;
|
|
|
|
_vm->_goblin->_goblins[1]->stateMach[11][0]->sndFrame = 13;
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
for (int state = 40; state < 70; state++) {
|
2006-05-11 19:43:30 +00:00
|
|
|
pState = new Goblin::Gob_State;
|
2007-03-20 14:51:57 +00:00
|
|
|
memset(pState, 0, sizeof(Goblin::Gob_State));
|
2006-05-11 19:43:30 +00:00
|
|
|
_vm->_goblin->_goblins[3]->stateMach[state][0] = pState;
|
|
|
|
_vm->_goblin->_goblins[3]->stateMach[state][1] = 0;
|
|
|
|
|
|
|
|
pState->animation = 9;
|
|
|
|
pState->layer = state - 40;
|
|
|
|
pState->sndItem = -1;
|
|
|
|
}
|
2007-03-20 14:51:57 +00:00
|
|
|
}
|
2006-05-11 19:43:30 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
void Map_v1::loadObjects(Common::SeekableReadStream &data, uint32 objsPos) {
|
|
|
|
Goblin::Gob_State *pState;
|
|
|
|
uint32 tmpStateData[40 * 6];
|
|
|
|
uint32 tmpPos;
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_goblin->_objCount = data.readUint16LE();
|
|
|
|
for (int i = 0; i < _vm->_goblin->_objCount; i++) {
|
2006-05-11 19:43:30 +00:00
|
|
|
_vm->_goblin->_objects[i] = new Goblin::Gob_Object;
|
2007-03-20 14:51:57 +00:00
|
|
|
memset(_vm->_goblin->_objects[i], 0, sizeof(Goblin::Gob_Object));
|
2006-05-11 19:43:30 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
tmpPos = data.pos();
|
|
|
|
data.seek(objsPos);
|
|
|
|
_vm->_goblin->_objects[i]->xPos = data.readUint16LE();
|
|
|
|
_vm->_goblin->_objects[i]->yPos = data.readUint16LE();
|
|
|
|
_vm->_goblin->_objects[i]->order = data.readUint16LE();
|
|
|
|
_vm->_goblin->_objects[i]->state = data.readUint16LE();
|
|
|
|
objsPos = data.pos();
|
|
|
|
data.seek(tmpPos);
|
2006-05-11 19:43:30 +00:00
|
|
|
|
|
|
|
_vm->_goblin->_objects[i]->stateMach = new Goblin::Gob_StateLine[40];
|
2007-03-20 14:51:57 +00:00
|
|
|
for (int state = 0; state < 40; ++state) {
|
|
|
|
for (int col = 0; col < 6; ++col) {
|
|
|
|
_vm->_goblin->_objects[i]->stateMach[state][col] = 0;
|
|
|
|
tmpStateData[state * 6 + col] = data.readUint32LE();
|
2006-05-11 19:43:30 +00:00
|
|
|
}
|
|
|
|
}
|
2007-03-20 14:51:57 +00:00
|
|
|
|
|
|
|
data.skip(160);
|
|
|
|
_vm->_goblin->_objects[i]->multObjIndex = data.readByte();
|
|
|
|
data.skip(1);
|
|
|
|
|
|
|
|
_vm->_goblin->_objects[i]->realStateMach =
|
|
|
|
_vm->_goblin->_objects[i]->stateMach;
|
|
|
|
for (int state = 0; state < 40; state++) {
|
|
|
|
for (int col = 0; col < 6; col++) {
|
|
|
|
if (tmpStateData[state * 6 + col] == 0) {
|
2006-05-11 19:43:30 +00:00
|
|
|
_vm->_goblin->_objects[i]->stateMach[state][col] = 0;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
Goblin::Gob_State *tmpState = new Goblin::Gob_State;
|
2007-03-20 14:51:57 +00:00
|
|
|
memset(tmpState, 0, sizeof(Goblin::Gob_State));
|
2006-05-11 19:43:30 +00:00
|
|
|
_vm->_goblin->_objects[i]->stateMach[state][col] = tmpState;
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
tmpState->animation = data.readUint16LE();
|
|
|
|
tmpState->layer = data.readUint16LE();
|
|
|
|
data.skip(8);
|
|
|
|
tmpState->unk0 = data.readUint16LE();
|
|
|
|
tmpState->unk1 = data.readUint16LE();
|
|
|
|
|
|
|
|
data.skip(2);
|
|
|
|
if (data.readUint32LE() == 0) {
|
|
|
|
data.skip(2);
|
2006-05-11 19:43:30 +00:00
|
|
|
tmpState->sndItem = -1;
|
2007-03-20 14:51:57 +00:00
|
|
|
} else
|
|
|
|
tmpState->sndItem = data.readUint16LE();
|
|
|
|
|
|
|
|
tmpState->freq = data.readUint16LE();
|
|
|
|
tmpState->repCount = data.readUint16LE();
|
|
|
|
tmpState->sndFrame = data.readUint16LE();
|
2006-05-11 19:43:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_vm->_goblin->_objects[10] = new Goblin::Gob_Object;
|
|
|
|
memset(_vm->_goblin->_objects[10], 0, sizeof(Goblin::Gob_Object));
|
|
|
|
|
|
|
|
_vm->_goblin->_objects[10]->stateMach = new Goblin::Gob_StateLine[40];
|
2007-03-20 14:51:57 +00:00
|
|
|
for (int state = 0; state < 40; ++state)
|
|
|
|
for (int col = 0; col < 6; ++col)
|
2006-05-11 19:43:30 +00:00
|
|
|
_vm->_goblin->_objects[10]->stateMach[state][col] = 0;
|
|
|
|
|
|
|
|
pState = new Goblin::Gob_State;
|
2007-03-20 14:51:57 +00:00
|
|
|
memset(pState, 0, sizeof(Goblin::Gob_State));
|
2006-05-11 19:43:30 +00:00
|
|
|
_vm->_goblin->_objects[10]->stateMach[0][0] = pState;
|
|
|
|
|
|
|
|
pState->animation = 9;
|
|
|
|
pState->layer = 27;
|
|
|
|
pState->sndItem = -1;
|
|
|
|
|
|
|
|
_vm->_goblin->placeObject(_vm->_goblin->_objects[10], 1, 0, 0, 0, 0);
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_goblin->_objects[10]->realStateMach =
|
|
|
|
_vm->_goblin->_objects[10]->stateMach;
|
2006-05-11 19:43:30 +00:00
|
|
|
_vm->_goblin->_objects[10]->type = 1;
|
|
|
|
_vm->_goblin->_objects[10]->unk14 = 1;
|
2007-03-20 14:51:57 +00:00
|
|
|
}
|
2006-05-11 19:43:30 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
void Map_v1::loadItemToObject(Common::SeekableReadStream &data) {
|
|
|
|
int16 count;
|
2006-05-11 19:43:30 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if (data.readUint16LE() == 0)
|
|
|
|
return;
|
2006-05-11 19:43:30 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
data.skip(1456);
|
|
|
|
count = data.readUint16LE();
|
|
|
|
for (int i = 0; i < count; i++) {
|
|
|
|
data.skip(20);
|
|
|
|
_vm->_goblin->_itemToObject[i] = data.readUint16LE();
|
|
|
|
data.skip(5);
|
2006-05-11 19:43:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-06-07 18:49:20 +00:00
|
|
|
void Map_v1::optimizePoints(Mult::Mult_Object *obj, int16 x, int16 y) {
|
2006-05-29 18:24:52 +00:00
|
|
|
if (_nearestWayPoint < _nearestDest) {
|
2007-03-20 14:51:57 +00:00
|
|
|
for (int i = _nearestWayPoint; i <= _nearestDest; i++) {
|
2006-06-07 18:49:20 +00:00
|
|
|
if (checkDirectPath(0, _curGoblinX, _curGoblinY,
|
2006-05-29 18:24:52 +00:00
|
|
|
_wayPoints[i].x, _wayPoints[i].y) == 1)
|
|
|
|
_nearestWayPoint = i;
|
|
|
|
}
|
|
|
|
} else if (_nearestWayPoint > _nearestDest) {
|
2007-03-20 14:51:57 +00:00
|
|
|
for (int i = _nearestWayPoint; i >= _nearestDest; i--) {
|
2006-06-07 18:49:20 +00:00
|
|
|
if (checkDirectPath(0, _curGoblinX, _curGoblinY,
|
2006-05-29 18:24:52 +00:00
|
|
|
_wayPoints[i].x, _wayPoints[i].y) == 1)
|
|
|
|
_nearestWayPoint = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-06-07 18:49:20 +00:00
|
|
|
void Map_v1::findNearestToGob(Mult::Mult_Object *obj) {
|
2006-05-29 18:24:52 +00:00
|
|
|
int16 wayPoint = findNearestWayPoint(_curGoblinX, _curGoblinY);
|
|
|
|
|
|
|
|
if (wayPoint != -1)
|
|
|
|
_nearestWayPoint = wayPoint;
|
|
|
|
}
|
|
|
|
|
2006-06-07 18:49:20 +00:00
|
|
|
void Map_v1::findNearestToDest(Mult::Mult_Object *obj) {
|
2006-05-29 18:24:52 +00:00
|
|
|
int16 wayPoint = findNearestWayPoint(_destX, _destY);
|
|
|
|
|
|
|
|
if (wayPoint != -1)
|
|
|
|
_nearestDest = wayPoint;
|
|
|
|
}
|
|
|
|
|
2006-05-11 19:43:30 +00:00
|
|
|
} // End of namespace Gob
|