Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit aa0591c

Browse files
Add animation related functions (#3734)
* Add `getPedAnimationProgress` & `getPedAnimationSpeed` functions
1 parent 889567a commit aa0591c

16 files changed

+181
-88
lines changed

‎Client/game_sa/CAnimBlendAssociationSA.cpp‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ std::unique_ptr<CAnimBlendHierarchy> CAnimBlendAssociationSA::GetAnimHierarchy()
113113
return pGame->GetAnimManager()->GetAnimBlendHierarchy(m_pInterface->pAnimHierarchy);
114114
}
115115

116+
const std::unique_ptr<CAnimBlendHierarchy> CAnimBlendAssociationSA::GetAnimHierarchy() const noexcept
117+
{
118+
return pGame->GetAnimManager()->GetAnimBlendHierarchy(m_pInterface->pAnimHierarchy);
119+
}
120+
116121
void CAnimBlendAssociationSA::SetCurrentProgress(float fProgress)
117122
{
118123
float fTime = m_pInterface->pAnimHierarchy->fTotalTime * fProgress;

‎Client/game_sa/CAnimBlendAssociationSA.h‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <CVector.h>
1717
#include <game/RenderWare.h>
1818
#include <game/CAnimBlendAssociation.h>
19+
#include <game/CAnimBlendHierarchy.h>
1920
#include "CAnimBlendNodeSA.h"
2021

2122
class CAnimBlendAssocGroupSA;
@@ -159,12 +160,15 @@ class CAnimBlendAssociationSA : public CAnimBlendAssociation
159160
eAnimGroup GetAnimGroup() { return static_cast<eAnimGroup>(m_pInterface->sAnimGroup); }
160161
eAnimID GetAnimID() { return static_cast<eAnimID>(m_pInterface->sAnimID); }
161162
std::unique_ptr<CAnimBlendHierarchy> GetAnimHierarchy();
163+
const std::unique_ptr<CAnimBlendHierarchy> GetAnimHierarchy() const noexcept;
162164

163165
float GetBlendAmount() { return m_pInterface->fBlendAmount; }
164166
void SetBlendAmount(float fAmount) { m_pInterface->fBlendAmount = fAmount; }
165167
void SetCurrentProgress(float fProgress);
166-
float GetCurrentSpeed() { return m_pInterface->fSpeed; }
168+
float GetCurrentProgress() const noexcept { return m_pInterface->fCurrentTime; }
169+
float GetCurrentSpeed() const noexcept { return m_pInterface->fSpeed; }
167170
void SetCurrentSpeed(float fSpeed) { m_pInterface->fSpeed = fSpeed; }
171+
float GetLength() const noexcept { return GetAnimHierarchy()->GetTotalTime(); }
168172
void SetAnimID(short sAnimID) { m_pInterface->sAnimID = sAnimID; }
169173
void SetAnimGroup(short sAnimGroup) { m_pInterface->sAnimGroup = sAnimGroup; }
170174
void SetFlags(short sFlags) { m_pInterface->m_nFlags = sFlags; }

‎Client/game_sa/CAnimBlendHierarchySA.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class CAnimBlendHierarchySA : public CAnimBlendHierarchy
5353
void RemoveFromUncompressedCache();
5454
void RemoveQuaternionFlips();
5555
void CalculateTotalTime();
56+
float GetTotalTime() const noexcept { return m_pInterface->fTotalTime; }
5657
CAnimBlendSequenceSAInterface* GetSequence(DWORD dwIndex);
5758
CAnimBlendSequenceSAInterface* GetSequences() { return m_pInterface->pSequences; }
5859
unsigned short GetNumSequences() { return m_pInterface->usNumSequences; }

‎Client/game_sa/TaskBasicSA.cpp‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,27 @@
1313
#include "TaskBasicSA.h"
1414
#include "CPedSA.h"
1515

16+
17+
CTaskSimpleRunNamedAnimSAInterface* CTaskSimpleRunNamedAnimSA::GetAnimationInterface() noexcept
18+
{
19+
return reinterpret_cast<CTaskSimpleRunNamedAnimSAInterface*>(this->GetInterface());
20+
}
21+
22+
const CTaskSimpleRunNamedAnimSAInterface* CTaskSimpleRunNamedAnimSA::GetAnimationInterface() const noexcept
23+
{
24+
return reinterpret_cast<const CTaskSimpleRunNamedAnimSAInterface*>(this->GetInterface());
25+
}
26+
27+
const char* CTaskSimpleRunNamedAnimSA::GetAnimName() const noexcept
28+
{
29+
return GetAnimationInterface()->m_animName;
30+
}
31+
32+
const char* CTaskSimpleRunNamedAnimSA::GetGroupName() const noexcept
33+
{
34+
return GetAnimationInterface()->m_animGroupName;
35+
}
36+
1637
CTaskComplexUseMobilePhoneSA::CTaskComplexUseMobilePhoneSA(const int iDuration)
1738
{
1839
CreateTaskInterface(sizeof(CTaskComplexUseMobilePhoneSAInterface));

‎Client/game_sa/TaskBasicSA.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,12 @@ class CTaskSimpleRunNamedAnimSA : public virtual CTaskSimpleAnimSA, public virtu
113113
CTaskSimpleRunNamedAnimSA(const char* pAnimName, const char* pAnimGroupName, const int flags, const float fBlendDelta, const int iTime = -1,
114114
const bool bDontInterrupt = false, const bool bRunInSequence = false, const bool bOffsetPed = false,
115115
const bool bHoldLastFrame = false);
116+
117+
CTaskSimpleRunNamedAnimSAInterface* GetAnimationInterface() noexcept;
118+
const CTaskSimpleRunNamedAnimSAInterface* GetAnimationInterface() const noexcept;
119+
120+
const char* GetAnimName() const noexcept override;
121+
const char* GetGroupName() const noexcept override;
116122
};
117123

118124
class CTaskComplexDieSAInterface : public CTaskComplexSAInterface

‎Client/game_sa/TaskSA.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ class CTaskSA : public virtual CTask
8585

8686
// our function(s)
8787
void SetInterface(CTaskSAInterface* pInterface) { TaskInterface = pInterface; };
88-
CTaskSAInterface* GetInterface() { return TaskInterface; }
88+
CTaskSAInterface* GetInterface() noexcept { return TaskInterface; }
89+
const CTaskSAInterface* GetInterface() const noexcept { return TaskInterface; }
8990
bool IsValid() { return GetInterface() != NULL; }
9091

9192
void CreateTaskInterface(size_t nSize);

‎Client/mods/deathmatch/logic/CClientPed.cpp‎

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5695,28 +5695,6 @@ bool CClientPed::IsRunningAnimation()
56955695
return (m_AnimationCache.bLoop && m_pAnimationBlock);
56965696
}
56975697

5698-
void CClientPed::RunAnimation(AssocGroupId animGroup, AnimationId animID)
5699-
{
5700-
KillAnimation();
5701-
5702-
if (m_pPlayerPed)
5703-
{
5704-
// Remove jetpack now so it doesn't stay on (#9522#c25612)
5705-
if (HasJetPack())
5706-
SetHasJetPack(false);
5707-
5708-
// Let's not choke them any longer
5709-
if (IsChoking())
5710-
SetChoking(false);
5711-
5712-
CTask* pTask = g_pGame->GetTasks()->CreateTaskSimpleRunAnim(animGroup, animID, 4.0f, TASK_SIMPLE_ANIM, "TASK_SIMPLE_ANIM");
5713-
if (pTask)
5714-
{
5715-
pTask->SetAsPedTask(m_pPlayerPed, TASK_PRIORITY_PRIMARY);
5716-
}
5717-
}
5718-
}
5719-
57205698
void CClientPed::RunNamedAnimation(std::unique_ptr<CAnimBlock>& pBlock, const char* szAnimName, int iTime, int iBlend, bool bLoop, bool bUpdatePosition,
57215699
bool bInterruptable, bool bFreezeLastFrame, bool bRunInSequence, bool bOffsetPed, bool bHoldLastFrame)
57225700
{

‎Client/mods/deathmatch/logic/CClientPed.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,6 @@ class CClientPed : public CClientStreamElement, public CAntiCheatModule
460460

461461
bool GetRunningAnimationName(SString& strBlockName, SString& strAnimName);
462462
bool IsRunningAnimation();
463-
void RunAnimation(AssocGroupId animGroup, AnimationId animID);
464463
void RunNamedAnimation(std::unique_ptr<CAnimBlock>& pBlock, const char* szAnimName, int iTime = -1, int iBlend = 250, bool bLoop = true,
465464
bool bUpdatePosition = true, bool bInterruptable = false, bool bFreezeLastFrame = true, bool bRunInSequence = false,
466465
bool bOffsetPed = false, bool bHoldLastFrame = false);

‎Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include <game/CWeaponStat.h>
2929
#include <game/CWeaponStatManager.h>
3030
#include <game/CBuildingRemoval.h>
31-
#include <game/Task.h>
31+
#include <game/TaskBasic.h>
3232

3333
using std::list;
3434

‎Client/mods/deathmatch/logic/CStaticFunctionDefinitions.h‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,10 @@ class CStaticFunctionDefinitions
167167
static bool SetPedCanBeKnockedOffBike(CClientEntity& Entity, bool bCanBeKnockedOffBike);
168168
static bool SetPedAnimation(CClientEntity& Entity, const SString& strBlockName, const char* szAnimName, int iTime, int iBlend, bool bLoop,
169169
bool bUpdatePosition, bool bInterruptable, bool bFreezeLastFrame);
170-
static bool SetPedAnimationProgress(CClientEntity& Entity, const SString& strAnimName, float fProgress);
171-
static bool SetPedAnimationSpeed(CClientEntity& Entity, const SString& strAnimName, float fSpeed);
170+
171+
static bool SetPedAnimationProgress(CClientEntity& Entity, const SString& strAnimName, float fProgress);
172+
static bool SetPedAnimationSpeed(CClientEntity& Entity, const SString& strAnimName, float fSpeed);
173+
172174
static bool SetPedMoveAnim(CClientEntity& Entity, unsigned int iMoveAnim);
173175
static bool AddPedClothes(CClientEntity& Entity, const char* szTexture, const char* szModel, unsigned char ucType);
174176
static bool RemovePedClothes(CClientEntity& Entity, unsigned char ucType);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /