aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/scumm/script.cpp53
-rw-r--r--engines/scumm/script_v0.cpp3
-rw-r--r--engines/scumm/scumm_v0.h9
-rw-r--r--engines/scumm/verbs.cpp4
4 files changed, 55 insertions, 14 deletions
diff --git a/engines/scumm/script.cpp b/engines/scumm/script.cpp
index 31eef50a6a..cda2b3cd82 100644
--- a/engines/scumm/script.cpp
+++ b/engines/scumm/script.cpp
@@ -1135,7 +1135,7 @@ void ScummEngine_v0::walkToActorOrObject(int object) {
ActorC64 *a = (ActorC64 *)derefActor(VAR(VAR_EGO), "walkToObject");
_walkToObject = object;
- _walkToObjectIdx = getObjectIndex(object);
+ _walkToObjectState = kWalkToObjectStateWalk;
if (OBJECT_V0_TYPE(object) == kObjectV0TypeActor) {
walkActorToActor(VAR(VAR_EGO), OBJECT_V0_ID(object), 4);
@@ -1152,19 +1152,52 @@ void ScummEngine_v0::walkToActorOrObject(int object) {
// actor must not move if frozen
if (a->_miscflags & kActorMiscFlagFreeze)
a->stopActorMoving();
+}
+
+bool ScummEngine_v0::checkPendingWalkAction() {
+ // before a sentence script is executed, it might be necessary to walk to
+ // and pickup objects before. Check if such an action is pending and handle
+ // it if available.
+ if (_walkToObjectState == kWalkToObjectStateDone)
+ return false;
+
+ int actor = VAR(VAR_EGO);
+ ActorC64 *a = (ActorC64 *)derefActor(actor, "checkAndRunSentenceScript");
+
+ // wait until walking or turning action is finished
+ if (a->_moving)
+ return true;
+
+ // after walking and turning finally execute the script
+ if (_walkToObjectState == kWalkToObjectStateTurn) {
+ runSentenceScript();
+ // change actor facing
+ } else if (getObjActToObjActDist(actorToObj(actor), _walkToObject) <= 4) {
+ if (objIsActor(_walkToObject)) { // walk to actor finished
+ // make actors turn to each other
+ a->faceToObject(_walkToObject);
+ int otherActor = objToActor(_walkToObject);
+ // ignore the plant
+ if (otherActor != 19) {
+ Actor *b = derefActor(otherActor, "checkAndRunSentenceScript(2)");
+ b->faceToObject(actorToObj(actor));
+ }
+ } else { // walk to object finished
+ int x, y, dir;
+ getObjectXYPos(_walkToObject, x, y, dir);
+ a->turnToDirection(dir);
+ }
+ _walkToObjectState = kWalkToObjectStateTurn;
+ return true;
}
+
+ _walkToObjectState = kWalkToObjectStateDone;
+ return false;
}
void ScummEngine_v0::checkAndRunSentenceScript() {
- if (_walkToObjectIdx) {
- ActorC64 *a = (ActorC64 *)derefActor(VAR(VAR_EGO), "checkAndRunSentenceScript");
- if (a->_moving)
- return;
- // TODO: change actor facing
- _walkToObjectIdx = 0;
- runSentenceScript();
+ if (checkPendingWalkAction())
return;
- }
if (!_sentenceNum || _sentence[_sentenceNum - 1].freezeCount)
return;
@@ -1214,7 +1247,7 @@ void ScummEngine_v0::checkAndRunSentenceScript() {
runSentenceScript();
if (_currentMode == kModeKeypad) {
- _walkToObjectIdx = 0;
+ _walkToObjectState = kWalkToObjectStateDone;
}
}
diff --git a/engines/scumm/script_v0.cpp b/engines/scumm/script_v0.cpp
index a04f23aea8..4d9a206118 100644
--- a/engines/scumm/script_v0.cpp
+++ b/engines/scumm/script_v0.cpp
@@ -976,7 +976,8 @@ void ScummEngine_v0::resetSentence() {
_activeVerb = kVerbWalkTo;
_activeObject = 0;
_activeObject2 = 0;
- _walkToObjectIdx = 0;
+
+ _walkToObjectState = kWalkToObjectStateDone;
_redrawSentenceLine = true;
}
diff --git a/engines/scumm/scumm_v0.h b/engines/scumm/scumm_v0.h
index 10ae18ace5..e25d6f5826 100644
--- a/engines/scumm/scumm_v0.h
+++ b/engines/scumm/scumm_v0.h
@@ -39,6 +39,12 @@ protected:
kModeNormal = 3, // normal playing mode
};
+ enum WalkToObjectState {
+ kWalkToObjectStateDone = 0,
+ kWalkToObjectStateWalk = 1,
+ kWalkToObjectStateTurn = 2,
+ };
+
protected:
byte _currentMode;
@@ -51,7 +57,7 @@ protected:
int _cmdObject2; // 2nd script object or actor (see OBJECT_V0())
int _walkToObject;
- int _walkToObjectIdx;
+ int _walkToObjectState;
bool _redrawSentenceLine;
public:
@@ -81,6 +87,7 @@ protected:
virtual void runSentenceScript();
virtual void checkAndRunSentenceScript();
+ bool checkPendingWalkAction();
bool checkSentenceComplete();
virtual void checkExecVerbs();
virtual void handleMouseOver(bool updateInventory);
diff --git a/engines/scumm/verbs.cpp b/engines/scumm/verbs.cpp
index 9334f40048..91c9cc159a 100644
--- a/engines/scumm/verbs.cpp
+++ b/engines/scumm/verbs.cpp
@@ -699,7 +699,7 @@ void ScummEngine_v0::verbExec() {
_activeObject = 0;
_activeObject2 = 0;
}
- _walkToObjectIdx = 0;
+ _walkToObjectState = kWalkToObjectStateDone;
return;
}
@@ -845,7 +845,7 @@ void ScummEngine_v0::checkExecVerbs() {
_redrawSentenceLine = true;
if (_activeVerb == kVerbWalkTo && zone->number == kMainVirtScreen) {
- _walkToObjectIdx = 0;
+ _walkToObjectState = kWalkToObjectStateDone;
execute = true;
}
}