/** * Sets the mover Z position */ void SetMoverZ(PMOVER pMover, int y, uint32 zFactor) { if (!pMover->bHidden) { if (MoverIsSWalking(pMover) && pMover->zOverride != -1) { // Special for SWalk() MultiSetZPosition(pMover->actorObj, (pMover->zOverride << ZSHIFT) + y); } else { // Normal case MultiSetZPosition(pMover->actorObj, (zFactor << ZSHIFT) + y); } } }
/** * Guess what these do. */ int AsetZPos(OBJECT *pObj, int y, int32 z) { int zPos; z += z ? -1 : 0; zPos = y + (z << ZSHIFT); MultiSetZPosition(pObj, zPos); return zPos; }
/** * Change which reel is playing for a moving actor. */ void AlterMover(PMOVER pMover, SCNHANDLE film, AR_FUNCTION fn) { const FILM *pfilm; assert(pMover->actorObj); // Altering null moving actor's animation script if (fn == AR_POPREEL) { // Use the saved film film = pMover->hPushedFilm; } if (fn == AR_PUSHREEL) { // Save the one we're replacing pMover->hPushedFilm = (pMover->bSpecReel) ? pMover->hLastFilm : 0; } if (film == 0) { if (pMover->bSpecReel) { // Revert to 'normal' actor SetMoverWalkReel(pMover, pMover->direction, pMover->scale, true); pMover->bSpecReel = false; } } else { // Remember this one in case the actor talks pMover->hLastFilm = film; pfilm = (const FILM *)LockMem(film); assert(pfilm != NULL); InitStepAnimScript(&pMover->actorAnim, pMover->actorObj, FROM_32(pfilm->reels[0].script), ONE_SECOND / FROM_32(pfilm->frate)); if (!TinselV2) pMover->stepCount = 0; // If no path, just use first path in the scene if (pMover->hCpath != NOPOLY) SetMoverZ(pMover, pMover->objY, GetPolyZfactor(pMover->hCpath)); else SetMoverZ(pMover, pMover->objY, GetPolyZfactor(FirstPathPoly())); if (fn == AR_WALKREEL) { pMover->bSpecReel = false; pMover->bWalkReel = true; } else { pMover->bSpecReel = true; pMover->bWalkReel = false; #ifdef DEBUG assert(StepAnimScript(&pMover->actorAnim) != ScriptFinished); // Actor reel has finished! #else StepAnimScript(&pMover->actorAnim); // 04/01/95 #endif } // Hang on, we may not want him yet! 04/01/95 if (pMover->bHidden) MultiSetZPosition(pMover->actorObj, -1); } }
/** * If the actor's object exists, move it behind the background. * MultiHideObject() is deliberately not used, as StepAnimScript() calls * cause the object to re-appear. */ void HideMover(PMOVER pMover, int sf) { assert(pMover); // Hiding null moving actor pMover->bHidden = true; if (!TinselV2) { // sf is only passed in Tinsel v1 pMover->SlowFactor = sf; } else { // Tinsel 2 specific code if (IsTaggedActor(pMover->actorID)) { // It may be pointed to SetActorPointedTo(pMover->actorID, false); SetActorTagWanted(pMover->actorID, false, false, 0); } } if (pMover->actorObj) MultiSetZPosition(pMover->actorObj, -1); }
/** * Run main animation that comprises the scene background. */ static void BGmainProcess(CORO_PARAM, const void *param) { // COROUTINE CORO_BEGIN_CONTEXT; CORO_END_CONTEXT(_ctx); CORO_BEGIN_CODE(_ctx); const FILM *pFilm; const FREEL *pReel; const MULTI_INIT *pmi; // get the stuff copied to process when it was created if (pBG[0] == NULL) { /*** At start of scene ***/ if (!TinselV2) { pReel = (const FREEL *)param; // Get the MULTI_INIT structure pmi = (const MULTI_INIT *)LockMem(FROM_LE_32(pReel->mobj)); // Initialise and insert the object, and initialise its script. pBG[0] = MultiInitObject(pmi); MultiInsertObject(GetPlayfieldList(FIELD_WORLD), pBG[0]); InitStepAnimScript(&thisAnim[0], pBG[0], FROM_LE_32(pReel->script), BGspeed); bgReels = 1; } else { /*** At start of scene ***/ pFilm = (const FILM *)LockMem(hBackground); bgReels = FROM_LE_32(pFilm->numreels); int i; for (i = 0; i < bgReels; i++) { // Get the MULTI_INIT structure pmi = (PMULTI_INIT) LockMem(FROM_LE_32(pFilm->reels[i].mobj)); // Initialise and insert the object, and initialise its script. pBG[i] = MultiInitObject(pmi); MultiInsertObject(GetPlayfieldList(FIELD_WORLD), pBG[i]); MultiSetZPosition(pBG[i], 0); InitStepAnimScript(&thisAnim[i], pBG[i], FROM_LE_32(pFilm->reels[i].script), BGspeed); if (i > 0) pBG[i-1]->pSlave = pBG[i]; } } if (bDoFadeIn) { FadeInFast(NULL); bDoFadeIn = false; } else if (TinselV2) PokeInTagColor(); for (;;) { for (int i = 0; i < bgReels; i++) { if (StepAnimScript(&thisAnim[i]) == ScriptFinished) error("Background animation has finished"); } CORO_SLEEP(1); } } else { // New background during scene if (!TinselV2) { pReel = (const FREEL *)param; InitStepAnimScript(&thisAnim[0], pBG[0], FROM_LE_32(pReel->script), BGspeed); StepAnimScript(&thisAnim[0]); } else { pFilm = (const FILM *)LockMem(hBackground); assert(bgReels == (int32)FROM_LE_32(pFilm->numreels)); // Just re-initialise the scripts. for (int i = 0; i < bgReels; i++) { InitStepAnimScript(&thisAnim[i], pBG[i], pFilm->reels[i].script, BGspeed); StepAnimScript(&thisAnim[i]); } } } CORO_END_CODE; }