summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreray orçunus <erayorcunus@gmail.com>2020-06-20 20:26:27 +0300
committereray orçunus <erayorcunus@gmail.com>2020-06-20 20:26:27 +0300
commitcc60ad1946794bfa8cc8ae86e62829035ff6f360 (patch)
tree2710ee93888a29547e66887e3977a4fb2f375dc4
parent2d2833f2e4f038f37cf75025e98476a4f1ad9a13 (diff)
ducking & anim fix
-rw-r--r--src/animation/AnimBlendAssociation.cpp7
-rw-r--r--src/animation/AnimBlendNode.cpp6
-rw-r--r--src/animation/AnimManager.cpp5
-rw-r--r--src/peds/Ped.cpp11
-rw-r--r--src/peds/PlayerPed.cpp54
5 files changed, 53 insertions, 30 deletions
diff --git a/src/animation/AnimBlendAssociation.cpp b/src/animation/AnimBlendAssociation.cpp
index 9a29601b..a6c679eb 100644
--- a/src/animation/AnimBlendAssociation.cpp
+++ b/src/animation/AnimBlendAssociation.cpp
@@ -133,8 +133,11 @@ CAnimBlendAssociation::SetCurrentTime(float time)
int i;
for(currentTime = time; currentTime >= hierarchy->totalLength; currentTime -= hierarchy->totalLength)
- if(!IsRepeating())
- return;
+ if (!IsRepeating()) {
+ currentTime = hierarchy->totalLength;
+ break;
+ }
+
CAnimManager::UncompressAnimation(hierarchy);
if(hierarchy->compressed2){
for(i = 0; i < numNodes; i++)
diff --git a/src/animation/AnimBlendNode.cpp b/src/animation/AnimBlendNode.cpp
index 4186e994..860046e8 100644
--- a/src/animation/AnimBlendNode.cpp
+++ b/src/animation/AnimBlendNode.cpp
@@ -102,8 +102,8 @@ CAnimBlendNode::FindKeyFrame(float t)
// advance until t is between frameB and frameA
while(t > sequence->GetKeyFrame(frameA)->deltaTime){
t -= sequence->GetKeyFrame(frameA)->deltaTime;
- frameB = frameA++;
- if(frameA >= sequence->numFrames){
+ frameA++;
+ if(frameA + 1 >= sequence->numFrames){
// reached end of animation
if(!association->IsRepeating()){
CalcDeltas();
@@ -111,8 +111,8 @@ CAnimBlendNode::FindKeyFrame(float t)
return false;
}
frameA = 0;
- frameB = 0;
}
+ frameB = frameA;
}
remainingTime = sequence->GetKeyFrame(frameA)->deltaTime - t;
diff --git a/src/animation/AnimManager.cpp b/src/animation/AnimManager.cpp
index c2f1c8bc..385f1f67 100644
--- a/src/animation/AnimManager.cpp
+++ b/src/animation/AnimManager.cpp
@@ -237,14 +237,14 @@ AnimAssocDesc aMeleeAnimDescs[] = {
{ ANIM_MELEE_ATTACK, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL },
{ ANIM_MELEE_ATTACK_2ND, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL },
{ ANIM_MELEE_ATTACK_START, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_NOWALK },
- { ANIM_WEAPON_CROUCHRELOAD, ASSOC_REPEAT }, // TODO(Miami): Overload that name for melee/swing
+ { ANIM_MELEE_IDLE_FIGHTMODE, ASSOC_REPEAT },
{ ANIM_WEAPON_SPECIAL, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION }, // TODO(Miami): Overload that name for melee/swing
};
AnimAssocDesc aSwingAnimDescs[] = {
{ ANIM_MELEE_ATTACK, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL },
{ ANIM_MELEE_ATTACK_2ND, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL },
{ ANIM_MELEE_ATTACK_START, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL },
- { ANIM_WEAPON_CROUCHRELOAD, ASSOC_REPEAT }, // TODO(Miami): Overload that name for melee/swing
+ { ANIM_MELEE_IDLE_FIGHTMODE, ASSOC_REPEAT },
{ ANIM_WEAPON_SPECIAL, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, // TODO(Miami): Overload that name for melee/swing
};
AnimAssocDesc aWeaponAnimDescs[] = {
@@ -1006,6 +1006,7 @@ CAnimManager::UncompressAnimation(CAnimBlendHierarchy *hier)
if(link == nil){
ms_animCache.tail.prev->item->RemoveUncompressedData();
ms_animCache.Remove(ms_animCache.tail.prev);
+ ms_animCache.tail.prev->item->linkPtr = nil;
link = ms_animCache.Insert(hier);
}
hier->linkPtr = link;
diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp
index 6f969c5c..8f7e02b7 100644
--- a/src/peds/Ped.cpp
+++ b/src/peds/Ped.cpp
@@ -1098,8 +1098,7 @@ CPed::FinishedAttackCB(CAnimBlendAssociation *attackAssoc, void *arg)
return;
}
- // Not for unarmed, it's for weapons using unarmed anims
- if (currentWeapon->m_bUse2nd && ped->bIsAttacking && currentWeapon->m_AnimToPlay == ASSOCGRP_UNARMED) {
+ if (currentWeapon->m_bUse2nd && ped->bIsAttacking && currentWeapon->m_AnimToPlay != ASSOCGRP_THROW) {
AnimationId groundAnim = GetFireAnimGround(currentWeapon);
CAnimBlendAssociation *groundAnimAssoc = RpAnimBlendClumpGetAssociation(ped->GetClump(), groundAnim);
if (!groundAnimAssoc || groundAnimAssoc->blendAmount <= 0.95f && groundAnimAssoc->blendDelta <= 0.0f) {
@@ -11392,14 +11391,6 @@ CPed::ProcessControl(void)
if (m_nWaitState != WAITSTATE_FALSE)
Wait();
- if (m_nPedState != PED_IDLE) {
- CAnimBlendAssociation *idleAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_IDLE_ARMED);
- if(idleAssoc) {
- idleAssoc->blendDelta = -8.0f;
- idleAssoc->flags |= ASSOC_DELETEFADEDOUT;
- }
- }
-
switch (m_nPedState) {
case PED_IDLE:
Idle();
diff --git a/src/peds/PlayerPed.cpp b/src/peds/PlayerPed.cpp
index 7933cc1e..887ebc11 100644
--- a/src/peds/PlayerPed.cpp
+++ b/src/peds/PlayerPed.cpp
@@ -348,7 +348,7 @@ CPlayerPed::SetRealMoveAnim(void)
RestoreHeadingRate();
if (!curIdleAssoc) {
- if (m_fCurrentStamina < 0.0f && !CWorld::TestSphereAgainstWorld(GetPosition(), 0.0f,
+ if (m_fCurrentStamina < 0.0f && !bIsAimingGun && !CWorld::TestSphereAgainstWorld(GetPosition(), 0.0f,
nil, true, false, false, false, false, false)) {
curIdleAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_IDLE_TIRED, 8.0f);
@@ -362,7 +362,7 @@ CPlayerPed::SetRealMoveAnim(void)
} else if (m_fMoveSpeed == 0.0f && !curSprintAssoc) {
if (!curIdleAssoc) {
- if (m_fCurrentStamina < 0.0f && !CWorld::TestSphereAgainstWorld(GetPosition(), 0.0f,
+ if (m_fCurrentStamina < 0.0f && !bIsAimingGun && !CWorld::TestSphereAgainstWorld(GetPosition(), 0.0f,
nil, true, false, false, false, false, false)) {
curIdleAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_IDLE_TIRED, 4.0f);
@@ -373,11 +373,11 @@ CPlayerPed::SetRealMoveAnim(void)
m_nWaitTimer = CTimer::GetTimeInMilliseconds() + CGeneral::GetRandomNumberInRange(2500, 4000);
}
- if (m_fCurrentStamina > 0.0f && curIdleAssoc->animId == ANIM_IDLE_TIRED) {
+ if ((m_fCurrentStamina > 0.0f || bIsAimingGun) && curIdleAssoc->animId == ANIM_IDLE_TIRED) {
CAnimManager::BlendAnimation(GetClump(), m_animGroup, ANIM_IDLE_STANCE, 4.0f);
} else if (m_nPedState != PED_FIGHT) {
- if (m_fCurrentStamina < 0.0f && curIdleAssoc->animId != ANIM_IDLE_TIRED
+ if (m_fCurrentStamina < 0.0f && !bIsAimingGun && curIdleAssoc->animId != ANIM_IDLE_TIRED
&& !CWorld::TestSphereAgainstWorld(GetPosition(), 0.0f, nil, true, false, false, false, false, false)) {
CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_IDLE_TIRED, 4.0f);
@@ -623,6 +623,7 @@ CPlayerPed::IsThisPedAttackingPlayer(CPed *suspect)
return false;
}
+// --MIAMI: Done
void
CPlayerPed::PlayerControlSniper(CPad *padUsed)
{
@@ -637,15 +638,23 @@ CPlayerPed::PlayerControlSniper(CPad *padUsed)
bCrouchWhenShooting = false;
}
- if (!padUsed->GetTarget()) {
+ if (!padUsed->GetTarget() && !m_attachedTo) {
RestorePreviousState();
TheCamera.ClearPlayerWeaponMode();
}
- if (padUsed->WeaponJustDown()) {
+ int firingRate = GetWeapon()->m_eWeaponType == WEAPONTYPE_LASERSCOPE ? 333 : 266;
+ if (padUsed->WeaponJustDown() && CTimer::GetTimeInMilliseconds() > GetWeapon()->m_nTimer) {
CVector firePos(0.0f, 0.0f, 0.6f);
firePos = GetMatrix() * firePos;
GetWeapon()->Fire(this, &firePos);
+ m_nPadDownPressedInMilliseconds = CTimer::GetTimeInMilliseconds();
+ } else if (CTimer::GetTimeInMilliseconds() > m_nPadDownPressedInMilliseconds + firingRate &&
+ CTimer::GetTimeInMilliseconds() - CTimer::GetTimeStepInMilliseconds() < m_nPadDownPressedInMilliseconds + firingRate && padUsed->GetWeapon()) {
+
+ if (GetWeapon()->m_nAmmoTotal > 0) {
+ DMAudio.PlayFrontEndSound(SOUND_WEAPON_AK47_BULLET_ECHO, GetWeapon()->m_eWeaponType);
+ }
}
GetWeapon()->Update(m_audioEntityId, nil);
}
@@ -1405,9 +1414,16 @@ CPlayerPed::PlayerControlZelda(CPad *padUsed)
}
}
+ if (m_nPedState == PED_ANSWER_MOBILE) {
+ SetRealMoveAnim();
+ return;
+ }
+
if (!(CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_bHeavy)
&& padUsed->GetSprint()) {
- m_nMoveState = PEDMOVE_SPRINT;
+
+ if (!m_pCurrentPhysSurface || !m_pCurrentPhysSurface->bInfiniteMass || m_pCurrentPhysSurface->m_phy_flagA08)
+ m_nMoveState = PEDMOVE_SPRINT;
}
if (m_nPedState != PED_FIGHT)
SetRealMoveAnim();
@@ -1499,11 +1515,11 @@ CPlayerPed::ProcessControl(void)
m_nMoveState = PEDMOVE_STILL;
if (bIsLanding)
RunningLand(padUsed);
- if (padUsed && padUsed->WeaponJustDown() && m_nPedState != PED_SNIPER_MODE) {
+ if (padUsed && padUsed->WeaponJustDown() && !TheCamera.Using1stPersonWeaponMode()) {
// ...Really?
eWeaponType playerWeapon = FindPlayerPed()->GetWeapon()->m_eWeaponType;
- if (playerWeapon == WEAPONTYPE_SNIPERRIFLE) {
+ if (playerWeapon == WEAPONTYPE_SNIPERRIFLE || playerWeapon == WEAPONTYPE_LASERSCOPE) {
DMAudio.PlayFrontEndSound(SOUND_WEAPON_SNIPER_SHOT_NO_ZOOM, 0);
} else if (playerWeapon == WEAPONTYPE_ROCKETLAUNCHER) {
DMAudio.PlayFrontEndSound(SOUND_WEAPON_ROCKET_SHOT_NO_ZOOM, 0);
@@ -1518,8 +1534,12 @@ CPlayerPed::ProcessControl(void)
case PED_ATTACK:
case PED_FIGHT:
case PED_AIM_GUN:
- if (!RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_BLOCK)) {
- if (TheCamera.Cams[0].Using3rdPersonMouseCam()) {
+ case PED_ANSWER_MOBILE:
+ if (!RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_BLOCK) && !m_attachedTo) {
+ if (TheCamera.Using1stPersonWeaponMode()) {
+ if (padUsed)
+ PlayerControlFighter(padUsed);
+ } else if (TheCamera.Cams[0].Using3rdPersonMouseCam()) {
if (padUsed)
PlayerControl1stPersonRunAround(padUsed);
} else if (m_nPedState == PED_FIGHT) {
@@ -1529,7 +1549,7 @@ CPlayerPed::ProcessControl(void)
PlayerControlZelda(padUsed);
}
}
- if (IsPedInControl() && padUsed)
+ if (IsPedInControl() && m_nPedState != PED_ANSWER_MOBILE && padUsed)
ProcessPlayerWeapon(padUsed);
break;
case PED_LOOK_ENTITY:
@@ -1553,8 +1573,13 @@ CPlayerPed::ProcessControl(void)
case PED_INVESTIGATE:
case PED_STEP_AWAY:
case PED_ON_FIRE:
+ case PED_SUN_BATHE:
+ case PED_FLASH:
+ case PED_JOG:
case PED_UNKNOWN:
case PED_STATES_NO_AI:
+ case PED_ABSEIL:
+ case PED_SIT:
case PED_STAGGER:
case PED_DIVE_AWAY:
case PED_STATES_NO_ST:
@@ -1646,7 +1671,7 @@ CPlayerPed::ProcessControl(void)
BeingDraggedFromCar();
break;
}
- if (padUsed && IsPedShootable()) {
+ if (padUsed && IsPedShootable() && m_nPedState != PED_ANSWER_MOBILE && m_nLastPedState != PED_ANSWER_MOBILE) {
ProcessWeaponSwitch(padUsed);
GetWeapon()->Update(m_audioEntityId, this);
}
@@ -1697,6 +1722,9 @@ CPlayerPed::ProcessControl(void)
m_bSpeedTimerFlag = false;
}
+ if (m_nPedState != PED_SNIPER_MODE && (GetWeapon()->m_eWeaponState == WEAPONSTATE_FIRING || m_nPedState == PED_ATTACK))
+ m_nPadDownPressedInMilliseconds = CTimer::GetTimeInMilliseconds();
+
#ifdef PED_SKIN
if (!bIsVisible && IsClumpSkinned(GetClump()))
UpdateRpHAnim();