ASYLUM: Implement Actor::canInteract()

This commit is contained in:
Julien Templier 2011-07-27 13:45:54 -04:00 committed by Eugene Sandulenko
parent da7fd8c203
commit 82ff79f04c
No known key found for this signature in database
GPG key ID: 014D387312D34F08
3 changed files with 110 additions and 9 deletions

View file

@ -1502,8 +1502,110 @@ void Actor::processNext(ActorIndex nextActor, int32 actionAreaId, ActorDirection
updateDirection();
}
bool Actor::process_4069B0(int32 *x, int32 *y) {
error("[Actor::process_4069B0] Not implemented!");
bool Actor::canInteract(Common::Point *point, int32* param) {
Actor *player = getScene()->getActor();
uint32 offset = 65;
if (getWorld()->chapter != kChapter2 || _index != 8)
offset = 40;
int32 parameter = 5;
Common::Point pt = _point1 + _point2;
if (getWorld()->chapter != kChapter2 || _index != 1) {
Common::Point diff = *player->getPoint1() - _point1;
if (abs(diff.y) <= abs(diff.x)) {
if (diff.x < 0) {
parameter = 2;
pt.x -= offset;
if (getScene()->findActionArea(kActionAreaType2, pt) != -1)
goto processActor;
parameter = 3;
pt.x -= offset;
pt.y += offset;
if (getScene()->findActionArea(kActionAreaType2, pt) != -1)
goto processActor;
parameter = 1;
pt.x -= offset;
pt.y -= offset;
} else {
parameter = 6;
pt.x += offset;
if (getScene()->findActionArea(kActionAreaType2, pt) != -1)
goto processActor;
parameter = 5;
pt.x += offset;
pt.y += offset;
if (getScene()->findActionArea(kActionAreaType2, pt) != -1)
goto processActor;
parameter = 7;
pt.x += offset;
pt.y -= offset;
}
} else {
if (diff.y >= 0) {
parameter = 4;
pt.y += offset;
if (getScene()->findActionArea(kActionAreaType2, pt) != -1)
goto processActor;
parameter = 3;
pt.x -= offset;
pt.y += offset;
if (getScene()->findActionArea(kActionAreaType2, pt) != -1)
goto processActor;
parameter = 5;
pt.x += offset;
pt.y += offset;
} else {
parameter = 0;
pt.y -= offset;
if (getScene()->findActionArea(kActionAreaType2, pt) != -1)
goto processActor;
parameter = 1;
pt.x -= offset;
pt.y -= offset;
if (getScene()->findActionArea(kActionAreaType2, pt) != -1)
goto processActor;
parameter = 7;
pt.x += offset;
pt.y -= offset;
}
}
} else {
parameter = 5;
pt.x += offset;
pt.y += offset;
}
if (getScene()->findActionArea(kActionAreaType2, pt) == -1)
return false;
processActor:
if (!process(pt))
return false;
*point = pt;
*param = abs(parameter + 4) & 7;
return true;
}
bool Actor::canMove(Common::Point *point, ActorDirection direction, uint32 distance, bool hasDelta) {

View file

@ -256,7 +256,7 @@ public:
bool process(const Common::Point &point);
void processStatus(int32 actorX, int32 actorY, bool doSpeech);
void processNext(ActorIndex nextActor, int32 actionAreaId, ActorDirection nextDirection, const Common::Point &nextPosition, bool invertPriority, const Common::Point &nextPositionOffset);
bool process_4069B0(int32 *x, int32 *y);
bool canInteract(Common::Point *point, int* param);
bool canMove(Common::Point *point, ActorDirection direction, uint32 count, bool hasDelta);
void move(ActorDirection dir, uint32 distance);
void addReactionHive(int32 reactionIndex, int32 numberValue01Add);

View file

@ -1673,13 +1673,12 @@ IMPLEMENT_OPCODE(Interact)
_currentQueueEntry->currentLine = cmd->param3;
}
} else {
int32 x = 0;
int32 y = 0; // FIXME: is is set somewhere else?
Common::Point point;
if (actor->process_4069B0(&x, &cmd->param4) == 1) {
getScene()->getActor()->processStatus(x, y, (bool)cmd->param4);
cmd->param6 = x;
cmd->param7 = y;
if (actor->canInteract(&point, &cmd->param4) == 1) {
getScene()->getActor()->processStatus(point.x, point.y, (bool)cmd->param4);
cmd->param6 = point.x;
cmd->param7 = point.y;
if (cmd->param2 == 1) {
cmd->param2 = 2;