@@ -3697,9 +3697,9 @@ CAnimBlendAssociationSAInterface * CClientGame::StaticAddAnimationHandler ( RpCl
3697
3697
return g_pClientGame->AddAnimationHandler ( pClump, animGroup, animID );
3698
3698
}
3699
3699
3700
- void CClientGame::StaticBlendAnimationHandler ( RpClump * pClump, AssocGroupId animGroup, AnimationId animID , float fBlendDelta )
3700
+ CAnimBlendHierarchySAInterface * CClientGame::StaticBlendAnimationHandler ( RpClump * pClump, CAnimBlendHierarchySAInterface * pAnimHierarchy, int flags , float fBlendDelta )
3701
3701
{
3702
- g_pClientGame->BlendAnimationHandler ( pClump, animGroup, animID , fBlendDelta );
3702
+ return g_pClientGame->BlendAnimationHandler ( pClump, pAnimHierarchy, flags , fBlendDelta );
3703
3703
}
3704
3704
3705
3705
void CClientGame::StaticPreWorldProcessHandler ( void )
@@ -3983,38 +3983,151 @@ bool CClientGame::ChokingHandler ( unsigned char ucWeaponType )
3983
3983
return m_pLocalPlayer->CallEvent ( " onClientPlayerChoke" , Arguments, true );
3984
3984
}
3985
3985
3986
+ #include < ../game_sa/CAnimBlendHierarchySA.h> // ---------------- REMOVE THIS LATER
3987
+
3986
3988
CAnimBlendAssociationSAInterface * CClientGame::AddAnimationHandler ( RpClump * pClump, AssocGroupId animGroup, AnimationId animID )
3987
3989
{
3988
3990
printf ( " AddAnimationHandler called! pClump, GroupID, AnimID: %p, %d, %d\n " , (void *)pClump, animGroup, animID );
3989
3991
3992
+ CClientPed * pClientPed = GetClientPedByClump ( *pClump ); // pAnimationManager->GetPedPointerFromMap ( pClump ); //m_pRootEntity->GetClientPedByClump ( *pClump );
3993
+ if ( pClientPed != nullptr )
3994
+ {
3995
+ // pClientPed->setCurrentAnimationCustom ( false );
3996
+ }
3997
+ /*
3998
+ hCAnimBlendAssocGroup_CopyAnimation CAnimBlendAssocGroup_CopyAnimation = (hCAnimBlendAssocGroup_CopyAnimation)0x004CE130;
3999
+ hUncompressAnimation UncompressAnimation = (hUncompressAnimation)0x4d41c0;
4000
+ hCAnimBlendAssoc_Constructor_staticAssocRef OLD_CAnimBlendAssoc_Constructor_staticAssocRef = (hCAnimBlendAssoc_Constructor_staticAssocRef)0x4CF080;
4001
+ hCAnimBlendStaticAssoc_Constructor OLD_CAnimBlendStaticAssoc_Constructor = *(hCAnimBlendStaticAssoc_Constructor)0x4CE940;
4002
+ hCAnimBlendStaticAssoc_Init OLD_CAnimBlendStaticAssoc_Init = (hCAnimBlendStaticAssoc_Init)0x004CEC20;
4003
+
3990
4004
CAnimManager * pAnimationManager = g_pGame->GetAnimManager();
3991
-
4005
+ auto pOriginalAnimStaticAssoc = pAnimationManager->GetAnimStaticAssociation ( animGroup, animID );
4006
+
3992
4007
CClientPed * pClientPed = pAnimationManager->GetPedPointerFromMap ( pClump );
3993
4008
if ( pClientPed != nullptr )
3994
4009
{
3995
- if ( pClientPed->isNextAnimationCustom () )
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 )
3996
4015
{
3997
- printf (" pClientPed->isNextAnimationCustom () is true \n " );
4016
+ printf("AddAnimationHandler: found IFP pointer from map \n");
3998
4017
3999
- auto pAnimStaticAssoc = pAnimationManager->GetAnimStaticAssociation ( animGroup, animID );
4000
- if ( pAnimationManager->isGateWayAnimationHierarchy ( pAnimStaticAssoc->pAnimHeirarchy ) )
4001
- {
4002
- printf (" pAnimationManager->isGateWayAnimationHierarchy() is true\n " );
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;
4003
4035
4004
- pClientPed->setNextAnimationNormal ( );
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());
4005
4065
}
4006
4066
}
4067
+ else
4068
+ {
4069
+ printf("AddAnimationHandler: could not find IFP block name '%s'\n", strBlockName.c_str());
4070
+ }
4007
4071
}
4008
-
4072
+
4073
+ printf("AddAnimationHandler: executing normal flow instead of custom animation\n");
4074
+ */
4075
+ // normal flow
4009
4076
std::unique_ptr < CAnimBlendAssocGroup > pAnimAssocGroup = g_pGame->CreateAnimBlendAssocGroup ( animGroup );
4010
4077
CAnimBlendAssociationSAInterface * pAnimAssociation = pAnimAssocGroup->CopyAnimation ( animID );
4011
4078
4079
+ printf (" \n " );
4080
+
4012
4081
return pAnimAssociation;
4013
4082
}
4014
4083
4015
- void CClientGame::BlendAnimationHandler ( RpClump * pClump, AssocGroupId animGroup, AnimationId animID , float fBlendDelta )
4084
+ CAnimBlendHierarchySAInterface * CClientGame::BlendAnimationHandler ( RpClump * pClump, CAnimBlendHierarchySAInterface * pAnimHierarchy, int flags , float fBlendDelta )
4016
4085
{
4017
- // CClientPed * pPed = m_pPedManager->Get ( pClump, true );
4086
+ printf (" CClientGame::BlendAnimationHandler called | pClump: %p\n " , (void *)pClump);
4087
+
4088
+ CAnimManager * pAnimationManager = g_pGame->GetAnimManager ();
4089
+ CClientPed * pClientPed = GetClientPedByClump ( *pClump ); // pAnimationManager->GetPedPointerFromMap ( pClump ); //m_pRootEntity->GetClientPedByClump ( *pClump );
4090
+ if ( pClientPed != nullptr )
4091
+ {
4092
+ printf (" BlendAnimationHandler: Found pClientPed\n " );
4093
+ if ( pClientPed->isNextAnimationCustom () )
4094
+ {
4095
+ const SString & strBlockName = pClientPed->GetNextAnimationCustomBlockName ( );
4096
+ CClientIFP * pIFP = GetIFPPointerFromMap ( strBlockName );
4097
+ if ( pIFP )
4098
+ {
4099
+ const SString & strAnimationName = pClientPed->GetNextAnimationCustomName ( );
4100
+ auto pCustomAnimBlendHierarchy = pIFP->GetAnimationHierarchy ( strAnimationName );
4101
+ if ( pCustomAnimBlendHierarchy != nullptr )
4102
+ {
4103
+ printf (" BlendAnimationHandler: Found Hierarchy, returning \n " );
4104
+
4105
+ pClientPed->setCurrentAnimationCustom ( true );
4106
+
4107
+ // Modifying a hierarchy like this is just bad, it's much better to create a new CAnimBlendHierarchySAInterface for every animation
4108
+ // and then delete it once animation is over
4109
+ pCustomAnimBlendHierarchy->iHashKey = pAnimHierarchy->iHashKey ;
4110
+ pCustomAnimBlendHierarchy->iAnimBlockID = pAnimHierarchy->iAnimBlockID ;
4111
+ pClientPed->setNextAnimationNormal ( );
4112
+ return pCustomAnimBlendHierarchy;
4113
+ }
4114
+ else
4115
+ {
4116
+ printf (" BlendAnimationHandler: could not find IFP animation hierarchy '%s'\n " , strAnimationName.c_str ());
4117
+ }
4118
+ }
4119
+ else
4120
+ {
4121
+ printf (" BlendAnimationHandler: could not find IFP block name '%s'\n " , strBlockName.c_str ());
4122
+ }
4123
+ }
4124
+ else
4125
+ {
4126
+ pClientPed->setCurrentAnimationCustom ( false );
4127
+ }
4128
+ pClientPed->setNextAnimationNormal ( );
4129
+ }
4130
+ return pAnimHierarchy;
4018
4131
}
4019
4132
4020
4133
bool CClientGame::ProcessCollisionHandler ( CEntitySAInterface* pThisInterface, CEntitySAInterface* pOtherInterface )
@@ -6747,25 +6860,60 @@ void CClientGame::RestreamModel ( unsigned short usModel )
6747
6860
6748
6861
}
6749
6862
6750
- void CClientGame::InsertIFPPointerToMap ( SString strBlockName, CClientIFP * pIFP )
6863
+ void CClientGame::InsertIFPPointerToMap ( const SString & strBlockName, CClientIFP * pIFP )
6751
6864
{
6752
- if ( m_mapOfIfpPointers.count ( strBlockName ) == 0 )
6865
+ const SString mapKey = strBlockName.ToLower ( );
6866
+ if ( m_mapOfIfpPointers.count ( mapKey ) == 0 )
6753
6867
{
6754
- m_mapOfIfpPointers [ strBlockName ] = pIFP;
6868
+ m_mapOfIfpPointers [ mapKey ] = pIFP;
6755
6869
}
6756
6870
}
6757
6871
6758
- void CClientGame::RemoveIFPPointerFromMap ( SString strBlockName )
6872
+ void CClientGame::RemoveIFPPointerFromMap ( const SString & strBlockName )
6759
6873
{
6760
- m_mapOfIfpPointers.erase ( strBlockName );
6874
+ m_mapOfIfpPointers.erase ( strBlockName. ToLower ( ) );
6761
6875
}
6762
6876
6763
- CClientIFP * CClientGame::GetIFPPointerFromMap ( SString strBlockName )
6877
+ CClientIFP * CClientGame::GetIFPPointerFromMap ( const SString & strBlockName )
6764
6878
{
6765
- std::map < SString, CClientIFP * >::iterator it = m_mapOfIfpPointers.find ( strBlockName );
6879
+ const SString mapKey = strBlockName.ToLower ( );
6880
+ std::map < SString, CClientIFP * >::iterator it = m_mapOfIfpPointers.find ( mapKey );
6766
6881
if ( it != m_mapOfIfpPointers.end ( ) )
6767
6882
{
6768
6883
return it->second ;
6769
6884
}
6770
6885
return nullptr ;
6771
6886
}
6887
+
6888
+ void CClientGame::InsertPedPointerToMap ( CClientPed * pPed )
6889
+ {
6890
+ if ( m_mapOfPedPointers.count ( pPed ) == 0 )
6891
+ {
6892
+ m_mapOfPedPointers [ pPed ] = true ;
6893
+ }
6894
+ }
6895
+
6896
+ void CClientGame::RemovePedPointerFromMap ( CClientPed * pPed )
6897
+ {
6898
+ m_mapOfPedPointers.erase ( pPed );
6899
+ }
6900
+
6901
+ CClientPed * CClientGame::GetClientPedByClump ( const RpClump & Clump )
6902
+ {
6903
+ for ( auto it = m_mapOfPedPointers.begin (); it != m_mapOfPedPointers.end (); it++ )
6904
+ {
6905
+ CEntity * pEntity = it->first ->GetGameEntity ();
6906
+ if ( pEntity != nullptr )
6907
+ {
6908
+ if ( pEntity->GetRpClump () != nullptr )
6909
+ {
6910
+ const RpClump & entityClump = *pEntity->GetRpClump ();
6911
+ if ( std::addressof ( entityClump ) == std::addressof ( Clump ) )
6912
+ {
6913
+ return it->first ;
6914
+ }
6915
+ }
6916
+ }
6917
+ }
6918
+ return nullptr ;
6919
+ }
0 commit comments