diff options
author | Paul Gilbert | 2008-01-08 06:13:55 +0000 |
---|---|---|
committer | Paul Gilbert | 2008-01-08 06:13:55 +0000 |
commit | 965eddf0dc0df514a74504d4b92365afe6f3b892 (patch) | |
tree | 68926a5f57232fed70c658c143df8237b1697691 /engines/lure | |
parent | 660d9a89d7d3fd1888027e83ac1d4f889c5a115c (diff) | |
download | scummvm-rg350-965eddf0dc0df514a74504d4b92365afe6f3b892.tar.gz scummvm-rg350-965eddf0dc0df514a74504d4b92365afe6f3b892.tar.bz2 scummvm-rg350-965eddf0dc0df514a74504d4b92365afe6f3b892.zip |
Enhanced NPC walk-to logic to handle separately several special Ids that were previously handled identically
svn-id: r30339
Diffstat (limited to 'engines/lure')
-rw-r--r-- | engines/lure/hotspots.cpp | 79 | ||||
-rw-r--r-- | engines/lure/hotspots.h | 2 |
2 files changed, 54 insertions, 27 deletions
diff --git a/engines/lure/hotspots.cpp b/engines/lure/hotspots.cpp index fbe80235fe..abad4d31ec 100644 --- a/engines/lure/hotspots.cpp +++ b/engines/lure/hotspots.cpp @@ -959,7 +959,7 @@ HotspotPrecheckResult Hotspot::actionPrecheck(HotspotData *hotspot) { (hotspot->characterMode == CHARMODE_WAIT_FOR_PLAYER) || (hotspot->characterMode == CHARMODE_WAIT_FOR_INTERACT)) { // loc_880 - if (characterWalkingCheck(hotspot)) + if (characterWalkingCheck(hotspot->hotspotId)) return PC_WAIT; } else { // loc_886 @@ -974,7 +974,7 @@ HotspotPrecheckResult Hotspot::actionPrecheck(HotspotData *hotspot) { ((hotspot->actionHotspotId != _hotspotId) && (hotspot->characterMode == CHARMODE_WAIT_FOR_PLAYER))) { // loc_880 - if (characterWalkingCheck(hotspot)) + if (characterWalkingCheck(hotspot->hotspotId)) return PC_WAIT; } else if (hotspot->actionHotspotId != _hotspotId) { @@ -1077,33 +1077,60 @@ bool Hotspot::findClearBarPlace() { return false; } -bool Hotspot::characterWalkingCheck(HotspotData *hotspot) { +bool Hotspot::characterWalkingCheck(uint16 hotspotId) { + Resources &res = Resources::getReference(); int16 xp, yp; + bool altFlag; + HotspotData *hotspot; + + // Note that several invalid hotspot Ids are used to identify special walk to + // coordinates used throughout the game + + _walkFlag = true; + altFlag = false; - if (hotspot == NULL) { - // DEBUG for now - hardcoded value for 3E7h (NULL) + switch (hotspotId) { + case 997: + xp = 169; yp = 146; + altFlag = true; + break; + + case 998: + xp = 124; yp = 169; + break; + + case 999: xp = 78; yp = 162; - _walkFlag = true; + break; + + default: + hotspot = res.getHotspot(hotspotId); + if (hotspot == NULL) { + // Should never come here, as all other constants are handled + warning("characterWalkingCheck done on unknown hotspot Id %xh", hotspotId); + xp = 78; yp = 162; + } else if ((hotspot->walkX == 0) && (hotspot->walkY == 0)) { + // The hotspot doesn't have any walk co-ordinates + xp = hotspot->startX; + yp = hotspot->startY + hotspot->heightCopy - 4; + _walkFlag = false; + } else { + xp = hotspot->walkX; + yp = hotspot->walkY & 0x7fff; + altFlag = (hotspot->walkY & 0x8000) != 0; + } + break; } - else if ((hotspot->walkX == 0) && (hotspot->walkY == 0)) { - // The hotspot doesn't have any walk co-ordinates - xp = hotspot->startX; - yp = hotspot->startY + hotspot->heightCopy - 4; - _walkFlag = false; - } else { - xp = hotspot->walkX; - yp = hotspot->walkY & 0x7fff; - _walkFlag = true; - - if ((hotspot->walkY & 0x8000) != 0) { - if (((x() >> 3) != (xp >> 3)) || - ((((y() + heightCopy()) >> 3) - 1) != (yp >> 3))) { - // Walk to the specified destination - walkTo(xp, yp); - return true; - } else { - return false; - } + + if (altFlag) { + // Alternate walking check + if (((x() >> 3) != (xp >> 3)) || + ((((y() + heightCopy()) >> 3) - 1) != (yp >> 3))) { + // Walk to the specified destination + walkTo(xp, yp); + return true; + } else { + return false; } } @@ -1987,7 +2014,7 @@ void Hotspot::npcWalkingCheck(HotspotData *hotspot) { fields.setField(ACTIVE_HOTSPOT_ID, hId); if ((hId < PLAYER_ID) || (hotspot->roomNumber == _roomNumber)) { - characterWalkingCheck(hotspot); + characterWalkingCheck(hId); } } diff --git a/engines/lure/hotspots.h b/engines/lure/hotspots.h index aa7a2a0f4c..dce3e16307 100644 --- a/engines/lure/hotspots.h +++ b/engines/lure/hotspots.h @@ -304,7 +304,7 @@ private: HotspotPrecheckResult actionPrecheck(HotspotData *hotspot); BarPlaceResult getBarPlace(); bool findClearBarPlace(); - bool characterWalkingCheck(HotspotData *hotspot); + bool characterWalkingCheck(uint16 hotspotId); bool doorCloseCheck(uint16 doorId); void resetDirection(); |