aboutsummaryrefslogtreecommitdiff
path: root/engines/xeen/combat.cpp
diff options
context:
space:
mode:
authorPaul Gilbert2015-02-19 21:12:33 -0500
committerPaul Gilbert2015-02-19 21:12:33 -0500
commitb66bf1a838b01181c93b19e214c59c810e05955d (patch)
tree106d47ce5f8ff68fa04e26b8f9276d2156ef34d8 /engines/xeen/combat.cpp
parent7c3f373b9b935b71b3006f203a1f75442818673a (diff)
downloadscummvm-rg350-b66bf1a838b01181c93b19e214c59c810e05955d.tar.gz
scummvm-rg350-b66bf1a838b01181c93b19e214c59c810e05955d.tar.bz2
scummvm-rg350-b66bf1a838b01181c93b19e214c59c810e05955d.zip
XEEN: Implemented stopAttack
Diffstat (limited to 'engines/xeen/combat.cpp')
-rw-r--r--engines/xeen/combat.cpp106
1 files changed, 102 insertions, 4 deletions
diff --git a/engines/xeen/combat.cpp b/engines/xeen/combat.cpp
index 7ed349906d..a9ead958a8 100644
--- a/engines/xeen/combat.cpp
+++ b/engines/xeen/combat.cpp
@@ -568,15 +568,113 @@ void Combat::attackMonster(int monsterId) {
}
-bool Combat::stopAttack(const Common::Point &diffPt) {
+int Combat::stopAttack(const Common::Point &diffPt) {
Map &map = *_vm->_map;
+ Party &party = *_vm->_party;
+ Direction dir = party._mazeDirection;
+ const Common::Point &mazePos = party._mazePosition;
if (map._isOutdoors) {
+ if (diffPt.x > 0) {
+ for (int x = 1; x <= diffPt.x; ++x) {
+ int v = map.mazeLookup(Common::Point(mazePos.x + x, mazePos.y), 0, 8);
+ if (v)
+ return 0;
+ }
+ return (dir == DIR_EAST) ? diffPt.x + 1 : 1;
+
+ } else if (diffPt.x < 0) {
+ for (int x = diffPt.x; x < 0; ++x) {
+ int v = map.mazeLookup(Common::Point(mazePos.x + x, mazePos.y), 4);
+ switch (v) {
+ case 0:
+ case 2:
+ case 4:
+ case 5:
+ case 8:
+ case 11:
+ case 13:
+ case 14:
+ break;
+ default:
+ return 0;
+ }
+ }
+ return dir == DIR_WEST ? diffPt.x * -1 + 1 : 1;
+
+ } else if (diffPt.y <= 0) {
+ for (int y = diffPt.y; y < 0; ++y) {
+ int v = map.mazeLookup(Common::Point(mazePos.x, mazePos.y + y), 4);
+ switch (v) {
+ case 0:
+ case 2:
+ case 4:
+ case 5:
+ case 8:
+ case 11:
+ case 13:
+ case 14:
+ break;
+ default:
+ return 0;
+ }
+ }
+ return party._mazeDirection == DIR_SOUTH ? diffPt.y * -1 + 1 : 1;
- }
+ } else {
+ for (int y = 1; y <= diffPt.y; ++y) {
+ int v = map.mazeLookup(Common::Point(mazePos.x, mazePos.y + y), 4);
+ switch (v) {
+ case 0:
+ case 2:
+ case 4:
+ case 5:
+ case 8:
+ case 11:
+ case 13:
+ case 14:
+ break;
+ default:
+ return 0;
+ }
+ }
+ return dir == DIR_NORTH ? diffPt.y + 1 : 1;
+ }
+ } else {
+ // Indoors
+ if (diffPt.x > 0) {
+ for (int x = 1; x <= diffPt.x; ++x) {
+ int v = map.mazeLookup(Common::Point(mazePos.x + x, mazePos.y), 0, 8);
+ if (v)
+ return 0;
+ }
+ return dir == DIR_EAST ? diffPt.x + 1 : 1;
- // TODO
- return false;
+ } else if (diffPt.x < 0) {
+ for (int x = diffPt.x; x < 0; ++x) {
+ int v = map.mazeLookup(Common::Point(mazePos.x + x, mazePos.y), 0, 0x800);
+ if (v)
+ return 0;
+ }
+ return dir == DIR_WEST ? diffPt.x * -1 + 1 : 1;
+
+ } else if (diffPt.y <= 0) {
+ for (int y = diffPt.y; y < 0; ++y) {
+ int v = map.mazeLookup(Common::Point(mazePos.x, mazePos.y + y), 0, 0x8000);
+ if (v)
+ return 0;
+ }
+ return dir == DIR_SOUTH ? diffPt.y * -1 + 1 : 1;
+
+ } else {
+ for (int y = 1; y <= diffPt.y; ++y) {
+ int v = map.mazeLookup(Common::Point(mazePos.x, mazePos.y + y), 0, 0x80);
+ if (v)
+ return 0;
+ }
+ return dir == DIR_NORTH ? diffPt.y + 1 : 1;
+ }
+ }
}
/**