2002-05-14 19:11:20 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
|
|
|
* Copyright (C) 2001 Ludvig Strigeus
|
2006-01-18 17:39:49 +00:00
|
|
|
* Copyright (C) 2001-2006 The ScummVM project
|
2002-05-14 19:11:20 +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
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-05-14 19:11:20 +00:00
|
|
|
*
|
2006-02-11 09:55:41 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2002-05-14 19:11:20 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2007-02-19 17:48:19 +00:00
|
|
|
#ifndef SCUMM_ACTOR_H
|
|
|
|
#define SCUMM_ACTOR_H
|
2002-05-14 19:11:20 +00:00
|
|
|
|
2002-12-25 21:04:47 +00:00
|
|
|
#include "common/scummsys.h"
|
2005-10-21 23:01:13 +00:00
|
|
|
#include "scumm/saveload.h"
|
2003-10-03 18:33:57 +00:00
|
|
|
#include "scumm/scumm.h"
|
2005-04-10 12:59:17 +00:00
|
|
|
|
|
|
|
|
2003-10-03 18:33:57 +00:00
|
|
|
namespace Scumm {
|
2002-05-14 23:35:28 +00:00
|
|
|
|
2006-10-19 00:26:55 +00:00
|
|
|
|
|
|
|
enum {
|
|
|
|
V12_X_MULTIPLIER = 8,
|
2007-02-15 18:12:29 +00:00
|
|
|
V12_Y_MULTIPLIER = 2,
|
|
|
|
|
|
|
|
V12_X_SHIFT = 3,
|
|
|
|
V12_Y_SHIFT = 1
|
2006-10-19 00:26:55 +00:00
|
|
|
};
|
|
|
|
|
2002-05-23 21:22:08 +00:00
|
|
|
enum MoveFlags {
|
|
|
|
MF_NEW_LEG = 1,
|
|
|
|
MF_IN_LEG = 2,
|
|
|
|
MF_TURN = 4,
|
2003-03-08 02:06:56 +00:00
|
|
|
MF_LAST_LEG = 8,
|
|
|
|
MF_FROZEN = 0x80
|
2002-05-23 21:22:08 +00:00
|
|
|
};
|
|
|
|
|
2002-05-14 19:11:20 +00:00
|
|
|
struct CostumeData {
|
|
|
|
byte active[16];
|
2003-06-01 18:20:38 +00:00
|
|
|
uint16 animCounter;
|
|
|
|
byte soundCounter;
|
2002-05-14 19:11:20 +00:00
|
|
|
uint16 stopped;
|
|
|
|
uint16 curpos[16];
|
|
|
|
uint16 start[16];
|
|
|
|
uint16 end[16];
|
|
|
|
uint16 frame[16];
|
2002-07-07 19:31:51 +00:00
|
|
|
|
2005-09-23 23:23:34 +00:00
|
|
|
uint16 heJumpOffsetTable[16];
|
|
|
|
uint16 heJumpCountTable[16];
|
|
|
|
uint32 heCondMaskTable[16];
|
2004-09-08 21:14:12 +00:00
|
|
|
|
2002-07-07 19:31:51 +00:00
|
|
|
void reset() {
|
2002-05-23 00:37:00 +00:00
|
|
|
stopped = 0;
|
|
|
|
for (int i = 0; i < 16; i++) {
|
|
|
|
active[i] = 0;
|
|
|
|
curpos[i] = start[i] = end[i] = frame[i] = 0xFFFF;
|
2002-07-15 01:38:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2002-05-14 19:11:20 +00:00
|
|
|
|
2003-07-02 13:47:03 +00:00
|
|
|
struct AdjustBoxResult { /* Result type of AdjustBox functions */
|
|
|
|
int16 x, y;
|
|
|
|
byte box;
|
|
|
|
};
|
|
|
|
|
2005-10-21 23:01:13 +00:00
|
|
|
class Actor : public Serializable {
|
2002-05-14 23:35:28 +00:00
|
|
|
|
2003-05-20 20:42:28 +00:00
|
|
|
public:
|
|
|
|
static byte kInvalidBox;
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2003-10-02 22:42:03 +00:00
|
|
|
static void initActorClass(ScummEngine *scumm);
|
2003-05-20 20:42:28 +00:00
|
|
|
|
2006-11-19 00:39:48 +00:00
|
|
|
protected:
|
2004-09-04 10:29:06 +00:00
|
|
|
/** The position of the actor inside the virtual screen. */
|
2003-10-02 17:43:02 +00:00
|
|
|
Common::Point _pos;
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2006-11-19 00:39:48 +00:00
|
|
|
public:
|
2004-09-04 10:29:06 +00:00
|
|
|
/** HE specific: This rect is used to clip actor drawing. */
|
2004-09-28 19:28:59 +00:00
|
|
|
Common::Rect _clipOverride;
|
2004-09-04 10:29:06 +00:00
|
|
|
|
2004-09-28 19:28:59 +00:00
|
|
|
int _offsX, _offsY;
|
2005-03-11 01:10:06 +00:00
|
|
|
int _top, _bottom;
|
|
|
|
uint _width;
|
|
|
|
byte _number;
|
|
|
|
uint16 _costume;
|
|
|
|
byte _room;
|
2006-11-19 00:39:48 +00:00
|
|
|
|
|
|
|
public:
|
2005-03-11 01:10:06 +00:00
|
|
|
byte _talkColor;
|
|
|
|
int _talkFrequency;
|
|
|
|
byte _talkPan;
|
|
|
|
byte _talkVolume;
|
|
|
|
uint16 _boxscale;
|
|
|
|
byte _scalex, _scaley;
|
|
|
|
byte _charset;
|
|
|
|
byte _moving;
|
|
|
|
bool _ignoreBoxes;
|
|
|
|
byte _forceClip;
|
2004-09-28 19:28:59 +00:00
|
|
|
|
|
|
|
byte _initFrame;
|
|
|
|
byte _walkFrame;
|
|
|
|
byte _standFrame;
|
|
|
|
byte _talkStartFrame;
|
|
|
|
byte _talkStopFrame;
|
|
|
|
|
2005-03-11 01:10:06 +00:00
|
|
|
bool _needRedraw, _needBgReset, _visible;
|
2004-09-28 19:28:59 +00:00
|
|
|
byte _shadowMode;
|
2005-03-11 01:10:06 +00:00
|
|
|
bool _flip;
|
|
|
|
byte _frame;
|
2004-09-28 19:28:59 +00:00
|
|
|
byte _walkbox;
|
2005-03-11 01:10:06 +00:00
|
|
|
int16 _talkPosX, _talkPosY;
|
|
|
|
uint16 _talkScript, _walkScript;
|
|
|
|
bool _ignoreTurns;
|
|
|
|
bool _drawToBackBuf;
|
2005-10-21 12:06:03 +00:00
|
|
|
int32 _layer;
|
2005-03-11 01:10:06 +00:00
|
|
|
uint16 _sound[32];
|
|
|
|
CostumeData _cost;
|
2004-10-12 14:12:20 +00:00
|
|
|
|
|
|
|
/* HE specific */
|
2005-03-11 01:10:06 +00:00
|
|
|
bool _heNoTalkAnimation;
|
|
|
|
bool _heSkipLimbs;
|
2004-10-12 14:40:32 +00:00
|
|
|
bool _heTalking;
|
2005-03-11 01:10:06 +00:00
|
|
|
uint32 _heCondMask;
|
2005-10-22 04:08:48 +00:00
|
|
|
uint32 _hePaletteNum;
|
|
|
|
uint32 _heXmapNum;
|
2006-07-10 10:14:10 +00:00
|
|
|
byte _heFlags;
|
2004-10-12 14:12:20 +00:00
|
|
|
|
2005-03-11 01:10:06 +00:00
|
|
|
AuxBlock _auxBlock;
|
2004-09-28 00:58:00 +00:00
|
|
|
|
|
|
|
struct {
|
|
|
|
int16 posX;
|
|
|
|
int16 posY;
|
|
|
|
int16 color;
|
|
|
|
byte sentence[128];
|
2005-03-11 01:10:06 +00:00
|
|
|
} _heTalkQueue[16];
|
2004-09-28 00:58:00 +00:00
|
|
|
|
2002-05-14 23:35:28 +00:00
|
|
|
protected:
|
2006-11-19 00:39:48 +00:00
|
|
|
struct ActorWalkData {
|
|
|
|
Common::Point dest; // Final destination point
|
|
|
|
byte destbox; // Final destination box
|
|
|
|
int16 destdir; // Final destination, direction to face at
|
2006-12-21 15:09:13 +00:00
|
|
|
|
2006-11-19 00:39:48 +00:00
|
|
|
Common::Point cur; // Last position
|
|
|
|
byte curbox; // Last box
|
2006-12-21 15:09:13 +00:00
|
|
|
|
2006-11-19 00:39:48 +00:00
|
|
|
Common::Point next; // Next position on our way to the destination, i.e. our intermediate destination
|
2006-12-21 15:09:13 +00:00
|
|
|
|
2006-11-19 00:39:48 +00:00
|
|
|
Common::Point point3;
|
|
|
|
int32 deltaXFactor, deltaYFactor;
|
|
|
|
uint16 xfrac, yfrac;
|
|
|
|
};
|
2006-12-21 15:09:13 +00:00
|
|
|
|
2006-11-19 00:39:48 +00:00
|
|
|
|
2005-03-11 01:10:06 +00:00
|
|
|
byte _palette[256];
|
2004-09-28 19:28:59 +00:00
|
|
|
int _elevation;
|
2005-03-11 01:10:06 +00:00
|
|
|
uint16 _facing;
|
|
|
|
uint16 _targetFacing;
|
|
|
|
uint _speedx, _speedy;
|
|
|
|
byte _animProgress, _animSpeed;
|
|
|
|
bool _costumeNeedsInit;
|
|
|
|
ActorWalkData _walkdata;
|
|
|
|
int16 _animVariable[27];
|
2003-05-26 02:26:13 +00:00
|
|
|
|
2003-10-02 22:42:03 +00:00
|
|
|
static ScummEngine *_vm;
|
2002-05-14 23:35:28 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2006-12-25 15:37:20 +00:00
|
|
|
Actor(int id);
|
|
|
|
virtual ~Actor() {}
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2002-05-14 23:35:28 +00:00
|
|
|
//protected:
|
2002-05-14 19:11:20 +00:00
|
|
|
void hideActor();
|
|
|
|
void showActor();
|
|
|
|
|
2006-12-25 15:37:20 +00:00
|
|
|
virtual void initActor(int mode);
|
2006-12-21 15:09:13 +00:00
|
|
|
|
|
|
|
void putActor() {
|
|
|
|
putActor(_pos.x, _pos.y, _room);
|
|
|
|
}
|
|
|
|
|
2007-02-04 01:24:43 +00:00
|
|
|
void putActor(int room) {
|
|
|
|
putActor(_pos.x, _pos.y, room);
|
|
|
|
}
|
|
|
|
|
2006-12-21 15:09:13 +00:00
|
|
|
void putActor(int x, int y) {
|
|
|
|
putActor(x, y, _room);
|
|
|
|
}
|
|
|
|
|
|
|
|
void putActor(int x, int y, int room);
|
2002-05-14 19:11:20 +00:00
|
|
|
void setActorWalkSpeed(uint newSpeedX, uint newSpeedY);
|
2002-07-18 15:45:10 +00:00
|
|
|
protected:
|
2004-09-30 23:49:46 +00:00
|
|
|
int calcMovementFactor(const Common::Point& next);
|
2002-05-14 19:11:20 +00:00
|
|
|
int actorWalkStep();
|
2002-08-18 13:55:30 +00:00
|
|
|
int remapDirection(int dir, bool is_walking);
|
2007-02-04 01:24:43 +00:00
|
|
|
virtual void setupActorScale();
|
2002-05-14 19:11:20 +00:00
|
|
|
|
2002-07-18 15:45:10 +00:00
|
|
|
void setBox(int box);
|
2002-08-18 13:55:30 +00:00
|
|
|
int updateActorDirection(bool is_walking);
|
2002-07-18 15:45:10 +00:00
|
|
|
|
|
|
|
public:
|
2003-01-26 06:17:25 +00:00
|
|
|
void adjustActorPos();
|
2003-05-20 19:35:40 +00:00
|
|
|
AdjustBoxResult adjustXYToBeInBox(int dstX, int dstY);
|
2003-01-01 18:22:41 +00:00
|
|
|
|
|
|
|
void setDirection(int direction);
|
2003-04-20 17:11:13 +00:00
|
|
|
void faceToObject(int obj);
|
2002-05-14 19:11:20 +00:00
|
|
|
void turnToDirection(int newdir);
|
2006-12-25 17:21:54 +00:00
|
|
|
virtual void walkActor();
|
2005-04-12 02:29:50 +00:00
|
|
|
void drawActorToBackBuf(int x, int y);
|
2004-09-03 19:54:58 +00:00
|
|
|
void drawActorCostume(bool hitTestMode = false);
|
2002-08-04 02:53:50 +00:00
|
|
|
void animateCostume();
|
2002-05-14 19:11:20 +00:00
|
|
|
void setActorCostume(int c);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2003-01-06 16:04:01 +00:00
|
|
|
void animateLimb(int limb, int f);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-09-03 19:54:58 +00:00
|
|
|
bool actorHitTest(int x, int y);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2007-03-06 07:09:18 +00:00
|
|
|
const byte *getActorName();
|
2002-05-14 19:11:20 +00:00
|
|
|
void startWalkActor(int x, int y, int dir);
|
2003-01-01 18:22:41 +00:00
|
|
|
void stopActorMoving();
|
2003-09-09 19:30:25 +00:00
|
|
|
protected:
|
2003-01-01 18:22:41 +00:00
|
|
|
void startWalkAnim(int cmd, int angle);
|
2003-09-09 19:30:25 +00:00
|
|
|
public:
|
2004-07-15 12:26:10 +00:00
|
|
|
void runActorTalkScript(int f);
|
2003-01-01 18:22:41 +00:00
|
|
|
void startAnimActor(int frame);
|
2002-07-07 19:31:51 +00:00
|
|
|
|
2002-08-19 17:23:48 +00:00
|
|
|
void remapActorPalette(int r_fact, int g_fact, int b_fact, int threshold);
|
2004-01-16 01:52:49 +00:00
|
|
|
void remapActorPaletteColor(int slot, int color);
|
2002-06-04 23:32:53 +00:00
|
|
|
|
|
|
|
void animateActor(int anim);
|
2002-05-23 00:37:00 +00:00
|
|
|
|
2003-05-26 02:26:13 +00:00
|
|
|
bool isInCurrentRoom() const {
|
2005-03-11 01:10:06 +00:00
|
|
|
return _room == _vm->_currentRoom;
|
2002-07-07 19:31:51 +00:00
|
|
|
}
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2007-02-04 01:24:43 +00:00
|
|
|
Common::Point getPos() const {
|
|
|
|
Common::Point p(_pos);
|
|
|
|
if (_vm->_game.version <= 2) {
|
|
|
|
p.x *= V12_X_MULTIPLIER;
|
|
|
|
p.y *= V12_Y_MULTIPLIER;
|
|
|
|
}
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
|
|
|
const Common::Point& getRealPos() const {
|
2006-11-19 00:39:48 +00:00
|
|
|
return _pos;
|
|
|
|
}
|
2003-01-01 18:22:41 +00:00
|
|
|
|
2003-05-26 02:26:13 +00:00
|
|
|
int getRoom() const {
|
2005-03-11 01:10:06 +00:00
|
|
|
return _room;
|
2002-07-07 19:31:51 +00:00
|
|
|
}
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2003-07-24 17:44:00 +00:00
|
|
|
int getFacing() const {
|
2005-03-11 01:10:06 +00:00
|
|
|
return _facing;
|
2003-07-24 17:44:00 +00:00
|
|
|
}
|
2002-07-07 19:31:51 +00:00
|
|
|
|
2006-07-24 12:49:58 +00:00
|
|
|
void setFacing(int newFacing) {
|
|
|
|
_facing = newFacing;
|
|
|
|
}
|
|
|
|
|
2005-04-10 12:59:17 +00:00
|
|
|
int getAnimVar(byte var) const;
|
|
|
|
void setAnimVar(byte var, int value);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2003-07-24 17:44:00 +00:00
|
|
|
void setAnimSpeed(byte newAnimSpeed) {
|
2005-03-11 01:10:06 +00:00
|
|
|
_animSpeed = newAnimSpeed;
|
|
|
|
_animProgress = 0;
|
2003-07-24 17:44:00 +00:00
|
|
|
}
|
2004-01-05 16:19:14 +00:00
|
|
|
|
2005-03-08 05:56:21 +00:00
|
|
|
int getAnimSpeed() const {
|
2005-03-11 01:10:06 +00:00
|
|
|
return _animSpeed;
|
2005-03-08 05:56:21 +00:00
|
|
|
}
|
|
|
|
|
2004-09-21 05:59:26 +00:00
|
|
|
int getAnimProgress() const {
|
2005-03-11 01:10:06 +00:00
|
|
|
return _animProgress;
|
2004-09-21 05:59:26 +00:00
|
|
|
}
|
|
|
|
|
2004-01-05 16:19:14 +00:00
|
|
|
int getElevation() const {
|
2004-09-28 19:28:59 +00:00
|
|
|
return _elevation;
|
2004-01-05 16:19:14 +00:00
|
|
|
}
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-01-05 16:19:14 +00:00
|
|
|
void setElevation(int newElevation) {
|
2004-09-28 19:28:59 +00:00
|
|
|
if (_elevation != newElevation) {
|
|
|
|
_elevation = newElevation;
|
2005-03-11 01:10:06 +00:00
|
|
|
_needRedraw = true;
|
2004-01-05 16:19:14 +00:00
|
|
|
}
|
|
|
|
}
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-01-05 16:30:00 +00:00
|
|
|
void setPalette(int idx, int val) {
|
2005-03-11 01:10:06 +00:00
|
|
|
_palette[idx] = val;
|
|
|
|
_needRedraw = true;
|
2004-01-05 16:30:00 +00:00
|
|
|
}
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-01-05 16:30:00 +00:00
|
|
|
void setScale(int sx, int sy) {
|
|
|
|
if (sx != -1)
|
2005-03-11 01:10:06 +00:00
|
|
|
_scalex = sx;
|
2004-01-05 16:30:00 +00:00
|
|
|
if (sy != -1)
|
2005-03-11 01:10:06 +00:00
|
|
|
_scaley = sy;
|
|
|
|
_needRedraw = true;
|
2004-01-05 16:30:00 +00:00
|
|
|
}
|
|
|
|
|
2002-07-26 16:13:04 +00:00
|
|
|
void classChanged(int cls, bool value);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2006-07-10 10:14:10 +00:00
|
|
|
void setHEFlag(int bit, int set);
|
|
|
|
|
2004-09-08 21:14:12 +00:00
|
|
|
void setUserCondition(int slot, int set);
|
2004-09-21 21:10:23 +00:00
|
|
|
bool isUserConditionSet(int slot) const;
|
2004-09-08 21:14:12 +00:00
|
|
|
|
|
|
|
void setTalkCondition(int slot);
|
2004-09-21 21:10:23 +00:00
|
|
|
bool isTalkConditionSet(int slot) const;
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2005-10-21 23:01:13 +00:00
|
|
|
// Used by the save/load system:
|
|
|
|
void saveLoadWithSerializer(Serializer *ser);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2002-07-15 22:56:24 +00:00
|
|
|
protected:
|
|
|
|
bool isInClass(int cls);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2003-05-22 00:51:42 +00:00
|
|
|
bool isPlayer();
|
2003-05-26 02:26:13 +00:00
|
|
|
|
2003-10-02 17:43:02 +00:00
|
|
|
bool findPathTowards(byte box, byte box2, byte box3, Common::Point &foundPath);
|
2006-12-25 17:21:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class ActorOldWalk : public Actor {
|
|
|
|
public:
|
|
|
|
ActorOldWalk(int id) : Actor(id) {}
|
|
|
|
|
|
|
|
virtual void walkActor();
|
|
|
|
|
|
|
|
protected:
|
2007-02-04 01:24:43 +00:00
|
|
|
virtual void setupActorScale();
|
2003-10-02 17:43:02 +00:00
|
|
|
void findPathTowardsOld(byte box, byte box2, byte box3, Common::Point &p2, Common::Point &p3);
|
2002-05-14 19:11:20 +00:00
|
|
|
};
|
|
|
|
|
2006-12-25 17:21:54 +00:00
|
|
|
class ActorC64 : public ActorOldWalk {
|
2006-12-25 15:37:20 +00:00
|
|
|
public:
|
|
|
|
// FIXME: This flag is never saved, which might lead to broken save states.
|
|
|
|
byte _miscflags;
|
|
|
|
|
|
|
|
public:
|
2006-12-25 17:21:54 +00:00
|
|
|
ActorC64(int id) : ActorOldWalk(id) {}
|
2006-12-25 15:37:20 +00:00
|
|
|
virtual void initActor(int mode) {
|
2006-12-29 23:50:54 +00:00
|
|
|
ActorOldWalk::initActor(mode);
|
2006-12-25 15:37:20 +00:00
|
|
|
if (mode == -1) {
|
|
|
|
_miscflags = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2006-12-29 23:50:54 +00:00
|
|
|
|
2006-12-25 15:37:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2003-10-03 18:33:57 +00:00
|
|
|
} // End of namespace Scumm
|
|
|
|
|
2002-05-14 19:11:20 +00:00
|
|
|
#endif
|