aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/wage/script.cpp2
-rw-r--r--engines/wage/wage.cpp101
-rw-r--r--engines/wage/wage.h6
3 files changed, 103 insertions, 6 deletions
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index 3be74cc2c1..a26a733860 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -233,7 +233,7 @@ Script::Operand *Script::readOperand() {
case 0xC2: // PLAYER@
return new Operand(_world->_player, CHR);
case 0xC3: // MONSTER@
- return new Operand(_callbacks->_monster, CHR);
+ return new Operand(_callbacks->getMonster(), CHR);
case 0xC4: // RANDOMSCN@
return new Operand(_world->_orderedScenes[_callbacks->_rnd->getRandomNumber(_world->_orderedScenes.size())], SCENE);
case 0xC5: // RANDOMCHR@
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 677737f4d5..ff57d885f8 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -70,6 +70,10 @@ WageEngine::WageEngine(OSystem *syst, const ADGameDescription *desc) : Engine(sy
_rnd = new Common::RandomSource("wage");
_aim = -1;
+ _temporarilyHidden = false;
+ _isGameOver = false;
+ _monster = NULL;
+ _lastScene = NULL;
debug("WageEngine::WageEngine()");
}
@@ -110,7 +114,9 @@ Common::Error WageEngine::run() {
screen.create(640, 480, Graphics::PixelFormat::createFormatCLUT8());
Common::Rect r(0, 0, screen.w, screen.h);
+ _temporarilyHidden = true;
performInitialSetup();
+ _temporarilyHidden = false;
Common::String input("look");
@@ -143,23 +149,34 @@ void WageEngine::processEvents() {
}
void WageEngine::playSound(String soundName) {
- warning("STUB: playSound");
+ warning("STUB: WageEngine::playSound(%s)", soundName.c_str());
}
void WageEngine::setMenu(String soundName) {
- warning("STUB: setMenu");
+ warning("STUB: WageEngine::setMenu");
}
void WageEngine::appendText(String str) {
- warning("STUB: appendText(%s)", str.c_str());
+ warning("STUB: WageEngine::appendText(%s)", str.c_str());
}
Obj *WageEngine::getOffer() {
- warning("STUB: getOffer");
+ warning("STUB: WageEngine::getOffer");
return NULL;
}
+Chr *WageEngine::getMonster() {
+ if (_monster != NULL && _monster->_currentScene != _world->_player->_currentScene) {
+ _monster = NULL;
+ }
+ return _monster;
+}
+
+void WageEngine::gameOver() {
+ warning("STUB: WageEngine::gameOver()");
+}
+
void WageEngine::performInitialSetup() {
for (int i = 0; i < _world->_orderedObjs.size(); i++)
_world->move(_world->_orderedObjs[i], _world->_storageScene);
@@ -210,8 +227,82 @@ void WageEngine::performInitialSetup() {
}
}
+Scene *WageEngine::getSceneByName(String &location) {
+ Scene *scene;
+ if (location.equals("random@")) {
+ scene = _world->getRandomScene();
+ } else {
+ scene = _world->_scenes[location];
+ }
+ return scene;
+}
+
void WageEngine::onMove(Designed *what, Designed *from, Designed *to) {
- warning("STUB WageEngine::onMove()");
+ Chr *player = _world->_player;
+ Scene *currentScene = player->_currentScene;
+ if (currentScene == _world->_storageScene && !_temporarilyHidden) {
+ if (!_isGameOver) {
+ _isGameOver = true;
+ gameOver();
+ }
+ return;
+ }
+
+ if (what != player && what->_classType == CHR) {
+ Chr *chr = (Chr *)what;
+ if (to == _world->_storageScene) {
+ int returnTo = chr->_returnTo;
+ if (returnTo != Chr::RETURN_TO_STORAGE) {
+ String returnToSceneName;
+ if (returnTo == Chr::RETURN_TO_INITIAL_SCENE) {
+ returnToSceneName = chr->_initialScene;
+ returnToSceneName.toLowercase();
+ } else {
+ returnToSceneName = "random@";
+ }
+ Scene *scene = getSceneByName(returnToSceneName);
+ if (scene != NULL && scene != _world->_storageScene) {
+ _world->move(chr, scene);
+ // To avoid sleeping twice, return if the above move command would cause a sleep.
+ if (scene == currentScene)
+ return;
+ }
+ }
+ } else if (to == player->_currentScene) {
+ if (getMonster() == NULL) {
+ _monster = chr;
+ encounter(player, chr);
+ }
+ }
+ }
+ if (!_temporarilyHidden) {
+ if (to == currentScene || from == currentScene) {
+ redrawScene();
+ g_system->delayMillis(100);
+ }
+ }
+}
+
+void WageEngine::encounter(Chr *player, Chr *chr) {
+ warning("STUB WageEngine::encounter()");
+}
+
+void WageEngine::redrawScene() {
+ Scene *currentScene = _world->_player->_currentScene;
+ if (currentScene != NULL) {
+ //bool firstTime = (_lastScene != currentScene);
+ _lastScene = currentScene;
+
+ warning("STUB: WageEngine::redrawScene()");
+
+ //updateConsoleForScene(console, currentScene);
+ //updateSceneViewerForScene(viewer, currentScene);
+ //viewer.paintImmediately(viewer.getBounds());
+ //getContentPane().validate();
+ //getContentPane().repaint();
+ //console.postUpdateUI();
+ //soundManager.updateSoundTimerForScene(currentScene, firstTime);
+ }
}
} // End of namespace Wage
diff --git a/engines/wage/wage.h b/engines/wage/wage.h
index 5a7d5a072d..4d75acef96 100644
--- a/engines/wage/wage.h
+++ b/engines/wage/wage.h
@@ -126,13 +126,19 @@ public:
bool _commandWasQuick;
int _aim;
bool _temporarilyHidden;
+ bool _isGameOver;
void playSound(String soundName);
void setMenu(String soundName);
void appendText(String str);
+ void gameOver();
Obj *getOffer();
+ Chr *getMonster();
void processEvents();
+ Scene *getSceneByName(String &location);
void onMove(Designed *what, Designed *from, Designed *to);
+ void encounter(Chr *player, Chr *chr);
+ void redrawScene();
private:
Console *_console;