aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2015-02-19 21:12:33 -0500
committerPaul Gilbert2015-02-19 21:12:33 -0500
commitb66bf1a838b01181c93b19e214c59c810e05955d (patch)
tree106d47ce5f8ff68fa04e26b8f9276d2156ef34d8
parent7c3f373b9b935b71b3006f203a1f75442818673a (diff)
downloadscummvm-rg350-b66bf1a838b01181c93b19e214c59c810e05955d.tar.gz
scummvm-rg350-b66bf1a838b01181c93b19e214c59c810e05955d.tar.bz2
scummvm-rg350-b66bf1a838b01181c93b19e214c59c810e05955d.zip
XEEN: Implemented stopAttack
-rw-r--r--engines/xeen/combat.cpp106
-rw-r--r--engines/xeen/combat.h2
2 files changed, 103 insertions, 5 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;
+ }
+ }
}
/**
diff --git a/engines/xeen/combat.h b/engines/xeen/combat.h
index 5ff6beb16b..b9293233e7 100644
--- a/engines/xeen/combat.h
+++ b/engines/xeen/combat.h
@@ -99,7 +99,7 @@ public:
void monsterOvercome();
- bool stopAttack(const Common::Point &diffPt);
+ int stopAttack(const Common::Point &diffPt);
public:
Combat(XeenEngine *vm);