Skip to content
Permalink
Browse files

BLADERUNNER: Added more functionality to movement track

  • Loading branch information
peterkohaut committed Mar 22, 2017
1 parent c084e98 commit 52476b0778d4e02a67b61793b9ebeb1725658b40
@@ -91,6 +91,9 @@ void Actor::setup(int actorId) {
_retiredWidth = 0;
_retiredHeight = 0;

_movementTrackWalkingToWaypointId = -1;
_movementTrackDelayOnNextWaypoint = -1;

for (int i = 0; i != 7; ++i) {
_timersRemain[i] = 0;
_timersStart[i] = _vm->getTotalPlayTime();
@@ -107,6 +110,12 @@ void Actor::setup(int actorId) {
_maxHP = 50;
_goalNumber = -1;

_movementTrackPaused = false;
_movementTrackNextWaypointId = -1;
_movementTrackNextDelay = -1;
_movementTrackNextAngle = -1;
_movementTrackNextRunning = false;

_timersRemain[4] = 60000;
_animationMode = -1;
_screenRectangle = Common::Rect(-1, -1, -1, -1);
@@ -151,30 +160,174 @@ void Actor::setFPS(int fps) {
}
}

void Actor::processMovement() {
/*if (movementTrack::is_paused(this->movementTrack) != 1 && this->id)
{
if (this->walkingWaypointId >= 0 && this->timeoutWalkingWaypoint >= 0)
{
worldWaypoints::get_sceneId(WorldWaypoints, this->walkingWaypointId);
if (!this->timeoutWalkingWaypoint)
{
this->timeoutWalkingWaypoint = 1;
void Actor::countdownTimerStart(int timerId, int interval) {
assert(timerId >= 0 && timerId < 7);
_timersRemain[timerId] = interval;
_timersStart[timerId] = _vm->getTotalPlayTime();
}

void Actor::countdownTimerReset(int timerId) {
assert(timerId >= 0 && timerId < 7);
_timersRemain[timerId] = 0;
}

int Actor::countdownTimerGetRemainingTime(int timerId) {
assert(timerId >= 0 && timerId < 7);
return _timersRemain[timerId];
}

void Actor::countdownTimersUpdate() {
for (int i = 0; i <= 6; i++) {
countdownTimerUpdate(i);
}
}

void Actor::countdownTimerUpdate(int timerId) {
if (_timersRemain[timerId] == 0) {
return;
}

uint32 now = _vm->getTotalPlayTime();
int tickInterval = now - _timersStart[timerId];
_timersStart[timerId] = now;

//warning("tickInterval: %d", tickInterval);
_timersRemain[timerId] -= tickInterval;

if (_timersRemain[timerId] <= 0) {
switch (timerId) {
case 0:
case 1:
case 2:
if (!_vm->_aiScripts->IsInsideScript() && !_vm->_script->IsInsideScript()) {
_vm->_aiScripts->TimerExpired(this->_id, timerId);
this->_timersRemain[timerId] = 0;
} else {
this->_timersRemain[timerId] = 1;
}
break;
case 3:
_timersRemain[3] = 0;
if (_movementTrack->isPaused()) {
_timersRemain[3] = 1;
} else {
movementTrackNext(false);
}
break;
case 4:
// Something timer
break;
case 5:
// Actor animation frame timer
break;
case 6:
if (isRunning()) {
if (_fps > 15) {
int newFps = _fps - 2;
if (newFps < 15) {
newFps = 15;
}
setFPS(newFps);
}
}
_timersRemain[6] = 200;
break;
}
}
}

void Actor::movementTrackNext(bool omitAiScript) {
bool hasNextMovement;
int waypointSetId;
int running;
int angle;
int delay;
int waypointId;
Vector3 waypointPosition;
bool stopped;

hasNextMovement = _movementTrack->next(&waypointId, &delay, &angle, &running);
_movementTrackNextWaypointId = waypointId;
_movementTrackNextDelay = delay;
_movementTrackNextAngle = angle;
_movementTrackNextRunning = running;
if (hasNextMovement) {
if (angle == -1) {
angle = 0;
}
waypointSetId = _vm->_waypoints->getSetId(waypointId);
_vm->_waypoints->getXYZ(waypointId, &waypointPosition.x, &waypointPosition.y, &waypointPosition.z);
if (_setId == waypointSetId && waypointSetId == _vm->_actors[0]->_setId) {
stopWalking(false);
_walkInfo->setup(_id, running, _position, waypointPosition, false, &stopped);

_movementTrackWalkingToWaypointId = waypointId;
_movementTrackDelayOnNextWaypoint = delay;
if (stopped) {
movementTrackWaypointReached();
}
} else {
setSetId(waypointSetId);
setAtXYZ(waypointPosition, angle, true, false, false);

if (!delay) {
delay = 1;
}
if (delay > 1) {
changeAnimationMode(0, false);
}
countdownTimerStart(3, delay);
}
//return true;
} else {
if (!omitAiScript) {
_vm->_aiScripts->CompletedMovementTrack(_id);
}
//return false;
}
}

void Actor::movementTrackPause() {
_movementTrack->pause();
if (isWalking()) {
_movementTrackPaused = true;
stopWalking(false);
} else {
_movementTrackPaused = false;
}
}

void Actor::movementTrackUnpause() {
Vector3 waypointPosition;
bool stopped;

_movementTrack->unpause();
if (_movementTrackNextWaypointId >= 0 && _movementTrackPaused) {
_vm->_waypoints->getXYZ(_movementTrackNextWaypointId, &waypointPosition.x, &waypointPosition.y, &waypointPosition.z);
_walkInfo->setup(_id, _movementTrackNextRunning, _position, waypointPosition, false, &stopped);
_movementTrackPaused = false;
}
}

void Actor::movementTrackWaypointReached() {
int seconds;
if (!_movementTrack->isPaused() && _id != 0) {
if (_movementTrackWalkingToWaypointId >= 0 && _movementTrackDelayOnNextWaypoint) {
if (!_movementTrackDelayOnNextWaypoint) {
_movementTrackDelayOnNextWaypoint = 1;
}
if (actorScript::call_ReachedMovementTrackWaypoint(ActorScript, this->id, this->walkingWaypointId) == 1)
{
seconds = this->timeoutWalkingWaypoint;
if (seconds > 1)
{
actor::changeAnimationMode(this, 0, 0);
seconds = this->timeoutWalkingWaypoint;
if (_vm->_aiScripts->ReachedMovementTrackWaypoint(_id, _movementTrackWalkingToWaypointId)) {
seconds = _movementTrackDelayOnNextWaypoint;
if (seconds > 1) {
changeAnimationMode(0, false);
seconds = _movementTrackDelayOnNextWaypoint; // todo: analyze if movement is changed in some aiscript->ChangeAnimationMode?
}
actor::startTimer(this, 3, seconds);
countdownTimerStart(3, seconds);
}
}
this->walkingWaypointId = -1;
this->timeoutWalkingWaypoint = 0;
}*/
_movementTrackWalkingToWaypointId = -1;
_movementTrackDelayOnNextWaypoint = 0;
}
}

bool Actor::loopWalkToActor(int otherActorId, int destinationOffset, int a3, bool run, bool a5, bool *isRunning) {
@@ -375,10 +528,8 @@ bool Actor::loopWalkToSceneObject(const char *objectName, int destinationOffset,
}

bool Actor::loopWalkToWaypoint(int waypointId, int destinationOffset, int a3, bool run, bool a5, bool *isRunning) {
float x, y, z;
_vm->_waypoints->getXYZ(waypointId, &x, &y, &z);
Vector3 waypointPosition(x, y, z);

Vector3 waypointPosition;
_vm->_waypoints->getXYZ(waypointId, &waypointPosition.x, &waypointPosition.y, &waypointPosition.z);
return loopWalk(waypointPosition, destinationOffset, a3, run, _position, 0.0f, 24.0f, a5, isRunning, false);
}

@@ -432,7 +583,7 @@ bool Actor::tick(bool forceDraw) {
if (walked) {
_vm->_actors[_id]->changeAnimationMode(0);

this->processMovement();
this->movementTrackWaypointReached();
if (this->inCombat()) {
this->changeAnimationMode(this->_combatAnimationMode, false);
} else {
@@ -613,6 +764,10 @@ bool Actor::isWalking() {
return _walkInfo->isWalking();
}

bool Actor::isRunning() {
return _walkInfo->isRunning();
}

void Actor::stopWalking(bool value) {
if (value && _id == 0) {
_vm->_playerActorIdle = true;
@@ -927,69 +1082,6 @@ int Actor::soundBalance() {
return 127.0f * (MAX(MIN(screenPosition.x / 640.0f, 1.0f), 0.0f) * 2.0f - 1.0f);
}

void Actor::countdownTimerStart(int timerId, int interval) {
assert(timerId >= 0 && timerId < 7);
_timersRemain[timerId] = interval;
_timersStart[timerId] = _vm->getTotalPlayTime();
}

void Actor::countdownTimerReset(int timerId) {
assert(timerId >= 0 && timerId < 7);
_timersRemain[timerId] = 0;
}

int Actor::countdownTimerGetRemainingTime(int timerId) {
assert(timerId >= 0 && timerId < 7);
return _timersRemain[timerId];
}

void Actor::countdownTimersUpdate() {
for (int i = 0; i <= 6; i++) {
countdownTimerUpdate(i);
}
}

void Actor::countdownTimerUpdate(int timerId) {
if (_timersRemain[timerId] == 0)
return;

uint32 now = _vm->getTotalPlayTime();
int tickInterval = now - _timersStart[timerId];
_timersStart[timerId] = now;

// warning("tickInterval: %d", tickInterval);
_timersRemain[timerId] -= tickInterval;

if (_timersRemain[timerId] <= 0) {
switch (timerId) {
case 0:
case 1:
case 2:
if (!_vm->_aiScripts->IsInsideScript() && !_vm->_script->IsInsideScript()) {
_vm->_aiScripts->TimerExpired(this->_id, timerId);
this->_timersRemain[timerId] = 0;
//return false;
} else {
this->_timersRemain[timerId] = 1;
//return true;
}
break;
case 3:
// Movement track timer
break;
case 4:
// Something timer
break;
case 5:
// Actor animation frame timer
break;
case 6:
// Slow down actor run timer?
break;
}
}
}

bool Actor::walkFindU1(const Vector3 &startPosition, const Vector3 &targetPosition, float size, Vector3 *newDestination) {
newDestination->x = 0.0f;
newDestination->y = 0.0f;
@@ -78,6 +78,16 @@ class Actor {
bool _isMoving;
bool _damageAnimIfMoving;

// Movement
bool _movementTrackPaused;
int _movementTrackNextWaypointId;
int _movementTrackNextDelay; // probably not used
int _movementTrackNextAngle; // probably not used
bool _movementTrackNextRunning;

int _movementTrackWalkingToWaypointId;
int _movementTrackDelayOnNextWaypoint;

// Animation
int _width;
int _height;
@@ -122,7 +132,16 @@ class Actor {
void changeAnimationMode(int animationMode, bool force = false);
void setFPS(int fps);

void processMovement();
void countdownTimerStart(int timerId, int interval);
void countdownTimerReset(int timerId);
int countdownTimerGetRemainingTime(int timerId);
void countdownTimersUpdate();
void countdownTimerUpdate(int timerId);

void movementTrackNext(bool omitAiScript);
void movementTrackPause();
void movementTrackUnpause();
void movementTrackWaypointReached();

bool loopWalkToActor(int otherActorId, int destinationOffset, int a3, bool run, bool a5, bool *isRunning);
bool loopWalkToItem(int itemId, int destinationOffset, int a3, bool run, bool a5, bool *isRunning);
@@ -133,12 +152,6 @@ class Actor {
bool tick(bool forceUpdate);
void draw();

void countdownTimerStart(int timerId, int interval);
void countdownTimerReset(int timerId);
int countdownTimerGetRemainingTime(int timerId);
void countdownTimersUpdate();
void countdownTimerUpdate(int timerId);

int getSetId();
void setSetId(int setId);
BoundingBox *getBoundingBox() { return _bbox; }
@@ -152,6 +165,7 @@ class Actor {
bool isMoving() { return _isMoving; }
void setMoving(bool value) { _isMoving = value; }
bool isWalking();
bool isRunning();
void stopWalking(bool value);

void faceActor(int otherActorId, bool animate);
@@ -488,6 +488,9 @@ void BladeRunnerEngine::shutdown() {
delete _actors[i];
_actors[i] = nullptr;
}
delete _actors[VOICEOVER_ACTOR];
_actors[VOICEOVER_ACTOR] = nullptr;

_playerActor = nullptr;

// TODO: Delete proper ZBuf class

0 comments on commit 52476b0

Please sign in to comment.
You can’t perform that action at this time.