- some "actors walk" work progression
svn-id: r16308
This commit is contained in:
parent
a8c8a7ab4c
commit
a66080b80a
5 changed files with 154 additions and 97 deletions
120
saga/actor.cpp
120
saga/actor.cpp
|
@ -218,7 +218,7 @@ void Actor::updateActorsScene() {
|
||||||
if (actor->flags & (kProtagonist | kFollower)) {
|
if (actor->flags & (kProtagonist | kFollower)) {
|
||||||
actor->sceneNumber = _vm->_scene->currentSceneNumber();
|
actor->sceneNumber = _vm->_scene->currentSceneNumber();
|
||||||
if (actor->flags & kProtagonist) {
|
if (actor->flags & kProtagonist) {
|
||||||
// actor->finalTarget = a->obj.loc;
|
//todo: actor->finalTarget = a->obj.loc;
|
||||||
_centerActor = _protagonist = actor;
|
_centerActor = _protagonist = actor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -436,7 +436,7 @@ void Actor::handleActions(int msec, bool setup) {
|
||||||
actor->cycleTimeCount = actor->cycleDelay;
|
actor->cycleTimeCount = actor->cycleDelay;
|
||||||
actor->actionCycle++;
|
actor->actionCycle++;
|
||||||
|
|
||||||
frameRange = getActorFrameRange( actor->actorId, actor->cycleFrameNumber);
|
frameRange = getActorFrameRange( actor->actorId, actor->cycleFrameSequence);
|
||||||
|
|
||||||
if (actor->currentAction == kActionPongFrames) {
|
if (actor->currentAction == kActionPongFrames) {
|
||||||
if (actor->actionCycle >= frameRange->frameCount * 2 - 2) {
|
if (actor->actionCycle >= frameRange->frameCount * 2 - 2) {
|
||||||
|
@ -505,24 +505,13 @@ int Actor::direct(int msec) {
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Actor::createDrawOrderList() {
|
void Actor::calcActorScreenPosition(ActorData * actor) {
|
||||||
int i;
|
|
||||||
int beginSlope, endSlope, middle;
|
int beginSlope, endSlope, middle;
|
||||||
ActorData *actor;
|
|
||||||
|
|
||||||
_drawOrderList.clear();
|
|
||||||
for (i = 0; i < ACTORCOUNT; i++) {
|
|
||||||
actor = &_actors[i];
|
|
||||||
if (actor->disabled) continue;
|
|
||||||
if (actor->sceneNumber != _vm->_scene->currentSceneNumber()) continue;
|
|
||||||
|
|
||||||
_drawOrderList.pushBack(actor, actorCompare);
|
|
||||||
|
|
||||||
// tiled stuff
|
// tiled stuff
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
middle = ITE_STATUS_Y - actor->location.y / ACTOR_LMULT,
|
middle = ITE_STATUS_Y - actor->location.y / ACTOR_LMULT;
|
||||||
|
|
||||||
_vm->_scene->getSlopes(beginSlope, endSlope);
|
_vm->_scene->getSlopes(beginSlope, endSlope);
|
||||||
|
|
||||||
|
@ -543,6 +532,21 @@ void Actor::createDrawOrderList() {
|
||||||
actor->screenPosition.x = (actor->location.x / ACTOR_LMULT);
|
actor->screenPosition.x = (actor->location.x / ACTOR_LMULT);
|
||||||
actor->screenPosition.y = (actor->location.y / ACTOR_LMULT) - actor->location.z;
|
actor->screenPosition.y = (actor->location.y / ACTOR_LMULT) - actor->location.z;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Actor::createDrawOrderList() {
|
||||||
|
int i;
|
||||||
|
ActorData *actor;
|
||||||
|
|
||||||
|
_drawOrderList.clear();
|
||||||
|
for (i = 0; i < ACTORCOUNT; i++) {
|
||||||
|
actor = &_actors[i];
|
||||||
|
if (actor->disabled) continue;
|
||||||
|
if (actor->sceneNumber != _vm->_scene->currentSceneNumber()) continue;
|
||||||
|
|
||||||
|
_drawOrderList.pushBack(actor, actorCompare);
|
||||||
|
|
||||||
|
calcActorScreenPosition(actor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -635,26 +639,90 @@ void Actor::StoA(Point &actorPoint, const Point &screenPoint) {
|
||||||
actorPoint.y = (screenPoint.y * ACTOR_LMULT);
|
actorPoint.y = (screenPoint.y * ACTOR_LMULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Actor::actorWalkTo(uint16 actorId, const ActorLocation &actorLocation) {
|
bool Actor::followProtagonist(ActorData * actor) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Actor::actorEndWalk(uint16 actorId, bool recurse) {
|
||||||
|
bool walkMore = false;
|
||||||
|
ActorData *actor;
|
||||||
|
|
||||||
|
actor = getActor(actorId);
|
||||||
|
actor->actorFlags &= ~kActorBackwards;
|
||||||
|
|
||||||
|
if (actor->location.distance(actor->finalTarget) > 8) {
|
||||||
|
if ((actor->flags & kProtagonist) && recurse && !(actor->actorFlags & kActorNoCollide)) {
|
||||||
|
actor->actorFlags |= kActorNoCollide;
|
||||||
|
return actorWalkTo(actorId, actor->finalTarget);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
actor->currentAction = kActionWait;
|
||||||
|
if (actor->actorFlags & kActorFinalFace) {
|
||||||
|
actor->facingDirection = actor->actionDirection = (actor->actorFlags >> 6) & 0x07; //?
|
||||||
|
}
|
||||||
|
|
||||||
|
actor->actorFlags &= ~(kActorNoCollide | kActorCollided | kActorFinalFace | kActorFacingMask);
|
||||||
|
actor->flags &= ~(kFaster | kFastest);
|
||||||
|
|
||||||
|
if (actor == _protagonist) {
|
||||||
|
_vm->_script->wakeUpActorThread(kWaitTypeWalk, actor);
|
||||||
|
//todo: it
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (recurse && (actor->flags & kFollower))
|
||||||
|
walkMore = followProtagonist(actor);
|
||||||
|
|
||||||
|
_vm->_script->wakeUpActorThread(kWaitTypeWalk, actor);
|
||||||
|
}
|
||||||
|
return walkMore;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Actor::actorWalkTo(uint16 actorId, const ActorLocation &toLocation) {
|
||||||
ActorData *actor;
|
ActorData *actor;
|
||||||
|
|
||||||
actor = getActor(actorId);
|
actor = getActor(actorId);
|
||||||
|
|
||||||
/* if (a == protag)
|
|
||||||
{
|
|
||||||
sceneDoors[ 2 ] = 0xff; // closed
|
|
||||||
sceneDoors[ 3 ] = 0; // open
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sceneDoors[ 2 ] = 0; // open
|
|
||||||
sceneDoors[ 3 ] = 0xff; // closed
|
|
||||||
}*/
|
|
||||||
|
|
||||||
// tiled stuff
|
// tiled stuff
|
||||||
{
|
{
|
||||||
|
//todo: it
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
Point pointFrom, pointTo, pointBest;
|
||||||
|
|
||||||
|
pointFrom.x = actor->location.x / ACTOR_LMULT;
|
||||||
|
pointFrom.y = actor->location.y / ACTOR_LMULT;
|
||||||
|
|
||||||
|
|
||||||
|
pointTo.x = toLocation.x / ACTOR_LMULT;
|
||||||
|
pointTo.y = toLocation.y / ACTOR_LMULT;
|
||||||
|
|
||||||
|
|
||||||
|
if (_vm->_scene->isBGMaskPresent()) {
|
||||||
|
//todo: it
|
||||||
|
} else {
|
||||||
|
actor->walkPath[0] = pointTo.x / 2;
|
||||||
|
actor->walkPath[1] = pointTo.y;
|
||||||
|
actor->walkStepsCount = 2;
|
||||||
|
actor->walkStepIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
actor->partialTarget = actor->location;
|
||||||
|
actor->finalTarget = toLocation;
|
||||||
|
if (actor->walkStepsCount == 0) {
|
||||||
|
actorEndWalk(actorId, false);
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
if (actor->flags & kProtagonist) {
|
||||||
|
_actors[1].actorFlags &= ~kActorNoFollow;
|
||||||
|
_actors[2].actorFlags &= ~kActorNoFollow;
|
||||||
|
}
|
||||||
|
|
||||||
|
actor->currentAction = (actor->walkStepsCount == ACTOR_STEPS_COUNT) ? kActionWalkToLink : kActionWalkToPoint;
|
||||||
|
actor->walkFrameSequence = kFrameWalk;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
55
saga/actor.h
55
saga/actor.h
|
@ -35,7 +35,8 @@ namespace Saga {
|
||||||
#define ACTOR_BASE_SPEED 0.25
|
#define ACTOR_BASE_SPEED 0.25
|
||||||
#define ACTOR_BASE_ZMOD 0.5
|
#define ACTOR_BASE_ZMOD 0.5
|
||||||
|
|
||||||
#define ACTOR_DEFAULT_ORIENT 2
|
#define ACTOR_STEPS_COUNT 32
|
||||||
|
#define ACTOR_STEPS_MAX (ACTOR_STEPS_COUNT*2)
|
||||||
|
|
||||||
#define ACTOR_ACTIONTIME 80
|
#define ACTOR_ACTIONTIME 80
|
||||||
|
|
||||||
|
@ -106,7 +107,7 @@ enum ActorFlagsEx {
|
||||||
kActorFinishRight = ((1 << 5) | (kDirRight << 6)),
|
kActorFinishRight = ((1 << 5) | (kDirRight << 6)),
|
||||||
kActorFinishUp = ((1 << 5) | (kDirUp << 6)),
|
kActorFinishUp = ((1 << 5) | (kDirUp << 6)),
|
||||||
kActorFinishDown = ((1 << 5) | (kDirDown << 6)),
|
kActorFinishDown = ((1 << 5) | (kDirDown << 6)),
|
||||||
kActorFacing = (0xf << 5),
|
kActorFacingMask = (0xf << 5),
|
||||||
kActorRandom = (1 << 10)
|
kActorRandom = (1 << 10)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -124,6 +125,9 @@ struct ActorLocation {
|
||||||
int x; // Actor's logical coordinates
|
int x; // Actor's logical coordinates
|
||||||
int y; //
|
int y; //
|
||||||
int z; //
|
int z; //
|
||||||
|
int distance(const ActorLocation &location) {
|
||||||
|
return max(abs(x - location.x), abs(y - location.y));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
struct ActorData {
|
struct ActorData {
|
||||||
bool disabled; // Actor disabled in init section
|
bool disabled; // Actor disabled in init section
|
||||||
|
@ -149,7 +153,7 @@ struct ActorData {
|
||||||
int frameNumber; // current actor frame number
|
int frameNumber; // current actor frame number
|
||||||
uint16 targetObject;
|
uint16 targetObject;
|
||||||
|
|
||||||
int cycleFrameNumber;
|
int cycleFrameSequence;
|
||||||
uint8 cycleDelay;
|
uint8 cycleDelay;
|
||||||
uint8 cycleTimeCount;
|
uint8 cycleTimeCount;
|
||||||
uint8 cycleFlags;
|
uint8 cycleFlags;
|
||||||
|
@ -161,6 +165,12 @@ struct ActorData {
|
||||||
int framesCount; // Actor's frames count
|
int framesCount; // Actor's frames count
|
||||||
int frameListResourceId; // Actor's frame list resource id
|
int frameListResourceId; // Actor's frame list resource id
|
||||||
|
|
||||||
|
int walkPath[ACTOR_STEPS_MAX];
|
||||||
|
int walkStepsCount;
|
||||||
|
int walkStepIndex;
|
||||||
|
ActorLocation finalTarget;
|
||||||
|
ActorLocation partialTarget;
|
||||||
|
int walkFrameSequence;
|
||||||
|
|
||||||
void cycleWrap(int cycleLimit) {
|
void cycleWrap(int cycleLimit) {
|
||||||
if (actionCycle >= cycleLimit)
|
if (actionCycle >= cycleLimit)
|
||||||
|
@ -168,39 +178,7 @@ struct ActorData {
|
||||||
}
|
}
|
||||||
|
|
||||||
ActorData() {
|
ActorData() {
|
||||||
disabled = false;
|
memset(this, 0xFE, sizeof(*this));
|
||||||
index = 0;
|
|
||||||
actorId = 0;
|
|
||||||
|
|
||||||
nameIndex = 0;
|
|
||||||
speechColor = 0;
|
|
||||||
|
|
||||||
frames = NULL;
|
|
||||||
framesCount = 0;
|
|
||||||
frameListResourceId = 0;
|
|
||||||
|
|
||||||
spriteList = NULL;
|
|
||||||
spriteListResourceId = 0;
|
|
||||||
|
|
||||||
flags = 0;
|
|
||||||
sceneNumber = 0;
|
|
||||||
location.x = 0;
|
|
||||||
location.y = 0;
|
|
||||||
location.z = 0;
|
|
||||||
screenDepth = 0;
|
|
||||||
|
|
||||||
actorFlags = 0;
|
|
||||||
currentAction = 0;
|
|
||||||
facingDirection = 0;
|
|
||||||
actionDirection = 0;
|
|
||||||
actionCycle = 0;
|
|
||||||
targetObject = ID_NOTHING;
|
|
||||||
|
|
||||||
cycleFrameNumber = 0;
|
|
||||||
cycleDelay = 0;
|
|
||||||
cycleTimeCount = 0;
|
|
||||||
cycleFlags = 0;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -245,7 +223,8 @@ public:
|
||||||
void StoA(Point &actorPoint, const Point &screenPoint);
|
void StoA(Point &actorPoint, const Point &screenPoint);
|
||||||
|
|
||||||
|
|
||||||
bool actorWalkTo(uint16 actorId, const ActorLocation &actorLocation);
|
bool actorEndWalk(uint16 actorId, bool recurse);
|
||||||
|
bool actorWalkTo(uint16 actorId, const ActorLocation &toLocation);
|
||||||
ActorData *getActor(uint16 actorId);
|
ActorData *getActor(uint16 actorId);
|
||||||
ActorFrameRange *getActorFrameRange(uint16 actorId, int frameType);
|
ActorFrameRange *getActorFrameRange(uint16 actorId, int frameType);
|
||||||
|
|
||||||
|
@ -267,6 +246,8 @@ private:
|
||||||
bool loadActorResources(ActorData * actor);
|
bool loadActorResources(ActorData * actor);
|
||||||
|
|
||||||
void createDrawOrderList();
|
void createDrawOrderList();
|
||||||
|
void calcActorScreenPosition(ActorData * actor);
|
||||||
|
bool followProtagonist(ActorData * actor);
|
||||||
void handleSpeech(int msec);
|
void handleSpeech(int msec);
|
||||||
void handleActions(int msec, bool setup);
|
void handleActions(int msec, bool setup);
|
||||||
|
|
||||||
|
|
|
@ -40,14 +40,14 @@
|
||||||
namespace Saga {
|
namespace Saga {
|
||||||
|
|
||||||
static VERB_DATA I_VerbData[] = {
|
static VERB_DATA I_VerbData[] = {
|
||||||
{I_VERB_WALKTO, "verb_walkto", "Walk to", S_VERB_WALKTO},
|
{I_VERB_WALKTO, "verb_walkto", "Walk to", kVerbWalkTo},
|
||||||
{I_VERB_LOOKAT, "verb_lookat", "Look at", S_VERB_LOOKAT},
|
{I_VERB_LOOKAT, "verb_lookat", "Look at", kVerbLookAt},
|
||||||
{I_VERB_PICKUP, "verb_pickup", "Pick up", S_VERB_PICKUP},
|
{I_VERB_PICKUP, "verb_pickup", "Pick up", kVerbPickup},
|
||||||
{I_VERB_TALKTO, "verb_talkto", "Talk to", S_VERB_TALKTO},
|
{I_VERB_TALKTO, "verb_talkto", "Talk to", kVerbSpeakTo},
|
||||||
{I_VERB_OPEN, "verb_open", "Open", S_VERB_OPEN},
|
{I_VERB_OPEN, "verb_open", "Open", kVerbOpen},
|
||||||
{I_VERB_CLOSE, "verb_close", "Close", S_VERB_CLOSE},
|
{I_VERB_CLOSE, "verb_close", "Close", kVerbClose},
|
||||||
{I_VERB_USE, "verb_use", "Use", S_VERB_USE},
|
{I_VERB_USE, "verb_use", "Use", kVerbUse},
|
||||||
{I_VERB_GIVE, "verb_give", "Give", S_VERB_GIVE}
|
{I_VERB_GIVE, "verb_give", "Give", kVerbGive}
|
||||||
};
|
};
|
||||||
|
|
||||||
static INTERFACE_DESC ITE_interface = {
|
static INTERFACE_DESC ITE_interface = {
|
||||||
|
|
|
@ -51,15 +51,23 @@ namespace Saga {
|
||||||
|
|
||||||
typedef unsigned int ScriptDataWord;
|
typedef unsigned int ScriptDataWord;
|
||||||
|
|
||||||
enum SCRIPT_VERBS {
|
enum VerbTypes {
|
||||||
S_VERB_WALKTO = 0,
|
//todo: LUT for drawing
|
||||||
S_VERB_LOOKAT = 2,
|
kVerbNone = 0,
|
||||||
S_VERB_PICKUP = 1,
|
kVerbPickup = 1,
|
||||||
S_VERB_TALKTO,
|
kVerbLookAt = 2,
|
||||||
S_VERB_OPEN = 5,
|
kVerbWalkTo = 3,
|
||||||
S_VERB_CLOSE = 6,
|
kVerbSpeakTo = 4,
|
||||||
S_VERB_USE = 8,
|
kVerbOpen = 5,
|
||||||
S_VERB_GIVE
|
kVerbClose = 6,
|
||||||
|
kVerbGive = 7,
|
||||||
|
kVerbUse = 8,
|
||||||
|
kVerbOptions = 9,
|
||||||
|
kVerbEnter = 10,
|
||||||
|
kVerbLeave = 11,
|
||||||
|
kVerbBegin = 12,
|
||||||
|
kVerbWalkOnly = 13,
|
||||||
|
kVerbLookOnly = 14
|
||||||
};
|
};
|
||||||
|
|
||||||
#define STHREAD_TIMESLICE 8
|
#define STHREAD_TIMESLICE 8
|
||||||
|
|
|
@ -694,13 +694,13 @@ int Script::SF_actorWalk(SCRIPTFUNC_PARAMS) {
|
||||||
int Script::sfCycleFrames(SCRIPTFUNC_PARAMS) {
|
int Script::sfCycleFrames(SCRIPTFUNC_PARAMS) {
|
||||||
uint16 actorId;
|
uint16 actorId;
|
||||||
int flags;
|
int flags;
|
||||||
int cycleFrameNumber;
|
int cycleFrameSequence;
|
||||||
int cycleDelay;
|
int cycleDelay;
|
||||||
ActorData *actor;
|
ActorData *actor;
|
||||||
|
|
||||||
actorId = getSWord(thread->pop());
|
actorId = getSWord(thread->pop());
|
||||||
flags = getUWord(thread->pop());
|
flags = getUWord(thread->pop());
|
||||||
cycleFrameNumber = getUWord(thread->pop());
|
cycleFrameSequence = getUWord(thread->pop());
|
||||||
cycleDelay = getUWord(thread->pop());
|
cycleDelay = getUWord(thread->pop());
|
||||||
|
|
||||||
actor = _vm->_actor->getActor(actorId);
|
actor = _vm->_actor->getActor(actorId);
|
||||||
|
@ -723,7 +723,7 @@ int Script::sfCycleFrames(SCRIPTFUNC_PARAMS) {
|
||||||
actor->actorFlags |= kActorBackwards;
|
actor->actorFlags |= kActorBackwards;
|
||||||
}
|
}
|
||||||
|
|
||||||
actor->cycleFrameNumber = cycleFrameNumber;
|
actor->cycleFrameSequence = cycleFrameSequence;
|
||||||
actor->cycleTimeCount = 0;
|
actor->cycleTimeCount = 0;
|
||||||
actor->cycleDelay = cycleDelay;
|
actor->cycleDelay = cycleDelay;
|
||||||
actor->actionCycle = 0;
|
actor->actionCycle = 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue