2002-05-14 19:11:20 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
|
|
|
* Copyright (C) 2001 Ludvig Strigeus
|
2005-01-01 16:09:25 +00:00
|
|
|
* Copyright (C) 2001-2005 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
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* $Header$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef ACTOR_H
|
|
|
|
#define ACTOR_H
|
|
|
|
|
2002-12-25 21:04:47 +00:00
|
|
|
#include "common/scummsys.h"
|
2003-10-03 18:33:57 +00:00
|
|
|
#include "scumm/scumm.h"
|
|
|
|
namespace Scumm {
|
2002-05-14 23:35:28 +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 ActorWalkData {
|
2004-09-28 23:05:45 +00:00
|
|
|
Common::Point dest; // Final destination point
|
|
|
|
byte destbox; // Final destination box
|
|
|
|
int16 destdir; // Final destination, direction to face at
|
|
|
|
|
|
|
|
Common::Point cur; // Last position
|
|
|
|
byte curbox; // Last box
|
|
|
|
|
|
|
|
Common::Point next; // Next position on our way to the destination, i.e. our intermediate destination
|
|
|
|
|
2003-10-02 17:43:02 +00:00
|
|
|
Common::Point point3;
|
2003-05-05 12:09:22 +00:00
|
|
|
int32 deltaXFactor, deltaYFactor;
|
2002-07-07 19:31:51 +00:00
|
|
|
uint16 xfrac, yfrac;
|
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
|
|
|
|
2004-09-08 21:14:12 +00:00
|
|
|
uint16 seq1[16];
|
|
|
|
uint16 seq2[16];
|
|
|
|
uint32 seq3[16];
|
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
2003-05-26 14:20:05 +00:00
|
|
|
struct SaveLoadEntry;
|
2003-05-26 02:26:13 +00:00
|
|
|
|
2002-05-14 23:35:28 +00:00
|
|
|
class Actor {
|
|
|
|
|
2003-05-20 20:42:28 +00:00
|
|
|
public:
|
|
|
|
static byte kInvalidBox;
|
|
|
|
|
2003-10-02 22:42:03 +00:00
|
|
|
static void initActorClass(ScummEngine *scumm);
|
2003-05-20 20:42:28 +00:00
|
|
|
|
2002-05-14 23:35:28 +00:00
|
|
|
public:
|
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;
|
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;
|
2003-09-14 18:16:45 +00:00
|
|
|
int top, bottom;
|
2002-05-14 19:11:20 +00:00
|
|
|
uint width;
|
|
|
|
byte number;
|
|
|
|
uint16 costume;
|
|
|
|
byte room;
|
|
|
|
byte talkColor;
|
2003-01-26 10:54:34 +00:00
|
|
|
int talkFrequency;
|
2003-09-03 17:00:33 +00:00
|
|
|
byte talkPan;
|
2004-02-09 08:05:23 +00:00
|
|
|
byte talkVolume;
|
2004-07-28 11:56:14 +00:00
|
|
|
uint16 boxscale;
|
2002-07-07 19:31:51 +00:00
|
|
|
byte scalex, scaley;
|
2002-05-14 19:11:20 +00:00
|
|
|
byte charset;
|
|
|
|
byte moving;
|
2003-05-18 19:44:22 +00:00
|
|
|
bool ignoreBoxes;
|
2002-05-14 19:11:20 +00:00
|
|
|
byte forceClip;
|
2004-09-28 19:28:59 +00:00
|
|
|
|
|
|
|
byte _initFrame;
|
|
|
|
byte _walkFrame;
|
|
|
|
byte _standFrame;
|
|
|
|
byte _talkStartFrame;
|
|
|
|
byte _talkStopFrame;
|
|
|
|
|
2003-05-30 00:55:21 +00:00
|
|
|
bool needRedraw, needBgReset, visible;
|
2004-09-28 19:28:59 +00:00
|
|
|
byte _shadowMode;
|
2002-05-14 19:11:20 +00:00
|
|
|
bool flip;
|
2002-10-23 00:22:55 +00:00
|
|
|
byte frame;
|
2004-09-28 19:28:59 +00:00
|
|
|
byte _walkbox;
|
2002-12-23 14:16:43 +00:00
|
|
|
int16 talkPosX, talkPosY;
|
2003-05-31 14:27:47 +00:00
|
|
|
uint16 talkScript, walkScript;
|
2004-01-05 16:30:00 +00:00
|
|
|
bool ignoreTurns;
|
2004-08-29 11:27:16 +00:00
|
|
|
bool drawToBackBuf;
|
2004-09-28 19:28:59 +00:00
|
|
|
int8 _layer;
|
2004-09-05 09:36:51 +00:00
|
|
|
uint16 sound[32];
|
2002-05-14 19:11:20 +00:00
|
|
|
CostumeData cost;
|
2004-10-12 14:12:20 +00:00
|
|
|
|
|
|
|
/* HE specific */
|
2004-10-12 14:40:32 +00:00
|
|
|
byte hePaletteNum;
|
|
|
|
bool heNoTalkAnimation;
|
|
|
|
bool heSkipLimbs;
|
|
|
|
bool _heTalking;
|
|
|
|
uint32 heCondMask;
|
2004-10-12 14:12:20 +00:00
|
|
|
|
2004-09-18 00:36:17 +00:00
|
|
|
AuxBlock auxBlock;
|
2004-09-28 00:58:00 +00:00
|
|
|
|
|
|
|
struct {
|
|
|
|
int16 posX;
|
|
|
|
int16 posY;
|
|
|
|
int16 color;
|
|
|
|
byte sentence[128];
|
2004-10-12 14:40:32 +00:00
|
|
|
} heTalkQueue[16];
|
2004-09-28 00:58:00 +00:00
|
|
|
|
2002-05-14 23:35:28 +00:00
|
|
|
protected:
|
2004-01-05 16:30:00 +00:00
|
|
|
byte palette[256];
|
2004-09-28 19:28:59 +00:00
|
|
|
int _elevation;
|
2003-07-24 17:44:00 +00:00
|
|
|
uint16 facing;
|
|
|
|
uint16 targetFacing;
|
|
|
|
uint speedx, speedy;
|
|
|
|
byte animProgress, animSpeed;
|
2003-05-30 00:55:21 +00:00
|
|
|
bool costumeNeedsInit;
|
2003-05-26 02:26:13 +00:00
|
|
|
ActorWalkData walkdata;
|
2004-10-02 10:58:15 +00:00
|
|
|
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:
|
|
|
|
|
2003-07-27 23:45:43 +00:00
|
|
|
Actor();
|
2003-03-07 02:43:21 +00:00
|
|
|
|
2002-05-14 23:35:28 +00:00
|
|
|
//protected:
|
2002-05-14 19:11:20 +00:00
|
|
|
void hideActor();
|
|
|
|
void showActor();
|
|
|
|
|
|
|
|
void initActor(int mode);
|
2002-07-18 15:45:10 +00:00
|
|
|
void putActor(int x, int y, byte 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);
|
2002-05-14 19:11:20 +00:00
|
|
|
void setupActorScale();
|
|
|
|
|
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);
|
|
|
|
void walkActor();
|
2003-09-13 23:50:29 +00:00
|
|
|
void walkActorOld();
|
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);
|
2003-01-06 16:04:01 +00:00
|
|
|
|
|
|
|
void animateLimb(int limb, int f);
|
|
|
|
|
2004-09-03 19:54:58 +00:00
|
|
|
bool actorHitTest(int x, int y);
|
|
|
|
|
2002-05-14 19:11:20 +00:00
|
|
|
byte *getActorName();
|
|
|
|
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 {
|
2002-07-07 19:31:51 +00:00
|
|
|
return room == _vm->_currentRoom;
|
|
|
|
}
|
2002-12-25 21:04:47 +00:00
|
|
|
|
2003-07-24 17:44:00 +00:00
|
|
|
int getActorXYPos(int &x, int &y) const;
|
2003-01-01 18:22:41 +00:00
|
|
|
|
2003-05-26 02:26:13 +00:00
|
|
|
int getRoom() const {
|
2002-07-07 19:31:51 +00:00
|
|
|
return room;
|
|
|
|
}
|
2003-07-24 17:44:00 +00:00
|
|
|
|
|
|
|
int getFacing() const {
|
|
|
|
return facing;
|
|
|
|
}
|
2002-07-07 19:31:51 +00:00
|
|
|
|
2003-05-26 02:26:13 +00:00
|
|
|
int getAnimVar(byte var) const {
|
2004-10-02 10:58:15 +00:00
|
|
|
checkRange(26, 0, var, "getAnimVar %d out of range(r)");
|
2002-07-07 19:31:51 +00:00
|
|
|
return animVariable[var];
|
|
|
|
}
|
|
|
|
void setAnimVar(byte var, int value) {
|
2004-10-02 10:58:15 +00:00
|
|
|
checkRange(26, 0, var, "setAnimVar %d out of range(r)");
|
2002-07-07 19:31:51 +00:00
|
|
|
animVariable[var] = value;
|
|
|
|
}
|
2002-07-26 16:13:04 +00:00
|
|
|
|
2003-07-24 17:44:00 +00:00
|
|
|
void setAnimSpeed(byte newAnimSpeed) {
|
|
|
|
animSpeed = newAnimSpeed;
|
|
|
|
animProgress = 0;
|
|
|
|
}
|
2004-01-05 16:19:14 +00:00
|
|
|
|
2004-09-21 05:59:26 +00:00
|
|
|
int getAnimProgress() const {
|
|
|
|
return animProgress;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void setElevation(int newElevation) {
|
2004-09-28 19:28:59 +00:00
|
|
|
if (_elevation != newElevation) {
|
|
|
|
_elevation = newElevation;
|
2004-01-05 16:19:14 +00:00
|
|
|
needRedraw = true;
|
|
|
|
}
|
|
|
|
}
|
2003-07-24 17:44:00 +00:00
|
|
|
|
2004-01-05 16:30:00 +00:00
|
|
|
void setPalette(int idx, int val) {
|
|
|
|
palette[idx] = val;
|
|
|
|
needRedraw = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setScale(int sx, int sy) {
|
|
|
|
if (sx != -1)
|
|
|
|
scalex = sx;
|
|
|
|
if (sy != -1)
|
|
|
|
scaley = sy;
|
|
|
|
needRedraw = true;
|
|
|
|
}
|
|
|
|
|
2002-07-26 16:13:04 +00:00
|
|
|
void classChanged(int cls, bool value);
|
2003-05-20 20:42:28 +00:00
|
|
|
|
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;
|
2004-09-08 21:14:12 +00:00
|
|
|
|
2003-05-26 02:26:13 +00:00
|
|
|
// Used by the save/load syste:
|
|
|
|
static const SaveLoadEntry *getSaveLoadEntries();
|
|
|
|
|
2002-07-15 22:56:24 +00:00
|
|
|
protected:
|
|
|
|
bool isInClass(int cls);
|
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);
|
|
|
|
void findPathTowardsOld(byte box, byte box2, byte box3, Common::Point &p2, Common::Point &p3);
|
2002-05-14 19:11:20 +00:00
|
|
|
};
|
|
|
|
|
2003-10-03 18:33:57 +00:00
|
|
|
} // End of namespace Scumm
|
|
|
|
|
2002-05-14 19:11:20 +00:00
|
|
|
#endif
|