ACCESS: Implement chkVLine and chkHLine

This commit is contained in:
Strangerke 2014-11-13 08:18:18 +01:00 committed by Paul Gilbert
parent c74821161b
commit 4ca5cc5ab4
2 changed files with 92 additions and 8 deletions

View file

@ -683,12 +683,94 @@ void AmazonScripts::mWhile(int param1) {
} }
} }
void AmazonScripts::CHKVLINE() { void AmazonScripts::VCODE(Common::Rect bounds) {
warning("TODO: CHKVLINE()"); warning("TODO: VCODE()");
} }
void AmazonScripts::CHKHLINE() { void AmazonScripts::HCODE(Common::Rect bounds) {
warning("TODO: CHKHLINE()"); warning("TODO: HCODE()");
}
void AmazonScripts::chkVLine() {
if (_game->_guard._position.x > _vm->_player->_rawPlayer.x)
_game->_guard._bounds = Common::Rect(_vm->_player->_rawPlayer.x, _vm->_player->_rawPlayer.y, _game->_guard._position.x, _game->_guard._position.y);
else
_game->_guard._bounds = Common::Rect(_game->_guard._position.x, _game->_guard._position.y, _vm->_player->_rawPlayer.x, _vm->_player->_rawPlayer.y);
if (_vm->_screen->_orgY1 > _vm->_screen->_orgY2)
SWAP(_vm->_screen->_orgY1, _vm->_screen->_orgY2);
while (true) {
VCODE(_game->_guard._bounds);
int code = _game->_guard._gCode1 | _game->_guard._gCode2;
if (code == 10) {
_game->_guardFind = 0;
return;
}
int code2 = _game->_guard._gCode1 & _game->_guard._gCode2;
code2 &= 5;
if (((code & 10) == 8) || ((code & 10) == 2) || (code2 != 0))
return;
int midX = (_game->_guard._bounds.left + _game->_guard._bounds.right) / 2;
int midY = (_game->_guard._bounds.top + _game->_guard._bounds.bottom) / 2;
if (midX < _vm->_screen->_orgX1) {
if ((midX == _game->_guard._bounds.left) && (midY == _game->_guard._bounds.top))
return;
_game->_guard._bounds.left = midX;
_game->_guard._bounds.top = midY;
} else {
if ((midX == _game->_guard._bounds.right) && (midY == _game->_guard._bounds.bottom))
return;
_game->_guard._bounds.right = midX;
_game->_guard._bounds.bottom = midY;
}
}
}
void AmazonScripts::chkHLine() {
if (_game->_guard._position.y > _vm->_player->_rawPlayer.y)
_game->_guard._bounds = Common::Rect(_vm->_player->_rawPlayer.x, _vm->_player->_rawPlayer.y, _game->_guard._position.x, _game->_guard._position.y);
else
_game->_guard._bounds = Common::Rect(_game->_guard._position.x, _game->_guard._position.y, _vm->_player->_rawPlayer.x, _vm->_player->_rawPlayer.y);
if (_vm->_screen->_orgX1 > _vm->_screen->_orgX2)
SWAP(_vm->_screen->_orgX1, _vm->_screen->_orgX2);
while (true) {
HCODE(_game->_guard._bounds);
int code = _game->_guard._gCode1 | _game->_guard._gCode2;
if (code == 5) {
_game->_guardFind = 0;
return;
}
int code2 = _game->_guard._gCode1 & _game->_guard._gCode2;
code2 &= 10;
if (((code & 5) == 4) || ((code & 5) == 1) || (code2 != 0))
return;
int midX = (_game->_guard._bounds.left + _game->_guard._bounds.right) / 2;
int midY = (_game->_guard._bounds.top + _game->_guard._bounds.bottom) / 2;
if (midY < _vm->_screen->_orgY1) {
if ((midX == _game->_guard._bounds.left) && (midY == _game->_guard._bounds.top))
return;
_game->_guard._bounds.left = midX;
_game->_guard._bounds.top = midY;
} else {
if ((midX == _game->_guard._bounds.right) && (midY == _game->_guard._bounds.bottom))
return;
_game->_guard._bounds.right = midX;
_game->_guard._bounds.bottom = midY;
}
}
} }
void AmazonScripts::guardSee() { void AmazonScripts::guardSee() {
@ -712,11 +794,11 @@ void AmazonScripts::guardSee() {
_vm->_screen->_orgX2 = _vm->_room->_plotter._walls[idx].right; _vm->_screen->_orgX2 = _vm->_room->_plotter._walls[idx].right;
_vm->_screen->_orgY2 = _vm->_room->_plotter._walls[idx].bottom; _vm->_screen->_orgY2 = _vm->_room->_plotter._walls[idx].bottom;
if (_vm->_screen->_orgX1 == _vm->_screen->_orgX2) { if (_vm->_screen->_orgX1 == _vm->_screen->_orgX2) {
CHKVLINE(); chkVLine();
if (_game->_guardFind == 0) if (_game->_guardFind == 0)
return; return;
} else if (_vm->_screen->_orgY1 == _vm->_screen->_orgY2) { } else if (_vm->_screen->_orgY1 == _vm->_screen->_orgY2) {
CHKHLINE(); chkHLine();
if (_game->_guardFind == 0) if (_game->_guardFind == 0)
return; return;
} }

View file

@ -72,8 +72,10 @@ protected:
void mWhileJWalk(); void mWhileJWalk();
void mWhileDoOpen(); void mWhileDoOpen();
void mWhile(int param1); void mWhile(int param1);
void CHKVLINE(); void VCODE(Common::Rect bounds);
void CHKHLINE(); void HCODE(Common::Rect bounds);
void chkVLine();
void chkHLine();
void guardSee(); void guardSee();
void setGuardFrame(); void setGuardFrame();
void guard(); void guard();