aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Kurushin2004-12-25 11:17:03 +0000
committerAndrew Kurushin2004-12-25 11:17:03 +0000
commita66080b80a592f0610d1e4c7e8adeefe8a30e680 (patch)
treec8369fd5e48f99b4f27704f3081485920f9d1c61
parenta8c8a7ab4ca20c8d5cdfef2191166388902f6891 (diff)
downloadscummvm-rg350-a66080b80a592f0610d1e4c7e8adeefe8a30e680.tar.gz
scummvm-rg350-a66080b80a592f0610d1e4c7e8adeefe8a30e680.tar.bz2
scummvm-rg350-a66080b80a592f0610d1e4c7e8adeefe8a30e680.zip
- some "actors walk" work progression
svn-id: r16308
-rw-r--r--saga/actor.cpp144
-rw-r--r--saga/actor.h57
-rw-r--r--saga/interface.cpp16
-rw-r--r--saga/script.h26
-rw-r--r--saga/sfuncs.cpp6
5 files changed, 153 insertions, 96 deletions
diff --git a/saga/actor.cpp b/saga/actor.cpp
index 69b6f06e09..5dc5bcaa1b 100644
--- a/saga/actor.cpp
+++ b/saga/actor.cpp
@@ -218,7 +218,7 @@ void Actor::updateActorsScene() {
if (actor->flags & (kProtagonist | kFollower)) {
actor->sceneNumber = _vm->_scene->currentSceneNumber();
if (actor->flags & kProtagonist) {
-// actor->finalTarget = a->obj.loc;
+//todo: actor->finalTarget = a->obj.loc;
_centerActor = _protagonist = actor;
}
@@ -436,7 +436,7 @@ void Actor::handleActions(int msec, bool setup) {
actor->cycleTimeCount = actor->cycleDelay;
actor->actionCycle++;
- frameRange = getActorFrameRange( actor->actorId, actor->cycleFrameNumber);
+ frameRange = getActorFrameRange( actor->actorId, actor->cycleFrameSequence);
if (actor->currentAction == kActionPongFrames) {
if (actor->actionCycle >= frameRange->frameCount * 2 - 2) {
@@ -505,9 +505,37 @@ int Actor::direct(int msec) {
return SUCCESS;
}
+void Actor::calcActorScreenPosition(ActorData * actor) {
+ int beginSlope, endSlope, middle;
+ // tiled stuff
+ {
+ }
+ {
+ middle = ITE_STATUS_Y - actor->location.y / ACTOR_LMULT;
+
+ _vm->_scene->getSlopes(beginSlope, endSlope);
+
+ actor->screenDepth = (14 * middle) / endSlope + 1;
+
+ if (middle <= beginSlope) {
+ actor->screenScale = 256;
+ } else {
+ if (middle >= endSlope) {
+ actor->screenScale = 1;
+ } else {
+ middle -= beginSlope;
+ endSlope -= beginSlope;
+ actor->screenScale = 256 - (middle * 256) / endSlope;
+ }
+ }
+
+ actor->screenPosition.x = (actor->location.x / ACTOR_LMULT);
+ actor->screenPosition.y = (actor->location.y / ACTOR_LMULT) - actor->location.z;
+ }
+}
+
void Actor::createDrawOrderList() {
int i;
- int beginSlope, endSlope, middle;
ActorData *actor;
_drawOrderList.clear();
@@ -518,31 +546,7 @@ void Actor::createDrawOrderList() {
_drawOrderList.pushBack(actor, actorCompare);
- // tiled stuff
- {
- }
- {
- middle = ITE_STATUS_Y - actor->location.y / ACTOR_LMULT,
-
- _vm->_scene->getSlopes(beginSlope, endSlope);
-
- actor->screenDepth = (14 * middle) / endSlope + 1;
-
- if (middle <= beginSlope) {
- actor->screenScale = 256;
- } else {
- if (middle >= endSlope) {
- actor->screenScale = 1;
- } else {
- middle -= beginSlope;
- endSlope -= beginSlope;
- actor->screenScale = 256 - (middle * 256) / endSlope;
- }
- }
-
- actor->screenPosition.x = (actor->location.x / ACTOR_LMULT);
- actor->screenPosition.y = (actor->location.y / ACTOR_LMULT) - actor->location.z;
- }
+ calcActorScreenPosition(actor);
}
}
@@ -635,26 +639,90 @@ void Actor::StoA(Point &actorPoint, const Point &screenPoint) {
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 (a == protag)
- {
- sceneDoors[ 2 ] = 0xff; // closed
- sceneDoors[ 3 ] = 0; // open
+ if (actor->location.distance(actor->finalTarget) > 8) {
+ if ((actor->flags & kProtagonist) && recurse && !(actor->actorFlags & kActorNoCollide)) {
+ actor->actorFlags |= kActorNoCollide;
+ return actorWalkTo(actorId, actor->finalTarget);
+ }
}
- else
- {
- sceneDoors[ 2 ] = 0; // open
- sceneDoors[ 3 ] = 0xff; // closed
- }*/
+
+ 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;
+
+ actor = getActor(actorId);
+
// 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;
diff --git a/saga/actor.h b/saga/actor.h
index bc445324dc..e67219d176 100644
--- a/saga/actor.h
+++ b/saga/actor.h
@@ -35,7 +35,8 @@ namespace Saga {
#define ACTOR_BASE_SPEED 0.25
#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
@@ -106,7 +107,7 @@ enum ActorFlagsEx {
kActorFinishRight = ((1 << 5) | (kDirRight << 6)),
kActorFinishUp = ((1 << 5) | (kDirUp << 6)),
kActorFinishDown = ((1 << 5) | (kDirDown << 6)),
- kActorFacing = (0xf << 5),
+ kActorFacingMask = (0xf << 5),
kActorRandom = (1 << 10)
};
@@ -124,6 +125,9 @@ struct ActorLocation {
int x; // Actor's logical coordinates
int y; //
int z; //
+ int distance(const ActorLocation &location) {
+ return max(abs(x - location.x), abs(y - location.y));
+ }
};
struct ActorData {
bool disabled; // Actor disabled in init section
@@ -149,7 +153,7 @@ struct ActorData {
int frameNumber; // current actor frame number
uint16 targetObject;
- int cycleFrameNumber;
+ int cycleFrameSequence;
uint8 cycleDelay;
uint8 cycleTimeCount;
uint8 cycleFlags;
@@ -160,7 +164,13 @@ struct ActorData {
ActorFrameSequence *frames; // Actor's frames
int framesCount; // Actor's frames count
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) {
if (actionCycle >= cycleLimit)
@@ -168,39 +178,7 @@ struct ActorData {
}
ActorData() {
- disabled = false;
- 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;
-
+ memset(this, 0xFE, sizeof(*this));
}
};
@@ -245,7 +223,8 @@ public:
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);
ActorFrameRange *getActorFrameRange(uint16 actorId, int frameType);
@@ -267,6 +246,8 @@ private:
bool loadActorResources(ActorData * actor);
void createDrawOrderList();
+ void calcActorScreenPosition(ActorData * actor);
+ bool followProtagonist(ActorData * actor);
void handleSpeech(int msec);
void handleActions(int msec, bool setup);
diff --git a/saga/interface.cpp b/saga/interface.cpp
index d8111d135d..613b74f39a 100644
--- a/saga/interface.cpp
+++ b/saga/interface.cpp
@@ -40,14 +40,14 @@
namespace Saga {
static VERB_DATA I_VerbData[] = {
- {I_VERB_WALKTO, "verb_walkto", "Walk to", S_VERB_WALKTO},
- {I_VERB_LOOKAT, "verb_lookat", "Look at", S_VERB_LOOKAT},
- {I_VERB_PICKUP, "verb_pickup", "Pick up", S_VERB_PICKUP},
- {I_VERB_TALKTO, "verb_talkto", "Talk to", S_VERB_TALKTO},
- {I_VERB_OPEN, "verb_open", "Open", S_VERB_OPEN},
- {I_VERB_CLOSE, "verb_close", "Close", S_VERB_CLOSE},
- {I_VERB_USE, "verb_use", "Use", S_VERB_USE},
- {I_VERB_GIVE, "verb_give", "Give", S_VERB_GIVE}
+ {I_VERB_WALKTO, "verb_walkto", "Walk to", kVerbWalkTo},
+ {I_VERB_LOOKAT, "verb_lookat", "Look at", kVerbLookAt},
+ {I_VERB_PICKUP, "verb_pickup", "Pick up", kVerbPickup},
+ {I_VERB_TALKTO, "verb_talkto", "Talk to", kVerbSpeakTo},
+ {I_VERB_OPEN, "verb_open", "Open", kVerbOpen},
+ {I_VERB_CLOSE, "verb_close", "Close", kVerbClose},
+ {I_VERB_USE, "verb_use", "Use", kVerbUse},
+ {I_VERB_GIVE, "verb_give", "Give", kVerbGive}
};
static INTERFACE_DESC ITE_interface = {
diff --git a/saga/script.h b/saga/script.h
index 7f230361f5..ef9ba36a45 100644
--- a/saga/script.h
+++ b/saga/script.h
@@ -51,15 +51,23 @@ namespace Saga {
typedef unsigned int ScriptDataWord;
-enum SCRIPT_VERBS {
- S_VERB_WALKTO = 0,
- S_VERB_LOOKAT = 2,
- S_VERB_PICKUP = 1,
- S_VERB_TALKTO,
- S_VERB_OPEN = 5,
- S_VERB_CLOSE = 6,
- S_VERB_USE = 8,
- S_VERB_GIVE
+enum VerbTypes {
+//todo: LUT for drawing
+ kVerbNone = 0,
+ kVerbPickup = 1,
+ kVerbLookAt = 2,
+ kVerbWalkTo = 3,
+ kVerbSpeakTo = 4,
+ kVerbOpen = 5,
+ kVerbClose = 6,
+ kVerbGive = 7,
+ kVerbUse = 8,
+ kVerbOptions = 9,
+ kVerbEnter = 10,
+ kVerbLeave = 11,
+ kVerbBegin = 12,
+ kVerbWalkOnly = 13,
+ kVerbLookOnly = 14
};
#define STHREAD_TIMESLICE 8
diff --git a/saga/sfuncs.cpp b/saga/sfuncs.cpp
index 9bfc78ce8d..4eb1efc5f5 100644
--- a/saga/sfuncs.cpp
+++ b/saga/sfuncs.cpp
@@ -694,13 +694,13 @@ int Script::SF_actorWalk(SCRIPTFUNC_PARAMS) {
int Script::sfCycleFrames(SCRIPTFUNC_PARAMS) {
uint16 actorId;
int flags;
- int cycleFrameNumber;
+ int cycleFrameSequence;
int cycleDelay;
ActorData *actor;
actorId = getSWord(thread->pop());
flags = getUWord(thread->pop());
- cycleFrameNumber = getUWord(thread->pop());
+ cycleFrameSequence = getUWord(thread->pop());
cycleDelay = getUWord(thread->pop());
actor = _vm->_actor->getActor(actorId);
@@ -723,7 +723,7 @@ int Script::sfCycleFrames(SCRIPTFUNC_PARAMS) {
actor->actorFlags |= kActorBackwards;
}
- actor->cycleFrameNumber = cycleFrameNumber;
+ actor->cycleFrameSequence = cycleFrameSequence;
actor->cycleTimeCount = 0;
actor->cycleDelay = cycleDelay;
actor->actionCycle = 0;