/** * Called from TagProcess, NextTaggedActor() is * called repeatedly until the caller gets fed up or * there are no more tagged actors to look at. */ int NextTaggedActor(int previous) { PMOVER pMover; // Convert actor number to index if (!previous) previous = -1; else previous = TaggedActorIndex(previous); while (++previous < numTaggedActors) { pMover = GetMover(taggedActors[previous].id); // No tag on lead actor while he's moving if ((taggedActors[previous].id) == GetLeadId() && MoverMoving(pMover)) { taggedActors[previous].tagFlags &= ~(POINTING | TAGWANTED); continue; } // Not if the actor doesn't exist at the moment if (pMover && !MoverIs(pMover)) continue; if (!(pMover ? MoverHidden(pMover) : ActorHidden(taggedActors[previous].id))) { return taggedActors[previous].id; } } return 0; }
/** * See if the actor on whom the camera is is approaching an edge. * Request a scroll if he is. */ static void MonitorScroll() { int newx, newy; int Loffset, Toffset; /* * Only do it if the actor is there and is visible */ if (!g_pScrollMover || MoverHidden(g_pScrollMover) || !MoverIs(g_pScrollMover)) return; GetActorPos(g_scrollActor, &newx, &newy); if (g_oldx == newx && g_oldy == newy) return; PlayfieldGetPos(FIELD_WORLD, &Loffset, &Toffset); /* * Approaching right side or left side of the screen? */ if (newx > Loffset+SCREEN_WIDTH - RLDISTANCE && Loffset < g_ImageW - SCREEN_WIDTH) { if (newx > g_oldx) NeedScroll(LEFT); } else if (newx < Loffset + RLDISTANCE && Loffset) { if (newx < g_oldx) NeedScroll(RIGHT); } /* * Approaching bottom or top of the screen? */ if (newy > Toffset+SCREEN_HEIGHT-DDISTANCE && Toffset < g_ImageH-SCREEN_HEIGHT) { if (newy > g_oldy) NeedScroll(UP); } else if (Toffset && newy < Toffset + UDISTANCE + GetActorBottom(g_scrollActor) - GetActorTop(g_scrollActor)) { if (newy < g_oldy) NeedScroll(DOWN); } g_oldx = newx; g_oldy = newy; }
/** * Perform a walk directly initiated by a click. */ static void WalkProcess(CORO_PARAM, const void *param) { // COROUTINE CORO_BEGIN_CONTEXT; PMOVER pMover; int thisWalk; CORO_END_CONTEXT(_ctx); const WP_INIT *to = (const WP_INIT *)param; // get the co-ordinates - copied to process when it was created CORO_BEGIN_CODE(_ctx); _ctx->pMover = GetMover(LEAD_ACTOR); if (TinselV2 && MoverIs(_ctx->pMover) && !MoverIsSWalking(_ctx->pMover)) { assert(_ctx->pMover->hCpath != NOPOLY); // Lead actor is not in a path _ctx->thisWalk = SetActorDest(_ctx->pMover, to->x, to->y, false, 0); DontScrollCursor(); while (MoverMoving(_ctx->pMover) && (_ctx->thisWalk == GetWalkNumber(_ctx->pMover))) CORO_SLEEP(1); } else if (!TinselV2 && _ctx->pMover->bActive) { assert(_ctx->pMover->hCpath != NOPOLY); // Lead actor is not in a path GetToken(TOKEN_LEAD); SetActorDest(_ctx->pMover, to->x, to->y, false, 0); DontScrollCursor(); while (MoverMoving(_ctx->pMover)) CORO_SLEEP(1); FreeToken(TOKEN_LEAD); } CORO_END_CODE; }