diff options
-rw-r--r-- | engines/lure/fights.cpp | 10 | ||||
-rw-r--r-- | engines/lure/hotspots.cpp | 85 | ||||
-rw-r--r-- | engines/lure/hotspots.h | 1 |
3 files changed, 67 insertions, 29 deletions
diff --git a/engines/lure/fights.cpp b/engines/lure/fights.cpp index 4c478bbc17..374ea22c26 100644 --- a/engines/lure/fights.cpp +++ b/engines/lure/fights.cpp @@ -466,7 +466,7 @@ void FightsManager::fightHandler(Hotspot &h, uint16 moveOffset) { moveOffset += 2 * sizeof(uint16); if (v1 == opponent.fwblocking) { - Sound.playSound(42); + Sound.addSound(42); moveOffset = v2; } break; @@ -478,7 +478,7 @@ void FightsManager::fightHandler(Hotspot &h, uint16 moveOffset) { if (fighter.fwdist <= FIGHT_DISTANCE) { if (h.hotspotId() == PLAYER_ID) { // Player hits opponent - Sound.playSound(52); + Sound.addSound(52); if (opponent.fwhits != 5) { opponent.fwseq_ad = v1; @@ -490,13 +490,13 @@ void FightsManager::fightHandler(Hotspot &h, uint16 moveOffset) { } } else { // Opponent hit player - Sound.playSound(37); + Sound.addSound(37); opponent.fwseq_ad = v1; if (++opponent.fwhits == 10) { // Player has been killed fighter.fwhits = 10; opponent.fwseq_ad = FIGHT_PLAYER_DIES; - Sound.playSound(36); + Sound.addSound(36); } } } @@ -526,7 +526,7 @@ void FightsManager::fightHandler(Hotspot &h, uint16 moveOffset) { case 0xFFEA: // Fight sound - Sound.playSound(getWord(moveOffset)); + Sound.addSound(getWord(moveOffset) & 0xff); moveOffset += sizeof(uint16); break; diff --git a/engines/lure/hotspots.cpp b/engines/lure/hotspots.cpp index 7def0be9ab..f92fd5c6ff 100644 --- a/engines/lure/hotspots.cpp +++ b/engines/lure/hotspots.cpp @@ -35,6 +35,7 @@ #include "lure/events.h" #include "lure/game.h" #include "lure/fights.h" +#include "lure/sound.h" #include "common/endian.h" namespace Lure { @@ -165,6 +166,39 @@ Hotspot::Hotspot(Hotspot *character, uint16 objType): _pathFinder(this) { _nameBuffer[0] = '\0'; } +Hotspot::Hotspot(): _pathFinder(NULL) { + _data = NULL; + _anim = NULL; + _frames = NULL; + _numFrames = 0; + _persistant = false; + _hotspotId = 0xffff; + _override = NULL; + _colourOffset = 0; + _destHotspotId = 0; + _blockedOffset = 0; + _exitCtr = 0; + _voiceCtr = 0; + _walkFlag = false; + _skipFlag = false; + _roomNumber = 0; + _destHotspotId = 0; + _startX = 0; + _startY = 0; + _destX = 0; + _destY = 0; + _layer = 0; + _height = 0; + _width = 0; + _heightCopy = 0; + _widthCopy = 0; + _yCorrection = 0; + _tickCtr = 0; + _tickHandler = NULL; + _frameWidth = _width; + _frameStartsUsed = false; +} + Hotspot::~Hotspot() { if (_frames) delete _frames; } @@ -869,7 +903,7 @@ HotspotPrecheckResult Hotspot::actionPrecheck(HotspotData *hotspot) { return PC_WAIT; } else if (hotspot->actionHotspotId != _hotspotId) { - if (fields.getField(82) != 2) { + if (fields.getField(AREA_FLAG) != 2) { showMessage(5, hotspot->hotspotId); setDelayCtr(4); } @@ -1294,8 +1328,8 @@ void Hotspot::doClose(HotspotData *hotspot) { joinRec = res.getExitJoin(hotspot->hotspotId); if (!joinRec->blocked) { // Close the door - if (!doorCloseCheck(joinRec->hotspot1Id) || - !doorCloseCheck(joinRec->hotspot2Id)) { + if (!doorCloseCheck(joinRec->hotspots[0].hotspotId) || + !doorCloseCheck(joinRec->hotspots[1].hotspotId)) { // A character is preventing the door from closing showMessage(2); } else { @@ -2587,38 +2621,37 @@ void HotspotTickHandlers::puzzledAnimHandler(Hotspot &h) { void HotspotTickHandlers::roomExitAnimHandler(Hotspot &h) { Resources &res = Resources::getReference(); -// ValueTableData &fields = res.fieldList(); + ValueTableData &fields = res.fieldList(); + Room &room = Room::getReference(); + RoomExitJoinData *rec = res.getExitJoin(h.hotspotId()); if (!rec) return; - byte *currentFrame, *destFrame; + RoomExitJoinStruct &rs = (rec->hotspots[0].hotspotId == h.hotspotId()) ? + rec->hotspots[0] : rec->hotspots[1]; - if (rec->hotspot1Id == h.hotspotId()) { - currentFrame = &rec->h1CurrentFrame; - destFrame = &rec->h1DestFrame; - } else { - currentFrame = &rec->h2CurrentFrame; - destFrame = &rec->h2DestFrame; - } - - if ((rec->blocked != 0) && (*currentFrame != *destFrame)) { + if ((rec->blocked != 0) && (rs.currentFrame != rs.destFrame)) { // Closing the door h.setOccupied(true); - ++*currentFrame; - if (*currentFrame == *destFrame) { - // TODO: play closed door sound - } - } else if ((rec->blocked == 0) && (*currentFrame != 0)) { + ++rs.currentFrame; + if ((rs.currentFrame == rs.destFrame) && (h.hotspotId() == room.roomNumber())) + Sound.addSound(rs.closeSound); + + } else if ((rec->blocked == 0) && (rs.currentFrame != 0)) { // Opening the door h.setOccupied(false); - --*currentFrame; - if (*currentFrame == *destFrame) { - //TODO: Check against script val 88 and play sound + --rs.currentFrame; + if ((rs.currentFrame == rs.destFrame) && (h.hotspotId() == room.roomNumber())) { + Sound.addSound(rs.openSound); + + // If in the outside village, trash reverb + if (fields.getField(AREA_FLAG) == 1) + Sound.musicInterface_TrashReverb(); } } - h.setFrameNumber(*currentFrame); + h.setFrameNumber(rs.currentFrame); } void HotspotTickHandlers::playerAnimHandler(Hotspot &h) { @@ -2931,10 +2964,11 @@ void HotspotTickHandlers::followerAnimHandler(Hotspot &h) { void HotspotTickHandlers::jailorAnimHandler(Hotspot &h) { Resources &res = Resources::getReference(); ValueTableData &fields = res.fieldList(); + Game &game = Game::getReference(); HotspotData *player = res.getHotspot(PLAYER_ID); if ((fields.getField(11) != 0) || (h.hotspotId() == CASTLE_SKORL_ID)) { - if (!h.skipFlag() && (h.roomNumber() == player->roomNumber)) { + if (!h.skipFlag() && !game.preloadFlag() && (h.roomNumber() == player->roomNumber)) { if (Support::charactersIntersecting(h.resource(), player)) { // Skorl has caught the player Game::getReference().setState(GS_RESTORE_RESTART | GS_CAUGHT); @@ -2966,6 +3000,9 @@ void HotspotTickHandlers::droppingTorchAnimHandler(Hotspot &h) { res.deactivateHotspot(h.hotspotId()); res.activateHotspot(0x41C); + // Add sound + Sound.addSound(8); + // Enable the fire and activate its animation HotspotData *fire = res.getHotspot(0x418); fire->flags |= 0x80; diff --git a/engines/lure/hotspots.h b/engines/lure/hotspots.h index fb3bb1478b..96a02be2a7 100644 --- a/engines/lure/hotspots.h +++ b/engines/lure/hotspots.h @@ -345,6 +345,7 @@ private: public: Hotspot(HotspotData *res); Hotspot(Hotspot *character, uint16 objType); + Hotspot(); ~Hotspot(); void setAnimation(uint16 newAnimId); |