@@ -3989,96 +3989,65 @@ CAnimBlendAssociationSAInterface * CClientGame::AddAnimationHandler ( RpClump *
39893989{
39903990 printf ( " AddAnimationHandler called! pClump, GroupID, AnimID: %p, %d, %d\n " , (void *)pClump, animGroup, animID );
39913991
3992- CClientPed * pClientPed = GetClientPedByClump ( *pClump ); // pAnimationManager->GetPedPointerFromMap ( pClump ); //m_pRootEntity->GetClientPedByClump ( *pClump );
3993- if ( pClientPed != nullptr )
3994- {
3995- // pClientPed->setCurrentAnimationCustom ( false );
3996- }
3997- /*
39983992 hCAnimBlendAssocGroup_CopyAnimation CAnimBlendAssocGroup_CopyAnimation = (hCAnimBlendAssocGroup_CopyAnimation)0x004CE130 ;
39993993 hUncompressAnimation UncompressAnimation = (hUncompressAnimation)0x4d41c0 ;
40003994 hCAnimBlendAssoc_Constructor_staticAssocRef OLD_CAnimBlendAssoc_Constructor_staticAssocRef = (hCAnimBlendAssoc_Constructor_staticAssocRef)0x4CF080 ;
40013995 hCAnimBlendStaticAssoc_Constructor OLD_CAnimBlendStaticAssoc_Constructor = *(hCAnimBlendStaticAssoc_Constructor)0x4CE940 ;
40023996 hCAnimBlendStaticAssoc_Init OLD_CAnimBlendStaticAssoc_Init = (hCAnimBlendStaticAssoc_Init)0x004CEC20 ;
4003-
4004- CAnimManager * pAnimationManager = g_pGame->GetAnimManager();
4005- auto pOriginalAnimStaticAssoc = pAnimationManager->GetAnimStaticAssociation ( animGroup, animID );
4006-
4007- CClientPed * pClientPed = pAnimationManager->GetPedPointerFromMap ( pClump );
4008- if ( pClientPed != nullptr )
4009- {
4010- printf("AddAnimationHandler: found client ped pointer from map\n");
4011-
4012- const SString & strBlockName = pClientPed->GetNextAnimationCustomBlockName ( );
4013- CClientIFP * pIFP = GetIFPPointerFromMap ( strBlockName );
4014- if ( pIFP )
4015- {
4016- printf("AddAnimationHandler: found IFP pointer from map\n");
4017-
4018- const SString & strAnimationName = pClientPed->GetNextAnimationCustomName ( );
4019- _CAnimBlendHierarchy * pCustomAnimBlendHierarchy = (_CAnimBlendHierarchy *)pIFP->GetAnimationHierarchy ( strAnimationName );
4020- if ( pCustomAnimBlendHierarchy != nullptr )
4021- {
4022- printf("AddAnimationHandler:got custom animation hierarchy\n");
4023-
4024- if ( animGroup == 0 && animID == 55 ) // if it's crouch animation
4025- {
4026- printf("AddAnimationHandler: Internal GTA Courch Animation Total Sequences: %d\n", pOriginalAnimStaticAssoc->pAnimHeirarchy->usNumSequences);
4027-
4028-
4029- auto pCrouchAnimStaticAssoc = pAnimationManager->GetAnimStaticAssociation ( 0, 55 ); // 0, 55 for crouch animation
4030-
4031- CAnimBlendStaticAssoc * pOriginalAnimStaticAssoc = (CAnimBlendStaticAssoc *)pCrouchAnimStaticAssoc;
4032-
4033- // let's play the original crouch animation instead for testing ^^
4034- pCustomAnimBlendHierarchy = pOriginalAnimStaticAssoc->m_pAnimBlendHier;
4035-
4036- pCustomAnimBlendHierarchy->m_hashKey = pOriginalAnimStaticAssoc->m_pAnimBlendHier->m_hashKey;
4037- pCustomAnimBlendHierarchy->m_nAnimBlockId = pOriginalAnimStaticAssoc->m_pAnimBlendHier->m_nAnimBlockId;
4038-
4039- CAnimBlendStaticAssoc CustomAnimStaticAssoc;
4040- OLD_CAnimBlendStaticAssoc_Constructor ( &CustomAnimStaticAssoc );
4041-
4042- CustomAnimStaticAssoc.m_nFlags = pOriginalAnimStaticAssoc->m_nFlags;
4043-
4044- OLD_CAnimBlendStaticAssoc_Init ( &CustomAnimStaticAssoc, pClump, pCustomAnimBlendHierarchy);
4045-
4046- CustomAnimStaticAssoc.m_nAnimGroup = pOriginalAnimStaticAssoc->m_nAnimGroup;
4047- CustomAnimStaticAssoc.m_nAnimID = pOriginalAnimStaticAssoc->m_nAnimID;
4048-
4049- UncompressAnimation ( CustomAnimStaticAssoc.m_pAnimBlendHier );
4050- CAnimBlendAssoc * pAnimAssoc = (CAnimBlendAssoc *)malloc(sizeof(CAnimBlendAssoc));
4051- OLD_CAnimBlendAssoc_Constructor_staticAssocRef ( pAnimAssoc, CustomAnimStaticAssoc);
4052-
4053- pAnimAssoc->m_nAnimGroup = pOriginalAnimStaticAssoc->m_nAnimGroup;
4054- pAnimAssoc->m_nFlags = pOriginalAnimStaticAssoc->m_nFlags;
4055-
4056- printf("AddAnimationHandler: returning pAnimAssoc\n");
4057- return (CAnimBlendAssociationSAInterface * ) pAnimAssoc;
4058- //auto pAnimStaticAssoc = pAnimationManager->GetAnimStaticAssociation ( 0, 55 ); // 0, 55 for crouch animation
4059- //return pAnimStaticAssoc->pAnimHeirarchy;
4060- }
4061- }
4062- else
4063- {
4064- printf ("AddAnimationHandler: could not find IFP animation hierarchy '%s'\n", strAnimationName.c_str());
4065- }
4066- }
4067- else
4068- {
4069- printf("AddAnimationHandler: could not find IFP block name '%s'\n", strBlockName.c_str());
4070- }
4071- }
4072-
4073- printf("AddAnimationHandler: executing normal flow instead of custom animation\n");
4074- */
4075- // normal flow
4076- std::unique_ptr < CAnimBlendAssocGroup > pAnimAssocGroup = g_pGame->CreateAnimBlendAssocGroup ( animGroup );
4077- CAnimBlendAssociationSAInterface * pAnimAssociation = pAnimAssocGroup->CopyAnimation ( animID );
4078-
4079- printf (" \n " );
4080-
4081- return pAnimAssociation;
3997+ hCAnimBlendAssoc_SyncAnimation CAnimBlendAssoc_SyncAnimation = (hCAnimBlendAssoc_SyncAnimation)0x004CEB40 ;
3998+ hCAnimBlendAssoc_Start CAnimBlendAssoc_Start = (hCAnimBlendAssoc_Start)0x004CEB70 ;
3999+
4000+ CAnimBlendAssoc * pAnimAssoc; // esi
4001+ int *clumpData; // edi
4002+ int *next; // eax
4003+ DWORD *tempAssoc; // eax
4004+ int *nextAssoc; // ecx
4005+ // We need to remove this line and add some code here for running animations simultaneously
4006+ pAnimAssoc = CAnimBlendAssocGroup_CopyAnimation ((DWORD *) (*(DWORD*)0x00B4EA34 ) + 5 * animGroup, animID);
4007+
4008+ // //ofs << "Done calling CAnimBlendAssocGroup_CopyAnimation " << std::endl;
4009+
4010+ clumpData = *(int **)( (*(DWORD*)0xB5F878 ) + ((int )pClump));
4011+
4012+ if ( !((*((BYTE *)pAnimAssoc + 46 ) >> 5 ) & 1 ) )
4013+ goto LABEL_5;
4014+ next = (int *)*clumpData;
4015+ if ( !*clumpData )
4016+ goto LABEL_5;
4017+ while ( !((*((BYTE *)next + 42 ) >> 5 ) & 1 ) )
4018+ {
4019+ next = (int *)*next;
4020+ if ( !next )
4021+ goto LABEL_5;
4022+ }
4023+ if ( next )
4024+ {
4025+ CAnimBlendAssoc_SyncAnimation (pAnimAssoc, (CAnimBlendAssoc *)(next - 1 ));
4026+ *((BYTE *)pAnimAssoc + 46 ) |= 1u ;
4027+ }
4028+ else
4029+ {
4030+ LABEL_5:
4031+ CAnimBlendAssoc_Start (pAnimAssoc, 0 );
4032+ }
4033+
4034+ tempAssoc = ((DWORD*)pAnimAssoc) + 1 ;
4035+
4036+ if ( *clumpData ) // clumpData->nextAssoc
4037+ *(DWORD *)(*clumpData + 4 ) = (DWORD)tempAssoc;
4038+
4039+ nextAssoc = (int *)*clumpData;
4040+
4041+ DWORD * dwpAnimAssoc = (DWORD*) pAnimAssoc;
4042+
4043+ dwpAnimAssoc[2 ] = (DWORD)clumpData;
4044+ // pAnimAssoc[2] = clumpData;
4045+
4046+ *tempAssoc = (DWORD)nextAssoc;
4047+
4048+ *clumpData = (int )tempAssoc;
4049+
4050+ return (CAnimBlendAssociationSAInterface *)pAnimAssoc;
40824051}
40834052
40844053CAnimBlendHierarchySAInterface * CClientGame::BlendAnimationHandler ( RpClump * pClump, CAnimBlendHierarchySAInterface * pAnimHierarchy, int flags, float fBlendDelta )
0 commit comments