Skip to content

Commit aa722ff

Browse files
authored
Merge pull request #1 from saml1er/custom_ifp_animations
Custom ifp animations
2 parents ceb5663 + 80aec0e commit aa722ff

25 files changed

+2533
-28
lines changed

Client/game_sa/CAnimBlendHierarchySA.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class CAnimBlendHierarchySAInterface
2727
{
2828
public:
2929
int GetIndex ( void );
30-
int iHashKey;
30+
unsigned int iHashKey;
3131
CAnimBlendSequence * pSequences;
3232
unsigned short usNumSequences;
3333
BYTE pad;

Client/game_sa/CAnimBlendStaticAssociationSA.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@ class CAnimBlendHierarchy;
2424

2525
class CAnimBlendStaticAssociationSAInterface
2626
{
27+
protected:
28+
void * vTable;
2729
public:
28-
BYTE pad [ 6 ];
30+
unsigned short nNumBlendNodes;
2931
short sAnimID;
3032
short sAnimGroup;
3133
short sFlags;
32-
BYTE pad2 [ 4 ];
34+
DWORD * pAnimBlendNodesSequenceArray;
3335
CAnimBlendHierarchySAInterface * pAnimHeirarchy;
3436
};
3537

Client/game_sa/CAnimManagerSA.cpp

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,9 @@ CAnimBlendAssociation * CAnimManagerSA::CreateAnimAssociation ( AssocGroupId ani
256256
}
257257

258258

259-
CAnimBlendAssociation * CAnimManagerSA::GetAnimAssociation ( AssocGroupId animGroup, AnimationId animID )
259+
CAnimBlendStaticAssociationSAInterface * CAnimManagerSA::GetAnimStaticAssociation ( AssocGroupId animGroup, AnimationId animID )
260260
{
261-
CAnimBlendAssociationSAInterface * pInterface;
261+
CAnimBlendStaticAssociationSAInterface * pInterface;
262262
DWORD dwFunc = FUNC_CAnimManager_GetAnimAssociation;
263263
_asm
264264
{
@@ -268,7 +268,7 @@ CAnimBlendAssociation * CAnimManagerSA::GetAnimAssociation ( AssocGroupId animGr
268268
mov pInterface, eax
269269
add esp, 0x8
270270
}
271-
return GetAnimBlendAssociation ( pInterface );
271+
return pInterface;
272272
}
273273

274274

@@ -760,24 +760,39 @@ CAnimBlendHierarchy * CAnimManagerSA::GetAnimBlendHierarchy ( CAnimBlendHierarch
760760
}
761761
return NULL;
762762
}
763+
764+
bool CAnimManagerSA::isGateWayAnimationHierarchy ( CAnimBlendHierarchySAInterface * pInterface )
765+
{
766+
return pGame->GetKeyGen()->GetUppercaseKey ( m_kGateWayAnimationName.c_str ( ) ) == pInterface->iHashKey;
767+
}
768+
769+
const SString & CAnimManagerSA::GetGateWayBlockName ( void )
770+
{
771+
return m_kGateWayBlockName;
772+
}
773+
774+
const SString & CAnimManagerSA::GetGateWayAnimationName ( void )
775+
{
776+
return m_kGateWayAnimationName;
777+
}
763778

764-
void CAnimManagerSA::InsertPedClumpToMap ( RpClump * pClump, CClientPed * pClientPed )
779+
void CAnimManagerSA::InsertPedPointerToMap ( RpClump * pClump, CClientPed * pClientPed )
765780
{
766-
if ( m_mapOfPedClumps.count ( pClump ) == 0 )
781+
if ( m_mapOfPedPointers.count ( pClump ) == 0 )
767782
{
768-
m_mapOfPedClumps [ pClump ] = pClientPed;
783+
m_mapOfPedPointers [ pClump ] = pClientPed;
769784
}
770785
}
771786

772-
void CAnimManagerSA::RemovePedClumpFromMap ( RpClump * pClump )
787+
void CAnimManagerSA::RemovePedPointerFromMap ( RpClump * pClump )
773788
{
774-
m_mapOfPedClumps.erase ( pClump );
789+
m_mapOfPedPointers.erase ( pClump );
775790
}
776791

777-
CClientPed * CAnimManagerSA::GetClientPedFromClumpMap ( RpClump * pClump )
792+
CClientPed * CAnimManagerSA::GetPedPointerFromMap ( RpClump * pClump )
778793
{
779-
ClumpMap_type::iterator it = m_mapOfPedClumps.find ( pClump );
780-
if ( it != m_mapOfPedClumps.end ( ) )
794+
ClumpMap_type::iterator it = m_mapOfPedPointers.find ( pClump );
795+
if ( it != m_mapOfPedPointers.end ( ) )
781796
{
782797
return it->second;
783798
}

Client/game_sa/CAnimManagerSA.h

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ class CAnimManagerSAInterface
7979

8080
class CAnimManagerSA : public CAnimManager
8181
{
82+
typedef CAnimBlendStaticAssociationSAInterface * StaticAssocIntface_type;
8283
typedef std::map < RpClump *, CClientPed * > ClumpMap_type;
8384

8485
public:
@@ -108,7 +109,7 @@ class CAnimManagerSA : public CAnimManager
108109
const char * GetAnimBlockName ( AssocGroupId groupID );
109110

110111
CAnimBlendAssociation * CreateAnimAssociation ( AssocGroupId animGroup, AnimationId animID );
111-
CAnimBlendAssociation * GetAnimAssociation ( AssocGroupId animGroup, AnimationId animID );
112+
StaticAssocIntface_type GetAnimStaticAssociation ( AssocGroupId animGroup, AnimationId animID );
112113
CAnimBlendAssociation * GetAnimAssociation ( AssocGroupId animGroup, const char * szAnimName );
113114
CAnimBlendAssociation * AddAnimation ( RpClump * pClump, AssocGroupId animGroup, AnimationId animID );
114115
CAnimBlendAssociation * AddAnimation ( RpClump * pClump, CAnimBlendHierarchy *, int ID );
@@ -150,18 +151,31 @@ class CAnimManagerSA : public CAnimManager
150151
CAnimBlock * GetAnimBlock ( CAnimBlockSAInterface * pInterface );
151152
CAnimBlendHierarchy * GetAnimBlendHierarchy ( CAnimBlendHierarchySAInterface * pInterface );
152153

154+
bool isGateWayAnimationHierarchy ( CAnimBlendHierarchySAInterface * pInterface );
155+
const SString & GetGateWayBlockName ( void );
156+
const SString & GetGateWayAnimationName ( void );
157+
153158
// This is used in AddAnimationHandler and AddAnimationAndSyncHandler for playing
154159
// custom animations and to help in replacing and restoring animations
155-
void InsertPedClumpToMap ( RpClump * pClump, CClientPed * pClientPed );
156-
void RemovePedClumpFromMap ( RpClump * pClump );
157-
CClientPed * GetClientPedFromClumpMap ( RpClump * pClump );
160+
void InsertPedPointerToMap ( RpClump * pClump, CClientPed * pClientPed );
161+
void RemovePedPointerFromMap ( RpClump * pClump );
162+
CClientPed * GetPedPointerFromMap ( RpClump * pClump );
158163

159164
private:
160165
CAnimBlendAssocGroup * m_pAnimAssocGroups [ MAX_ANIM_GROUPS ];
161166
CAnimBlendHierarchy * m_pAnimations [ MAX_ANIMATIONS ];
162167
CAnimBlock * m_pAnimBlocks [ MAX_ANIM_BLOCKS ];
163168
std::list < CAnimBlendAssociation * > m_Associations;
164-
ClumpMap_type m_mapOfPedClumps;
169+
ClumpMap_type m_mapOfPedPointers;
170+
171+
// This "gateway" animation will allow us to play custom animations by simply playing this animation
172+
// and then in AddAnimation and AddAnimationAndSync hook, we can return our custom animation in the
173+
// hook instead of run_wuzi. This will trick GTA SA into thinking that it is playing run_wuzi from
174+
// ped block, but in reality, it's playing our custom animation, and Of course, we can return run_wuzi
175+
// animation within the hook if we want to play it instead. Why run_wuzi? We can also use another animation,
176+
// but I've tested with this one mostly, so let's stick to this.
177+
const SString m_kGateWayBlockName = "ped";
178+
const SString m_kGateWayAnimationName = "run_wuzi";
165179

166180
};
167181

Client/mods/deathmatch/StdInc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
#include <CClientStreamSectorRow.h>
7878
#include <CClientTask.h>
7979
#include <CClientTXD.h>
80+
#include <CClientIFP.h>
8081
#include <CClientWater.h>
8182
#include <CClientWeapon.h>
8283
#include <CClientRenderElement.h>

Client/mods/deathmatch/logic/CClientEntity.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ enum eClientEntityType
8383
CCLIENTRENDERTARGET,
8484
CCLIENTBROWSER,
8585
CCLIENTSEARCHLIGHT,
86+
CCLIENTIFP,
8687
CCLIENTUNKNOWN,
8788
};
8889

Client/mods/deathmatch/logic/CClientGame.cpp

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3987,11 +3987,23 @@ CAnimBlendAssociationSAInterface * CClientGame::AddAnimationHandler ( RpClump *
39873987
{
39883988
printf ( "AddAnimationHandler called! pClump, GroupID, AnimID: %p, %d, %d\n", (void*)pClump, animGroup, animID );
39893989

3990-
//CClientPed * pPed = m_pPedManager->Get ( pClump, true );
3991-
CClientPed * pClientPed = g_pGame->GetAnimManager()->GetClientPedFromClumpMap ( pClump );
3990+
CAnimManager * pAnimationManager = g_pGame->GetAnimManager();
3991+
3992+
CClientPed * pClientPed = pAnimationManager->GetPedPointerFromMap ( pClump );
39923993
if ( pClientPed != nullptr )
39933994
{
3994-
printf ("pClientPed found!\n");
3995+
if ( pClientPed->isNextAnimationCustom () )
3996+
{
3997+
printf("pClientPed->isNextAnimationCustom () is true\n");
3998+
3999+
auto pAnimStaticAssoc = pAnimationManager->GetAnimStaticAssociation ( animGroup, animID );
4000+
if ( pAnimationManager->isGateWayAnimationHierarchy ( pAnimStaticAssoc->pAnimHeirarchy ) )
4001+
{
4002+
printf("pAnimationManager->isGateWayAnimationHierarchy() is true\n");
4003+
4004+
pClientPed->setNextAnimationNormal ( );
4005+
}
4006+
}
39954007
}
39964008

39974009
std::unique_ptr < CAnimBlendAssocGroup > pAnimAssocGroup = g_pGame->CreateAnimBlendAssocGroup ( animGroup );
@@ -6734,3 +6746,26 @@ void CClientGame::RestreamModel ( unsigned short usModel )
67346746
m_pManager->GetVehicleManager ()->RestreamVehicleUpgrades ( usModel );
67356747

67366748
}
6749+
6750+
void CClientGame::InsertIFPPointerToMap ( SString strBlockName, CClientIFP * pIFP )
6751+
{
6752+
if ( m_mapOfIfpPointers.count ( strBlockName ) == 0 )
6753+
{
6754+
m_mapOfIfpPointers [ strBlockName ] = pIFP;
6755+
}
6756+
}
6757+
6758+
void CClientGame::RemoveIFPPointerFromMap ( SString strBlockName )
6759+
{
6760+
m_mapOfIfpPointers.erase ( strBlockName );
6761+
}
6762+
6763+
CClientIFP * CClientGame::GetIFPPointerFromMap ( SString strBlockName )
6764+
{
6765+
std::map < SString, CClientIFP * >::iterator it = m_mapOfIfpPointers.find ( strBlockName );
6766+
if ( it != m_mapOfIfpPointers.end ( ) )
6767+
{
6768+
return it->second;
6769+
}
6770+
return nullptr;
6771+
}

Client/mods/deathmatch/logic/CClientGame.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,10 @@ class CClientGame
586586
void SetFileCacheRoot ( void );
587587
const char* GetFileCacheRoot ( void ) { return m_strFileCacheRoot; }
588588

589+
void InsertIFPPointerToMap ( SString strBlockName, CClientIFP * pIFP );
590+
void RemoveIFPPointerFromMap ( SString strBlockName );
591+
CClientIFP * GetIFPPointerFromMap ( SString strBlockName );
592+
589593
private:
590594
eStatus m_Status;
591595
eServerType m_ServerType;
@@ -798,6 +802,9 @@ class CClientGame
798802
SString m_strFileCacheRoot;
799803

800804
SharedUtil::CAsyncTaskScheduler* m_pAsyncTaskScheduler;
805+
806+
// (SString) Key is custom block name that is supplied to engineLoadIFP
807+
std::map < SString, CClientIFP * > m_mapOfIfpPointers;
801808
};
802809

803810
extern CClientGame* g_pClientGame;

0 commit comments

Comments
 (0)