aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Kurushin2007-06-08 23:33:35 +0000
committerAndrew Kurushin2007-06-08 23:33:35 +0000
commit78cf0243519608eb08f8502ba5588f0122f553db (patch)
treec72aaf2a50217dd1f88be3b97a86a9bc256875c6
parentb9d77d2d402c51c324f33bb588485ea11345fd6a (diff)
downloadscummvm-rg350-78cf0243519608eb08f8502ba5588f0122f553db.tar.gz
scummvm-rg350-78cf0243519608eb08f8502ba5588f0122f553db.tar.bz2
scummvm-rg350-78cf0243519608eb08f8502ba5588f0122f553db.zip
fix IHNM pathfinding engine. now TED(Chapter 5) interacts with the books properly
svn-id: r27225
-rw-r--r--engines/saga/actor.cpp18
-rw-r--r--engines/saga/objectmap.cpp10
-rw-r--r--engines/saga/script.cpp69
3 files changed, 74 insertions, 23 deletions
diff --git a/engines/saga/actor.cpp b/engines/saga/actor.cpp
index 2a73eac604..75cf22b46a 100644
--- a/engines/saga/actor.cpp
+++ b/engines/saga/actor.cpp
@@ -93,9 +93,9 @@ inline int16 int16Compare(int16 i1, int16 i2) {
return ((i1) > (i2) ? 1 : ((i1) < (i2) ? -1 : 0));
}
-inline int16 quickDistance(const Point &point1, const Point &point2) {
+inline int16 quickDistance(const Point &point1, const Point &point2, int16 compressX) {
Point delta;
- delta.x = ABS(point1.x - point2.x) / 2;
+ delta.x = ABS(point1.x - point2.x) / compressX;
delta.y = ABS(point1.y - point2.y);
return ((delta.x < delta.y) ? (delta.y + delta.x / 2) : (delta.x + delta.y / 2));
}
@@ -2009,9 +2009,12 @@ bool Actor::actorEndWalk(uint16 actorId, bool recurse) {
actor = getActor(actorId);
actor->_actorFlags &= ~kActorBackwards;
- if (actor->_location.distance(actor->_finalTarget) > 8 && (actor->_flags & kProtagonist) && recurse && !(actor->_actorFlags & kActorNoCollide)) {
- actor->_actorFlags |= kActorNoCollide;
- return actorWalkTo(actorId, actor->_finalTarget);
+ if (_vm->getGameType() == GType_ITE) {
+
+ if (actor->_location.distance(actor->_finalTarget) > 8 && (actor->_flags & kProtagonist) && recurse && !(actor->_actorFlags & kActorNoCollide)) {
+ actor->_actorFlags |= kActorNoCollide;
+ return actorWalkTo(actorId, actor->_finalTarget);
+ }
}
actor->_currentAction = kActionWait;
@@ -2725,10 +2728,11 @@ int Actor::fillPathArray(const Point &fromPoint, const Point &toPoint, Point &be
const PathDirectionData *samplePathDirection;
Point nextPoint;
int directionCount;
+ int16 compressX = (_vm->getGameType() == GType_ITE) ? 2 : 1;
_pathDirectionListCount = 0;
pointCounter = 0;
- bestRating = quickDistance(fromPoint, toPoint);
+ bestRating = quickDistance(fromPoint, toPoint, compressX);
bestPath = fromPoint;
for (startDirection = 0; startDirection < 4; startDirection++) {
@@ -2776,7 +2780,7 @@ int Actor::fillPathArray(const Point &fromPoint, const Point &toPoint, Point &be
bestPoint = toPoint;
return pointCounter;
}
- currentRating = quickDistance(nextPoint, toPoint);
+ currentRating = quickDistance(nextPoint, toPoint, compressX);
if (currentRating < bestRating) {
bestRating = currentRating;
bestPath = nextPoint;
diff --git a/engines/saga/objectmap.cpp b/engines/saga/objectmap.cpp
index fd9e7197b7..52f2e89be7 100644
--- a/engines/saga/objectmap.cpp
+++ b/engines/saga/objectmap.cpp
@@ -146,6 +146,8 @@ void HitZone::draw(SagaEngine *vm, Surface *ds, int color) {
Location location;
HitZone::ClickArea *clickArea;
Point *points;
+ Point specialPoint1;
+ Point specialPoint2;
for (i = 0; i < _clickAreasCount; i++) {
clickArea = &_clickAreas[i];
pointsCount = clickArea->pointsCount;
@@ -175,6 +177,14 @@ void HitZone::draw(SagaEngine *vm, Surface *ds, int color) {
}
}
+ if (getSpecialPoint(specialPoint1)) {
+ specialPoint2 = specialPoint1;
+ specialPoint1.x--;
+ specialPoint1.y--;
+ specialPoint2.x++;
+ specialPoint2.y++;
+ ds->drawFrame(specialPoint1, specialPoint2, color);
+ }
}
diff --git a/engines/saga/script.cpp b/engines/saga/script.cpp
index 41cfa61976..0829b3a381 100644
--- a/engines/saga/script.cpp
+++ b/engines/saga/script.cpp
@@ -639,10 +639,19 @@ void Script::playfieldClick(const Point& mousePoint, bool leftButton) {
}
if (hitZone != NULL) {
- if (hitZone->getFlags() & kHitZoneNoWalk) {
- _vm->_actor->actorFaceTowardsPoint(ID_PROTAG, pickLocation);
- doVerb();
- return;
+ if (_vm->getGameType() == GType_ITE) {
+ if (hitZone->getFlags() & kHitZoneNoWalk) {
+ _vm->_actor->actorFaceTowardsPoint(ID_PROTAG, pickLocation);
+ doVerb();
+ return;
+ }
+ } else {
+ if (_vm->getGameType() == GType_IHNM) {
+ if ((hitZone->getFlags() & kHitZoneNoWalk) && (_pendingVerb == getVerbType(kVerbWalkTo))) {
+ doVerb();
+ return;
+ }
+ }
}
if (hitZone->getFlags() & kHitZoneProject) {
@@ -663,26 +672,54 @@ void Script::playfieldClick(const Point& mousePoint, bool leftButton) {
}
}
- if ((_pendingVerb == getVerbType(kVerbWalkTo)) ||
- (_pendingVerb == getVerbType(kVerbPickUp)) ||
- (_pendingVerb == getVerbType(kVerbOpen)) ||
- (_pendingVerb == getVerbType(kVerbClose)) ||
- (_pendingVerb == getVerbType(kVerbUse))) {
- _vm->_actor->actorWalkTo(ID_PROTAG, pickLocation);
- } else {
- if (_pendingVerb == getVerbType(kVerbLookAt)) {
- if (objectTypeId(_pendingObject[0]) != kGameObjectActor ) {
+ if (_vm->getGameType() == GType_ITE) {
+ if ((_pendingVerb == getVerbType(kVerbWalkTo)) ||
+ (_pendingVerb == getVerbType(kVerbPickUp)) ||
+ (_pendingVerb == getVerbType(kVerbOpen)) ||
+ (_pendingVerb == getVerbType(kVerbClose)) ||
+ (_pendingVerb == getVerbType(kVerbUse))) {
_vm->_actor->actorWalkTo(ID_PROTAG, pickLocation);
+ } else {
+ if (_pendingVerb == getVerbType(kVerbLookAt)) {
+ if (objectTypeId(_pendingObject[0]) != kGameObjectActor ) {
+ _vm->_actor->actorWalkTo(ID_PROTAG, pickLocation);
+ } else {
+ doVerb();
+ }
} else {
- doVerb();
+ if ((_pendingVerb == getVerbType(kVerbTalkTo)) ||
+ (_pendingVerb == getVerbType(kVerbGive))) {
+ doVerb();
+ }
}
+ }
+ }
+
+ if (_vm->getGameType() == GType_IHNM) {
+
+ if ((_pendingVerb == getVerbType(kVerbWalkTo)) ||
+ (_pendingVerb == getVerbType(kVerbPickUp)) ||
+ (_pendingVerb == getVerbType(kVerbOpen)) ||
+ (_pendingVerb == getVerbType(kVerbClose)) ||
+ (_pendingVerb == getVerbType(kVerbUse))) {
+ _vm->_actor->actorWalkTo(ID_PROTAG, pickLocation);
} else {
- if ((_pendingVerb == getVerbType(kVerbTalkTo)) ||
- (_pendingVerb == getVerbType(kVerbGive))) {
+ if (_pendingVerb == getVerbType(kVerbLookAt)) {
+ if (objectTypeId(_pendingObject[0]) != kGameObjectActor ) {
+ _vm->_actor->actorWalkTo(ID_PROTAG, pickLocation);
+ } else {
+ _vm->_actor->actorFaceTowardsObject(ID_PROTAG, _pendingObject[0]);
doVerb();
+ }
+ } else {
+ if ((_pendingVerb == getVerbType(kVerbTalkTo)) ||
+ (_pendingVerb == getVerbType(kVerbGive))) {
+ doVerb();
+ }
}
}
}
+
}
void Script::whichObject(const Point& mousePoint) {