aboutsummaryrefslogtreecommitdiff
path: root/engines/lure/game.cpp
diff options
context:
space:
mode:
authorPaul Gilbert2006-04-29 11:22:05 +0000
committerPaul Gilbert2006-04-29 11:22:05 +0000
commit1192f0dfca144db2b6913ce8db950dce028d012c (patch)
tree078ab9fccfc7f6436930adbc8b37d895576b4c1c /engines/lure/game.cpp
parent946d0582dcd24ceeb4245c1709b65f2de4ee480a (diff)
downloadscummvm-rg350-1192f0dfca144db2b6913ce8db950dce028d012c.tar.gz
scummvm-rg350-1192f0dfca144db2b6913ce8db950dce028d012c.tar.bz2
scummvm-rg350-1192f0dfca144db2b6913ce8db950dce028d012c.zip
Enhanced hotspot action so that the player will properly walk to a hotspot before performing an action
svn-id: r22209
Diffstat (limited to 'engines/lure/game.cpp')
-rw-r--r--engines/lure/game.cpp58
1 files changed, 29 insertions, 29 deletions
diff --git a/engines/lure/game.cpp b/engines/lure/game.cpp
index a760faac02..0b756694d0 100644
--- a/engines/lure/game.cpp
+++ b/engines/lure/game.cpp
@@ -281,12 +281,16 @@ void Game::handleClick() {
fields.setField(NEW_ROOM_NUMBER, oldRoomNumber);
fields.setField(OLD_ROOM_NUMBER, 0);
}
- } else if (res.getTalkState() != TALK_NONE) {
+ } else if ((room.cursorState() == CS_TALKING) ||
+ (res.getTalkState() != TALK_NONE)) {
// Currently talking, so let it's tick proc handle it
} else if (mouse.y() < MENUBAR_Y_SIZE) {
uint8 response = Menu::getReference().execute();
if (response != MENUITEM_NONE)
handleMenuResponse(response);
+ } else if ((room.cursorState() == CS_SEQUENCE) ||
+ (room.cursorState() == CS_UNKNOWN)) {
+ // No action necessary
} else {
if (mouse.lButton())
handleLeftClick();
@@ -303,7 +307,7 @@ void Game::handleRightClickMenu() {
HotspotData *hotspot;
Action action;
uint32 actions;
- uint16 itemId;
+ uint16 itemId = 0xffff;
if (room.hotspotId() != 0) {
// Get hotspot actions
@@ -353,23 +357,9 @@ void Game::handleRightClickMenu() {
}
}
- // Set fields used by the script interpreter
- fields.setField(CHARACTER_HOTSPOT_ID, PLAYER_ID);
- if (hotspot) {
- fields.setField(ACTIVE_HOTSPOT_ID, hotspot->hotspotId);
- if ((action != USE) && (action != GIVE)) {
- fields.setField(USE_HOTSPOT_ID, 0xffff);
- }
- }
-
if (action != NONE) {
- res.setCurrentAction(action);
- room.update();
- Screen::getReference().update();
- player->doAction(action, hotspot);
-
- if (action != TALK_TO)
- res.setCurrentAction(NONE);
+ player->stopWalking();
+ doAction(action, (hotspot != NULL) ? hotspot->hotspotId : NULL, itemId);
}
}
@@ -377,22 +367,17 @@ void Game::handleLeftClick() {
Room &room = Room::getReference();
Mouse &mouse = Mouse::getReference();
Resources &res = Resources::getReference();
- ValueTableData &fields = res.fieldList();
Hotspot *player = res.getActiveHotspot(PLAYER_ID);
+ room.setCursorState(CS_NONE);
+ player->stopWalking();
+ player->setDestHotspot(0);
+ player->setActionCtr(0);
+
if ((room.destRoomNumber() == 0) && (room.hotspotId() != 0)) {
// Handle look at hotspot
- HotspotData *hs = res.getHotspot(room.hotspotId());
+ doAction(LOOK_AT, room.hotspotId(), 0xffff);
- fields.setField(CHARACTER_HOTSPOT_ID, PLAYER_ID);
- fields.setField(ACTIVE_HOTSPOT_ID, hs->hotspotId);
- fields.setField(USE_HOTSPOT_ID, 0xffff);
-
- res.setCurrentAction(LOOK_AT);
- room.update();
- Screen::getReference().update();
- player->doAction(LOOK_AT, hs);
- res.setCurrentAction(NONE);
} else if (room.destRoomNumber() != 0) {
// Walk to another room
RoomExitCoordinateData &exitData =
@@ -406,6 +391,21 @@ void Game::handleLeftClick() {
}
}
+void Game::doAction(Action action, uint16 hotspotId, uint16 usedId) {
+ Resources &res = Resources::getReference();
+ Room &room = Room::getReference();
+ ValueTableData &fields = res.fieldList();
+ Hotspot *player = res.getActiveHotspot(PLAYER_ID);
+
+ fields.setField(CHARACTER_HOTSPOT_ID, PLAYER_ID);
+ fields.setField(ACTIVE_HOTSPOT_ID, hotspotId);
+ fields.setField(USE_HOTSPOT_ID, usedId);
+
+ res.setCurrentAction(action);
+ room.setCursorState(CS_ACTION);
+ player->setCurrentAction(DISPATCH_ACTION, action, hotspotId, usedId);
+}
+
void Game::doShowCredits() {
Events &events = Events::getReference();
Mouse &mouse = Mouse::getReference();