Ped: PlayerPed: sync with master
This commit is contained in:
parent
941e70a701
commit
28ec412369
@ -2037,7 +2037,8 @@ CPed::SelectGunIfArmed(void)
|
|||||||
for (int i = 0; i < m_maxWeaponTypeAllowed; i++) {
|
for (int i = 0; i < m_maxWeaponTypeAllowed; i++) {
|
||||||
if (GetWeapon(i).m_nAmmoTotal > 0) {
|
if (GetWeapon(i).m_nAmmoTotal > 0) {
|
||||||
eWeaponType weaponType = GetWeapon(i).m_eWeaponType;
|
eWeaponType weaponType = GetWeapon(i).m_eWeaponType;
|
||||||
if (weaponType >= WEAPONTYPE_COLT45 && weaponType != WEAPONTYPE_M16 && weaponType <= WEAPONTYPE_FLAMETHROWER) {
|
if (weaponType == WEAPONTYPE_BASEBALLBAT || weaponType == WEAPONTYPE_COLT45 || weaponType == WEAPONTYPE_UZI || weaponType == WEAPONTYPE_SHOTGUN ||
|
||||||
|
weaponType == WEAPONTYPE_M16 || weaponType == WEAPONTYPE_SNIPERRIFLE || weaponType == WEAPONTYPE_ROCKETLAUNCHER) {
|
||||||
SetCurrentWeapon(i);
|
SetCurrentWeapon(i);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -522,9 +522,7 @@ CPed::Attack(void)
|
|||||||
CAnimBlendAssociation *weaponAnimAssoc;
|
CAnimBlendAssociation *weaponAnimAssoc;
|
||||||
int32 weaponAnim;
|
int32 weaponAnim;
|
||||||
float animStart;
|
float animStart;
|
||||||
eWeaponType ourWeaponType;
|
|
||||||
float weaponAnimTime;
|
float weaponAnimTime;
|
||||||
eWeaponFire ourWeaponFire;
|
|
||||||
float animLoopEnd;
|
float animLoopEnd;
|
||||||
CWeaponInfo *ourWeapon;
|
CWeaponInfo *ourWeapon;
|
||||||
bool attackShouldContinue;
|
bool attackShouldContinue;
|
||||||
@ -533,9 +531,7 @@ CPed::Attack(void)
|
|||||||
float delayBetweenAnimAndFire;
|
float delayBetweenAnimAndFire;
|
||||||
CVector firePos;
|
CVector firePos;
|
||||||
|
|
||||||
ourWeaponType = GetWeapon()->m_eWeaponType;
|
ourWeapon = CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType);
|
||||||
ourWeapon = CWeaponInfo::GetWeaponInfo(ourWeaponType);
|
|
||||||
ourWeaponFire = ourWeapon->m_eWeaponFire;
|
|
||||||
weaponAnimAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ourWeapon->m_AnimToPlay);
|
weaponAnimAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ourWeapon->m_AnimToPlay);
|
||||||
attackShouldContinue = bIsAttacking;
|
attackShouldContinue = bIsAttacking;
|
||||||
reloadAnimAssoc = nil;
|
reloadAnimAssoc = nil;
|
||||||
@ -576,8 +572,8 @@ CPed::Attack(void)
|
|||||||
|
|
||||||
if (!weaponAnimAssoc) {
|
if (!weaponAnimAssoc) {
|
||||||
if (attackShouldContinue) {
|
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 (!CGame::nastyGame || ourWeaponFire != WEAPON_FIRE_MELEE || CheckForPedsOnGroundToAttack(this, nil) < PED_ON_THE_FLOOR) {
|
if (!CGame::nastyGame || ourWeapon->m_eWeaponFire != WEAPON_FIRE_MELEE || CheckForPedsOnGroundToAttack(this, nil) < PED_ON_THE_FLOOR) {
|
||||||
weaponAnimAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ourWeapon->m_AnimToPlay, 8.0f);
|
weaponAnimAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ourWeapon->m_AnimToPlay, 8.0f);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -617,12 +613,12 @@ CPed::Attack(void)
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
firePos = ourWeapon->m_vecFireOffset;
|
firePos = ourWeapon->m_vecFireOffset;
|
||||||
if (ourWeaponType == WEAPONTYPE_BASEBALLBAT) {
|
if (GetWeapon()->m_eWeaponType == WEAPONTYPE_BASEBALLBAT) {
|
||||||
if (weaponAnimAssoc->animId == ourWeapon->m_Anim2ToPlay)
|
if (weaponAnimAssoc->animId == ourWeapon->m_Anim2ToPlay)
|
||||||
firePos.z = 0.7f * ourWeapon->m_fRadius - 1.0f;
|
firePos.z = 0.7f * ourWeapon->m_fRadius - 1.0f;
|
||||||
|
|
||||||
firePos = GetMatrix() * firePos;
|
firePos = GetMatrix() * firePos;
|
||||||
} else if (ourWeaponType != WEAPONTYPE_UNARMED) {
|
} else if (GetWeapon()->m_eWeaponType != WEAPONTYPE_UNARMED) {
|
||||||
TransformToNode(firePos, weaponAnimAssoc->animId == ANIM_KICK_FLOOR ? PED_FOOTR : PED_HANDR);
|
TransformToNode(firePos, weaponAnimAssoc->animId == ANIM_KICK_FLOOR ? PED_FOOTR : PED_HANDR);
|
||||||
} else {
|
} else {
|
||||||
firePos = GetMatrix() * firePos;
|
firePos = GetMatrix() * firePos;
|
||||||
@ -630,10 +626,10 @@ CPed::Attack(void)
|
|||||||
|
|
||||||
GetWeapon()->Fire(this, &firePos);
|
GetWeapon()->Fire(this, &firePos);
|
||||||
|
|
||||||
if (ourWeaponType == WEAPONTYPE_MOLOTOV || ourWeaponType == WEAPONTYPE_GRENADE) {
|
if (GetWeapon()->m_eWeaponType == WEAPONTYPE_MOLOTOV || GetWeapon()->m_eWeaponType == WEAPONTYPE_GRENADE) {
|
||||||
RemoveWeaponModel(ourWeapon->m_nModelId);
|
RemoveWeaponModel(ourWeapon->m_nModelId);
|
||||||
}
|
}
|
||||||
if (!GetWeapon()->m_nAmmoTotal && ourWeaponFire != WEAPON_FIRE_MELEE && FindPlayerPed() != this) {
|
if (!GetWeapon()->m_nAmmoTotal && ourWeapon->m_eWeaponFire != WEAPON_FIRE_MELEE && FindPlayerPed() != this) {
|
||||||
SelectGunIfArmed();
|
SelectGunIfArmed();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -666,7 +662,7 @@ CPed::Attack(void)
|
|||||||
attackShouldContinue = false;
|
attackShouldContinue = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ourWeaponType == WEAPONTYPE_SHOTGUN) {
|
if (GetWeapon()->m_eWeaponType == WEAPONTYPE_SHOTGUN) {
|
||||||
weaponAnimTime = weaponAnimAssoc->currentTime;
|
weaponAnimTime = weaponAnimAssoc->currentTime;
|
||||||
firePos = ourWeapon->m_vecFireOffset;
|
firePos = ourWeapon->m_vecFireOffset;
|
||||||
|
|
||||||
@ -692,7 +688,7 @@ CPed::Attack(void)
|
|||||||
if (IsPlayer()) {
|
if (IsPlayer()) {
|
||||||
if (CPad::GetPad(0)->GetSprint()) {
|
if (CPad::GetPad(0)->GetSprint()) {
|
||||||
// animBreakout is a member of WeaponInfo in VC, so it's me that added the below line.
|
// animBreakout is a member of WeaponInfo in VC, so it's me that added the below line.
|
||||||
float animBreakOut = ((ourWeaponType == WEAPONTYPE_FLAMETHROWER || ourWeaponType == WEAPONTYPE_UZI || ourWeaponType == WEAPONTYPE_SHOTGUN) ? 25 / 30.0f : 99 / 30.0f);
|
float animBreakOut = ((GetWeapon()->m_eWeaponType == WEAPONTYPE_FLAMETHROWER || GetWeapon()->m_eWeaponType == WEAPONTYPE_UZI || GetWeapon()->m_eWeaponType == WEAPONTYPE_SHOTGUN) ? 25 / 30.0f : 99 / 30.0f);
|
||||||
if (!attackShouldContinue && weaponAnimAssoc->currentTime > animBreakOut) {
|
if (!attackShouldContinue && weaponAnimAssoc->currentTime > animBreakOut) {
|
||||||
weaponAnimAssoc->blendDelta = -4.0f;
|
weaponAnimAssoc->blendDelta = -4.0f;
|
||||||
FinishedAttackCB(nil, this);
|
FinishedAttackCB(nil, this);
|
||||||
@ -702,20 +698,20 @@ CPed::Attack(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
animLoopEnd = ourWeapon->m_fAnimLoopEnd;
|
animLoopEnd = ourWeapon->m_fAnimLoopEnd;
|
||||||
if (ourWeaponFire == WEAPON_FIRE_MELEE && weaponAnimAssoc->animId == ourWeapon->m_Anim2ToPlay)
|
if (ourWeapon->m_eWeaponFire == WEAPON_FIRE_MELEE && weaponAnimAssoc->animId == ourWeapon->m_Anim2ToPlay)
|
||||||
animLoopEnd = 3.4f/6.0f;
|
animLoopEnd = 3.4f/6.0f;
|
||||||
|
|
||||||
weaponAnimTime = weaponAnimAssoc->currentTime;
|
weaponAnimTime = weaponAnimAssoc->currentTime;
|
||||||
|
|
||||||
// Anim loop end, either start the loop again or finish the attack
|
// 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 (weaponAnimTime - 2.0f * weaponAnimAssoc->timeStep <= animLoopEnd
|
if (weaponAnimTime - 2.0f * weaponAnimAssoc->timeStep <= animLoopEnd
|
||||||
&& (bIsAttacking || CTimer::GetTimeInMilliseconds() < m_shootTimer)
|
&& (bIsAttacking || CTimer::GetTimeInMilliseconds() < m_shootTimer)
|
||||||
&& GetWeapon()->m_eWeaponState != WEAPONSTATE_RELOADING) {
|
&& GetWeapon()->m_eWeaponState != WEAPONSTATE_RELOADING) {
|
||||||
|
|
||||||
weaponAnim = weaponAnimAssoc->animId;
|
weaponAnim = weaponAnimAssoc->animId;
|
||||||
if (ourWeaponFire != WEAPON_FIRE_MELEE || CheckForPedsOnGroundToAttack(this, nil) < PED_ON_THE_FLOOR) {
|
if (ourWeapon->m_eWeaponFire != WEAPON_FIRE_MELEE || CheckForPedsOnGroundToAttack(this, nil) < PED_ON_THE_FLOOR) {
|
||||||
if (weaponAnim != ourWeapon->m_Anim2ToPlay || weaponAnim == ANIM_RBLOCK_CSHOOT) {
|
if (weaponAnim != ourWeapon->m_Anim2ToPlay || weaponAnim == ANIM_RBLOCK_CSHOOT) {
|
||||||
weaponAnimAssoc->Start(ourWeapon->m_fAnimLoopStart);
|
weaponAnimAssoc->Start(ourWeapon->m_fAnimLoopStart);
|
||||||
} else {
|
} else {
|
||||||
@ -738,7 +734,7 @@ CPed::Attack(void)
|
|||||||
|
|
||||||
// Echoes of bullets, at the end of the attack. (Bug: doesn't play while reloading)
|
// Echoes of bullets, at the end of the attack. (Bug: doesn't play while reloading)
|
||||||
if (weaponAnimAssoc->currentTime - weaponAnimAssoc->timeStep <= ourWeapon->m_fAnimLoopEnd) {
|
if (weaponAnimAssoc->currentTime - weaponAnimAssoc->timeStep <= ourWeapon->m_fAnimLoopEnd) {
|
||||||
switch (ourWeaponType) {
|
switch (GetWeapon()->m_eWeaponType) {
|
||||||
case WEAPONTYPE_UZI:
|
case WEAPONTYPE_UZI:
|
||||||
DMAudio.PlayOneShot(m_audioEntityId, SOUND_WEAPON_UZI_BULLET_ECHO, 0.0f);
|
DMAudio.PlayOneShot(m_audioEntityId, SOUND_WEAPON_UZI_BULLET_ECHO, 0.0f);
|
||||||
break;
|
break;
|
||||||
@ -754,7 +750,7 @@ CPed::Attack(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fun fact: removing this part leds to reloading flamethrower
|
// 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_DELETEFADEDOUT;
|
||||||
weaponAnimAssoc->flags &= ~ASSOC_RUNNING;
|
weaponAnimAssoc->flags &= ~ASSOC_RUNNING;
|
||||||
weaponAnimAssoc->blendDelta = -4.0f;
|
weaponAnimAssoc->blendDelta = -4.0f;
|
||||||
|
@ -628,11 +628,13 @@ CPlayerPed::ProcessWeaponSwitch(CPad *padUsed)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Out of ammo, switch to another weapon
|
||||||
} else if (CWeaponInfo::GetWeaponInfo((eWeaponType)m_currentWeapon)->m_eWeaponFire != WEAPON_FIRE_MELEE) {
|
} else if (CWeaponInfo::GetWeaponInfo((eWeaponType)m_currentWeapon)->m_eWeaponFire != WEAPON_FIRE_MELEE) {
|
||||||
if (GetWeapon(m_currentWeapon).m_nAmmoTotal <= 0) {
|
if (GetWeapon(m_currentWeapon).m_nAmmoTotal <= 0) {
|
||||||
if (TheCamera.PlayerWeaponMode.Mode != CCam::MODE_M16_1STPERSON
|
if (TheCamera.PlayerWeaponMode.Mode == CCam::MODE_M16_1STPERSON
|
||||||
&& TheCamera.PlayerWeaponMode.Mode != CCam::MODE_SNIPER
|
|| TheCamera.PlayerWeaponMode.Mode == CCam::MODE_SNIPER
|
||||||
&& TheCamera.PlayerWeaponMode.Mode != CCam::MODE_ROCKETLAUNCHER) {
|
|| TheCamera.PlayerWeaponMode.Mode == CCam::MODE_ROCKETLAUNCHER)
|
||||||
|
return;
|
||||||
|
|
||||||
for (m_nSelectedWepSlot = m_currentWeapon - 1; m_nSelectedWepSlot >= 0; --m_nSelectedWepSlot) {
|
for (m_nSelectedWepSlot = m_currentWeapon - 1; m_nSelectedWepSlot >= 0; --m_nSelectedWepSlot) {
|
||||||
if (m_nSelectedWepSlot == WEAPONTYPE_BASEBALLBAT && HasWeapon(WEAPONTYPE_BASEBALLBAT)
|
if (m_nSelectedWepSlot == WEAPONTYPE_BASEBALLBAT && HasWeapon(WEAPONTYPE_BASEBALLBAT)
|
||||||
@ -643,7 +645,6 @@ CPlayerPed::ProcessWeaponSwitch(CPad *padUsed)
|
|||||||
m_nSelectedWepSlot = WEAPONTYPE_UNARMED;
|
m_nSelectedWepSlot = WEAPONTYPE_UNARMED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
switchDetectDone:
|
switchDetectDone:
|
||||||
if (m_nSelectedWepSlot != m_currentWeapon) {
|
if (m_nSelectedWepSlot != m_currentWeapon) {
|
||||||
|
Loading…
Reference in New Issue
Block a user