Advertisement
Guest User

setPedAnimationProgress

a guest
Aug 9th, 2011
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 7.44 KB | None | 0 0
  1. Index: MTA10/game_sa/CAnimBlendAssociationSA.cpp
  2. ===================================================================
  3. --- MTA10/game_sa/CAnimBlendAssociationSA.cpp   (revision 2973)
  4. +++ MTA10/game_sa/CAnimBlendAssociationSA.cpp   (working copy)
  5. @@ -18,3 +18,15 @@
  6.  {
  7.      return pGame->GetAnimManager ()->GetAnimBlendHierarchy ( m_pInterface->pAnimHierarchy );
  8.  }
  9. +
  10. +void CAnimBlendAssociationSA::SetCurrentTime ( float fTime )
  11. +{
  12. +   DWORD DwFunc = 0x4CEA80;
  13. +   DWORD DwThisInterface = reinterpret_cast<DWORD> (m_pInterface);
  14. +   _asm
  15. +   {
  16. +       mov     ecx, DwThisInterface
  17. +       push    fTime
  18. +       call    DwFunc
  19. +   };
  20. +}
  21. \ No newline at end of file
  22. Index: MTA10/game_sa/CAnimBlendAssociationSA.h
  23. ===================================================================
  24. --- MTA10/game_sa/CAnimBlendAssociationSA.h (revision 2973)
  25. +++ MTA10/game_sa/CAnimBlendAssociationSA.h (working copy)
  26. @@ -51,6 +51,8 @@
  27.      inline float                        GetBlendAmount          ( void )            { return m_pInterface->fBlendAmount; }
  28.      inline void                         SetBlendAmount          ( float fAmount )   { m_pInterface->fBlendAmount = fAmount; }
  29.  
  30. +   void                                SetCurrentTime          ( float fTime );
  31. +
  32.  protected:
  33.      CAnimBlendAssociationSAInterface *  m_pInterface;
  34.  };
  35. Index: MTA10/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp
  36. ===================================================================
  37. --- MTA10/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp  (revision 2973)
  38. +++ MTA10/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp  (working copy)
  39. @@ -1898,6 +1898,31 @@
  40.  }
  41.  
  42.  
  43. +bool CStaticFunctionDefinitions::SetPedAnimationProgress ( CClientEntity& Entity, const char * szAnimName, float fProgress )
  44. +{    
  45. +    RUN_CHILDREN SetPedAnimationProgress ( **iter, szAnimName, fProgress );
  46. +
  47. +    if ( IS_PED ( &Entity ) )
  48. +    {
  49. +        CClientPed& Ped = static_cast < CClientPed& > ( Entity );
  50. +        CAnimBlendAssociation* pA = g_pGame->GetAnimManager ()->RpAnimBlendClumpGetAssociation ( Ped.GetClump (), szAnimName );
  51. +
  52. +        if ( pA )
  53. +        {
  54. +            /*
  55. +            Here must be something like
  56. +            float fNewTime = pA->GetInterface()->pAnimHierarchy->fTotalTime * fProgress;
  57. +            But only abstract classes avaliable here
  58. +            */
  59. +            float fNewTime = *(float *)(*(DWORD *)( ((DWORD)(pA->GetInterface())) + 20) + 16) * fProgress;
  60. +            pA->SetCurrentTime ( fNewTime );
  61. +        }
  62. +    }
  63. +
  64. +    return false;
  65. +}
  66. +
  67. +
  68.  bool CStaticFunctionDefinitions::SetPedMoveAnim ( CClientEntity& Entity, unsigned int iMoveAnim )
  69.  {    
  70.      RUN_CHILDREN SetPedMoveAnim ( **iter, iMoveAnim );
  71. Index: MTA10/mods/deathmatch/logic/CStaticFunctionDefinitions.h
  72. ===================================================================
  73. --- MTA10/mods/deathmatch/logic/CStaticFunctionDefinitions.h    (revision 2973)
  74. +++ MTA10/mods/deathmatch/logic/CStaticFunctionDefinitions.h    (working copy)
  75. @@ -147,6 +147,7 @@
  76.      static bool                         SetPedRotation                      ( CClientEntity& Entity, float fRotation );
  77.      static bool                         SetPedCanBeKnockedOffBike           ( CClientEntity& Entity, bool bCanBeKnockedOffBike );
  78.      static bool                         SetPedAnimation                     ( CClientEntity& Entity, const char * szBlockName, const char * szAnimName, int iTime, bool bLoop, bool bUpdatePosition, bool bInterruptable, bool bFreezeLastFrame );
  79. +    static bool                         SetPedAnimationProgress             ( CClientEntity& Entity, const char * szAnimName, float fProgress );
  80.      static bool                         SetPedMoveAnim                      ( CClientEntity& Entity, unsigned int iMoveAnim );
  81.      static bool                         AddPedClothes                       ( CClientEntity& Entity, char* szTexture, char* szModel, unsigned char ucType );
  82.      static bool                         RemovePedClothes                    ( CClientEntity& Entity, unsigned char ucType );
  83. Index: MTA10/mods/shared_logic/lua/CLuaFunctionDefs.h
  84. ===================================================================
  85. --- MTA10/mods/shared_logic/lua/CLuaFunctionDefs.h  (revision 2973)
  86. +++ MTA10/mods/shared_logic/lua/CLuaFunctionDefs.h  (working copy)
  87. @@ -234,6 +234,7 @@
  88.      LUA_DECLARE ( SetPedRotation );
  89.      LUA_DECLARE ( SetPedCanBeKnockedOffBike );
  90.      LUA_DECLARE ( SetPedAnimation );
  91. +   LUA_DECLARE ( SetPedAnimationProgress );
  92.      LUA_DECLARE ( SetPedMoveAnim );
  93.      LUA_DECLARE ( SetPedWeaponSlot );
  94.      LUA_DECLARE ( AddPedClothes );
  95. Index: MTA10/mods/shared_logic/lua/CLuaFunctionDefs.Ped.cpp
  96. ===================================================================
  97. --- MTA10/mods/shared_logic/lua/CLuaFunctionDefs.Ped.cpp    (revision 2973)
  98. +++ MTA10/mods/shared_logic/lua/CLuaFunctionDefs.Ped.cpp    (working copy)
  99. @@ -1603,7 +1603,39 @@
  100.      return 1;
  101.  }
  102.  
  103. +int CLuaFunctionDefs::SetPedAnimationProgress( lua_State* luaVM )
  104. +{
  105. +    // Check types
  106. +    if ( lua_istype ( luaVM, 1, LUA_TLIGHTUSERDATA ) )
  107. +    {
  108. +        // Grab the element
  109. +        CClientEntity* pEntity = lua_toelement ( luaVM, 1 );
  110. +        if ( pEntity )
  111. +        {
  112. +            const char * szAnimName = NULL;
  113. +            float fProgress = 0.0f;
  114. +            if ( lua_type ( luaVM, 2 ) == LUA_TSTRING ) szAnimName = lua_tostring ( luaVM, 2 );
  115. +            if ( lua_type ( luaVM, 3 ) == LUA_TNUMBER ) fProgress = static_cast < float > ( lua_tonumber ( luaVM, 3 ) );
  116.  
  117. +          
  118. +           if ( CStaticFunctionDefinitions::SetPedAnimationProgress ( *pEntity, szAnimName, fProgress ) );
  119. +            {
  120. +                lua_pushboolean ( luaVM, true );
  121. +                return 1;
  122. +            }
  123. +        }
  124. +        else
  125. +            m_pScriptDebugging->LogBadPointer ( luaVM, "setPedAnimation", "element", 1 );
  126. +    }
  127. +    else
  128. +        m_pScriptDebugging->LogBadType ( luaVM, "setPedAnimation" );
  129. +
  130. +    // Failed
  131. +    lua_pushboolean ( luaVM, false );
  132. +    return 1;
  133. +}
  134. +
  135. +
  136.  int CLuaFunctionDefs::SetPedMoveAnim ( lua_State* luaVM )
  137.  {
  138.      // Check types
  139. Index: MTA10/mods/shared_logic/lua/CLuaManager.cpp
  140. ===================================================================
  141. --- MTA10/mods/shared_logic/lua/CLuaManager.cpp (revision 2973)
  142. +++ MTA10/mods/shared_logic/lua/CLuaManager.cpp (working copy)
  143. @@ -440,6 +440,7 @@
  144.      CLuaCFunctions::AddFunction ( "setPedRotation", CLuaFunctionDefs::SetPedRotation );
  145.      CLuaCFunctions::AddFunction ( "setPedCanBeKnockedOffBike", CLuaFunctionDefs::SetPedCanBeKnockedOffBike );
  146.      CLuaCFunctions::AddFunction ( "setPedAnimation", CLuaFunctionDefs::SetPedAnimation );
  147. +   CLuaCFunctions::AddFunction ( "setPedAnimationProgress", CLuaFunctionDefs::SetPedAnimationProgress );
  148.      //CLuaCFunctions::AddFunction ( "setPedWalkingStyle", CLuaFunctionDefs::SetPedMoveAnim );
  149.      CLuaCFunctions::AddFunction ( "addPedClothes", CLuaFunctionDefs::AddPedClothes );
  150.      CLuaCFunctions::AddFunction ( "removePedClothes", CLuaFunctionDefs::RemovePedClothes );
  151. Index: MTA10/sdk/game/CAnimBlendAssociation.h
  152. ===================================================================
  153. --- MTA10/sdk/game/CAnimBlendAssociation.h  (revision 2973)
  154. +++ MTA10/sdk/game/CAnimBlendAssociation.h  (working copy)
  155. @@ -27,6 +27,8 @@
  156.  
  157.      virtual float                               GetBlendAmount          ( void ) = 0;
  158.      virtual void                                SetBlendAmount          ( float fAmount ) = 0;
  159. +
  160. +   virtual void                                SetCurrentTime          ( float fTime ) = 0;
  161.  };
  162.  
  163.  #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement