2007-05-30 21:56:52 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
2004-04-12 21:40:49 +00:00
|
|
|
*
|
2007-05-30 21:56:52 +00:00
|
|
|
* 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.
|
2004-04-12 21:40:49 +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
|
2004-04-12 21:40:49 +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
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2004-04-12 21:40:49 +00:00
|
|
|
*
|
2006-02-11 12:44:16 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2004-04-12 21:40:49 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2004-05-01 06:16:57 +00:00
|
|
|
// Actor management module header file
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2006-07-23 15:16:50 +00:00
|
|
|
#ifndef SAGA_ACTOR_H
|
|
|
|
#define SAGA_ACTOR_H
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-05-23 18:53:36 +00:00
|
|
|
#include "common/savefile.h"
|
2005-04-27 11:51:11 +00:00
|
|
|
|
2004-08-03 01:07:34 +00:00
|
|
|
#include "saga/sprite.h"
|
2005-01-28 12:54:09 +00:00
|
|
|
#include "saga/itedata.h"
|
2005-01-08 20:30:07 +00:00
|
|
|
#include "saga/saga.h"
|
2005-11-03 18:20:12 +00:00
|
|
|
#include "saga/font.h"
|
2004-08-02 15:47:42 +00:00
|
|
|
|
2004-04-12 21:40:49 +00:00
|
|
|
namespace Saga {
|
|
|
|
|
2005-01-15 23:46:43 +00:00
|
|
|
class HitZone;
|
|
|
|
|
2005-01-18 21:13:44 +00:00
|
|
|
|
2007-07-13 16:45:11 +00:00
|
|
|
//#define ACTOR_DEBUG 1 //only for actor pathfinding debug!
|
2005-01-06 23:02:53 +00:00
|
|
|
|
2004-12-28 21:27:18 +00:00
|
|
|
#define ACTOR_BARRIERS_MAX 16
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-01-05 19:03:49 +00:00
|
|
|
#define ACTOR_MAX_STEPS_COUNT 32
|
2004-04-12 21:40:49 +00:00
|
|
|
|
|
|
|
#define ACTOR_DIALOGUE_HEIGHT 100
|
|
|
|
|
2004-10-27 21:32:28 +00:00
|
|
|
#define ACTOR_LMULT 4
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2007-05-29 12:55:17 +00:00
|
|
|
#define ACTOR_SPEED 72
|
|
|
|
|
2005-06-05 16:53:53 +00:00
|
|
|
#define ACTOR_CLIMB_SPEED 8
|
|
|
|
|
2004-12-28 21:27:18 +00:00
|
|
|
#define ACTOR_COLLISION_WIDTH 32
|
|
|
|
#define ACTOR_COLLISION_HEIGHT 8
|
|
|
|
|
2004-12-22 21:04:50 +00:00
|
|
|
#define ACTOR_DIRECTIONS_COUNT 4 // for ActorFrameSequence
|
2004-12-17 20:38:17 +00:00
|
|
|
|
2004-12-22 21:04:50 +00:00
|
|
|
#define ACTOR_SPEECH_STRING_MAX 16 // speech const
|
2004-12-21 06:49:07 +00:00
|
|
|
#define ACTOR_SPEECH_ACTORS_MAX 8
|
|
|
|
|
2005-06-29 20:00:44 +00:00
|
|
|
#define ACTOR_DRAGON_TURN_MOVES 4
|
2005-07-01 17:29:23 +00:00
|
|
|
#define ACTOR_DRAGON_INDEX 133
|
2005-06-29 20:00:44 +00:00
|
|
|
|
2005-05-08 14:04:06 +00:00
|
|
|
#define ACTOR_NO_ENTRANCE -1
|
|
|
|
|
2005-06-29 20:00:44 +00:00
|
|
|
#define ACTOR_EXP_KNOCK_RIF 24
|
|
|
|
|
2004-12-29 21:49:25 +00:00
|
|
|
#define PATH_NODE_EMPTY -1
|
|
|
|
|
2005-08-06 18:28:43 +00:00
|
|
|
#define ACTOR_INHM_SIZE 228
|
|
|
|
|
2008-12-23 15:26:55 +00:00
|
|
|
enum ActorDirections {
|
|
|
|
kDirectionRight = 0,
|
|
|
|
kDirectionLeft = 1,
|
|
|
|
kDirectionUp = 2,
|
|
|
|
kDirectionDown = 3
|
|
|
|
};
|
|
|
|
|
2004-12-21 06:49:07 +00:00
|
|
|
enum ActorActions {
|
|
|
|
kActionWait = 0,
|
|
|
|
kActionWalkToPoint = 1,
|
|
|
|
kActionWalkToLink = 2,
|
|
|
|
kActionWalkDir = 3,
|
|
|
|
kActionSpeak = 4,
|
|
|
|
kActionAccept = 5,
|
|
|
|
kActionStoop = 6,
|
|
|
|
kActionLook = 7,
|
|
|
|
kActionCycleFrames = 8,
|
|
|
|
kActionPongFrames = 9,
|
|
|
|
kActionFreeze = 10,
|
|
|
|
kActionFall = 11,
|
|
|
|
kActionClimb = 12
|
|
|
|
};
|
|
|
|
|
2007-09-15 15:02:40 +00:00
|
|
|
enum ActorFrameIds {
|
|
|
|
//ITE
|
|
|
|
kFrameITEStand = 0,
|
|
|
|
kFrameITEWalk = 1,
|
|
|
|
kFrameITESpeak = 2,
|
|
|
|
kFrameITEGive = 3,
|
|
|
|
kFrameITEGesture = 4,
|
|
|
|
kFrameITEWait = 5,
|
|
|
|
kFrameITEPickUp = 6,
|
|
|
|
kFrameITELook = 7,
|
|
|
|
//IHNM
|
|
|
|
kFrameIHNMStand = 0,
|
|
|
|
kFrameIHNMSpeak = 1,
|
|
|
|
kFrameIHNMWait = 2,
|
|
|
|
kFrameIHNMGesture = 3,
|
|
|
|
kFrameIHNMWalk = 4
|
|
|
|
};
|
|
|
|
|
2004-12-21 06:49:07 +00:00
|
|
|
enum SpeechFlags {
|
|
|
|
kSpeakNoAnimate = 1,
|
|
|
|
kSpeakAsync = 2,
|
2007-06-15 03:58:21 +00:00
|
|
|
kSpeakSlow = 4,
|
|
|
|
kSpeakForceText = 8
|
2004-12-21 06:49:07 +00:00
|
|
|
};
|
|
|
|
|
2004-12-22 21:04:50 +00:00
|
|
|
enum ActorFrameTypes {
|
2006-01-11 18:50:17 +00:00
|
|
|
kFrameStand,
|
|
|
|
kFrameWalk,
|
|
|
|
kFrameSpeak,
|
|
|
|
kFrameGive,
|
|
|
|
kFrameGesture,
|
|
|
|
kFrameWait,
|
|
|
|
kFramePickUp,
|
|
|
|
kFrameLook
|
2004-12-22 21:04:50 +00:00
|
|
|
};
|
|
|
|
|
2007-09-15 15:02:40 +00:00
|
|
|
// Lookup table to convert 8 cardinal directions to 4
|
2008-12-23 15:26:55 +00:00
|
|
|
static const int actorDirectionsLUT[8] = {
|
|
|
|
kDirectionUp, // kDirUp
|
|
|
|
kDirectionRight, // kDirUpRight
|
|
|
|
kDirectionRight, // kDirRight
|
|
|
|
kDirectionRight, // kDirDownRight
|
|
|
|
kDirectionDown, // kDirDown
|
|
|
|
kDirectionLeft, // kDirDownLeft
|
|
|
|
kDirectionLeft, // kDirLeft
|
|
|
|
kDirectionLeft // kDirUpLeft
|
2007-09-15 15:02:40 +00:00
|
|
|
};
|
|
|
|
|
2004-12-22 21:04:50 +00:00
|
|
|
enum ActorFlagsEx {
|
|
|
|
kActorNoCollide = (1 << 0),
|
|
|
|
kActorNoFollow = (1 << 1),
|
|
|
|
kActorCollided = (1 << 2),
|
|
|
|
kActorBackwards = (1 << 3),
|
|
|
|
kActorContinuous = (1 << 4),
|
|
|
|
kActorFinalFace = (1 << 5),
|
|
|
|
kActorFinishLeft = ((1 << 5) | (kDirLeft << 6)),
|
|
|
|
kActorFinishRight = ((1 << 5) | (kDirRight << 6)),
|
|
|
|
kActorFinishUp = ((1 << 5) | (kDirUp << 6)),
|
|
|
|
kActorFinishDown = ((1 << 5) | (kDirDown << 6)),
|
2004-12-25 11:17:03 +00:00
|
|
|
kActorFacingMask = (0xf << 5),
|
2004-12-22 21:04:50 +00:00
|
|
|
kActorRandom = (1 << 10)
|
|
|
|
};
|
|
|
|
|
2004-12-29 14:33:14 +00:00
|
|
|
enum PathCellType {
|
|
|
|
kPathCellEmpty = -1,
|
2005-07-30 21:11:48 +00:00
|
|
|
//kDirUp = 0 .... kDirUpLeft = 7
|
2004-12-29 14:33:14 +00:00
|
|
|
kPathCellBarrier = 0x57
|
|
|
|
};
|
2004-08-02 15:47:42 +00:00
|
|
|
|
2005-06-29 20:00:44 +00:00
|
|
|
enum DragonMoveTypes {
|
|
|
|
kDragonMoveUpLeft = 0,
|
|
|
|
kDragonMoveUpRight = 1,
|
|
|
|
kDragonMoveDownLeft = 2,
|
|
|
|
kDragonMoveDownRight = 3,
|
|
|
|
kDragonMoveUpLeft_Left = 4,
|
|
|
|
kDragonMoveUpLeft_Right = 5,
|
|
|
|
kDragonMoveUpRight_Left = 6,
|
|
|
|
kDragonMoveUpRight_Right = 7,
|
|
|
|
kDragonMoveDownLeft_Left = 8,
|
|
|
|
kDragonMoveDownLeft_Right = 9,
|
|
|
|
kDragonMoveDownRight_Left = 10,
|
|
|
|
kDragonMoveDownRight_Right = 11,
|
|
|
|
kDragonMoveInvalid = 12
|
|
|
|
};
|
|
|
|
|
2004-12-28 21:27:18 +00:00
|
|
|
struct PathDirectionData {
|
2005-01-06 22:22:20 +00:00
|
|
|
int8 direction;
|
2009-08-18 06:43:06 +00:00
|
|
|
int16 x;
|
|
|
|
int16 y;
|
2004-12-28 21:27:18 +00:00
|
|
|
};
|
|
|
|
|
2004-12-22 21:04:50 +00:00
|
|
|
struct ActorFrameRange {
|
2004-12-17 20:38:17 +00:00
|
|
|
int frameIndex;
|
|
|
|
int frameCount;
|
2004-04-25 14:42:14 +00:00
|
|
|
};
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-12-22 21:04:50 +00:00
|
|
|
struct ActorFrameSequence {
|
|
|
|
ActorFrameRange directions[ACTOR_DIRECTIONS_COUNT];
|
2004-04-25 14:42:14 +00:00
|
|
|
};
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2009-05-01 15:32:15 +00:00
|
|
|
uint pathLine(PointList &pointList, uint idx, const Point &point1, const Point &point2);
|
2005-05-31 01:03:13 +00:00
|
|
|
|
2005-01-15 20:12:49 +00:00
|
|
|
struct Location {
|
2005-04-27 11:51:11 +00:00
|
|
|
int32 x; // logical coordinates
|
2005-07-30 21:11:48 +00:00
|
|
|
int32 y; //
|
|
|
|
int32 z; //
|
2005-01-15 20:12:49 +00:00
|
|
|
Location() {
|
2004-12-28 21:27:18 +00:00
|
|
|
x = y = z = 0;
|
|
|
|
}
|
2005-05-23 18:53:36 +00:00
|
|
|
void saveState(Common::OutSaveFile *out) {
|
|
|
|
out->writeSint32LE(x);
|
|
|
|
out->writeSint32LE(y);
|
|
|
|
out->writeSint32LE(z);
|
2005-04-27 11:51:11 +00:00
|
|
|
}
|
2005-05-23 18:53:36 +00:00
|
|
|
void loadState(Common::InSaveFile *in) {
|
|
|
|
x = in->readSint32LE();
|
|
|
|
y = in->readSint32LE();
|
|
|
|
z = in->readSint32LE();
|
2005-04-27 11:51:11 +00:00
|
|
|
}
|
|
|
|
|
2005-01-15 20:12:49 +00:00
|
|
|
int distance(const Location &location) const {
|
2004-12-28 21:27:18 +00:00
|
|
|
return MAX(ABS(x - location.x), ABS(y - location.y));
|
|
|
|
}
|
2005-04-27 11:51:11 +00:00
|
|
|
int32 &u() {
|
2005-02-09 20:30:45 +00:00
|
|
|
return x;
|
|
|
|
}
|
2005-04-27 11:51:11 +00:00
|
|
|
int32 &v() {
|
2005-02-09 20:30:45 +00:00
|
|
|
return y;
|
|
|
|
}
|
2005-04-27 11:51:11 +00:00
|
|
|
int32 u() const {
|
2005-02-18 00:00:00 +00:00
|
|
|
return x;
|
|
|
|
}
|
2005-04-27 11:51:11 +00:00
|
|
|
int32 v() const {
|
2005-02-18 00:00:00 +00:00
|
|
|
return y;
|
|
|
|
}
|
2005-04-27 11:51:11 +00:00
|
|
|
int32 uv() const {
|
2005-03-13 17:43:50 +00:00
|
|
|
return u() + v();
|
|
|
|
}
|
2005-01-15 20:12:49 +00:00
|
|
|
void delta(const Location &location, Location &result) const {
|
2004-12-28 21:27:18 +00:00
|
|
|
result.x = x - location.x;
|
2005-01-04 18:54:29 +00:00
|
|
|
result.y = y - location.y;
|
2004-12-28 21:27:18 +00:00
|
|
|
result.z = z - location.z;
|
|
|
|
}
|
2005-04-19 11:07:06 +00:00
|
|
|
void addXY(const Location &location) {
|
|
|
|
x += location.x;
|
|
|
|
y += location.y;
|
|
|
|
}
|
2005-01-15 20:12:49 +00:00
|
|
|
void add(const Location &location) {
|
2004-12-28 21:27:18 +00:00
|
|
|
x += location.x;
|
|
|
|
y += location.y;
|
|
|
|
z += location.z;
|
2004-12-25 11:17:03 +00:00
|
|
|
}
|
2005-01-04 16:10:43 +00:00
|
|
|
void fromScreenPoint(const Point &screenPoint) {
|
|
|
|
x = (screenPoint.x * ACTOR_LMULT);
|
|
|
|
y = (screenPoint.y * ACTOR_LMULT);
|
|
|
|
z = 0;
|
|
|
|
}
|
2005-01-05 19:03:49 +00:00
|
|
|
void toScreenPointXY(Point &screenPoint) const {
|
|
|
|
screenPoint.x = x / ACTOR_LMULT;
|
|
|
|
screenPoint.y = y / ACTOR_LMULT;
|
|
|
|
}
|
2005-03-13 17:43:50 +00:00
|
|
|
void toScreenPointUV(Point &screenPoint) const {
|
|
|
|
screenPoint.x = u();
|
|
|
|
screenPoint.y = v();
|
|
|
|
}
|
2005-01-05 19:03:49 +00:00
|
|
|
void toScreenPointXYZ(Point &screenPoint) const {
|
|
|
|
screenPoint.x = x / ACTOR_LMULT;
|
|
|
|
screenPoint.y = y / ACTOR_LMULT - z;
|
|
|
|
}
|
2007-09-23 09:59:10 +00:00
|
|
|
void fromStream(MemoryReadStream &stream) {
|
2005-08-06 18:28:43 +00:00
|
|
|
x = stream.readUint16LE();
|
|
|
|
y = stream.readUint16LE();
|
|
|
|
z = stream.readUint16LE();
|
|
|
|
}
|
2005-09-03 07:56:42 +00:00
|
|
|
|
2008-01-27 15:54:16 +00:00
|
|
|
#if 0
|
|
|
|
// Obsolete function, throws warnings in older versions of GCC
|
|
|
|
// (warning: int format, int32 arg)
|
|
|
|
// Keeping it around for debug purposes
|
2005-09-03 07:56:42 +00:00
|
|
|
void debugPrint(int debuglevel = 0, const char *loc = "Loc:") const {
|
|
|
|
debug(debuglevel, "%s %d, %d, %d", loc, x, y, z);
|
|
|
|
}
|
2008-01-27 15:54:16 +00:00
|
|
|
#endif
|
|
|
|
|
2004-12-22 21:04:50 +00:00
|
|
|
};
|
2004-12-28 21:27:18 +00:00
|
|
|
|
2005-01-18 21:13:44 +00:00
|
|
|
class CommonObjectData {
|
|
|
|
public:
|
2005-04-27 11:51:11 +00:00
|
|
|
//constant
|
2005-08-10 14:53:17 +00:00
|
|
|
bool _disabled; // disabled in init section
|
|
|
|
int32 _index; // index in local array
|
|
|
|
uint16 _id; // object id
|
|
|
|
int32 _scriptEntrypointNumber; // script entrypoint number
|
2005-04-18 20:03:14 +00:00
|
|
|
|
2005-04-27 11:51:11 +00:00
|
|
|
//variables
|
2005-08-10 14:53:17 +00:00
|
|
|
uint16 _flags; // initial flags
|
|
|
|
int32 _nameIndex; // index in name string list
|
|
|
|
int32 _sceneNumber; // scene
|
|
|
|
int32 _spriteListResourceId; // sprite list resource id
|
|
|
|
|
|
|
|
Location _location; // logical coordinates
|
|
|
|
Point _screenPosition; // screen coordinates
|
|
|
|
int32 _screenDepth; //
|
|
|
|
int32 _screenScale; //
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2005-05-23 18:53:36 +00:00
|
|
|
void saveState(Common::OutSaveFile *out) {
|
2005-08-10 14:53:17 +00:00
|
|
|
out->writeUint16LE(_flags);
|
|
|
|
out->writeSint32LE(_nameIndex);
|
|
|
|
out->writeSint32LE(_sceneNumber);
|
|
|
|
out->writeSint32LE(_spriteListResourceId);
|
|
|
|
_location.saveState(out);
|
|
|
|
out->writeSint16LE(_screenPosition.x);
|
|
|
|
out->writeSint16LE(_screenPosition.y);
|
|
|
|
out->writeSint32LE(_screenDepth);
|
|
|
|
out->writeSint32LE(_screenScale);
|
2005-05-23 18:53:36 +00:00
|
|
|
}
|
|
|
|
void loadState(Common::InSaveFile *in) {
|
2005-08-10 14:53:17 +00:00
|
|
|
_flags = in->readUint16LE();
|
|
|
|
_nameIndex = in->readSint32LE();
|
|
|
|
_sceneNumber = in->readSint32LE();
|
|
|
|
_spriteListResourceId = in->readSint32LE();
|
|
|
|
_location.loadState(in);
|
|
|
|
_screenPosition.x = in->readSint16LE();
|
|
|
|
_screenPosition.y = in->readSint16LE();
|
|
|
|
_screenDepth = in->readSint32LE();
|
|
|
|
_screenScale = in->readSint32LE();
|
2005-01-18 21:13:44 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef CommonObjectData *CommonObjectDataPointer;
|
|
|
|
|
2009-04-11 09:54:55 +00:00
|
|
|
typedef Common::List<CommonObjectDataPointer> CommonObjectOrderList;
|
2005-01-18 21:13:44 +00:00
|
|
|
|
2005-07-30 21:11:48 +00:00
|
|
|
class ObjectData: public CommonObjectData {
|
2005-01-18 21:13:44 +00:00
|
|
|
public:
|
2005-04-27 11:51:11 +00:00
|
|
|
//constant
|
2005-08-10 14:53:17 +00:00
|
|
|
uint16 _interactBits;
|
2005-04-27 11:51:11 +00:00
|
|
|
ObjectData() {
|
2005-07-30 21:11:48 +00:00
|
|
|
memset(this, 0, sizeof(*this));
|
2005-04-27 11:51:11 +00:00
|
|
|
}
|
2005-01-18 21:13:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class ActorData: public CommonObjectData {
|
|
|
|
public:
|
2005-04-27 11:51:11 +00:00
|
|
|
//constant
|
2005-08-10 14:53:17 +00:00
|
|
|
SpriteList _spriteList; // sprite list data
|
2005-04-27 11:51:11 +00:00
|
|
|
|
2007-06-09 22:45:03 +00:00
|
|
|
bool _shareFrames;
|
2005-08-10 14:53:17 +00:00
|
|
|
ActorFrameSequence *_frames; // Actor's frames
|
|
|
|
int _framesCount; // Actor's frames count
|
|
|
|
int _frameListResourceId; // Actor's frame list resource id
|
2005-03-18 17:11:37 +00:00
|
|
|
|
2005-08-10 14:53:17 +00:00
|
|
|
byte _speechColor; // Actor dialogue color
|
2005-06-12 15:58:37 +00:00
|
|
|
//
|
2005-08-10 14:53:17 +00:00
|
|
|
bool _inScene;
|
2005-06-12 15:58:37 +00:00
|
|
|
|
2005-04-27 11:51:11 +00:00
|
|
|
//variables
|
2005-08-10 14:53:17 +00:00
|
|
|
uint16 _actorFlags; // dynamic flags
|
|
|
|
int32 _currentAction; // ActorActions type
|
|
|
|
int32 _facingDirection; // orientation
|
|
|
|
int32 _actionDirection;
|
|
|
|
int32 _actionCycle;
|
|
|
|
uint16 _targetObject;
|
|
|
|
const HitZone *_lastZone;
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2005-08-10 14:53:17 +00:00
|
|
|
int32 _cycleFrameSequence;
|
|
|
|
uint8 _cycleDelay;
|
|
|
|
uint8 _cycleTimeCount;
|
|
|
|
uint8 _cycleFlags;
|
2004-12-22 21:04:50 +00:00
|
|
|
|
2005-08-10 14:53:17 +00:00
|
|
|
int16 _fallVelocity;
|
|
|
|
int16 _fallAcceleration;
|
|
|
|
int16 _fallPosition;
|
2005-06-05 16:53:53 +00:00
|
|
|
|
2005-08-10 14:53:17 +00:00
|
|
|
uint8 _dragonBaseFrame;
|
|
|
|
uint8 _dragonStepCycle;
|
|
|
|
uint8 _dragonMoveType;
|
2005-06-29 20:00:44 +00:00
|
|
|
|
2005-08-10 14:53:17 +00:00
|
|
|
int32 _frameNumber; // current frame number
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2005-08-10 14:53:17 +00:00
|
|
|
int32 _tileDirectionsAlloced;
|
|
|
|
byte *_tileDirections;
|
2005-02-26 17:37:16 +00:00
|
|
|
|
2005-08-10 14:53:17 +00:00
|
|
|
int32 _walkStepsAlloced;
|
|
|
|
Point *_walkStepsPoints;
|
2005-01-05 19:03:49 +00:00
|
|
|
|
2005-08-10 14:53:17 +00:00
|
|
|
int32 _walkStepsCount;
|
|
|
|
int32 _walkStepIndex;
|
2005-02-26 17:37:16 +00:00
|
|
|
|
2005-08-10 14:53:17 +00:00
|
|
|
Location _finalTarget;
|
|
|
|
Location _partialTarget;
|
|
|
|
int32 _walkFrameSequence;
|
2005-04-27 11:51:11 +00:00
|
|
|
|
2005-08-07 00:00:43 +00:00
|
|
|
public:
|
2009-04-28 12:33:38 +00:00
|
|
|
ActorData();
|
|
|
|
~ActorData();
|
2005-06-29 20:00:44 +00:00
|
|
|
|
2009-04-28 12:33:38 +00:00
|
|
|
void saveState(Common::OutSaveFile *out);
|
|
|
|
void loadState(uint32 version, Common::InSaveFile *in);
|
2005-12-01 18:22:29 +00:00
|
|
|
|
2009-04-28 12:33:38 +00:00
|
|
|
void setTileDirectionsSize(int size, bool forceRealloc);
|
|
|
|
void cycleWrap(int cycleLimit);
|
|
|
|
void setWalkStepsPointsSize(int size, bool forceRealloc);
|
|
|
|
void addWalkStepPoint(const Point &point);
|
|
|
|
void freeSpriteList();
|
2004-04-25 14:42:14 +00:00
|
|
|
};
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2007-06-09 22:45:03 +00:00
|
|
|
struct ProtagStateData {
|
|
|
|
ActorFrameSequence *_frames; // Actor's frames
|
|
|
|
int _framesCount; // Actor's frames count
|
|
|
|
};
|
2005-01-18 21:13:44 +00:00
|
|
|
|
2004-12-15 00:24:12 +00:00
|
|
|
|
2004-12-21 06:49:07 +00:00
|
|
|
struct SpeechData {
|
2005-01-13 07:47:04 +00:00
|
|
|
int speechColor[ACTOR_SPEECH_ACTORS_MAX];
|
|
|
|
int outlineColor[ACTOR_SPEECH_ACTORS_MAX];
|
2004-12-21 06:49:07 +00:00
|
|
|
int speechFlags;
|
|
|
|
const char *strings[ACTOR_SPEECH_STRING_MAX];
|
2005-07-14 17:46:21 +00:00
|
|
|
Rect speechBox;
|
|
|
|
Rect drawRect;
|
2004-12-21 06:49:07 +00:00
|
|
|
int stringsCount;
|
|
|
|
int slowModeCharIndex;
|
|
|
|
uint16 actorIds[ACTOR_SPEECH_ACTORS_MAX];
|
|
|
|
int actorsCount;
|
|
|
|
int sampleResourceId;
|
|
|
|
bool playing;
|
|
|
|
int playingTime;
|
|
|
|
|
2005-07-30 21:11:48 +00:00
|
|
|
SpeechData() {
|
|
|
|
memset(this, 0, sizeof(*this));
|
2004-12-21 06:49:07 +00:00
|
|
|
}
|
2005-07-14 17:46:21 +00:00
|
|
|
|
|
|
|
FontEffectFlags getFontFlags(int i) {
|
|
|
|
if (outlineColor[i] != 0) {
|
|
|
|
return kFontOutline;
|
|
|
|
} else {
|
|
|
|
return kFontNormal;
|
|
|
|
}
|
|
|
|
}
|
2004-12-21 06:49:07 +00:00
|
|
|
};
|
|
|
|
|
2009-04-11 09:54:55 +00:00
|
|
|
typedef int (*CompareFunction) (const CommonObjectDataPointer& a, const CommonObjectDataPointer& b);
|
2005-01-15 23:46:43 +00:00
|
|
|
|
2004-08-02 15:47:42 +00:00
|
|
|
class Actor {
|
2005-04-22 14:11:04 +00:00
|
|
|
friend class IsoMap;
|
|
|
|
friend class SagaEngine;
|
2005-12-01 18:22:29 +00:00
|
|
|
friend class Puzzle;
|
2004-10-31 13:51:01 +00:00
|
|
|
public:
|
2004-12-22 21:04:50 +00:00
|
|
|
|
2004-08-02 15:47:42 +00:00
|
|
|
Actor(SagaEngine *vm);
|
|
|
|
~Actor();
|
2005-01-08 20:30:07 +00:00
|
|
|
|
|
|
|
void cmdActorWalkTo(int argc, const char **argv);
|
|
|
|
|
2005-01-18 21:13:44 +00:00
|
|
|
bool validActorId(uint16 id) { return (id == ID_PROTAG) || ((id >= objectIndexToId(kGameObjectActor, 0)) && (id < objectIndexToId(kGameObjectActor, _actorsCount))); }
|
2005-01-18 15:01:21 +00:00
|
|
|
int actorIdToIndex(uint16 id) { return (id == ID_PROTAG ) ? 0 : objectIdToIndex(id); }
|
|
|
|
uint16 actorIndexToId(int index) { return (index == 0 ) ? ID_PROTAG : objectIndexToId(kGameObjectActor, index); }
|
2005-01-18 21:13:44 +00:00
|
|
|
ActorData *getActor(uint16 actorId);
|
2007-06-19 01:37:48 +00:00
|
|
|
ActorData *getFirstActor() { return _actors[0]; }
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2005-01-18 21:13:44 +00:00
|
|
|
// clarification: Obj - means game object, such Hat, Spoon etc, Object - means Actor,Obj,HitZone,StepZone
|
|
|
|
|
|
|
|
bool validObjId(uint16 id) { return (id >= objectIndexToId(kGameObjectObject, 0)) && (id < objectIndexToId(kGameObjectObject, _objsCount)); }
|
|
|
|
int objIdToIndex(uint16 id) { return objectIdToIndex(id); }
|
|
|
|
uint16 objIndexToId(int index) { return objectIndexToId(kGameObjectObject, index); }
|
|
|
|
ObjectData *getObj(uint16 objId);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2005-01-18 21:13:44 +00:00
|
|
|
int getObjectScriptEntrypointNumber(uint16 id) {
|
|
|
|
int objectType;
|
|
|
|
objectType = objectTypeId(id);
|
|
|
|
if (!(objectType & (kGameObjectObject | kGameObjectActor))) {
|
|
|
|
error("Actor::getObjectScriptEntrypointNumber wrong id 0x%X", id);
|
|
|
|
}
|
2005-08-10 14:53:17 +00:00
|
|
|
return (objectType == kGameObjectObject) ? getObj(id)->_scriptEntrypointNumber : getActor(id)->_scriptEntrypointNumber;
|
2005-01-18 21:13:44 +00:00
|
|
|
}
|
|
|
|
int getObjectFlags(uint16 id) {
|
|
|
|
int objectType;
|
|
|
|
objectType = objectTypeId(id);
|
|
|
|
if (!(objectType & (kGameObjectObject | kGameObjectActor))) {
|
|
|
|
error("Actor::getObjectFlags wrong id 0x%X", id);
|
|
|
|
}
|
2005-08-10 14:53:17 +00:00
|
|
|
return (objectType == kGameObjectObject) ? getObj(id)->_flags : getActor(id)->_flags;
|
2005-01-18 21:13:44 +00:00
|
|
|
}
|
2005-01-08 20:30:07 +00:00
|
|
|
|
2005-06-15 19:26:32 +00:00
|
|
|
void direct(int msec);
|
2005-05-08 14:04:06 +00:00
|
|
|
void drawActors();
|
2005-01-15 23:46:43 +00:00
|
|
|
void updateActorsScene(int actorsEntrance); // calls from scene loading to update Actors info
|
2004-08-02 15:47:42 +00:00
|
|
|
|
2005-05-23 02:23:34 +00:00
|
|
|
void drawSpeech();
|
|
|
|
|
2008-12-04 18:38:02 +00:00
|
|
|
#ifdef ACTOR_DEBUG
|
2005-01-06 19:15:01 +00:00
|
|
|
void drawPathTest();
|
2008-12-04 18:38:02 +00:00
|
|
|
#endif
|
2005-01-06 19:15:01 +00:00
|
|
|
|
2005-04-18 20:03:14 +00:00
|
|
|
uint16 hitTest(const Point &testPoint, bool skipProtagonist);
|
2005-01-15 23:46:43 +00:00
|
|
|
void takeExit(uint16 actorId, const HitZone *hitZone);
|
2004-12-25 11:17:03 +00:00
|
|
|
bool actorEndWalk(uint16 actorId, bool recurse);
|
2005-07-30 21:11:48 +00:00
|
|
|
bool actorWalkTo(uint16 actorId, const Location &toLocation);
|
2006-01-11 18:50:17 +00:00
|
|
|
int getFrameType(ActorFrameTypes frameType);
|
2004-12-22 21:04:50 +00:00
|
|
|
ActorFrameRange *getActorFrameRange(uint16 actorId, int frameType);
|
2005-01-15 20:12:49 +00:00
|
|
|
void actorFaceTowardsPoint(uint16 actorId, const Location &toLocation);
|
2005-01-06 19:15:01 +00:00
|
|
|
void actorFaceTowardsObject(uint16 actorId, uint16 objectId);
|
2004-08-02 15:47:42 +00:00
|
|
|
|
2005-01-18 21:13:44 +00:00
|
|
|
void realLocation(Location &location, uint16 objectId, uint16 walkFlags);
|
|
|
|
|
2005-07-30 21:11:48 +00:00
|
|
|
// speech
|
2005-06-03 19:04:21 +00:00
|
|
|
void actorSpeech(uint16 actorId, const char **strings, int stringsCount, int sampleResourceId, int speechFlags);
|
2005-07-15 15:23:19 +00:00
|
|
|
void nonActorSpeech(const Common::Rect &box, const char **strings, int stringsCount, int sampleResourceId, int speechFlags);
|
2005-05-22 01:20:47 +00:00
|
|
|
void simulSpeech(const char *string, uint16 *actorIds, int actorIdsCount, int speechFlags, int sampleResourceId);
|
2004-12-21 06:49:07 +00:00
|
|
|
void setSpeechColor(int speechColor, int outlineColor) {
|
2005-01-13 07:47:04 +00:00
|
|
|
_activeSpeech.speechColor[0] = speechColor;
|
|
|
|
_activeSpeech.outlineColor[0] = outlineColor;
|
2004-12-21 06:49:07 +00:00
|
|
|
}
|
|
|
|
void abortAllSpeeches();
|
|
|
|
void abortSpeech();
|
|
|
|
bool isSpeaking() {
|
|
|
|
return _activeSpeech.stringsCount > 0;
|
|
|
|
}
|
2005-04-21 01:30:07 +00:00
|
|
|
|
2007-06-15 03:58:21 +00:00
|
|
|
int isForcedTextShown() {
|
|
|
|
return _activeSpeech.speechFlags & kSpeakForceText;
|
|
|
|
}
|
|
|
|
|
2005-05-23 18:53:36 +00:00
|
|
|
void saveState(Common::OutSaveFile *out);
|
|
|
|
void loadState(Common::InSaveFile *in);
|
2005-04-28 17:19:43 +00:00
|
|
|
|
2005-04-21 01:30:07 +00:00
|
|
|
void setProtagState(int state);
|
|
|
|
int getProtagState() { return _protagState; }
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2007-06-09 22:45:03 +00:00
|
|
|
void freeProtagStates();
|
|
|
|
|
2005-08-07 11:20:43 +00:00
|
|
|
void freeActorList();
|
|
|
|
void loadActorList(int protagonistIdx, int actorCount, int actorsResourceID,
|
2005-08-06 14:26:59 +00:00
|
|
|
int protagStatesCount, int protagStatesResourceID);
|
2005-08-07 00:00:43 +00:00
|
|
|
void freeObjList();
|
|
|
|
void loadObjList(int objectCount, int objectsResourceID);
|
2005-08-06 14:26:59 +00:00
|
|
|
|
2005-10-09 01:43:08 +00:00
|
|
|
protected:
|
|
|
|
friend class Script;
|
2004-12-30 18:45:48 +00:00
|
|
|
bool loadActorResources(ActorData *actor);
|
2007-06-09 22:45:03 +00:00
|
|
|
void loadFrameList(int frameListResourceId, ActorFrameSequence *&framesPointer, int &framesCount);
|
2005-10-09 01:43:08 +00:00
|
|
|
private:
|
2005-01-15 23:46:43 +00:00
|
|
|
void stepZoneAction(ActorData *actor, const HitZone *hitZone, bool exit, bool stopped);
|
2005-12-01 18:22:29 +00:00
|
|
|
void loadActorSpriteList(ActorData *actor);
|
2005-01-15 23:46:43 +00:00
|
|
|
|
2009-04-11 09:54:55 +00:00
|
|
|
void drawOrderListAdd(const CommonObjectDataPointer& element, CompareFunction compareFunction);
|
2004-12-18 20:33:02 +00:00
|
|
|
void createDrawOrderList();
|
2005-07-08 16:56:03 +00:00
|
|
|
bool calcScreenPosition(CommonObjectData *commonObjectData);
|
2005-01-18 23:15:41 +00:00
|
|
|
bool getSpriteParams(CommonObjectData *commonObjectData, int &frameNumber, SpriteList *&spriteList);
|
2005-01-18 21:13:44 +00:00
|
|
|
|
2004-12-30 18:45:48 +00:00
|
|
|
bool followProtagonist(ActorData *actor);
|
|
|
|
void findActorPath(ActorData *actor, const Point &fromPoint, const Point &toPoint);
|
2004-12-21 06:49:07 +00:00
|
|
|
void handleSpeech(int msec);
|
2004-12-22 21:04:50 +00:00
|
|
|
void handleActions(int msec, bool setup);
|
2005-01-04 18:54:29 +00:00
|
|
|
bool validPathCellPoint(const Point &testPoint) {
|
|
|
|
return !((testPoint.x < 0) || (testPoint.x >= _xCellCount) ||
|
|
|
|
(testPoint.y < 0) || (testPoint.y >= _yCellCount));
|
|
|
|
}
|
2005-07-30 21:11:48 +00:00
|
|
|
void setPathCell(const Point &testPoint, int8 value) {
|
2007-05-08 16:09:47 +00:00
|
|
|
#ifdef ACTOR_DEBUG
|
2005-01-04 18:54:29 +00:00
|
|
|
if (!validPathCellPoint(testPoint)) {
|
|
|
|
error("Actor::setPathCell wrong point");
|
|
|
|
}
|
2007-05-08 16:09:47 +00:00
|
|
|
#endif
|
2004-12-28 21:27:18 +00:00
|
|
|
_pathCell[testPoint.x + testPoint.y * _xCellCount] = value;
|
|
|
|
}
|
2005-01-06 22:22:20 +00:00
|
|
|
int8 getPathCell(const Point &testPoint) {
|
2007-05-08 16:09:47 +00:00
|
|
|
#ifdef ACTOR_DEBUG
|
2005-01-04 18:54:29 +00:00
|
|
|
if (!validPathCellPoint(testPoint)) {
|
|
|
|
error("Actor::getPathCell wrong point");
|
|
|
|
}
|
2007-05-08 16:09:47 +00:00
|
|
|
#endif
|
2004-12-28 21:27:18 +00:00
|
|
|
return _pathCell[testPoint.x + testPoint.y * _xCellCount];
|
|
|
|
}
|
|
|
|
bool scanPathLine(const Point &point1, const Point &point2);
|
2004-12-29 21:49:25 +00:00
|
|
|
int fillPathArray(const Point &fromPoint, const Point &toPoint, Point &bestPoint);
|
2004-12-30 18:45:48 +00:00
|
|
|
void setActorPath(ActorData *actor, const Point &fromPoint, const Point &toPoint);
|
2004-12-29 21:49:25 +00:00
|
|
|
void pathToNode();
|
|
|
|
void condenseNodeList();
|
|
|
|
void removeNodes();
|
|
|
|
void nodeToPath();
|
|
|
|
void removePathPoints();
|
2005-01-15 20:12:49 +00:00
|
|
|
bool validFollowerLocation(const Location &location);
|
2005-06-29 20:00:44 +00:00
|
|
|
void moveDragon(ActorData *actor);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
|
|
|
|
2005-02-26 11:44:30 +00:00
|
|
|
protected:
|
2005-04-28 17:19:43 +00:00
|
|
|
//constants
|
2005-01-15 20:12:49 +00:00
|
|
|
int _actorsCount;
|
|
|
|
ActorData **_actors;
|
2005-01-18 21:13:44 +00:00
|
|
|
|
|
|
|
int _objsCount;
|
|
|
|
ObjectData **_objs;
|
|
|
|
|
2005-04-28 17:19:43 +00:00
|
|
|
SagaEngine *_vm;
|
2005-07-19 19:05:52 +00:00
|
|
|
ResourceContext *_actorContext;
|
2005-04-28 17:19:43 +00:00
|
|
|
|
|
|
|
int _lastTickMsec;
|
|
|
|
CommonObjectOrderList _drawOrderList;
|
|
|
|
|
|
|
|
//variables
|
|
|
|
public:
|
|
|
|
ActorData *_centerActor;
|
|
|
|
ActorData *_protagonist;
|
2005-05-18 18:28:10 +00:00
|
|
|
int _handleActionDiv;
|
2005-08-07 00:00:43 +00:00
|
|
|
|
2005-08-10 17:39:29 +00:00
|
|
|
Rect _speechBoxScript;
|
|
|
|
|
2005-10-08 22:09:21 +00:00
|
|
|
StringsTable _objectsStrings;
|
|
|
|
StringsTable _actorsStrings;
|
|
|
|
|
2005-04-28 17:19:43 +00:00
|
|
|
protected:
|
2004-12-21 06:49:07 +00:00
|
|
|
SpeechData _activeSpeech;
|
2005-04-21 01:30:07 +00:00
|
|
|
int _protagState;
|
2005-06-29 20:00:44 +00:00
|
|
|
bool _dragonHunt;
|
2004-12-29 21:49:25 +00:00
|
|
|
|
2005-04-28 17:19:43 +00:00
|
|
|
private:
|
2007-06-09 22:45:03 +00:00
|
|
|
ProtagStateData *_protagStates;
|
2005-08-07 00:00:43 +00:00
|
|
|
int _protagStatesCount;
|
|
|
|
|
2004-12-29 21:49:25 +00:00
|
|
|
//path stuff
|
2005-01-18 21:13:44 +00:00
|
|
|
struct PathNode {
|
|
|
|
Point point;
|
|
|
|
int link;
|
2009-04-28 12:33:59 +00:00
|
|
|
|
|
|
|
PathNode() : link(0) {}
|
|
|
|
PathNode(const Point &p) : point(p), link(0) {}
|
|
|
|
PathNode(const Point &p, int l) : point(p), link(l) {}
|
2005-01-18 21:13:44 +00:00
|
|
|
};
|
2009-05-01 10:37:41 +00:00
|
|
|
typedef Common::Array<PathNode> PathNodeList;
|
2005-01-18 21:13:44 +00:00
|
|
|
|
2004-12-28 21:27:18 +00:00
|
|
|
Rect _barrierList[ACTOR_BARRIERS_MAX];
|
|
|
|
int _barrierCount;
|
2005-01-06 22:22:20 +00:00
|
|
|
int8 *_pathCell;
|
2005-01-06 21:57:10 +00:00
|
|
|
|
2004-12-28 21:27:18 +00:00
|
|
|
int _xCellCount;
|
|
|
|
int _yCellCount;
|
|
|
|
Rect _pathRect;
|
2005-01-06 21:57:10 +00:00
|
|
|
|
2009-05-01 15:32:15 +00:00
|
|
|
PointList _pathList;
|
|
|
|
uint _pathListIndex;
|
2005-01-06 21:57:10 +00:00
|
|
|
|
2009-05-01 10:37:41 +00:00
|
|
|
PathNodeList _pathNodeList;
|
2005-01-15 23:46:43 +00:00
|
|
|
|
2005-01-06 19:15:01 +00:00
|
|
|
public:
|
2005-01-06 23:02:53 +00:00
|
|
|
#ifdef ACTOR_DEBUG
|
2009-05-01 10:37:41 +00:00
|
|
|
#ifndef SAGA_DEBUG
|
|
|
|
you must also define SAGA_DEBUG
|
|
|
|
#endif
|
2005-01-06 19:15:01 +00:00
|
|
|
//path debug - use with care
|
|
|
|
struct DebugPoint {
|
|
|
|
Point point;
|
|
|
|
byte color;
|
2009-05-24 15:17:42 +00:00
|
|
|
|
2009-05-01 10:37:41 +00:00
|
|
|
DebugPoint() : color(0) {}
|
|
|
|
|
|
|
|
DebugPoint(const Point &p, byte c): point(p), color(c) {}
|
2005-01-06 19:15:01 +00:00
|
|
|
};
|
2009-05-01 10:37:41 +00:00
|
|
|
|
|
|
|
Common::Array<DebugPoint> _debugPoints;
|
|
|
|
uint _debugPointsCount;
|
|
|
|
// we still need this trick to speedup debug points addition
|
2005-01-06 19:15:01 +00:00
|
|
|
void addDebugPoint(const Point &point, byte color) {
|
2009-05-01 10:37:41 +00:00
|
|
|
if (_debugPointsCount < _debugPoints.size()) {
|
|
|
|
_debugPoints[_debugPointsCount].point = point;
|
|
|
|
_debugPoints[_debugPointsCount].color = color;
|
|
|
|
} else {
|
|
|
|
_debugPoints.push_back(DebugPoint(point, color));
|
2005-01-06 19:15:01 +00:00
|
|
|
}
|
2009-05-01 10:37:41 +00:00
|
|
|
++_debugPointsCount;
|
2005-01-06 19:15:01 +00:00
|
|
|
}
|
2005-01-06 23:02:53 +00:00
|
|
|
#endif
|
2004-08-02 15:47:42 +00:00
|
|
|
};
|
2004-04-12 21:40:49 +00:00
|
|
|
|
|
|
|
} // End of namespace Saga
|
|
|
|
|
2004-05-01 06:16:57 +00:00
|
|
|
#endif
|