1
0
Fork 0
mirror of https://git.rip/DMCA_FUCKER/re3.git synced 2024-12-24 18:00:01 +00:00

ducking & anim fix

This commit is contained in:
eray orçunus 2020-06-20 20:26:27 +03:00
parent 2d2833f2e4
commit cc60ad1946
5 changed files with 53 additions and 30 deletions

View file

@ -133,8 +133,11 @@ CAnimBlendAssociation::SetCurrentTime(float time)
int i; int i;
for(currentTime = time; currentTime >= hierarchy->totalLength; currentTime -= hierarchy->totalLength) for(currentTime = time; currentTime >= hierarchy->totalLength; currentTime -= hierarchy->totalLength)
if(!IsRepeating()) if (!IsRepeating()) {
return; currentTime = hierarchy->totalLength;
break;
}
CAnimManager::UncompressAnimation(hierarchy); CAnimManager::UncompressAnimation(hierarchy);
if(hierarchy->compressed2){ if(hierarchy->compressed2){
for(i = 0; i < numNodes; i++) for(i = 0; i < numNodes; i++)

View file

@ -102,8 +102,8 @@ CAnimBlendNode::FindKeyFrame(float t)
// advance until t is between frameB and frameA // advance until t is between frameB and frameA
while(t > sequence->GetKeyFrame(frameA)->deltaTime){ while(t > sequence->GetKeyFrame(frameA)->deltaTime){
t -= sequence->GetKeyFrame(frameA)->deltaTime; t -= sequence->GetKeyFrame(frameA)->deltaTime;
frameB = frameA++; frameA++;
if(frameA >= sequence->numFrames){ if(frameA + 1 >= sequence->numFrames){
// reached end of animation // reached end of animation
if(!association->IsRepeating()){ if(!association->IsRepeating()){
CalcDeltas(); CalcDeltas();
@ -111,8 +111,8 @@ CAnimBlendNode::FindKeyFrame(float t)
return false; return false;
} }
frameA = 0; frameA = 0;
frameB = 0;
} }
frameB = frameA;
} }
remainingTime = sequence->GetKeyFrame(frameA)->deltaTime - t; remainingTime = sequence->GetKeyFrame(frameA)->deltaTime - t;

View file

@ -237,14 +237,14 @@ AnimAssocDesc aMeleeAnimDescs[] = {
{ ANIM_MELEE_ATTACK, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, { ANIM_MELEE_ATTACK, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL },
{ ANIM_MELEE_ATTACK_2ND, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, { ANIM_MELEE_ATTACK_2ND, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL },
{ ANIM_MELEE_ATTACK_START, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_NOWALK }, { 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 { ANIM_WEAPON_SPECIAL, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL | ASSOC_HAS_TRANSLATION }, // TODO(Miami): Overload that name for melee/swing
}; };
AnimAssocDesc aSwingAnimDescs[] = { AnimAssocDesc aSwingAnimDescs[] = {
{ ANIM_MELEE_ATTACK, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, { ANIM_MELEE_ATTACK, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL },
{ ANIM_MELEE_ATTACK_2ND, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, { ANIM_MELEE_ATTACK_2ND, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL },
{ ANIM_MELEE_ATTACK_START, 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 { ANIM_WEAPON_SPECIAL, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, // TODO(Miami): Overload that name for melee/swing
}; };
AnimAssocDesc aWeaponAnimDescs[] = { AnimAssocDesc aWeaponAnimDescs[] = {
@ -1006,6 +1006,7 @@ CAnimManager::UncompressAnimation(CAnimBlendHierarchy *hier)
if(link == nil){ if(link == nil){
ms_animCache.tail.prev->item->RemoveUncompressedData(); ms_animCache.tail.prev->item->RemoveUncompressedData();
ms_animCache.Remove(ms_animCache.tail.prev); ms_animCache.Remove(ms_animCache.tail.prev);
ms_animCache.tail.prev->item->linkPtr = nil;
link = ms_animCache.Insert(hier); link = ms_animCache.Insert(hier);
} }
hier->linkPtr = link; hier->linkPtr = link;

View file

@ -1098,8 +1098,7 @@ CPed::FinishedAttackCB(CAnimBlendAssociation *attackAssoc, void *arg)
return; return;
} }
// Not for unarmed, it's for weapons using unarmed anims if (currentWeapon->m_bUse2nd && ped->bIsAttacking && currentWeapon->m_AnimToPlay != ASSOCGRP_THROW) {
if (currentWeapon->m_bUse2nd && ped->bIsAttacking && currentWeapon->m_AnimToPlay == ASSOCGRP_UNARMED) {
AnimationId groundAnim = GetFireAnimGround(currentWeapon); AnimationId groundAnim = GetFireAnimGround(currentWeapon);
CAnimBlendAssociation *groundAnimAssoc = RpAnimBlendClumpGetAssociation(ped->GetClump(), groundAnim); CAnimBlendAssociation *groundAnimAssoc = RpAnimBlendClumpGetAssociation(ped->GetClump(), groundAnim);
if (!groundAnimAssoc || groundAnimAssoc->blendAmount <= 0.95f && groundAnimAssoc->blendDelta <= 0.0f) { if (!groundAnimAssoc || groundAnimAssoc->blendAmount <= 0.95f && groundAnimAssoc->blendDelta <= 0.0f) {
@ -11392,14 +11391,6 @@ CPed::ProcessControl(void)
if (m_nWaitState != WAITSTATE_FALSE) if (m_nWaitState != WAITSTATE_FALSE)
Wait(); 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) { switch (m_nPedState) {
case PED_IDLE: case PED_IDLE:
Idle(); Idle();

View file

@ -348,7 +348,7 @@ CPlayerPed::SetRealMoveAnim(void)
RestoreHeadingRate(); RestoreHeadingRate();
if (!curIdleAssoc) { 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)) { nil, true, false, false, false, false, false)) {
curIdleAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_IDLE_TIRED, 8.0f); 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) { } else if (m_fMoveSpeed == 0.0f && !curSprintAssoc) {
if (!curIdleAssoc) { 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)) { nil, true, false, false, false, false, false)) {
curIdleAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_IDLE_TIRED, 4.0f); 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); 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); CAnimManager::BlendAnimation(GetClump(), m_animGroup, ANIM_IDLE_STANCE, 4.0f);
} else if (m_nPedState != PED_FIGHT) { } 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)) { && !CWorld::TestSphereAgainstWorld(GetPosition(), 0.0f, nil, true, false, false, false, false, false)) {
CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_IDLE_TIRED, 4.0f); CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_IDLE_TIRED, 4.0f);
@ -623,6 +623,7 @@ CPlayerPed::IsThisPedAttackingPlayer(CPed *suspect)
return false; return false;
} }
// --MIAMI: Done
void void
CPlayerPed::PlayerControlSniper(CPad *padUsed) CPlayerPed::PlayerControlSniper(CPad *padUsed)
{ {
@ -637,15 +638,23 @@ CPlayerPed::PlayerControlSniper(CPad *padUsed)
bCrouchWhenShooting = false; bCrouchWhenShooting = false;
} }
if (!padUsed->GetTarget()) { if (!padUsed->GetTarget() && !m_attachedTo) {
RestorePreviousState(); RestorePreviousState();
TheCamera.ClearPlayerWeaponMode(); 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); CVector firePos(0.0f, 0.0f, 0.6f);
firePos = GetMatrix() * firePos; firePos = GetMatrix() * firePos;
GetWeapon()->Fire(this, &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); GetWeapon()->Update(m_audioEntityId, nil);
} }
@ -1405,8 +1414,15 @@ CPlayerPed::PlayerControlZelda(CPad *padUsed)
} }
} }
if (m_nPedState == PED_ANSWER_MOBILE) {
SetRealMoveAnim();
return;
}
if (!(CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_bHeavy) if (!(CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_bHeavy)
&& padUsed->GetSprint()) { && padUsed->GetSprint()) {
if (!m_pCurrentPhysSurface || !m_pCurrentPhysSurface->bInfiniteMass || m_pCurrentPhysSurface->m_phy_flagA08)
m_nMoveState = PEDMOVE_SPRINT; m_nMoveState = PEDMOVE_SPRINT;
} }
if (m_nPedState != PED_FIGHT) if (m_nPedState != PED_FIGHT)
@ -1499,11 +1515,11 @@ CPlayerPed::ProcessControl(void)
m_nMoveState = PEDMOVE_STILL; m_nMoveState = PEDMOVE_STILL;
if (bIsLanding) if (bIsLanding)
RunningLand(padUsed); RunningLand(padUsed);
if (padUsed && padUsed->WeaponJustDown() && m_nPedState != PED_SNIPER_MODE) { if (padUsed && padUsed->WeaponJustDown() && !TheCamera.Using1stPersonWeaponMode()) {
// ...Really? // ...Really?
eWeaponType playerWeapon = FindPlayerPed()->GetWeapon()->m_eWeaponType; 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); DMAudio.PlayFrontEndSound(SOUND_WEAPON_SNIPER_SHOT_NO_ZOOM, 0);
} else if (playerWeapon == WEAPONTYPE_ROCKETLAUNCHER) { } else if (playerWeapon == WEAPONTYPE_ROCKETLAUNCHER) {
DMAudio.PlayFrontEndSound(SOUND_WEAPON_ROCKET_SHOT_NO_ZOOM, 0); DMAudio.PlayFrontEndSound(SOUND_WEAPON_ROCKET_SHOT_NO_ZOOM, 0);
@ -1518,8 +1534,12 @@ CPlayerPed::ProcessControl(void)
case PED_ATTACK: case PED_ATTACK:
case PED_FIGHT: case PED_FIGHT:
case PED_AIM_GUN: case PED_AIM_GUN:
if (!RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_BLOCK)) { case PED_ANSWER_MOBILE:
if (TheCamera.Cams[0].Using3rdPersonMouseCam()) { if (!RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_BLOCK) && !m_attachedTo) {
if (TheCamera.Using1stPersonWeaponMode()) {
if (padUsed)
PlayerControlFighter(padUsed);
} else if (TheCamera.Cams[0].Using3rdPersonMouseCam()) {
if (padUsed) if (padUsed)
PlayerControl1stPersonRunAround(padUsed); PlayerControl1stPersonRunAround(padUsed);
} else if (m_nPedState == PED_FIGHT) { } else if (m_nPedState == PED_FIGHT) {
@ -1529,7 +1549,7 @@ CPlayerPed::ProcessControl(void)
PlayerControlZelda(padUsed); PlayerControlZelda(padUsed);
} }
} }
if (IsPedInControl() && padUsed) if (IsPedInControl() && m_nPedState != PED_ANSWER_MOBILE && padUsed)
ProcessPlayerWeapon(padUsed); ProcessPlayerWeapon(padUsed);
break; break;
case PED_LOOK_ENTITY: case PED_LOOK_ENTITY:
@ -1553,8 +1573,13 @@ CPlayerPed::ProcessControl(void)
case PED_INVESTIGATE: case PED_INVESTIGATE:
case PED_STEP_AWAY: case PED_STEP_AWAY:
case PED_ON_FIRE: case PED_ON_FIRE:
case PED_SUN_BATHE:
case PED_FLASH:
case PED_JOG:
case PED_UNKNOWN: case PED_UNKNOWN:
case PED_STATES_NO_AI: case PED_STATES_NO_AI:
case PED_ABSEIL:
case PED_SIT:
case PED_STAGGER: case PED_STAGGER:
case PED_DIVE_AWAY: case PED_DIVE_AWAY:
case PED_STATES_NO_ST: case PED_STATES_NO_ST:
@ -1646,7 +1671,7 @@ CPlayerPed::ProcessControl(void)
BeingDraggedFromCar(); BeingDraggedFromCar();
break; break;
} }
if (padUsed && IsPedShootable()) { if (padUsed && IsPedShootable() && m_nPedState != PED_ANSWER_MOBILE && m_nLastPedState != PED_ANSWER_MOBILE) {
ProcessWeaponSwitch(padUsed); ProcessWeaponSwitch(padUsed);
GetWeapon()->Update(m_audioEntityId, this); GetWeapon()->Update(m_audioEntityId, this);
} }
@ -1697,6 +1722,9 @@ CPlayerPed::ProcessControl(void)
m_bSpeedTimerFlag = false; 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 #ifdef PED_SKIN
if (!bIsVisible && IsClumpSkinned(GetClump())) if (!bIsVisible && IsClumpSkinned(GetClump()))
UpdateRpHAnim(); UpdateRpHAnim();