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

Ped: PlayerPed: sync with master

This commit is contained in:
erorcun 2021-01-03 18:29:09 +03:00
parent 941e70a701
commit 28ec412369
3 changed files with 26 additions and 28 deletions

View file

@ -2037,7 +2037,8 @@ CPed::SelectGunIfArmed(void)
for (int i = 0; i < m_maxWeaponTypeAllowed; i++) {
if (GetWeapon(i).m_nAmmoTotal > 0) {
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);
return true;
}

View file

@ -522,9 +522,7 @@ CPed::Attack(void)
CAnimBlendAssociation *weaponAnimAssoc;
int32 weaponAnim;
float animStart;
eWeaponType ourWeaponType;
float weaponAnimTime;
eWeaponFire ourWeaponFire;
float animLoopEnd;
CWeaponInfo *ourWeapon;
bool attackShouldContinue;
@ -533,9 +531,7 @@ CPed::Attack(void)
float delayBetweenAnimAndFire;
CVector firePos;
ourWeaponType = GetWeapon()->m_eWeaponType;
ourWeapon = CWeaponInfo::GetWeaponInfo(ourWeaponType);
ourWeaponFire = ourWeapon->m_eWeaponFire;
ourWeapon = CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType);
weaponAnimAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ourWeapon->m_AnimToPlay);
attackShouldContinue = bIsAttacking;
reloadAnimAssoc = nil;
@ -576,8 +572,8 @@ CPed::Attack(void)
if (!weaponAnimAssoc) {
if (attackShouldContinue) {
if (ourWeaponFire != WEAPON_FIRE_PROJECTILE || !IsPlayer() || ((CPlayerPed*)this)->m_bHaveTargetSelected) {
if (!CGame::nastyGame || ourWeaponFire != WEAPON_FIRE_MELEE || CheckForPedsOnGroundToAttack(this, nil) < PED_ON_THE_FLOOR) {
if (ourWeapon->m_eWeaponFire != WEAPON_FIRE_PROJECTILE || !IsPlayer() || ((CPlayerPed*)this)->m_bHaveTargetSelected) {
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);
}
else {
@ -617,12 +613,12 @@ CPed::Attack(void)
} else {
firePos = ourWeapon->m_vecFireOffset;
if (ourWeaponType == WEAPONTYPE_BASEBALLBAT) {
if (GetWeapon()->m_eWeaponType == WEAPONTYPE_BASEBALLBAT) {
if (weaponAnimAssoc->animId == ourWeapon->m_Anim2ToPlay)
firePos.z = 0.7f * ourWeapon->m_fRadius - 1.0f;
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);
} else {
firePos = GetMatrix() * firePos;
@ -630,10 +626,10 @@ CPed::Attack(void)
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);
}
if (!GetWeapon()->m_nAmmoTotal && ourWeaponFire != WEAPON_FIRE_MELEE && FindPlayerPed() != this) {
if (!GetWeapon()->m_nAmmoTotal && ourWeapon->m_eWeaponFire != WEAPON_FIRE_MELEE && FindPlayerPed() != this) {
SelectGunIfArmed();
}
@ -666,7 +662,7 @@ CPed::Attack(void)
attackShouldContinue = false;
}
if (ourWeaponType == WEAPONTYPE_SHOTGUN) {
if (GetWeapon()->m_eWeaponType == WEAPONTYPE_SHOTGUN) {
weaponAnimTime = weaponAnimAssoc->currentTime;
firePos = ourWeapon->m_vecFireOffset;
@ -692,7 +688,7 @@ CPed::Attack(void)
if (IsPlayer()) {
if (CPad::GetPad(0)->GetSprint()) {
// 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) {
weaponAnimAssoc->blendDelta = -4.0f;
FinishedAttackCB(nil, this);
@ -702,20 +698,20 @@ CPed::Attack(void)
}
#endif
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;
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 (weaponAnimTime - 2.0f * weaponAnimAssoc->timeStep <= animLoopEnd
&& (bIsAttacking || CTimer::GetTimeInMilliseconds() < m_shootTimer)
&& GetWeapon()->m_eWeaponState != WEAPONSTATE_RELOADING) {
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) {
weaponAnimAssoc->Start(ourWeapon->m_fAnimLoopStart);
} else {
@ -738,7 +734,7 @@ CPed::Attack(void)
// Echoes of bullets, at the end of the attack. (Bug: doesn't play while reloading)
if (weaponAnimAssoc->currentTime - weaponAnimAssoc->timeStep <= ourWeapon->m_fAnimLoopEnd) {
switch (ourWeaponType) {
switch (GetWeapon()->m_eWeaponType) {
case WEAPONTYPE_UZI:
DMAudio.PlayOneShot(m_audioEntityId, SOUND_WEAPON_UZI_BULLET_ECHO, 0.0f);
break;
@ -754,7 +750,7 @@ CPed::Attack(void)
}
// 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;

View file

@ -628,20 +628,21 @@ CPlayerPed::ProcessWeaponSwitch(CPad *padUsed)
}
}
}
// Out of ammo, switch to another weapon
} else if (CWeaponInfo::GetWeaponInfo((eWeaponType)m_currentWeapon)->m_eWeaponFire != WEAPON_FIRE_MELEE) {
if (GetWeapon(m_currentWeapon).m_nAmmoTotal <= 0) {
if (TheCamera.PlayerWeaponMode.Mode != CCam::MODE_M16_1STPERSON
&& TheCamera.PlayerWeaponMode.Mode != CCam::MODE_SNIPER
&& TheCamera.PlayerWeaponMode.Mode != CCam::MODE_ROCKETLAUNCHER) {
if (TheCamera.PlayerWeaponMode.Mode == CCam::MODE_M16_1STPERSON
|| TheCamera.PlayerWeaponMode.Mode == CCam::MODE_SNIPER
|| TheCamera.PlayerWeaponMode.Mode == CCam::MODE_ROCKETLAUNCHER)
return;
for (m_nSelectedWepSlot = m_currentWeapon - 1; m_nSelectedWepSlot >= 0; --m_nSelectedWepSlot) {
if (m_nSelectedWepSlot == WEAPONTYPE_BASEBALLBAT && HasWeapon(WEAPONTYPE_BASEBALLBAT)
|| GetWeapon(m_nSelectedWepSlot).m_nAmmoTotal > 0 && m_nSelectedWepSlot != WEAPONTYPE_MOLOTOV && m_nSelectedWepSlot != WEAPONTYPE_GRENADE) {
goto switchDetectDone;
}
for (m_nSelectedWepSlot = m_currentWeapon - 1; m_nSelectedWepSlot >= 0; --m_nSelectedWepSlot) {
if (m_nSelectedWepSlot == WEAPONTYPE_BASEBALLBAT && HasWeapon(WEAPONTYPE_BASEBALLBAT)
|| GetWeapon(m_nSelectedWepSlot).m_nAmmoTotal > 0 && m_nSelectedWepSlot != WEAPONTYPE_MOLOTOV && m_nSelectedWepSlot != WEAPONTYPE_GRENADE) {
goto switchDetectDone;
}
m_nSelectedWepSlot = WEAPONTYPE_UNARMED;
}
m_nSelectedWepSlot = WEAPONTYPE_UNARMED;
}
}