Advertisement
Baoulettes

full func

May 19th, 2022
833
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 7.13 KB | None | 0 0
  1. uintptr_t SelectedAnim = 0;
  2. s16 EquipedStance;
  3. s16 FrameCountSinceLastAnim = 0;
  4. s16 MinFrameCount;
  5. void func_8009214C(GlobalContext* globalCtx, u8* segment, SkelAnime* skelAnime, Vec3f* pos, Vec3s* rot, f32 scale,
  6.                    s32 sword, s32 tunic, s32 shield, s32 boots) {
  7.     Input* p1Input = &globalCtx->state.input[0];
  8.     Vec3f eye = { 0.0f, 0.0f, -400.0f };
  9.     Vec3f at = { 0.0f, 0.0f, 0.0f };
  10.     Vec3s* destTable;
  11.     Vec3s* srcTable;
  12.     s32 i;
  13.     bool canswitchrnd = false;
  14.     s16 SelectedMode = CVar_GetS32("gPauseLiveLink", 1);
  15.     MinFrameCount = CVar_GetS32("gMinFrameCount", 200);
  16.     uintptr_t* PauseMenuAnimSet[15][4] = {
  17.         { 0, 0, 0, 0 }, // 0 = none
  18.         // IDLE               // Two Handed       // No shield        // Kid Hylian Shield
  19.         { gPlayerAnim_003238, gPlayerAnim_002BE0, gPlayerAnim_003240, gPlayerAnim_003240 }, // Idle
  20.         { gPlayerAnim_003200, gPlayerAnim_003200, gPlayerAnim_003200, gPlayerAnim_003200 }, // Idle look around
  21.         { gPlayerAnim_0033E0, gPlayerAnim_0033E0, gPlayerAnim_0033E0, gPlayerAnim_0033E0 }, // Idle Belt
  22.         { gPlayerAnim_003418, gPlayerAnim_003418, gPlayerAnim_003418, gPlayerAnim_003418 }, // Idle shield adjust
  23.         { gPlayerAnim_003420, gPlayerAnim_003428, gPlayerAnim_003420, gPlayerAnim_003420 }, // Idle test sword
  24.         { gPlayerAnim_0025D0, gPlayerAnim_002BD0, gPlayerAnim_0025D0, gPlayerAnim_0025D0 }, // Battle Stance
  25.         { gPlayerAnim_003290, gPlayerAnim_002BF8, gPlayerAnim_003290, gPlayerAnim_003290 }, // Walking (No shield)
  26.         { gPlayerAnim_003268, gPlayerAnim_002BF8, gPlayerAnim_003268, gPlayerAnim_003268 }, // Walking (Holding shield)
  27.         { gPlayerAnim_003138, gPlayerAnim_002B40, gPlayerAnim_003138, gPlayerAnim_003138 }, // Running (No shield)
  28.         { gPlayerAnim_003140, gPlayerAnim_002B40, gPlayerAnim_003140, gPlayerAnim_003140 }, // Running (Holding shield)
  29.         { gPlayerAnim_0031A8, gPlayerAnim_0031A8, gPlayerAnim_0031A8, gPlayerAnim_0031A8 }, // Hand on hip
  30.         { gPlayerAnim_0033F0, gPlayerAnim_0033F0, gPlayerAnim_0033F0, gPlayerAnim_0033F0 }, // Idle yawn
  31.         { gPlayerAnim_002AF0, gPlayerAnim_002928, gPlayerAnim_002AF0, gPlayerAnim_002AF0 }, // Spin Charge
  32.         { gPlayerAnim_002820, gPlayerAnim_002820, gPlayerAnim_002820, gPlayerAnim_002820 }, // Look at hand
  33.        
  34.     };
  35.     s16 AnimArraySize = ARRAY_COUNT(PauseMenuAnimSet);
  36.     gSegments[4] = VIRTUAL_TO_PHYSICAL(segment + 0x3800);
  37.     gSegments[6] = VIRTUAL_TO_PHYSICAL(segment + 0x8800);
  38.  
  39.     if (CVar_GetS32("gPauseLiveLink", 0) || CVar_GetS32("gPauseTriforce", 0)) {
  40.         uintptr_t anim = gPlayerAnim_003238; // idle
  41.  
  42.         if (CUR_EQUIP_VALUE(EQUIP_SWORD) >= 3) {
  43.             EquipedStance = 1;
  44.         } else if (CUR_EQUIP_VALUE(EQUIP_SHIELD) == 0) {
  45.             EquipedStance = 2;
  46.         } else if (CUR_EQUIP_VALUE(EQUIP_SHIELD) == 2 && LINK_AGE_IN_YEARS == YEARS_CHILD) {
  47.             EquipedStance = 3;
  48.         } else {
  49.             //Link is idle so revert to 0
  50.             EquipedStance = 0;
  51.         }
  52.        
  53.         if(SelectedMode == 18){
  54.             //Apply Random function
  55.             s16 SwitchAtFrame = 0;
  56.             s16 CurAnimDuration = 0;
  57.             if (FrameCountSinceLastAnim == 0) {
  58.                 //When opening Kaleido this will be passed one time
  59.                 SelectedAnim = rand() % (AnimArraySize - 0);
  60.                 if (SelectedAnim == 0){
  61.                     //prevent loading 0 that would result to a crash.
  62.                     SelectedAnim = 1;
  63.                 }
  64.             } else if (FrameCountSinceLastAnim >= 1){
  65.                 SwitchAtFrame = Animation_GetLastFrame(PauseMenuAnimSet[SelectedAnim][EquipedStance]);
  66.                 CurAnimDuration = Animation_GetLastFrame(PauseMenuAnimSet[SelectedAnim][EquipedStance]);
  67.                 if (SwitchAtFrame < MinFrameCount) {
  68.                     //Animation frame count is lower than minimal wait time then we wait for another round.
  69.                     //This will be looped to always add current animation time if that still lower than minimum time
  70.                     while (SwitchAtFrame < MinFrameCount) {
  71.                         SwitchAtFrame = SwitchAtFrame+CurAnimDuration;
  72.                     }
  73.                 } else if (CurAnimDuration >= MinFrameCount){
  74.                     //Since we have more (or same) animation time than min duration we set the wait time to animation time.
  75.                     SwitchAtFrame = CurAnimDuration;
  76.                 }
  77.                 if (FrameCountSinceLastAnim >= SwitchAtFrame) {
  78.                     SelectedAnim = rand() % (AnimArraySize - 0);
  79.                     if (SelectedAnim == 0){
  80.                         //prevent loading 0 that would result to a crash.
  81.                         SelectedAnim = 1;
  82.                     }
  83.                     FrameCountSinceLastAnim = 1;
  84.                 }
  85.                 anim = PauseMenuAnimSet[SelectedAnim][EquipedStance];
  86.             }
  87.             FrameCountSinceLastAnim++;
  88.         } else if (SelectedMode == 19) {
  89.             //When opening Kaleido this will be passed one time
  90.             if (FrameCountSinceLastAnim < 1) {
  91.                 SelectedAnim = rand() % (AnimArraySize - 0);
  92.                 FrameCountSinceLastAnim++;
  93.                 if (SelectedAnim == 0){
  94.                     //prevent loading 0 that would result to a crash.
  95.                     SelectedAnim = 1;
  96.                 }
  97.                 FrameCountSinceLastAnim = 1;
  98.             }
  99.             if(CHECK_BTN_ALL(p1Input->press.button, BTN_B) || CHECK_BTN_ALL(p1Input->press.button, BTN_START)) {
  100.                 FrameCountSinceLastAnim = 0;
  101.             }
  102.             anim = PauseMenuAnimSet[SelectedAnim][EquipedStance];
  103.         } else if (SelectedMode < 18) {
  104.             //Not random so we place our CVar as SelectedAnim
  105.             SelectedAnim = SelectedMode;
  106.             anim = PauseMenuAnimSet[SelectedAnim][EquipedStance];
  107.         }
  108.  
  109.         if (CVar_GetS32("gPauseTriforce", 0)) {
  110.             anim = gPlayerAnim_002D00;
  111.             sword = 0;
  112.             shield = 0;
  113.         }
  114.  
  115.         if (skelAnime->animation != anim) {
  116.             LinkAnimation_Change(globalCtx, skelAnime, anim, 1.0f, 0.0f, Animation_GetLastFrame(anim), ANIMMODE_LOOP,
  117.                                  -6.0f);
  118.         }
  119.  
  120.         LinkAnimation_Update(globalCtx, skelAnime);
  121.  
  122.         if (!LINK_IS_ADULT) {
  123.             // Link is placed too far up by default when animating
  124.             at.y += 60;
  125.         }
  126.     } else {
  127.  
  128.         if (!LINK_IS_ADULT) {
  129.             if (shield == PLAYER_SHIELD_DEKU) {
  130.                 srcTable = D_040020D0;
  131.             } else {
  132.                 srcTable = D_04002040;
  133.             }
  134.         } else {
  135.             if (sword == 3) {
  136.                 srcTable = D_04002160;
  137.             } else if (shield != PLAYER_SHIELD_NONE) {
  138.                 srcTable = D_04002280;
  139.             } else {
  140.                 srcTable = D_040021F0;
  141.             }
  142.         }
  143.  
  144.         srcTable = ResourceMgr_LoadArrayByNameAsVec3s(srcTable);
  145.         destTable = skelAnime->jointTable;
  146.         for (i = 0; i < skelAnime->limbCount; i++) {
  147.             *destTable++ = *srcTable++;
  148.         }
  149.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement