aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Sandulenko2016-01-08 00:26:31 +0100
committerEugene Sandulenko2016-01-08 00:27:40 +0100
commit87766f675351a5c1d2cf7affe40322fd845633ed (patch)
tree6078f13af65175c2a1e2b4bcc6b5738ea104e4c0
parent7bdb942cacea2d950c2b7fadd96e9bcdca06f8b4 (diff)
downloadscummvm-rg350-87766f675351a5c1d2cf7affe40322fd845633ed.tar.gz
scummvm-rg350-87766f675351a5c1d2cf7affe40322fd845633ed.tar.bz2
scummvm-rg350-87766f675351a5c1d2cf7affe40322fd845633ed.zip
WAGE: Implement monster following
-rw-r--r--engines/wage/wage.cpp10
-rw-r--r--engines/wage/world.cpp18
-rw-r--r--engines/wage/world.h1
3 files changed, 23 insertions, 6 deletions
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 1f0769c561..5841b470b4 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -463,13 +463,11 @@ void WageEngine::processTurn(Common::String *textInput, Designed *clickInput) {
if (prevMonster != NULL) {
bool followed = false;
if (_monster == NULL) {
- warning("STUB: processTurn(), monster");
- //Set<Scene> scenes = world.getAdjacentScenes(prevMonster.getState().getCurrentScene());
// TODO: adjacent scenes doesn't contain up/down etc... verify that monsters can't follow these...
- //if (scenes.contains(playerScene)) {
- // int chance = (int) (Math.random() * 255);
- // followed = (chance < prevMonster.getFollowsOpponent());
- //}
+ if (_world->scenesAreConnected(playerScene, prevMonster->_currentScene)) {
+ int chance = _rnd->getRandomNumber(255);
+ followed = (chance < prevMonster->_followsOpponent);
+ }
}
Common::String msg;
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index 22a7bc9b4b..d44267aeaf 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -469,4 +469,22 @@ Scene *World::getSceneAt(int x, int y) {
return NULL;
}
+static const int directionsX[] = { 0, 0, 1, -1 };
+static const int directionsY[] = { -1, 1, 0, 0 };
+
+bool World::scenesAreConnected(Scene *scene1, Scene *scene2) {
+ if (!scene1 || !scene2)
+ return false;
+
+ int x = scene2->_worldX;
+ int y = scene2->_worldY;
+
+ for (int dir = 0; dir < 4; dir++)
+ if (!scene2->_blocked[dir])
+ if (getSceneAt(x + directionsX[dir], y + directionsY[dir]) == scene1)
+ return true;
+
+ return false;
+}
+
} // End of namespace Wage
diff --git a/engines/wage/world.h b/engines/wage/world.h
index a4ca2fd66f..6afd1afb33 100644
--- a/engines/wage/world.h
+++ b/engines/wage/world.h
@@ -65,6 +65,7 @@ public:
void move(Chr *chr, Scene *scene, bool skipSort = false);
Scene *getRandomScene();
Scene *getSceneAt(int x, int y);
+ bool scenesAreConnected(Scene *scene1, Scene *scene2);
WageEngine *_engine;