Skip to content

Commit

Permalink
BLADERUNNER: Fixed item rotation
Browse files Browse the repository at this point in the history
Item's angle was not update after chaning "facing".
Police maze targets are now rotated correct way.
Added debug logging for the police maze tracts.
  • Loading branch information
peterkohaut committed Dec 24, 2018
1 parent 81288f2 commit 3f71260
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 45 deletions.
4 changes: 2 additions & 2 deletions engines/bladerunner/game_constants.h
Expand Up @@ -910,8 +910,8 @@ enum PoliceMazeTrackInstruction {
kPMTIVariableReset = -17,
kPMTIVariableSet = -16,
kPMTITargetSet = -15,
kPMTI12 = -14,
kPMTI13 = -13,
kPMTIPausedReset1of3 = -14,
kPMTIPausedReset1of2 = -13,
kPMTIPausedSet = -12,
kPMTIPausedReset = -11,
kPMTIPlaySound = -10,
Expand Down
9 changes: 3 additions & 6 deletions engines/bladerunner/item.cpp
Expand Up @@ -70,12 +70,9 @@ void Item::getWidthHeight(int *width, int *height) const {
*height = _height;
}

bool Item::isTarget() const {
return _isTarget;
}

bool Item::isPoliceMazeEnemy() const {
return _isPoliceMazeEnemy;
void Item::setFacing(int facing) {
_facing = facing;
_angle = _facing * (M_PI / 512.0f);
}

bool Item::tick(Common::Rect *screenRect, bool special) {
Expand Down
12 changes: 8 additions & 4 deletions engines/bladerunner/item.h
Expand Up @@ -69,18 +69,22 @@ class Item {

const BoundingBox &getBoundingBox() { return _boundingBox; }
const Common::Rect &getScreenRectangle() { return _screenRectangle; }

int getFacing() const { return _facing; }
void setFacing(int facing) { _facing = facing; }
void setFacing(int facing);

bool isTarget() const { return _isTarget; }
void setIsTarget(bool val) { _isTarget = val; }

bool isTarget() const;
bool isSpinning() const { return _isSpinning; }
void spinInWorld();

bool isVisible() const { return _isVisible; }
void setVisible(bool val) { _isVisible = val; }
bool isPoliceMazeEnemy() const;

bool isPoliceMazeEnemy() const { return _isPoliceMazeEnemy; }
void setPoliceMazeEnemy(bool val) { _isPoliceMazeEnemy = val; }
void spinInWorld();

bool tick(Common::Rect *screenRect, bool special);

void setup(int itemId, int setId, int animationId, Vector3 position, int facing, int height, int width, bool isTargetFlag, bool isVisibleFlag, bool isPoliceMazeEnemyFlag);
Expand Down
149 changes: 116 additions & 33 deletions engines/bladerunner/script/police_maze.cpp
Expand Up @@ -286,14 +286,14 @@ bool PoliceMazeTargetTrack::tick() {
while (cont) {
_dataIndex++;

debug ("ItemId %3i, pos %3i, instruction %3i", _itemId, _dataIndex - 1, _data[_dataIndex - 1]);

switch (_data[_dataIndex - 1]) {
case kPMTIActivate:
{
int variableId = _data[_dataIndex++];
int maxValue = _data[_dataIndex++];

#if BLADERUNNER_DEBUG_CONSOLE
debug("ItemId: %3i, Activate, VariableId: %i, Max value: %i", _itemId, variableId, maxValue);
#endif
if (Global_Variable_Query(variableId) >= maxValue) {
setPaused();
cont = false;
Expand All @@ -304,16 +304,23 @@ bool PoliceMazeTargetTrack::tick() {
}

case kPMTILeave:
if (!_vm->_items->isPoliceMazeEnemy(_itemId) && _vm->_items->isTarget(_itemId)) {
Police_Maze_Increment_Score(1);
{
#if BLADERUNNER_DEBUG_CONSOLE
debug("ItemId: %3i, Leave", _itemId);
#endif
if (!_vm->_items->isPoliceMazeEnemy(_itemId) && _vm->_items->isTarget(_itemId)) {
Police_Maze_Increment_Score(1);
}
break;
}
break;

case kPMTIShoot:
{
int soundId = _data[_dataIndex++];
_dataIndex++; // second argument is not used

#if BLADERUNNER_DEBUG_CONSOLE
debug("ItemId: %3i, Shoot, SoundId: %i", _itemId, soundId);
#endif
if (_vm->_items->isTarget(_itemId)) {
Sound_Play(soundId, 90, 0, 0, 50);
Police_Maze_Decrement_Score(1);
Expand Down Expand Up @@ -344,34 +351,49 @@ bool PoliceMazeTargetTrack::tick() {
case kPMTIEnemyReset:
{
int itemId = _data[_dataIndex++];
#if BLADERUNNER_DEBUG_CONSOLE
debug("ItemId: %3i, Enemy reset, OtherItemId: %i", _itemId, itemId);
#endif
_vm->_items->setPoliceMazeEnemy(itemId, false);
break;
}

case kPMTIEnemySet:
{
int itemId = _data[_dataIndex++];
#if BLADERUNNER_DEBUG_CONSOLE
debug("ItemId: %3i, Enemy set, OtherItemId: %i", _itemId, itemId);
#endif
_vm->_items->setPoliceMazeEnemy(itemId, true);
break;
}

case kPMTIFlagReset:
{
int gameFlagId = _data[_dataIndex++];
#if BLADERUNNER_DEBUG_CONSOLE
debug("ItemId: %3i, Flag reset, FlagId: %i", _itemId, gameFlagId);
#endif
Game_Flag_Reset(gameFlagId);
break;
}

case kPMTIFlagSet:
{
int gameFlagId = _data[_dataIndex++];
#if BLADERUNNER_DEBUG_CONSOLE
debug("ItemId: %3i, Flag set, FlagId: %i", _itemId, gameFlagId);
#endif
Game_Flag_Set(gameFlagId);
break;
}

case kPMTIVariableDec:
{
int variableId = _data[_dataIndex++];
#if BLADERUNNER_DEBUG_CONSOLE
debug("ItemId: %3i, Variable decrement, VariableId: %i", _itemId, variableId);
#endif
Global_Variable_Decrement(variableId, 1);
break;
}
Expand All @@ -380,6 +402,9 @@ bool PoliceMazeTargetTrack::tick() {
{
int variableId = _data[_dataIndex++];
int maxValue = _data[_dataIndex++];
#if BLADERUNNER_DEBUG_CONSOLE
debug("ItemId: %3i, Variable increment, VariableId: %i, Max value: %i", _itemId, variableId, maxValue);
#endif
if (Global_Variable_Query(variableId) < maxValue) {
Global_Variable_Increment(variableId, 1);
}
Expand All @@ -389,6 +414,9 @@ bool PoliceMazeTargetTrack::tick() {
case kPMTIVariableReset:
{
int variableId = _data[_dataIndex++];
#if BLADERUNNER_DEBUG_CONSOLE
debug("ItemId: %3i, Variable reset, VariableId: %i", _itemId, variableId);
#endif
Global_Variable_Reset(variableId);
break;
}
Expand All @@ -397,6 +425,9 @@ bool PoliceMazeTargetTrack::tick() {
{
int variableId = _data[_dataIndex++];
int value = _data[_dataIndex++];
#if BLADERUNNER_DEBUG_CONSOLE
debug("ItemId: %3i, Variable set, VariableId: %i, Value: %i", _itemId, variableId, value);
#endif
Global_Variable_Set(variableId, value);
break;
}
Expand All @@ -405,16 +436,21 @@ bool PoliceMazeTargetTrack::tick() {
{
int itemId = _data[_dataIndex++];
int value = _data[_dataIndex++];
#if BLADERUNNER_DEBUG_CONSOLE
debug("ItemId: %3i, Target set, OtherItemId: %i, Value: %i", _itemId, itemId, value);
#endif
_vm->_items->setIsTarget(itemId, value);
break;
}

case kPMTI12:
case kPMTIPausedReset1of3:
{
int trackId1 = _data[_dataIndex++];
int trackId2 = _data[_dataIndex++];
int trackId3 = _data[_dataIndex++];

#if BLADERUNNER_DEBUG_CONSOLE
debug("ItemId: %3i, Pause reset 1 of 3, TrackId1: %i, TrackId2: %i, TrackId3: %i", _itemId, trackId1, trackId2, trackId3);
#endif
switch (Random_Query(1, 3)) {
case 1:
_vm->_policeMaze->_tracks[trackId1]->resetPaused();
Expand All @@ -432,11 +468,13 @@ bool PoliceMazeTargetTrack::tick() {
break;
}

case kPMTI13:
case kPMTIPausedReset1of2:
{
int trackId1 = _data[_dataIndex++];
int trackId2 = _data[_dataIndex++];

#if BLADERUNNER_DEBUG_CONSOLE
debug("ItemId: %3i, Pause reset 1 of 2, TrackId1: %i, TrackId2: %i", _itemId, trackId1, trackId2);
#endif
if (Random_Query(1, 2) == 1) {
_vm->_policeMaze->_tracks[trackId1]->resetPaused();
} else {
Expand All @@ -448,13 +486,19 @@ bool PoliceMazeTargetTrack::tick() {
case kPMTIPausedSet:
{
int trackId = _data[_dataIndex++];
#if BLADERUNNER_DEBUG_CONSOLE
debug("ItemId: %3i, Pause set, TrackId: %i", _itemId, trackId);
#endif
_vm->_policeMaze->_tracks[trackId]->setPaused();
break;
}

case kPMTIPausedReset:
{
int trackId = _data[_dataIndex++];
#if BLADERUNNER_DEBUG_CONSOLE
debug("ItemId: %3i, Pause reset, TrackId: %i", _itemId, trackId);
#endif
_vm->_policeMaze->_tracks[trackId]->resetPaused();
break;
}
Expand All @@ -463,20 +507,29 @@ bool PoliceMazeTargetTrack::tick() {
{
int soundId = _data[_dataIndex++];
int volume = _data[_dataIndex++];
#if BLADERUNNER_DEBUG_CONSOLE
debug("ItemId: %3i, Sound, SoundId: %i, Volume: %i", _itemId, soundId, volume);
#endif
Sound_Play(soundId, volume, 0, 0, 50);
break;
}

case kPMTIObstacleReset:
{
int itemId = _data[_dataIndex++];
#if BLADERUNNER_DEBUG_CONSOLE
debug("ItemId: %3i, Obstacle reset, OtherItemId: %i", _itemId, itemId);
#endif
_vm->_items->setIsObstacle(itemId, 0);
break;
}

case kPMTIObstacleSet:
{
int itemId = _data[_dataIndex++];
#if BLADERUNNER_DEBUG_CONSOLE
debug("ItemId: %3i, Obstacle set, OtherItemId: %i", _itemId, itemId);
#endif
_vm->_items->setIsObstacle(itemId, 1);
break;
}
Expand All @@ -485,6 +538,9 @@ bool PoliceMazeTargetTrack::tick() {
{
int randomMin = _data[_dataIndex++];
int randomMax = _data[_dataIndex++];
#if BLADERUNNER_DEBUG_CONSOLE
debug("ItemId: %3i, Wait random, Min: %i, Max: %i", _itemId, randomMin, randomMax);
#endif
_timeLeftWait = Random_Query(randomMin, randomMax);
_isWaiting = true;

Expand All @@ -493,46 +549,73 @@ bool PoliceMazeTargetTrack::tick() {
}

case kPMTIRotate:
_angleTarget = _data[_dataIndex++];
_angleDelta = _data[_dataIndex++];
_isRotating = true;
{
_angleTarget = _data[_dataIndex++];
_angleDelta = _data[_dataIndex++];
#if BLADERUNNER_DEBUG_CONSOLE
debug("ItemId: %3i, Rotate, Target: %i, Delta: %i", _itemId, _angleTarget, _angleDelta);
#endif
_isRotating = true;

cont = false;
break;
cont = false;
break;
}

case kPMTIFacing:
{
int angle = _data[_dataIndex++];
#if BLADERUNNER_DEBUG_CONSOLE
debug("ItemId: %3i, Set facing, Angle: %i", _itemId, angle);
#endif
_vm->_items->setFacing(_itemId, angle);
break;
}

case kPMTIRestart:
_dataIndex = 0;

cont = false;
break;
{
_dataIndex = 0;
#if BLADERUNNER_DEBUG_CONSOLE
debug("ItemId: %3i, Restart", _itemId);
#endif
cont = false;
break;
}

case kPMTIWait:
_timeLeftWait = _data[_dataIndex++];
_isWaiting = true;
{
_timeLeftWait = _data[_dataIndex++];
#if BLADERUNNER_DEBUG_CONSOLE
debug("ItemId: %3i, Wait, Time: %i", _itemId, _timeLeftWait);
#endif
_isWaiting = true;

cont = false;
break;
cont = false;
break;
}

case kPMTIMove:
_pointTarget = _data[_dataIndex++];
_isMoving = true;
{
_pointTarget = _data[_dataIndex++];
#if BLADERUNNER_DEBUG_CONSOLE
debug("ItemId: %3i, Move, Target: %i", _itemId, _pointTarget);
#endif
_isMoving = true;

cont = false;
break;
cont = false;
break;
}

case kPMTIPosition:
_pointIndex = _data[_dataIndex++];
_isMoving = false;
_vm->_items->setXYZ(_itemId, _points[_pointIndex]);
readdObject(_itemId);
break;
{
_pointIndex = _data[_dataIndex++];
#if BLADERUNNER_DEBUG_CONSOLE
debug("ItemId: %3i, Position, Index: %i", _itemId, _pointIndex);
#endif
_isMoving = false;
_vm->_items->setXYZ(_itemId, _points[_pointIndex]);
readdObject(_itemId);
break;
}

default:
return false;
Expand Down

0 comments on commit 3f71260

Please sign in to comment.