diff options
author | erorcun <erorcunerorcun@hotmail.com.tr> | 2021-01-03 15:33:50 +0100 |
---|---|---|
committer | erorcun <erorcunerorcun@hotmail.com.tr> | 2021-01-03 15:33:50 +0100 |
commit | c4479a0185d348a534d1cf00aa40a2eaa6773e86 (patch) | |
tree | 6de2382b66880e701bbe854cd964274c1bdf9ca4 /src/peds | |
parent | Fix nFramesForPretendPlaying. (diff) | |
download | re3-c4479a0185d348a534d1cf00aa40a2eaa6773e86.tar re3-c4479a0185d348a534d1cf00aa40a2eaa6773e86.tar.gz re3-c4479a0185d348a534d1cf00aa40a2eaa6773e86.tar.bz2 re3-c4479a0185d348a534d1cf00aa40a2eaa6773e86.tar.lz re3-c4479a0185d348a534d1cf00aa40a2eaa6773e86.tar.xz re3-c4479a0185d348a534d1cf00aa40a2eaa6773e86.tar.zst re3-c4479a0185d348a534d1cf00aa40a2eaa6773e86.zip |
Diffstat (limited to 'src/peds')
-rw-r--r-- | src/peds/Ped.h | 2 | ||||
-rw-r--r-- | src/peds/PedAI.cpp | 6 | ||||
-rw-r--r-- | src/peds/PedFight.cpp | 48 | ||||
-rw-r--r-- | src/peds/PlayerPed.cpp | 34 | ||||
-rw-r--r-- | src/peds/PlayerPed.h | 2 |
5 files changed, 46 insertions, 46 deletions
diff --git a/src/peds/Ped.h b/src/peds/Ped.h index 88a16a95..6c0d9987 100644 --- a/src/peds/Ped.h +++ b/src/peds/Ped.h @@ -1003,7 +1003,7 @@ public: // My names. Inlined in VC AnimationId GetFireAnimNotDucking(CWeaponInfo* weapon) { if (m_nPedType == PEDTYPE_COP && weapon->IsFlagSet(WEAPONFLAG_COP3_RD)) - return ANIM_WEAPON_FIRE_3RD; + return Get3rdFireAnim(weapon); else return GetPrimaryFireAnim(weapon); } diff --git a/src/peds/PedAI.cpp b/src/peds/PedAI.cpp index 9297f87a..16e6c8e2 100644 --- a/src/peds/PedAI.cpp +++ b/src/peds/PedAI.cpp @@ -2147,10 +2147,10 @@ CPed::SelectGunIfArmed(void) if (GetWeapon(i).m_nAmmoTotal > 0) { eWeaponType weaponType = GetWeapon(i).m_eWeaponType; - if (weaponType == WEAPONTYPE_COLT45 || weaponType == WEAPONTYPE_PYTHON || weaponType == WEAPONTYPE_SHOTGUN || + if (weaponType == WEAPONTYPE_COLT45 || weaponType == WEAPONTYPE_UZI || weaponType == WEAPONTYPE_MP5 || weaponType == WEAPONTYPE_M4 || + weaponType == WEAPONTYPE_COLT45 || weaponType == WEAPONTYPE_PYTHON || weaponType == WEAPONTYPE_SHOTGUN || weaponType == WEAPONTYPE_SPAS12_SHOTGUN || weaponType == WEAPONTYPE_STUBBY_SHOTGUN || - weaponType == WEAPONTYPE_UZI || weaponType == WEAPONTYPE_M4 || weaponType == WEAPONTYPE_MP5 || - weaponType == WEAPONTYPE_ROCKETLAUNCHER || weaponType == WEAPONTYPE_FLAMETHROWER || weaponType == WEAPONTYPE_SNIPERRIFLE) { + weaponType == WEAPONTYPE_ROCKETLAUNCHER || weaponType == WEAPONTYPE_SNIPERRIFLE || weaponType == WEAPONTYPE_FLAMETHROWER) { SetCurrentWeapon(i); return true; } diff --git a/src/peds/PedFight.cpp b/src/peds/PedFight.cpp index 99894131..eaa2aa3d 100644 --- a/src/peds/PedFight.cpp +++ b/src/peds/PedFight.cpp @@ -661,9 +661,7 @@ CPed::Attack(void) { CAnimBlendAssociation *weaponAnimAssoc; int32 weaponAnim; - eWeaponType ourWeaponType; float weaponAnimTime; - eWeaponFire ourWeaponFire; float animLoopEnd; CWeaponInfo *ourWeapon; bool attackShouldContinue; @@ -673,9 +671,7 @@ CPed::Attack(void) float animLoopStart; CVector firePos; - ourWeaponType = GetWeapon()->m_eWeaponType; - ourWeapon = CWeaponInfo::GetWeaponInfo(ourWeaponType); - ourWeaponFire = ourWeapon->m_eWeaponFire; + ourWeapon = CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType); weaponAnimAssoc = nil; attackShouldContinue = !!bIsAttacking; reloadAnimAssoc = nil; @@ -694,14 +690,15 @@ CPed::Attack(void) delayBetweenAnimAndFire = ourWeapon->m_fAnim2FrameFire; } } - } else { - AnimationId anim = GetFireAnimNotDucking(ourWeapon); - weaponAnimAssoc = RpAnimBlendClumpGetAssociation(GetClump(), anim); - if (anim == ANIM_WEAPON_FIRE_3RD && weaponAnimAssoc) { + } else if (m_nPedType == PEDTYPE_COP && Get3rdFireAnim(ourWeapon)){ + weaponAnimAssoc = RpAnimBlendClumpGetAssociation(GetClump(), Get3rdFireAnim(ourWeapon)); + if (weaponAnimAssoc) { animLoopStart = 11.f/30.f; animLoopEnd = 19.f/30.f; delayBetweenAnimAndFire = 14.f/30.f; } + } else { + weaponAnimAssoc = RpAnimBlendClumpGetAssociation(GetClump(), GetPrimaryFireAnim(ourWeapon)); } if (GetReloadAnim(ourWeapon)) { @@ -778,15 +775,15 @@ CPed::Attack(void) if (!weaponAnimAssoc) { if (!throwAssoc) { if (attackShouldContinue) { - if (ourWeaponFire != WEAPON_FIRE_PROJECTILE || !IsPlayer() || ((CPlayerPed*)this)->m_bHaveTargetSelected) { + if (ourWeapon->m_eWeaponFire != WEAPON_FIRE_PROJECTILE || !IsPlayer() || ((CPlayerPed*)this)->m_bHaveTargetSelected) { if (bCrouchWhenShooting && bIsDucking && GetCrouchFireAnim(ourWeapon)) { weaponAnimAssoc = CAnimManager::BlendAnimation(GetClump(), ourWeapon->m_AnimToPlay, GetCrouchFireAnim(ourWeapon), 8.0f); } else if(GetSecondFireAnim(ourWeapon) && CGeneral::GetRandomNumber() & 1){ weaponAnimAssoc = CAnimManager::BlendAnimation(GetClump(), ourWeapon->m_AnimToPlay, GetSecondFireAnim(ourWeapon), 8.0f); - } else if(!CGame::nastyGame || ourWeaponFire != WEAPON_FIRE_MELEE || - GetFireAnimGround(ourWeapon) || + } else if(!CGame::nastyGame || ourWeapon->m_eWeaponFire != WEAPON_FIRE_MELEE || + !GetFireAnimGround(ourWeapon, false) || CheckForPedsOnGroundToAttack(this, nil) < PED_ON_THE_FLOOR) { weaponAnimAssoc = CAnimManager::BlendAnimation(GetClump(), ourWeapon->m_AnimToPlay, GetFireAnimNotDucking(ourWeapon), 8.0f); @@ -831,11 +828,11 @@ CPed::Attack(void) m_pedIK.m_flags &= ~CPedIK::AIMS_WITH_ARM; } - if (ourWeaponType != WEAPONTYPE_CHAINSAW + if (GetWeapon()->m_eWeaponType != WEAPONTYPE_CHAINSAW || !meleeAttackStarted && delayBetweenAnimAndFire - 0.5f >= weaponAnimAssoc->currentTime || weaponAnimAssoc->currentTime - weaponAnimAssoc->timeStep > delayBetweenAnimAndFire) { - if (ourWeaponType == WEAPONTYPE_CHAINSAW) { + if (GetWeapon()->m_eWeaponType == WEAPONTYPE_CHAINSAW) { DMAudio.PlayOneShot(m_audioEntityId, SOUND_WEAPON_CHAINSAW_ATTACK, 0.0f); } else if (weaponAnimTime <= delayBetweenAnimAndFire || weaponAnimTime - weaponAnimAssoc->timeStep > delayBetweenAnimAndFire || !weaponAnimAssoc->IsRunning()) { if (weaponAnimAssoc->speed < 1.0f) @@ -859,11 +856,11 @@ CPed::Attack(void) GetWeapon()->Fire(this, &firePos); - if (ourWeaponType == WEAPONTYPE_MOLOTOV || ourWeaponType == WEAPONTYPE_GRENADE || ourWeaponType == WEAPONTYPE_DETONATOR_GRENADE || - ourWeaponType == WEAPONTYPE_TEARGAS) { + if (GetWeapon()->m_eWeaponType == WEAPONTYPE_MOLOTOV || GetWeapon()->m_eWeaponType == WEAPONTYPE_GRENADE || GetWeapon()->m_eWeaponType == WEAPONTYPE_DETONATOR_GRENADE || + GetWeapon()->m_eWeaponType == WEAPONTYPE_TEARGAS) { RemoveWeaponModel(CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_nModelId); } - if (!GetWeapon()->m_nAmmoTotal && ourWeaponFire != WEAPON_FIRE_MELEE && FindPlayerPed() != this) { + if (GetWeapon()->m_nAmmoTotal == 0 && ourWeapon->m_eWeaponFire != WEAPON_FIRE_MELEE && FindPlayerPed() != this) { SelectGunIfArmed(); } @@ -875,13 +872,13 @@ CPed::Attack(void) switch (ourWeapon->m_AnimToPlay) { case ASSOCGRP_UNARMED: if (weaponAnimAssoc->animId == ANIM_MELEE_ATTACK || weaponAnimAssoc->animId == ANIM_MELEE_ATTACK_START) - DMAudio.PlayOneShot(m_audioEntityId, SOUND_FIGHT_46, (damagerType | (ourWeaponType << 8))); + DMAudio.PlayOneShot(m_audioEntityId, SOUND_FIGHT_46, (damagerType | (GetWeapon()->m_eWeaponType << 8))); break; case ASSOCGRP_KNIFE: case ASSOCGRP_BASEBALLBAT: case ASSOCGRP_GOLFCLUB: case ASSOCGRP_CHAINSAW: - DMAudio.PlayOneShot(m_audioEntityId, SOUND_WEAPON_BAT_ATTACK, (damagerType | (ourWeaponType << 8))); + DMAudio.PlayOneShot(m_audioEntityId, SOUND_WEAPON_BAT_ATTACK, (damagerType | (GetWeapon()->m_eWeaponType << 8))); break; default: break; @@ -944,14 +941,13 @@ CPed::Attack(void) } if (IsPlayer()) { - eWeaponType weaponType = GetWeapon()->m_eWeaponType; - if (weaponType == WEAPONTYPE_BASEBALLBAT || weaponType == WEAPONTYPE_GOLFCLUB || weaponType == WEAPONTYPE_KATANA) { + if (GetWeapon()->m_eWeaponType == WEAPONTYPE_BASEBALLBAT || GetWeapon()->m_eWeaponType == WEAPONTYPE_GOLFCLUB || GetWeapon()->m_eWeaponType == WEAPONTYPE_KATANA) { float loopEndWithDelay = animLoopEnd; if (loopEndWithDelay >= 98.0f) loopEndWithDelay = (14.0f / 30.0f) + delayBetweenAnimAndFire; if (weaponAnimAssoc->flags & ASSOC_RUNNING) { if (weaponAnimAssoc->currentTime >= animLoopStart && weaponAnimAssoc->currentTime <= loopEndWithDelay) - CSpecialFX::AddWeaponStreak(weaponType); + CSpecialFX::AddWeaponStreak(GetWeapon()->m_eWeaponType); } } } @@ -970,7 +966,7 @@ CPed::Attack(void) weaponAnimTime = weaponAnimAssoc->currentTime; // Anim loop end, either start the loop again or finish the attack - if (weaponAnimTime > animLoopEnd || !weaponAnimAssoc->IsRunning() && ourWeaponFire != WEAPON_FIRE_PROJECTILE) { + if (weaponAnimTime > animLoopEnd || !weaponAnimAssoc->IsRunning() && ourWeapon->m_eWeaponFire != WEAPON_FIRE_PROJECTILE) { if (GetWeapon()->m_eWeaponState == WEAPONSTATE_RELOADING) { if (GetReloadAnim(ourWeapon) && !reloadAnimAssoc) { if (!CWorld::Players[CWorld::PlayerInFocus].m_bFastReload) { @@ -997,7 +993,7 @@ CPed::Attack(void) PedOnGroundState pedOnGroundState; if (ourWeapon->m_eWeaponFire == WEAPON_FIRE_MELEE && (CGame::nastyGame && ((pedOnGroundState = CheckForPedsOnGroundToAttack(this, nil)) > PED_IN_FRONT_OF_ATTACKER) - || ourWeaponType == WEAPONTYPE_BASEBALLBAT && pedOnGroundState == NO_PED && bIsStanding && m_pCurSurface && m_pCurSurface->IsVehicle())) { + || GetWeapon()->m_eWeaponType == WEAPONTYPE_BASEBALLBAT && pedOnGroundState == NO_PED && bIsStanding && m_pCurSurface && m_pCurSurface->IsVehicle())) { AnimationId fireAnim = GetFireAnimGround(ourWeapon, false); if (weaponAnimAssoc->animId == fireAnim) @@ -1030,10 +1026,10 @@ CPed::Attack(void) // Echoes of bullets, at the end of the attack. (Bug: doesn't play while reloading) if (weaponAnimAssoc->currentTime - weaponAnimAssoc->timeStep < animLoopEnd) - DMAudio.PlayOneShot(m_audioEntityId, SOUND_WEAPON_AK47_BULLET_ECHO, ourWeaponType); + DMAudio.PlayOneShot(m_audioEntityId, SOUND_WEAPON_AK47_BULLET_ECHO, GetWeapon()->m_eWeaponType); // Fun fact: removing this part leds to reloading flamethrower - if (ourWeaponType == WEAPONTYPE_FLAMETHROWER && weaponAnimAssoc->IsRunning()) { + if (GetWeapon()->m_eWeaponType == WEAPONTYPE_FLAMETHROWER && weaponAnimAssoc->IsRunning()) { weaponAnimAssoc->flags |= ASSOC_DELETEFADEDOUT; weaponAnimAssoc->flags &= ~ASSOC_RUNNING; weaponAnimAssoc->blendDelta = -4.0f; diff --git a/src/peds/PlayerPed.cpp b/src/peds/PlayerPed.cpp index 8220b370..a3fc608e 100644 --- a/src/peds/PlayerPed.cpp +++ b/src/peds/PlayerPed.cpp @@ -61,7 +61,7 @@ CPlayerPed::CPlayerPed(void) : CPed(PEDTYPE_PLAYER1) m_pWanted->Initialise(); m_pArrestingCop = nil; m_currentWeapon = WEAPONTYPE_UNARMED; - m_nSelectedWepSlot = 0; + m_nSelectedWepSlot = WEAPONSLOT_UNARMED; m_nSpeedTimer = 0; m_bSpeedTimerFlag = false; SetWeaponLockOnTarget(nil); @@ -300,7 +300,7 @@ CPlayerPed::SetInitialState(void) m_nLastPedState = PED_NONE; m_animGroup = ASSOCGRP_PLAYER; m_fMoveSpeed = 0.0f; - m_nSelectedWepSlot = WEAPONTYPE_UNARMED; + m_nSelectedWepSlot = WEAPONSLOT_UNARMED; m_nEvadeAmount = 0; m_pEvadingFrom = nil; bIsPedDieAnimPlaying = false; @@ -748,17 +748,20 @@ CPlayerPed::ProcessWeaponSwitch(CPad *padUsed) && TheCamera.PlayerWeaponMode.Mode != CCam::MODE_ROCKETLAUNCHER && TheCamera.PlayerWeaponMode.Mode != CCam::MODE_CAMERA) { - for (m_nSelectedWepSlot = m_currentWeapon - 1; ; --m_nSelectedWepSlot) { + // I don't know what kind of loop that was + m_nSelectedWepSlot = m_currentWeapon - 1; + do { if (m_nSelectedWepSlot < 0) m_nSelectedWepSlot = TOTAL_WEAPON_SLOTS - 1; - if (m_nSelectedWepSlot == 0) + if (m_nSelectedWepSlot == WEAPONSLOT_UNARMED) break; - if (HasWeaponSlot(m_nSelectedWepSlot) && GetWeapon(m_nSelectedWepSlot).HasWeaponAmmoToBeUsed()) { + if (HasWeaponSlot(m_nSelectedWepSlot) && GetWeapon(m_nSelectedWepSlot).HasWeaponAmmoToBeUsed()) break; - } - } + + --m_nSelectedWepSlot; + } while (m_nSelectedWepSlot != WEAPONSLOT_UNARMED); } } } @@ -772,17 +775,17 @@ spentAmmoCheck: || TheCamera.PlayerWeaponMode.Mode == CCam::MODE_ROCKETLAUNCHER) return; - if (GetWeapon()->m_eWeaponType != WEAPONTYPE_DETONATOR - || GetWeapon(2).m_eWeaponType != WEAPONTYPE_DETONATOR_GRENADE) - m_nSelectedWepSlot = m_currentWeapon - 1; + if (GetWeapon()->m_eWeaponType == WEAPONTYPE_DETONATOR + && GetWeapon(WEAPONSLOT_PROJECTILE).m_eWeaponType == WEAPONTYPE_DETONATOR_GRENADE) + m_nSelectedWepSlot = WEAPONSLOT_PROJECTILE; else - m_nSelectedWepSlot = 2; + m_nSelectedWepSlot = m_currentWeapon - 1; - for (; m_nSelectedWepSlot >= 0; --m_nSelectedWepSlot) { + for (; m_nSelectedWepSlot >= WEAPONSLOT_UNARMED; --m_nSelectedWepSlot) { // BUG: m_nSelectedWepSlot and GetWeapon(..) takes slot in VC but they compared them against weapon types in whole condition! jeez #ifdef FIX_BUGS - if (m_nSelectedWepSlot == 1 || GetWeapon(m_nSelectedWepSlot).m_nAmmoTotal > 0 && m_nSelectedWepSlot != 2) { + if (m_nSelectedWepSlot == WEAPONSLOT_MELEE || GetWeapon(m_nSelectedWepSlot).m_nAmmoTotal > 0 && m_nSelectedWepSlot != WEAPONSLOT_PROJECTILE) { #else if (m_nSelectedWepSlot == WEAPONTYPE_BASEBALLBAT && GetWeapon(WEAPONTYPE_BASEBALLBAT).m_eWeaponType == WEAPONTYPE_BASEBALLBAT || GetWeapon(m_nSelectedWepSlot).m_nAmmoTotal > 0 @@ -791,15 +794,16 @@ spentAmmoCheck: goto switchDetectDone; } } - m_nSelectedWepSlot = 0; + m_nSelectedWepSlot = WEAPONSLOT_UNARMED; } } switchDetectDone: if (m_nSelectedWepSlot != m_currentWeapon) { - if (m_nPedState != PED_ATTACK && m_nPedState != PED_AIM_GUN && m_nPedState != PED_FIGHT) + if (m_nPedState != PED_ATTACK && m_nPedState != PED_AIM_GUN && m_nPedState != PED_FIGHT) { RemoveWeaponAnims(m_currentWeapon, -1000.0f); MakeChangesForNewWeapon(m_nSelectedWepSlot); + } } } diff --git a/src/peds/PlayerPed.h b/src/peds/PlayerPed.h index 3c58f7f5..09bd1377 100644 --- a/src/peds/PlayerPed.h +++ b/src/peds/PlayerPed.h @@ -15,7 +15,7 @@ public: float m_fCurrentStamina; float m_fMaxStamina; float m_fStaminaProgress; - int8 m_nSelectedWepSlot; // eWeaponType + int8 m_nSelectedWepSlot; bool m_bSpeedTimerFlag; uint8 m_nEvadeAmount; uint32 m_nSpeedTimer; // m_nStandStillTimer? |