diff options
Diffstat (limited to 'engines/bladerunner')
-rw-r--r-- | engines/bladerunner/actor.cpp | 184 | ||||
-rw-r--r-- | engines/bladerunner/actor.h | 14 | ||||
-rw-r--r-- | engines/bladerunner/bladerunner.cpp | 5 | ||||
-rw-r--r-- | engines/bladerunner/bladerunner.h | 2 | ||||
-rw-r--r-- | engines/bladerunner/script/script.cpp | 22 | ||||
-rw-r--r-- | engines/bladerunner/script/script.h | 14 |
6 files changed, 112 insertions, 129 deletions
diff --git a/engines/bladerunner/actor.cpp b/engines/bladerunner/actor.cpp index 22e9c00d11..013dace5e1 100644 --- a/engines/bladerunner/actor.cpp +++ b/engines/bladerunner/actor.cpp @@ -314,7 +314,7 @@ void Actor::movementTrackUnpause() { void Actor::movementTrackWaypointReached() { int seconds; - if (!_movementTrack->isPaused() && _id != 0) { + if (!_movementTrack->isPaused() && _id != kActorMcCoy) { if (_movementTrackWalkingToWaypointId >= 0 && _movementTrackDelayOnNextWaypoint) { if (!_movementTrackDelayOnNextWaypoint) { _movementTrackDelayOnNextWaypoint = 1; @@ -358,112 +358,90 @@ void Actor::setAtWaypoint(int waypointId, int angle, int moving, bool retired) { setAtXYZ(waypointPosition, angle, true, moving, retired); } -bool Actor::loopWalk(const Vector3 &destination, int destinationOffset, bool a3, bool run, const Vector3 &start, float targetWidth, float targetSize, bool a8, bool *flagIsRunning, bool async) { - if (true) { // simple walking - *flagIsRunning = false; - bool arrived; - _walkInfo->setup(_id, false, _position, destination, false, &arrived); +bool Actor::loopWalk(const Vector3 &destination, int destinationOffset, bool interruptible, bool run, const Vector3 &start, float targetWidth, float targetSize, bool a8, bool *flagIsRunning, bool async) { + *flagIsRunning = false; - if (async) { + if (destinationOffset > 0) { + float dist = distance(_position, destination); + if (dist - targetSize <= destinationOffset) { return false; } - while (true) { - _vm->gameTick(); - if (!_walkInfo->isWalking() && !_walkInfo->isRunning()) { - break; - } - if (!_vm->_gameIsRunning) { - break; - } - } - return false; - } else { - //TODO: - // original code, not yet working - *flagIsRunning = false; - - if (destinationOffset > 0) { - float dist = distance(_position, destination); - if (dist - targetSize <= destinationOffset) { - return false; - } - } + } - if (a8 && !async && _id && destinationOffset <= 24) { - if (distance(_vm->_playerActor->_position, destination) <= 24.0f) { - _vm->_playerActor->walkToNearestPoint(destination, 48.0f); - } + if (a8 && !async && _id != kActorMcCoy && destinationOffset <= 24) { + if (distance(_vm->_playerActor->_position, destination) <= 24.0f) { + _vm->_playerActor->walkToNearestPoint(destination, 48.0f); } + } - if (_id) { - a3 = false; - } + if (_id != kActorMcCoy) { + interruptible = false; + } - Vector3 destinationX(destination); + Vector3 destinationX(destination); - if (destinationOffset > 0) { - walkFindU2(&destinationX, targetWidth, destinationOffset, targetSize, _position, destination); - } + if (destinationOffset > 0) { + walkFindU2(&destinationX, targetWidth, destinationOffset, targetSize, _position, destination); + } - bool walking = walkTo(run, destinationX, a8); + bool walking = walkTo(run, destinationX, a8); - if (async) { - return false; - } + if (async) { + return false; + } - if (!walking && destinationOffset > 0) { - walking = walkTo(run, destination, a8); - } + if (!walking && destinationOffset > 0) { + walking = walkTo(run, destination, a8); + } - if (!walking) { - return false; - } + if (!walking) { + faceXYZ(destination.x, destination.y, destination.z, false); + return false; + } - if (async) { - return false; - } - if (_id) { - _vm->_mouse->disable(); - } - if (a3) { - // TODO: - // dword_482990 = 1; - // dword_482994 = 0; - } else { - _vm->playerLosesControl(); - } + if (async) { + return false; + } + if (_id != kActorMcCoy) { + _vm->_mouse->disable(); + } + if (interruptible) { + _vm->_isWalkingInterruptible = 1; + _vm->_interruptWalking = 0; + } else { + _vm->playerLosesControl(); + } - if (a8) { - _inWalkLoop = true; - } + if (a8) { + _inWalkLoop = true; + } - bool v46 = false; - while (_walkInfo->isWalking() && _vm->_gameIsRunning) { - if (_walkInfo->isRunning()) { - *flagIsRunning = true; - } - _vm->gameTick(); - if (_id == 0 && a3 /*&& dword_482994*/) { - stopWalking(false); - v46 = true; - } - } - if (a8) { - _inWalkLoop = false; - } - if (a3) { - // dword_482990 = 1; - } else { - _vm->playerGainsControl(); - } - if (!v46 && destinationOffset == 0 /* && !PlayerActorIdle*/) { - setAtXYZ(destination, _facing, true, false, false); + bool wasInterrupted = false; + while (_walkInfo->isWalking() && _vm->_gameIsRunning) { + if (_walkInfo->isRunning()) { + *flagIsRunning = true; } - if (_id) { - _vm->_mouse->enable(); + _vm->gameTick(); + if (_id == kActorMcCoy && interruptible && _vm->_interruptWalking) { + stopWalking(false); + wasInterrupted = true; } - return v46; } + if (a8) { + _inWalkLoop = false; + } + if (interruptible) { + _vm->_isWalkingInterruptible = false; + } else { + _vm->playerGainsControl(); + } + if (!wasInterrupted && destinationOffset == 0 && !_vm->_playerActorIdle) { + setAtXYZ(destination, _facing, true, false, false); + } + if (_id != kActorMcCoy) { + _vm->_mouse->enable(); + } + return wasInterrupted; } bool Actor::walkTo(bool run, const Vector3 &destination, bool a3) { @@ -472,21 +450,21 @@ bool Actor::walkTo(bool run, const Vector3 &destination, bool a3) { return _walkInfo->setup(_id, run, _position, destination, a3, &arrived); } -bool Actor::loopWalkToActor(int otherActorId, int destinationOffset, int a3, bool run, bool a5, bool *flagIsRunning) { - return loopWalk(_vm->_actors[otherActorId]->_position, destinationOffset, a3, run, _position, 24.0f, 24.0f, a5, flagIsRunning, false); +bool Actor::loopWalkToActor(int otherActorId, int destinationOffset, int interruptible, bool run, bool a5, bool *flagIsRunning) { + return loopWalk(_vm->_actors[otherActorId]->_position, destinationOffset, interruptible, run, _position, 24.0f, 24.0f, a5, flagIsRunning, false); } -bool Actor::loopWalkToItem(int itemId, int destinationOffset, int a3, bool run, bool a5, bool *flagIsRunning) { +bool Actor::loopWalkToItem(int itemId, int destinationOffset, int interruptible, bool run, bool a5, bool *flagIsRunning) { float x, y, z; int width, height; _vm->_items->getXYZ(itemId, &x, &y, &z); _vm->_items->getWidthHeight(itemId, &width, &height); Vector3 itemPosition(x, y, z); - return loopWalk(itemPosition, destinationOffset, a3, run, _position, width, 24.0f, a5, flagIsRunning, false); + return loopWalk(itemPosition, destinationOffset, interruptible, run, _position, width, 24.0f, a5, flagIsRunning, false); } -bool Actor::loopWalkToSceneObject(const char *objectName, int destinationOffset, bool a3, bool run, bool a5, bool *flagIsRunning) { +bool Actor::loopWalkToSceneObject(const char *objectName, int destinationOffset, bool interruptible, bool run, bool a5, bool *flagIsRunning) { int sceneObject = _vm->_scene->_set->findObject(objectName); if (sceneObject < 0) { return true; @@ -528,17 +506,17 @@ bool Actor::loopWalkToSceneObject(const char *objectName, int destinationOffset, float y = _vm->_scene->_set->getAltitudeAtXZ(closestX, closestZ, &inWalkbox); Vector3 destination(closestX, y, closestZ); - return loopWalk(destination, destinationOffset, a3, run, _position, 0.0f, 24.0f, a5, flagIsRunning, false); + return loopWalk(destination, destinationOffset, interruptible, run, _position, 0.0f, 24.0f, a5, flagIsRunning, false); } -bool Actor::loopWalkToWaypoint(int waypointId, int destinationOffset, int a3, bool run, bool a5, bool *flagIsRunning) { +bool Actor::loopWalkToWaypoint(int waypointId, int destinationOffset, int interruptible, bool run, bool a5, bool *flagIsRunning) { Vector3 waypointPosition; _vm->_waypoints->getXYZ(waypointId, &waypointPosition.x, &waypointPosition.y, &waypointPosition.z); - return loopWalk(waypointPosition, destinationOffset, a3, run, _position, 0.0f, 24.0f, a5, flagIsRunning, false); + return loopWalk(waypointPosition, destinationOffset, interruptible, run, _position, 0.0f, 24.0f, a5, flagIsRunning, false); } -bool Actor::loopWalkToXYZ(const Vector3 &destination, int destinationOffset, bool a3, bool run, bool a5, bool *flagIsRunning) { - return loopWalk(destination, destinationOffset, a3, run, _position, 0.0f, 24.0f, a5, flagIsRunning, false); +bool Actor::loopWalkToXYZ(const Vector3 &destination, int destinationOffset, bool interruptible, bool run, bool a5, bool *flagIsRunning) { + return loopWalk(destination, destinationOffset, interruptible, run, _position, 0.0f, 24.0f, a5, flagIsRunning, false); } bool Actor::asyncWalkToWaypoint(int waypointId, int destinationOffset, bool run, bool a5) { @@ -581,7 +559,7 @@ bool Actor::tick(bool forceDraw, Common::Rect *screenRect) { Vector3 positionChange = _vm->_sliceAnimations->getPositionChange(_animationId); float angleChange = _vm->_sliceAnimations->getFacingChange(_animationId); - if (_id == 47) { + if (_id == kActorHysteriaPatron1) { positionChange.x = 0.0f; positionChange.y = 0.0f; positionChange.z = 0.0f; @@ -797,7 +775,7 @@ bool Actor::isRunning() const { } void Actor::stopWalking(bool value) { - if (value && _id == 0) { + if (value && _id == kActorMcCoy) { _vm->_playerActorIdle = true; } @@ -949,7 +927,7 @@ void Actor::retire(bool retired, int width, int height, int retiredByActorId) { _isRetired = retired; _retiredWidth = MAX(width, 0); _retiredHeight = MAX(height, 0); - if (_id == 0 && _isRetired) { + if (_id == kActorMcCoy && _isRetired) { _vm->playerLosesControl(); _vm->_playerDead = true; } @@ -975,7 +953,7 @@ void Actor::combatModeOn(int a2, int a3, int otherActorId, int a5, int animation _animationModeCombatWalk = animationModeCombatWalk; _animationModeCombatRun = animationModeCombatRun; _inCombat = true; - if (_id > 0) + if (_id != kActorMcCoy) _combatInfo->combatOn(_id, a2, a3, otherActorId, a5, a9, a10, a11, ammoDamage, a13, a14); stopWalking(false); changeAnimationMode(_animationModeCombatIdle, false); diff --git a/engines/bladerunner/actor.h b/engines/bladerunner/actor.h index 5068143776..4fd513103a 100644 --- a/engines/bladerunner/actor.h +++ b/engines/bladerunner/actor.h @@ -143,11 +143,11 @@ public: void movementTrackUnpause(); void movementTrackWaypointReached(); - bool loopWalkToActor(int otherActorId, int destinationOffset, int a3, bool run, bool a5, bool *flagIsRunning); - bool loopWalkToItem(int itemId, int destinationOffset, int a3, bool run, bool a5, bool *flagIsRunning); - bool loopWalkToSceneObject(const char *objectName, int destinationOffset, bool a3, bool run, bool a5, bool *flagIsRunning); - bool loopWalkToWaypoint(int waypointId, int destinationOffset, int a3, bool run, bool a5, bool *flagIsRunning); - bool loopWalkToXYZ(const Vector3 &destination, int destinationOffset, bool a3, bool run, bool a5, bool *flagIsRunning); + bool loopWalkToActor(int otherActorId, int destinationOffset, int interruptible, bool run, bool a5, bool *flagIsRunning); + bool loopWalkToItem(int itemId, int destinationOffset, int interruptible, bool run, bool a5, bool *flagIsRunning); + bool loopWalkToSceneObject(const char *objectName, int destinationOffset, bool interruptible, bool run, bool a5, bool *flagIsRunning); + bool loopWalkToWaypoint(int waypointId, int destinationOffset, int interruptible, bool run, bool a5, bool *flagIsRunning); + bool loopWalkToXYZ(const Vector3 &destination, int destinationOffset, bool interruptible, bool run, bool a5, bool *flagIsRunning); bool asyncWalkToWaypoint(int waypointId, int destinationOffset, bool run, bool a5); void asyncWalkToXYZ(const Vector3 &destination, int destinationOffset, bool run, int a6); @@ -223,8 +223,8 @@ private: void setFacing(int facing, bool halfOrSet = true); void setBoundingBox(const Vector3 &position, bool retired); float distanceFromView(View *view) const; - - bool loopWalk(const Vector3 &destination, int destinationOffset, bool a3, bool run, const Vector3 &start, float a6, float a7, bool a8, bool *isRunning, bool async); + + bool loopWalk(const Vector3 &destination, int destinationOffset, bool interruptible, bool run, const Vector3 &start, float a6, float a7, bool a8, bool *isRunning, bool async); bool walkTo(bool run, const Vector3 &destination, bool a3); bool walkFindU1(const Vector3 &startPosition, const Vector3 &targetPosition, float a3, Vector3 *newDestination); diff --git a/engines/bladerunner/bladerunner.cpp b/engines/bladerunner/bladerunner.cpp index 27b770463b..f85642a8f2 100644 --- a/engines/bladerunner/bladerunner.cpp +++ b/engines/bladerunner/bladerunner.cpp @@ -629,7 +629,10 @@ bool BladeRunnerEngine::init2() { } Common::Point BladeRunnerEngine::getMousePos() const { - return _eventMan->getMousePos(); + Common::Point p = _eventMan->getMousePos(); + p.x = CLIP(p.x, int16(0), int16(639)); + p.y = CLIP(p.y, int16(0), int16(479)); + return p; } void BladeRunnerEngine::gameLoop() { diff --git a/engines/bladerunner/bladerunner.h b/engines/bladerunner/bladerunner.h index 06d5f7b194..593f414bc9 100644 --- a/engines/bladerunner/bladerunner.h +++ b/engines/bladerunner/bladerunner.h @@ -171,6 +171,8 @@ public: Common::RandomSource _rnd; + bool _isWalkingInterruptible; + bool _interruptWalking; bool _playerActorIdle; bool _playerDead; bool _speechSkipped; diff --git a/engines/bladerunner/script/script.cpp b/engines/bladerunner/script/script.cpp index 04e452273e..91a755bb41 100644 --- a/engines/bladerunner/script/script.cpp +++ b/engines/bladerunner/script/script.cpp @@ -399,7 +399,7 @@ int ScriptBase::Actor_Query_Animation_Mode(int actorId) { return _vm->_actors[actorId]->getAnimationMode(); } -bool ScriptBase::Loop_Actor_Walk_To_Actor(int actorId, int otherActorId, int distance, int a4, bool run) { +bool ScriptBase::Loop_Actor_Walk_To_Actor(int actorId, int otherActorId, int distance, bool interruptible, bool run) { _vm->gameWaitForActive(); if (_vm->_walkingActorId == actorId) { @@ -408,7 +408,7 @@ bool ScriptBase::Loop_Actor_Walk_To_Actor(int actorId, int otherActorId, int dis _vm->_playerActorIdle = false; bool isRunning; - bool result = _vm->_actors[actorId]->loopWalkToActor(otherActorId, distance, a4, run, true, &isRunning); + bool result = _vm->_actors[actorId]->loopWalkToActor(otherActorId, distance, interruptible, run, true, &isRunning); if (_vm->_playerActorIdle) { result = true; @@ -422,7 +422,7 @@ bool ScriptBase::Loop_Actor_Walk_To_Actor(int actorId, int otherActorId, int dis return result; } -bool ScriptBase::Loop_Actor_Walk_To_Item(int actorId, int itemId, int a3, int a4, bool run) { +bool ScriptBase::Loop_Actor_Walk_To_Item(int actorId, int itemId, int destinationOffset, bool interruptible, bool run) { _vm->gameWaitForActive(); if (_vm->_walkingActorId == actorId) { @@ -431,7 +431,7 @@ bool ScriptBase::Loop_Actor_Walk_To_Item(int actorId, int itemId, int a3, int a4 _vm->_playerActorIdle = false; bool isRunning; - bool result = _vm->_actors[actorId]->loopWalkToItem(itemId, a3, a4, run, true, &isRunning); + bool result = _vm->_actors[actorId]->loopWalkToItem(itemId, destinationOffset, interruptible, run, true, &isRunning); if (_vm->_playerActorIdle == 1) { result = true; @@ -445,7 +445,7 @@ bool ScriptBase::Loop_Actor_Walk_To_Item(int actorId, int itemId, int a3, int a4 return result; } -bool ScriptBase::Loop_Actor_Walk_To_Scene_Object(int actorId, const char *objectName, int destinationOffset, bool a4, bool run) { +bool ScriptBase::Loop_Actor_Walk_To_Scene_Object(int actorId, const char *objectName, int destinationOffset, bool interruptible, bool run) { _vm->gameWaitForActive(); if (_vm->_walkingActorId == actorId) { @@ -454,7 +454,7 @@ bool ScriptBase::Loop_Actor_Walk_To_Scene_Object(int actorId, const char *object _vm->_playerActorIdle = false; bool isRunning; - bool result = _vm->_actors[actorId]->loopWalkToSceneObject(objectName, destinationOffset, a4, run, true, &isRunning); + bool result = _vm->_actors[actorId]->loopWalkToSceneObject(objectName, destinationOffset, interruptible, run, true, &isRunning); if (_vm->_playerActorIdle) { result = true; @@ -468,7 +468,7 @@ bool ScriptBase::Loop_Actor_Walk_To_Scene_Object(int actorId, const char *object return result; } -bool ScriptBase::Loop_Actor_Walk_To_Waypoint(int actorId, int waypointId, int destinationOffset, int a4, bool run) { +bool ScriptBase::Loop_Actor_Walk_To_Waypoint(int actorId, int waypointId, int destinationOffset, bool interruptible, bool run) { _vm->gameWaitForActive(); if (_vm->_walkingActorId == actorId) { @@ -477,7 +477,7 @@ bool ScriptBase::Loop_Actor_Walk_To_Waypoint(int actorId, int waypointId, int de _vm->_playerActorIdle = false; bool isRunning; - bool result = _vm->_actors[actorId]->loopWalkToWaypoint(waypointId, destinationOffset, a4, run, true, &isRunning); + bool result = _vm->_actors[actorId]->loopWalkToWaypoint(waypointId, destinationOffset, interruptible, run, true, &isRunning); if (_vm->_playerActorIdle) { result = true; @@ -491,7 +491,7 @@ bool ScriptBase::Loop_Actor_Walk_To_Waypoint(int actorId, int waypointId, int de return result; } -bool ScriptBase::Loop_Actor_Walk_To_XYZ(int actorId, float x, float y, float z, int destinationOffset, int a5, bool run, int a7) { +bool ScriptBase::Loop_Actor_Walk_To_XYZ(int actorId, float x, float y, float z, int destinationOffset, bool interruptible, bool run, int a7) { _vm->gameWaitForActive(); if (_vm->_walkingActorId == actorId) { @@ -504,7 +504,7 @@ bool ScriptBase::Loop_Actor_Walk_To_XYZ(int actorId, float x, float y, float z, _vm->_playerActorIdle = false; bool isRunning; - bool result = _vm->_actors[actorId]->loopWalkToXYZ(Vector3(x, y, z), destinationOffset, a5, run, true, &isRunning); + bool result = _vm->_actors[actorId]->loopWalkToXYZ(Vector3(x, y, z), destinationOffset, interruptible, run, true, &isRunning); if (_vm->_playerActorIdle) { result = true; @@ -518,7 +518,7 @@ bool ScriptBase::Loop_Actor_Walk_To_XYZ(int actorId, float x, float y, float z, return result; } -void ScriptBase::Async_Actor_Walk_To_Waypoint(int actorId, int waypointId, int destinationOffset, int run) { +void ScriptBase::Async_Actor_Walk_To_Waypoint(int actorId, int waypointId, int destinationOffset, bool run) { _vm->gameWaitForActive(); if (_vm->_walkingActorId == actorId) { diff --git a/engines/bladerunner/script/script.h b/engines/bladerunner/script/script.h index 3b6e66ab5e..dabdec6b59 100644 --- a/engines/bladerunner/script/script.h +++ b/engines/bladerunner/script/script.h @@ -103,13 +103,13 @@ protected: int Slice_Animation_Query_Number_Of_Frames(int animationId); void Actor_Change_Animation_Mode(int actorId, int animationMode); int Actor_Query_Animation_Mode(int actorId); - bool Loop_Actor_Walk_To_Actor(int actorId, int otherActorId, int distance, int a4, bool running); - bool Loop_Actor_Walk_To_Item(int actorId, int itemId, int a3, int a4, bool run); - bool Loop_Actor_Walk_To_Scene_Object(int actorId, const char *objectName, int distance, bool a4, bool run); - bool Loop_Actor_Walk_To_Waypoint(int actorId, int waypointId, int a3, int a4, bool run); - bool Loop_Actor_Walk_To_XYZ(int actorId, float x, float y, float z, int a4, int a5, bool run, int a7); - void Async_Actor_Walk_To_Waypoint(int actorId, int waypointId, int a3, int run); - void Async_Actor_Walk_To_XYZ(int actorId, float x, float y, float z, int a5, bool run); + bool Loop_Actor_Walk_To_Actor(int actorId, int otherActorId, int distance, bool interruptible, bool run); + bool Loop_Actor_Walk_To_Item(int actorId, int itemId, int destinationOffset, bool interruptible, bool run); + bool Loop_Actor_Walk_To_Scene_Object(int actorId, const char *objectName, int distance, bool interruptible, bool run); + bool Loop_Actor_Walk_To_Waypoint(int actorId, int waypointId, int destinationOffset, bool interruptible, bool run); + bool Loop_Actor_Walk_To_XYZ(int actorId, float x, float y, float z, int destinationOffset, bool interruptible, bool run, int a7); + void Async_Actor_Walk_To_Waypoint(int actorId, int waypointId, int destinationOffset, bool run); + void Async_Actor_Walk_To_XYZ(int actorId, float x, float y, float z, int destinationOffset, bool run); void Actor_Force_Stop_Walking(int actorId); bool Loop_Actor_Travel_Stairs(int actorId, int a2, int a3, int a4); bool Loop_Actor_Travel_Ladder(int actorId, int a2, int a3, int a4); |