@@ -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, CAnimBlendHierarchySAInterface * pAnimHierarchy, int flags, float fBlendDelta )
3700
+ CAnimBlendHierarchySAInterface * CClientGame::StaticBlendAnimationHandler ( RpClump * pClump, CAnimBlendHierarchySAInterface * pAnimHierarchy, int flags, float fBlendDelta )
3701
3701
{
3702
- g_pClientGame->BlendAnimationHandler ( pClump, pAnimHierarchy, flags, fBlendDelta );
3702
+ return g_pClientGame->BlendAnimationHandler ( pClump, pAnimHierarchy, flags, fBlendDelta );
3703
3703
}
3704
3704
3705
3705
void CClientGame::StaticPreWorldProcessHandler ( void )
@@ -3983,37 +3983,136 @@ 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 );
3991
+ /*
3992
+ hCAnimBlendAssocGroup_CopyAnimation CAnimBlendAssocGroup_CopyAnimation = (hCAnimBlendAssocGroup_CopyAnimation)0x004CE130;
3993
+ hUncompressAnimation UncompressAnimation = (hUncompressAnimation)0x4d41c0;
3994
+ hCAnimBlendAssoc_Constructor_staticAssocRef OLD_CAnimBlendAssoc_Constructor_staticAssocRef = (hCAnimBlendAssoc_Constructor_staticAssocRef)0x4CF080;
3995
+ hCAnimBlendStaticAssoc_Constructor OLD_CAnimBlendStaticAssoc_Constructor = *(hCAnimBlendStaticAssoc_Constructor)0x4CE940;
3996
+ hCAnimBlendStaticAssoc_Init OLD_CAnimBlendStaticAssoc_Init = (hCAnimBlendStaticAssoc_Init)0x004CEC20;
3989
3997
3990
3998
CAnimManager * pAnimationManager = g_pGame->GetAnimManager();
3991
-
3999
+ auto pOriginalAnimStaticAssoc = pAnimationManager->GetAnimStaticAssociation ( animGroup, animID );
4000
+
3992
4001
CClientPed * pClientPed = pAnimationManager->GetPedPointerFromMap ( pClump );
3993
4002
if ( pClientPed != nullptr )
3994
4003
{
3995
- if ( pClientPed->isNextAnimationCustom () )
4004
+ printf("AddAnimationHandler: found client ped pointer from map\n");
4005
+
4006
+ const SString & strBlockName = pClientPed->GetNextAnimationCustomBlockName ( );
4007
+ CClientIFP * pIFP = GetIFPPointerFromMap ( strBlockName );
4008
+ if ( pIFP )
3996
4009
{
3997
- auto pAnimStaticAssoc = pAnimationManager->GetAnimStaticAssociation ( animGroup, animID );
3998
- if ( pAnimationManager->isGateWayAnimationHierarchy ( pAnimStaticAssoc->pAnimHeirarchy ) )
3999
- {
4000
- printf (" pAnimationManager->isGateWayAnimationHierarchy() is true\n " );
4010
+ printf("AddAnimationHandler: found IFP pointer from map\n");
4011
+
4012
+ const SString & strAnimationName = pClientPed->GetNextAnimationCustomName ( );
4013
+ _CAnimBlendHierarchy * pCustomAnimBlendHierarchy = (_CAnimBlendHierarchy *)pIFP->GetAnimationHierarchy ( strAnimationName );
4014
+ if ( pCustomAnimBlendHierarchy != nullptr )
4015
+ {
4016
+ printf("AddAnimationHandler:got custom animation hierarchy\n");
4017
+
4018
+ if ( animGroup == 0 && animID == 55 ) // if it's crouch animation
4019
+ {
4020
+ printf("AddAnimationHandler: Internal GTA Courch Animation Total Sequences: %d\n", pOriginalAnimStaticAssoc->pAnimHeirarchy->usNumSequences);
4001
4021
4002
- pClientPed->setNextAnimationNormal ( );
4022
+
4023
+ auto pCrouchAnimStaticAssoc = pAnimationManager->GetAnimStaticAssociation ( 0, 55 ); // 0, 55 for crouch animation
4024
+
4025
+ CAnimBlendStaticAssoc * pOriginalAnimStaticAssoc = (CAnimBlendStaticAssoc *)pCrouchAnimStaticAssoc;
4026
+
4027
+ // let's play the original crouch animation instead for testing ^^
4028
+ pCustomAnimBlendHierarchy = pOriginalAnimStaticAssoc->m_pAnimBlendHier;
4029
+
4030
+ pCustomAnimBlendHierarchy->m_hashKey = pOriginalAnimStaticAssoc->m_pAnimBlendHier->m_hashKey;
4031
+ pCustomAnimBlendHierarchy->m_nAnimBlockId = pOriginalAnimStaticAssoc->m_pAnimBlendHier->m_nAnimBlockId;
4032
+
4033
+ CAnimBlendStaticAssoc CustomAnimStaticAssoc;
4034
+ OLD_CAnimBlendStaticAssoc_Constructor ( &CustomAnimStaticAssoc );
4035
+
4036
+ CustomAnimStaticAssoc.m_nFlags = pOriginalAnimStaticAssoc->m_nFlags;
4037
+
4038
+ OLD_CAnimBlendStaticAssoc_Init ( &CustomAnimStaticAssoc, pClump, pCustomAnimBlendHierarchy);
4039
+
4040
+ CustomAnimStaticAssoc.m_nAnimGroup = pOriginalAnimStaticAssoc->m_nAnimGroup;
4041
+ CustomAnimStaticAssoc.m_nAnimID = pOriginalAnimStaticAssoc->m_nAnimID;
4042
+
4043
+ UncompressAnimation ( CustomAnimStaticAssoc.m_pAnimBlendHier );
4044
+ CAnimBlendAssoc * pAnimAssoc = (CAnimBlendAssoc *)malloc(sizeof(CAnimBlendAssoc));
4045
+ OLD_CAnimBlendAssoc_Constructor_staticAssocRef ( pAnimAssoc, CustomAnimStaticAssoc);
4046
+
4047
+ pAnimAssoc->m_nAnimGroup = pOriginalAnimStaticAssoc->m_nAnimGroup;
4048
+ pAnimAssoc->m_nFlags = pOriginalAnimStaticAssoc->m_nFlags;
4049
+
4050
+ printf("AddAnimationHandler: returning pAnimAssoc\n");
4051
+ return (CAnimBlendAssociationSAInterface * ) pAnimAssoc;
4052
+ //auto pAnimStaticAssoc = pAnimationManager->GetAnimStaticAssociation ( 0, 55 ); // 0, 55 for crouch animation
4053
+ //return pAnimStaticAssoc->pAnimHeirarchy;
4054
+ }
4055
+ }
4056
+ else
4057
+ {
4058
+ printf ("AddAnimationHandler: could not find IFP animation hierarchy '%s'\n", strAnimationName.c_str());
4003
4059
}
4004
4060
}
4061
+ else
4062
+ {
4063
+ printf("AddAnimationHandler: could not find IFP block name '%s'\n", strBlockName.c_str());
4064
+ }
4005
4065
}
4006
-
4066
+
4067
+ printf("AddAnimationHandler: executing normal flow instead of custom animation\n");
4068
+ */
4069
+ // normal flow
4007
4070
std::unique_ptr < CAnimBlendAssocGroup > pAnimAssocGroup = g_pGame->CreateAnimBlendAssocGroup ( animGroup );
4008
4071
CAnimBlendAssociationSAInterface * pAnimAssociation = pAnimAssocGroup->CopyAnimation ( animID );
4009
4072
4073
+ printf (" \n " );
4074
+
4010
4075
return pAnimAssociation;
4011
4076
}
4012
4077
4013
- void CClientGame::BlendAnimationHandler ( RpClump * pClump, CAnimBlendHierarchySAInterface * pAnimHierarchy, int flags, float fBlendDelta )
4078
+ CAnimBlendHierarchySAInterface * CClientGame::BlendAnimationHandler ( RpClump * pClump, CAnimBlendHierarchySAInterface * pAnimHierarchy, int flags, float fBlendDelta )
4014
4079
{
4015
- // CClientPed * pPed = m_pPedManager->Get ( pClump, true );
4016
- printf (" CClientGame::BlendAnimationHandler called! pClump: %p\n " , pClump);
4080
+ printf (" CClientGame::BlendAnimationHandler called\n " );
4081
+
4082
+ CAnimManager * pAnimationManager = g_pGame->GetAnimManager ();
4083
+ CClientPed * pClientPed = pAnimationManager->GetPedPointerFromMap ( pClump );
4084
+ if ( pClientPed != nullptr )
4085
+ {
4086
+ if ( pClientPed->isNextAnimationCustom () )
4087
+ {
4088
+ const SString & strBlockName = pClientPed->GetNextAnimationCustomBlockName ( );
4089
+ CClientIFP * pIFP = GetIFPPointerFromMap ( strBlockName );
4090
+ if ( pIFP )
4091
+ {
4092
+ const SString & strAnimationName = pClientPed->GetNextAnimationCustomName ( );
4093
+ auto pCustomAnimBlendHierarchy = pIFP->GetAnimationHierarchy ( strAnimationName );
4094
+ if ( pCustomAnimBlendHierarchy != nullptr )
4095
+ {
4096
+ // Modifying a hierarchy like this is just bad, it's much better to create a new CAnimBlendHierarchySAInterface for every animation
4097
+ // and then delete it once animation is over
4098
+ pCustomAnimBlendHierarchy->iHashKey = pAnimHierarchy->iHashKey ;
4099
+ pCustomAnimBlendHierarchy->iAnimBlockID = pAnimHierarchy->iAnimBlockID ;
4100
+ pClientPed->setNextAnimationNormal ( );
4101
+ return pCustomAnimBlendHierarchy;
4102
+ }
4103
+ else
4104
+ {
4105
+ printf (" BlendAnimationHandler: could not find IFP animation hierarchy '%s'\n " , strAnimationName.c_str ());
4106
+ }
4107
+ }
4108
+ else
4109
+ {
4110
+ printf (" BlendAnimationHandler: could not find IFP block name '%s'\n " , strBlockName.c_str ());
4111
+ }
4112
+ }
4113
+ pClientPed->setNextAnimationNormal ( );;
4114
+ }
4115
+ return pAnimHierarchy;
4017
4116
}
4018
4117
4019
4118
bool CClientGame::ProcessCollisionHandler ( CEntitySAInterface* pThisInterface, CEntitySAInterface* pOtherInterface )
@@ -6746,22 +6845,24 @@ void CClientGame::RestreamModel ( unsigned short usModel )
6746
6845
6747
6846
}
6748
6847
6749
- void CClientGame::InsertIFPPointerToMap ( SString strBlockName, CClientIFP * pIFP )
6848
+ void CClientGame::InsertIFPPointerToMap ( const SString & strBlockName, CClientIFP * pIFP )
6750
6849
{
6751
- if ( m_mapOfIfpPointers.count ( strBlockName ) == 0 )
6850
+ const SString mapKey = strBlockName.ToLower ( );
6851
+ if ( m_mapOfIfpPointers.count ( mapKey ) == 0 )
6752
6852
{
6753
- m_mapOfIfpPointers [ strBlockName ] = pIFP;
6853
+ m_mapOfIfpPointers [ mapKey ] = pIFP;
6754
6854
}
6755
6855
}
6756
6856
6757
- void CClientGame::RemoveIFPPointerFromMap ( SString strBlockName )
6857
+ void CClientGame::RemoveIFPPointerFromMap ( const SString & strBlockName )
6758
6858
{
6759
- m_mapOfIfpPointers.erase ( strBlockName );
6859
+ m_mapOfIfpPointers.erase ( strBlockName. ToLower ( ) );
6760
6860
}
6761
6861
6762
- CClientIFP * CClientGame::GetIFPPointerFromMap ( SString strBlockName )
6862
+ CClientIFP * CClientGame::GetIFPPointerFromMap ( const SString & strBlockName )
6763
6863
{
6764
- std::map < SString, CClientIFP * >::iterator it = m_mapOfIfpPointers.find ( strBlockName );
6864
+ const SString mapKey = strBlockName.ToLower ( );
6865
+ std::map < SString, CClientIFP * >::iterator it = m_mapOfIfpPointers.find ( mapKey );
6765
6866
if ( it != m_mapOfIfpPointers.end ( ) )
6766
6867
{
6767
6868
return it->second ;
0 commit comments