aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2015-02-27 20:52:59 -0500
committerPaul Gilbert2015-02-27 20:52:59 -0500
commitb9539c6cb168ecabda994353a453e050b380487f (patch)
treeb8a8a1dc61f0baf64d740bde2d125fffaa52704a /engines
parentb46561ef293da3299ff4e7fb85ffd49222faab67 (diff)
downloadscummvm-rg350-b9539c6cb168ecabda994353a453e050b380487f.tar.gz
scummvm-rg350-b9539c6cb168ecabda994353a453e050b380487f.tar.bz2
scummvm-rg350-b9539c6cb168ecabda994353a453e050b380487f.zip
XEEN: Fixes for marking grates as unlocked
Diffstat (limited to 'engines')
-rw-r--r--engines/xeen/interface.cpp2
-rw-r--r--engines/xeen/map.cpp11
-rw-r--r--engines/xeen/map.h2
-rw-r--r--engines/xeen/scripts.cpp79
-rw-r--r--engines/xeen/scripts.h2
5 files changed, 52 insertions, 44 deletions
diff --git a/engines/xeen/interface.cpp b/engines/xeen/interface.cpp
index ded3d9ca00..0354732b2b 100644
--- a/engines/xeen/interface.cpp
+++ b/engines/xeen/interface.cpp
@@ -299,12 +299,14 @@ void Interface::perform() {
}
case 6:
+ // Open grate being closed
if (!map._isOutdoors) {
scripts.openGrate(9, 0);
eventsFlag = _buttonValue != 0;
}
break;
case 9:
+ // Closed grate being opened
if (!map._isOutdoors) {
scripts.openGrate(6, 0);
eventsFlag = _buttonValue != 0;
diff --git a/engines/xeen/map.cpp b/engines/xeen/map.cpp
index 2017978398..e5a5531cbf 100644
--- a/engines/xeen/map.cpp
+++ b/engines/xeen/map.cpp
@@ -891,7 +891,7 @@ Map::Map(XeenEngine *vm) : _vm(vm), _mobData(vm) {
_currentSurfaceId = 0;
_currentWall = 0;
_currentTile = 0;
- _currentIsGrate = false;
+ _currentGrateUnlocked = false;
_currentCantRest = false;
_currentIsDrain = false;
_currentIsEvent = false;
@@ -1383,7 +1383,7 @@ void Map::cellFlagLookup(const Common::Point &pt) {
// Get the cell flags
const MazeCell &cell = _mazeData[_mazeDataIndex]._cells[pos.y][pos.x];
- _currentIsGrate = cell._flags & OUTFLAG_GRATE;
+ _currentGrateUnlocked = cell._flags & OUTFLAG_GRATE;
_currentCantRest = cell._flags & RESTRICTION_REST;
_currentIsDrain = cell._flags & OUTFLAG_DRAIN;
_currentIsEvent = cell._flags & FLAG_AUTOEXECUTE_EVENT;
@@ -1393,14 +1393,17 @@ void Map::cellFlagLookup(const Common::Point &pt) {
void Map::setCellSurfaceFlags(const Common::Point &pt, int bits) {
mazeLookup(pt, 0);
- _mazeData[0]._cells[pt.y][pt.x]._surfaceId |= bits;
+
+ Common::Point mapPos(pt.x & 15, pt.y & 15);
+ _mazeData[_mazeDataIndex]._cells[mapPos.y][mapPos.x]._surfaceId |= bits;
}
void Map::setWall(const Common::Point &pt, Direction dir, int v) {
const int XOR_MASKS[4] = { 0xFFF, 0xF0FF, 0xFF0F, 0xFFF0 };
mazeLookup(pt, 0, 0);
- MazeWallLayers &wallLayer = _mazeData[0]._wallData[pt.y][pt.x];
+ Common::Point mapPos(pt.x & 15, pt.y & 15);
+ MazeWallLayers &wallLayer = _mazeData[_mazeDataIndex]._wallData[mapPos.y][mapPos.x];
wallLayer._data &= XOR_MASKS[dir];
wallLayer._data |= v << WALL_SHIFTS[dir][2];
}
diff --git a/engines/xeen/map.h b/engines/xeen/map.h
index bd74837788..bfc09ec053 100644
--- a/engines/xeen/map.h
+++ b/engines/xeen/map.h
@@ -376,7 +376,7 @@ public:
SpriteResource _tileSprites;
SpriteResource _surfaceSprites[TOTAL_SURFACES];
WallSprites _wallSprites;
- bool _currentIsGrate;
+ bool _currentGrateUnlocked;
bool _currentCantRest;
bool _currentIsDrain;
bool _currentIsEvent;
diff --git a/engines/xeen/scripts.cpp b/engines/xeen/scripts.cpp
index f1bce0438c..4af7af1d6a 100644
--- a/engines/xeen/scripts.cpp
+++ b/engines/xeen/scripts.cpp
@@ -215,53 +215,56 @@ void Scripts::openGrate(int wallVal, int action) {
SoundManager &sound = *_vm->_sound;
bool isDarkCc = _vm->_files->_isDarkCc;
- if ((wallVal != 13 || map._currentIsGrate) && (!isDarkCc || wallVal != 9 ||
+ if ((wallVal != 13 || map._currentGrateUnlocked) && (!isDarkCc || wallVal != 9 ||
map.mazeData()._wallKind != 2)) {
- if (wallVal != 9 && !map._currentIsGrate) {
+ if (wallVal != 9 && !map._currentGrateUnlocked) {
int charIndex = WhoWill::show(_vm, 13, action, false) - 1;
- if (charIndex >= 0) {
- // There is a 1 in 4 chance the character will receive damage
- if (_vm->getRandomNumber(1, 4) == 1) {
- combat.giveCharDamage(map.mazeData()._trapDamage,
- (DamageType)_vm->getRandomNumber(0, 6), charIndex);
- }
-
- // Check whether character can unlock the door
- Character &c = party._activeParty[charIndex];
- if ((c.getThievery() + _vm->getRandomNumber(1, 20)) <
- map.mazeData()._difficulties._unlockDoor)
- return;
+ if (charIndex < 0) {
+ intf.draw3d(true);
+ return;
+ }
- c._experience += map.mazeData()._difficulties._unlockDoor * c.getCurrentLevel();
+ // There is a 1 in 4 chance the character will receive damage
+ if (_vm->getRandomNumber(1, 4) == 1) {
+ combat.giveCharDamage(map.mazeData()._trapDamage,
+ (DamageType)_vm->getRandomNumber(0, 6), charIndex);
}
- // Set the wall state for the wall party is facing
- map.setCellSurfaceFlags(party._mazePosition, 0x80);
- map.setWall(party._mazePosition, party._mazeDirection, wallVal);
+ // Check whether character can unlock the door
+ Character &c = party._activeParty[charIndex];
+ if ((c.getThievery() + _vm->getRandomNumber(1, 20)) <
+ map.mazeData()._difficulties._unlockDoor)
+ return;
- // Set the wall state for the reverse wall in the next cell over
- Common::Point pt = party._mazePosition;
- Direction dir = (Direction)((int)party._mazeDirection ^ 2);
- switch (party._mazeDirection) {
- case DIR_NORTH:
- pt.y++;
- break;
- case DIR_EAST:
- pt.x++;
- break;
- case DIR_SOUTH:
- pt.y--;
- break;
- case DIR_WEST:
- pt.x--;
- break;
- }
+ c._experience += map.mazeData()._difficulties._unlockDoor * c.getCurrentLevel();
+ }
+
+ // Flag the grate as unlocked, and the wall the grate is on
+ map.setCellSurfaceFlags(party._mazePosition, 0x80);
+ map.setWall(party._mazePosition, party._mazeDirection, wallVal);
- map.setCellSurfaceFlags(pt, 0x80);
- map.setWall(pt, dir, wallVal);
- sound.playFX(10);
+ // Set the grate as opened and the wall on the other side of the grate
+ Common::Point pt = party._mazePosition;
+ Direction dir = (Direction)((int)party._mazeDirection ^ 2);
+ switch (party._mazeDirection) {
+ case DIR_NORTH:
+ pt.y++;
+ break;
+ case DIR_EAST:
+ pt.x++;
+ break;
+ case DIR_SOUTH:
+ pt.y--;
+ break;
+ case DIR_WEST:
+ pt.x--;
+ break;
}
+ map.setCellSurfaceFlags(pt, 0x80);
+ map.setWall(pt, dir, wallVal);
+
+ sound.playFX(10);
intf.draw3d(true);
}
}
diff --git a/engines/xeen/scripts.h b/engines/xeen/scripts.h
index d347ec07bf..3a835d88b5 100644
--- a/engines/xeen/scripts.h
+++ b/engines/xeen/scripts.h
@@ -233,7 +233,7 @@ public:
int checkEvents();
- void openGrate(int v1, int action);
+ void openGrate(int wallVal, int action);
};
} // End of namespace Xeen