aboutsummaryrefslogtreecommitdiff
path: root/saga
diff options
context:
space:
mode:
authorTorbjörn Andersson2005-01-05 07:19:58 +0000
committerTorbjörn Andersson2005-01-05 07:19:58 +0000
commitc53c4f13d915e5365d669823dfc95a1033ec1252 (patch)
tree9acb8115ec15609aaab51922b51e481e28e91dde /saga
parent935f320e1ad51f0273edfa2b94d70e45c215ebda (diff)
downloadscummvm-rg350-c53c4f13d915e5365d669823dfc95a1033ec1252.tar.gz
scummvm-rg350-c53c4f13d915e5365d669823dfc95a1033ec1252.tar.bz2
scummvm-rg350-c53c4f13d915e5365d669823dfc95a1033ec1252.zip
Indentation
svn-id: r16437
Diffstat (limited to 'saga')
-rw-r--r--saga/actor.cpp355
1 files changed, 178 insertions, 177 deletions
diff --git a/saga/actor.cpp b/saga/actor.cpp
index d6a9474761..8c8fb19039 100644
--- a/saga/actor.cpp
+++ b/saga/actor.cpp
@@ -561,232 +561,233 @@ void Actor::handleActions(int msec, bool setup) {
debug(9, "Action: %d Flags: %x", actor->currentAction, actor->flags);
switch(actor->currentAction) {
- case kActionWait:
- if (!setup && (actor->flags & kFollower)) {
- followProtagonist(actor);
- if (actor->currentAction != kActionWait)
- break;
- }
-
- if (actor->targetObject != ID_NOTHING) {
- //todo: facetowardsobject
- }
-
- if (actor->flags & kCycle) {
- frameRange = getActorFrameRange(actor->actorId, kFrameStand);
- if (frameRange->frameCount > 0) {
- actor->actionCycle++;
- actor->actionCycle = (actor->actionCycle) % frameRange->frameCount;
- } else {
- actor->actionCycle = 0;
- }
- actor->frameNumber = frameRange->frameIndex + actor->actionCycle;
+ case kActionWait:
+ if (!setup && (actor->flags & kFollower)) {
+ followProtagonist(actor);
+ if (actor->currentAction != kActionWait)
break;
- }
-
- if ((actor->actionCycle & 3) == 0) {
- actor->cycleWrap(100);
+ }
- frameRange = getActorFrameRange(actor->actorId, kFrameWait);
- if ((frameRange->frameCount < 1 || actor->actionCycle > 33))
- frameRange = getActorFrameRange(actor->actorId, kFrameStand);
+ if (actor->targetObject != ID_NOTHING) {
+ //todo: facetowardsobject
+ }
- if (frameRange->frameCount) {
- actor->frameNumber = frameRange->frameIndex + (uint16)rand() % frameRange->frameCount;
- } else {
- actor->frameNumber = frameRange->frameIndex;
- }
+ if (actor->flags & kCycle) {
+ frameRange = getActorFrameRange(actor->actorId, kFrameStand);
+ if (frameRange->frameCount > 0) {
+ actor->actionCycle++;
+ actor->actionCycle = (actor->actionCycle) % frameRange->frameCount;
+ } else {
+ actor->actionCycle = 0;
}
- actor->actionCycle++;
+ actor->frameNumber = frameRange->frameIndex + actor->actionCycle;
break;
+ }
- case kActionWalkToPoint:
- case kActionWalkToLink:
- // tiled stuff
- if (_vm->_scene->getMode() == SCENE_MODE_ISO) {
- //todo: it
- } else {
- actor->partialTarget.delta(actor->location, delta);
-
- while ((delta.x == 0) && (delta.y == 0)) {
- int xstep;
-
- if (actor->walkStepIndex >= actor->walkStepsCount) {
- actorEndWalk(actor->actorId, true);
- break;
- }
+ if ((actor->actionCycle & 3) == 0) {
+ actor->cycleWrap(100);
- xstep = actor->walkPath[actor->walkStepIndex++];
- if (xstep > 256-32) {
- xstep -= 256;
- }
+ frameRange = getActorFrameRange(actor->actorId, kFrameWait);
+ if ((frameRange->frameCount < 1 || actor->actionCycle > 33))
+ frameRange = getActorFrameRange(actor->actorId, kFrameStand);
- actor->partialTarget.x = xstep * 2 * ACTOR_LMULT;
- actor->partialTarget.y = actor->walkPath[actor->walkStepIndex++] * ACTOR_LMULT;
- actor->partialTarget.z = 0;
+ if (frameRange->frameCount) {
+ actor->frameNumber = frameRange->frameIndex + (uint16)rand() % frameRange->frameCount;
+ } else {
+ actor->frameNumber = frameRange->frameIndex;
+ }
+ }
+ actor->actionCycle++;
+ break;
- actor->partialTarget.delta(actor->location, delta);
+ case kActionWalkToPoint:
+ case kActionWalkToLink:
+ // tiled stuff
+ if (_vm->_scene->getMode() == SCENE_MODE_ISO) {
+ //todo: it
+ } else {
+ actor->partialTarget.delta(actor->location, delta);
- if (ABS(delta.y) > ABS(delta.x)) {
- actor->actionDirection = delta.y > 0 ? kDirDown : kDirUp;
- } else {
- actor->actionDirection = delta.x > 0 ? kDirRight : kDirLeft;
- }
- }
+ while ((delta.x == 0) && (delta.y == 0)) {
+ int xstep;
- speed = (ACTOR_LMULT * 2 * actor->screenScale + 63) / 256;
- if (speed < 1) {
- speed = 1;
+ if (actor->walkStepIndex >= actor->walkStepsCount) {
+ actorEndWalk(actor->actorId, true);
+ break;
}
- if ((actor->actionDirection == kDirUp) || (actor->actionDirection == kDirDown)) { // move by 2's in vertical dimension
- addDelta.y = clamp(-speed, delta.y, speed);
- if (addDelta.y == delta.y) {
- addDelta.x = delta.x;
- } else {
- addDelta.x = delta.x * addDelta.y;
- addDelta.x += (addDelta.x > 0) ? (delta.y / 2) : (-delta.y / 2);
- addDelta.x /= delta.y;
- actor->facingDirection = actor->actionDirection;
- }
- } else {
- addDelta.x = clamp(-2 * speed, delta.x, 2 * speed);
- if (addDelta.x == delta.x) {
- addDelta.y = delta.y;
- } else {
- addDelta.y = delta.y * addDelta.x;
- addDelta.y += (addDelta.y > 0) ? (delta.x / 2) : (-delta.x / 2);
- addDelta.y /= delta.x;
- actor->facingDirection = actor->actionDirection;
- }
+ xstep = actor->walkPath[actor->walkStepIndex++];
+ if (xstep > 256 - 32) {
+ xstep -= 256;
}
- actor->location.add(addDelta);
- }
+ actor->partialTarget.x = xstep * 2 * ACTOR_LMULT;
+ actor->partialTarget.y = actor->walkPath[actor->walkStepIndex++] * ACTOR_LMULT;
+ actor->partialTarget.z = 0;
+ actor->partialTarget.delta(actor->location, delta);
- if (actor->actorFlags & kActorBackwards) {
- actor->facingDirection = (actor->actionDirection + 4) & 7;
- actor->actionCycle--;
- } else {
- actor->actionCycle++;
+ if (ABS(delta.y) > ABS(delta.x)) {
+ actor->actionDirection = delta.y > 0 ? kDirDown : kDirUp;
+ } else {
+ actor->actionDirection = delta.x > 0 ? kDirRight : kDirLeft;
+ }
}
- frameRange = getActorFrameRange(actor->actorId, actor->walkFrameSequence);
+ speed = (ACTOR_LMULT * 2 * actor->screenScale + 63) / 256;
+ if (speed < 1) {
+ speed = 1;
+ }
- if (actor->actionCycle < 0) {
- actor->actionCycle = frameRange->frameCount - 1;
- } else {
- if (actor->actionCycle >= frameRange->frameCount) {
- actor->actionCycle = 0;
+ if ((actor->actionDirection == kDirUp) || (actor->actionDirection == kDirDown)) {
+ // move by 2's in vertical dimension
+ addDelta.y = clamp(-speed, delta.y, speed);
+ if (addDelta.y == delta.y) {
+ addDelta.x = delta.x;
+ } else {
+ addDelta.x = delta.x * addDelta.y;
+ addDelta.x += (addDelta.x > 0) ? (delta.y / 2) : (-delta.y / 2);
+ addDelta.x /= delta.y;
+ actor->facingDirection = actor->actionDirection;
+ }
+ } else {
+ addDelta.x = clamp(-2 * speed, delta.x, 2 * speed);
+ if (addDelta.x == delta.x) {
+ addDelta.y = delta.y;
+ } else {
+ addDelta.y = delta.y * addDelta.x;
+ addDelta.y += (addDelta.y > 0) ? (delta.x / 2) : (-delta.x / 2);
+ addDelta.y /= delta.x;
+ actor->facingDirection = actor->actionDirection;
}
}
- actor->frameNumber = frameRange->frameIndex + actor->actionCycle;
- break;
+ actor->location.add(addDelta);
+ }
- case kActionWalkDir:
- // tiled stuff
- if (_vm->_scene->getMode() == SCENE_MODE_ISO) {
- //todo: it
- } else {
- actor->location.x += directionLUT[actor->actionDirection][0] * 2;
- actor->location.y += directionLUT[actor->actionDirection][1] * 2;
+ if (actor->actorFlags & kActorBackwards) {
+ actor->facingDirection = (actor->actionDirection + 4) & 7;
+ actor->actionCycle--;
+ } else {
+ actor->actionCycle++;
+ }
- frameRange = getActorFrameRange(actor->actorId, actor->walkFrameSequence);
- actor->actionCycle++;
- actor->cycleWrap(frameRange->frameCount);
- actor->frameNumber = frameRange->frameIndex + actor->actionCycle;
+ frameRange = getActorFrameRange(actor->actorId, actor->walkFrameSequence);
+
+ if (actor->actionCycle < 0) {
+ actor->actionCycle = frameRange->frameCount - 1;
+ } else {
+ if (actor->actionCycle >= frameRange->frameCount) {
+ actor->actionCycle = 0;
}
- break;
+ }
- case kActionSpeak:
+ actor->frameNumber = frameRange->frameIndex + actor->actionCycle;
+ break;
+
+ case kActionWalkDir:
+ // tiled stuff
+ if (_vm->_scene->getMode() == SCENE_MODE_ISO) {
+ //todo: it
+ } else {
+ actor->location.x += directionLUT[actor->actionDirection][0] * 2;
+ actor->location.y += directionLUT[actor->actionDirection][1] * 2;
+
+ frameRange = getActorFrameRange(actor->actorId, actor->walkFrameSequence);
actor->actionCycle++;
- actor->cycleWrap(64);
+ actor->cycleWrap(frameRange->frameCount);
+ actor->frameNumber = frameRange->frameIndex + actor->actionCycle;
+ }
+ break;
- frameRange = getActorFrameRange(actor->actorId, kFrameGesture);
- if (actor->actionCycle >= frameRange->frameCount) {
- if (actor->actionCycle & 1) break;
- frameRange = getActorFrameRange(actor->actorId, kFrameSpeak);
+ case kActionSpeak:
+ actor->actionCycle++;
+ actor->cycleWrap(64);
- state = (uint16)rand() % (frameRange->frameCount + 1);
+ frameRange = getActorFrameRange(actor->actorId, kFrameGesture);
+ if (actor->actionCycle >= frameRange->frameCount) {
+ if (actor->actionCycle & 1)
+ break;
+ frameRange = getActorFrameRange(actor->actorId, kFrameSpeak);
- if (state == 0) {
- frameRange = getActorFrameRange(actor->actorId, kFrameStand);
- } else {
- state--;
- }
+ state = (uint16)rand() % (frameRange->frameCount + 1);
+
+ if (state == 0) {
+ frameRange = getActorFrameRange(actor->actorId, kFrameStand);
} else {
- state = actor->actionCycle;
+ state--;
}
+ } else {
+ state = actor->actionCycle;
+ }
- actor->frameNumber = frameRange->frameIndex + state;
- break;
+ actor->frameNumber = frameRange->frameIndex + state;
+ break;
- case kActionAccept:
- case kActionStoop:
- break;
+ case kActionAccept:
+ case kActionStoop:
+ break;
- case kActionCycleFrames:
- case kActionPongFrames:
- if (actor->cycleTimeCount > 0) {
- actor->cycleTimeCount--;
- break;
- }
+ case kActionCycleFrames:
+ case kActionPongFrames:
+ if (actor->cycleTimeCount > 0) {
+ actor->cycleTimeCount--;
+ break;
+ }
- actor->cycleTimeCount = actor->cycleDelay;
- actor->actionCycle++;
+ actor->cycleTimeCount = actor->cycleDelay;
+ actor->actionCycle++;
- frameRange = getActorFrameRange(actor->actorId, actor->cycleFrameSequence);
+ frameRange = getActorFrameRange(actor->actorId, actor->cycleFrameSequence);
- if (actor->currentAction == kActionPongFrames) {
- if (actor->actionCycle >= frameRange->frameCount * 2 - 2) {
- if (actor->actorFlags & kActorContinuous) {
- actor->actionCycle = 0;
- } else {
- actor->currentAction = kActionFreeze;
- break;
- }
+ if (actor->currentAction == kActionPongFrames) {
+ if (actor->actionCycle >= frameRange->frameCount * 2 - 2) {
+ if (actor->actorFlags & kActorContinuous) {
+ actor->actionCycle = 0;
+ } else {
+ actor->currentAction = kActionFreeze;
+ break;
}
+ }
- state = actor->actionCycle;
- if (state >= frameRange->frameCount) {
- state = frameRange->frameCount * 2 - 2 - state;
- }
- } else {
- if (actor->actionCycle >= frameRange->frameCount) {
- if (actor->actorFlags & kActorContinuous) {
- actor->actionCycle = 0;
- } else {
- actor->currentAction = kActionFreeze;
- break;
- }
+ state = actor->actionCycle;
+ if (state >= frameRange->frameCount) {
+ state = frameRange->frameCount * 2 - 2 - state;
+ }
+ } else {
+ if (actor->actionCycle >= frameRange->frameCount) {
+ if (actor->actorFlags & kActorContinuous) {
+ actor->actionCycle = 0;
+ } else {
+ actor->currentAction = kActionFreeze;
+ break;
}
- state = actor->actionCycle;
}
+ state = actor->actionCycle;
+ }
- if (frameRange->frameCount && (actor->actorFlags & kActorRandom)) {
- state = rand() % frameRange->frameCount;
- }
+ if (frameRange->frameCount && (actor->actorFlags & kActorRandom)) {
+ state = rand() % frameRange->frameCount;
+ }
- if (actor->actorFlags & kActorBackwards) {
- actor->frameNumber = frameRange->frameIndex + frameRange->frameCount - 1 - state;
- } else {
- actor->frameNumber = frameRange->frameIndex + state;
- }
- break;
+ if (actor->actorFlags & kActorBackwards) {
+ actor->frameNumber = frameRange->frameIndex + frameRange->frameCount - 1 - state;
+ } else {
+ actor->frameNumber = frameRange->frameIndex + state;
+ }
+ break;
- case kActionFall:
- debug(9,"kActionFall not implemented");
+ case kActionFall:
+ debug(9, "kActionFall not implemented");
- //todo: do it
- break;
+ //todo: do it
+ break;
- case kActionClimb:
- debug(9,"kActionClimb not implemented");
+ case kActionClimb:
+ debug(9, "kActionClimb not implemented");
- //todo: do it
- break;
+ //todo: do it
+ break;
}
}