aboutsummaryrefslogtreecommitdiff
path: root/engines/xeen
diff options
context:
space:
mode:
authorPaul Gilbert2018-03-19 21:25:59 -0400
committerPaul Gilbert2018-03-19 21:25:59 -0400
commit9504ecd74e8cc48a86c577617c6b9b226170949b (patch)
tree519269ffa4ec11122be072ecc3cc92bc22c6c337 /engines/xeen
parent0a20df925912bf76c0f49c70f8e9a7e1979f374a (diff)
downloadscummvm-rg350-9504ecd74e8cc48a86c577617c6b9b226170949b.tar.gz
scummvm-rg350-9504ecd74e8cc48a86c577617c6b9b226170949b.tar.bz2
scummvm-rg350-9504ecd74e8cc48a86c577617c6b9b226170949b.zip
XEEN: Fix whether events are checked after openGrate calls
Diffstat (limited to 'engines/xeen')
-rw-r--r--engines/xeen/interface.cpp12
-rw-r--r--engines/xeen/scripts.cpp96
-rw-r--r--engines/xeen/scripts.h3
3 files changed, 55 insertions, 56 deletions
diff --git a/engines/xeen/interface.cpp b/engines/xeen/interface.cpp
index 11e0ee7256..aa58f25d74 100644
--- a/engines/xeen/interface.cpp
+++ b/engines/xeen/interface.cpp
@@ -285,28 +285,24 @@ void Interface::perform() {
switch (lookupId) {
case 1:
if (!map._isOutdoors) {
- scripts.openGrate(13, 1);
- eventsFlag = _buttonValue != 0;
+ eventsFlag = !scripts.openGrate(13, 1);
}
break;
case 6:
// Open grate being closed
if (!map._isOutdoors) {
- scripts.openGrate(9, 0);
- eventsFlag = _buttonValue != 0;
+ eventsFlag = !scripts.openGrate(9, 0);
}
break;
case 9:
// Closed grate being opened
if (!map._isOutdoors) {
- scripts.openGrate(6, 0);
- eventsFlag = _buttonValue != 0;
+ eventsFlag = !scripts.openGrate(6, 0);
}
break;
case 13:
if (!map._isOutdoors) {
- scripts.openGrate(1, 1);
- eventsFlag = _buttonValue != 0;
+ eventsFlag = !scripts.openGrate(1, 1);
}
break;
default:
diff --git a/engines/xeen/scripts.cpp b/engines/xeen/scripts.cpp
index cc42081f5c..3b989ab46a 100644
--- a/engines/xeen/scripts.cpp
+++ b/engines/xeen/scripts.cpp
@@ -269,7 +269,7 @@ int Scripts::checkEvents() {
return _scriptResult;
}
-void Scripts::openGrate(int wallVal, int action) {
+bool Scripts::openGrate(int wallVal, int action) {
Combat &combat = *_vm->_combat;
FileManager &files = *_vm->_files;
Interface &intf = *_vm->_interface;
@@ -278,60 +278,62 @@ void Scripts::openGrate(int wallVal, int action) {
Sound &sound = *_vm->_sound;
int ccNum = files._ccNum;
- if ((wallVal != 13 || map._currentGrateUnlocked) && (!ccNum || wallVal != 9 ||
- map.mazeData()._wallKind != 2)) {
- if (wallVal != 9 && !map._currentGrateUnlocked) {
- int charIndex = WhoWill::show(_vm, 13, action, false) - 1;
- if (charIndex < 0) {
- intf.draw3d(true);
- return;
- }
-
- // 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);
- }
+ if (!((wallVal != 13 || map._currentGrateUnlocked) && (!ccNum || wallVal != 9 ||
+ map.mazeData()._wallKind != 2)))
+ return false;
- // 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 (wallVal != 9 && !map._currentGrateUnlocked) {
+ int charIndex = WhoWill::show(_vm, 13, action, false) - 1;
+ if (charIndex < 0) {
+ intf.draw3d(true);
+ return true;
+ }
- 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);
}
- // Flag the grate as unlocked, and the wall the grate is on
- 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 true;
- // 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;
- default:
- break;
- }
+ c._experience += map.mazeData()._difficulties._unlockDoor * c.getCurrentLevel();
+ }
- map.setCellSurfaceFlags(pt, 0x80);
- map.setWall(pt, dir, wallVal);
+ // Flag the grate as unlocked, and the wall the grate is on
+ map.setCellSurfaceFlags(party._mazePosition, 0x80);
+ map.setWall(party._mazePosition, party._mazeDirection, wallVal);
- sound.playFX(10);
- intf.draw3d(true);
+ // 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;
+ default:
+ break;
}
+
+ map.setCellSurfaceFlags(pt, 0x80);
+ map.setWall(pt, dir, wallVal);
+
+ sound.playFX(10);
+ intf.draw3d(true);
+ return true;
}
bool Scripts::doOpcode(MazeEvent &event) {
diff --git a/engines/xeen/scripts.h b/engines/xeen/scripts.h
index 40564f3dda..f35aecedff 100644
--- a/engines/xeen/scripts.h
+++ b/engines/xeen/scripts.h
@@ -563,8 +563,9 @@ public:
/**
* Handles opening grates
+ * @returns If true, no further event checking should be done
*/
- void openGrate(int wallVal, int action);
+ bool openGrate(int wallVal, int action);
};
} // End of namespace Xeen