more weapon fixes

This commit is contained in:
eray orçunus 2020-06-20 17:30:28 +03:00
parent fd3cd2c26a
commit 2d2833f2e4
2 changed files with 39 additions and 17 deletions

View File

@ -738,6 +738,7 @@ switchDetectDone:
} }
} }
// --MIAMI: Done
void void
CPlayerPed::PlayerControlM16(CPad *padUsed) CPlayerPed::PlayerControlM16(CPad *padUsed)
{ {
@ -757,10 +758,19 @@ CPlayerPed::PlayerControlM16(CPad *padUsed)
TheCamera.ClearPlayerWeaponMode(); TheCamera.ClearPlayerWeaponMode();
} }
if (padUsed->GetWeapon()) { if (padUsed->GetWeapon() && CTimer::GetTimeInMilliseconds() > GetWeapon()->m_nTimer) {
if (GetWeapon()->m_eWeaponState == WEAPONSTATE_OUT_OF_AMMO) {
DMAudio.PlayFrontEndSound(SOUND_WEAPON_SNIPER_SHOT_NO_ZOOM, 0.f);
GetWeapon()->m_nTimer = CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_nFiringRate + CTimer::GetTimeInMilliseconds();
} else {
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() > GetWeapon()->m_nTimer &&
CTimer::GetTimeInMilliseconds() - CTimer::GetTimeStepInMilliseconds() < GetWeapon()->m_nTimer && GetWeapon()->m_eWeaponState != WEAPONSTATE_OUT_OF_AMMO) {
DMAudio.PlayFrontEndSound(SOUND_WEAPON_AK47_BULLET_ECHO, GetWeapon()->m_eWeaponType);
} }
GetWeapon()->Update(m_audioEntityId, nil); GetWeapon()->Update(m_audioEntityId, nil);
} }
@ -1583,11 +1593,11 @@ CPlayerPed::ProcessControl(void)
} }
break; break;
case PED_SNIPER_MODE: case PED_SNIPER_MODE:
if (FindPlayerPed()->GetWeapon()->m_eWeaponType == WEAPONTYPE_M4) { if (GetWeapon()->m_eWeaponType == WEAPONTYPE_SNIPERRIFLE || GetWeapon()->m_eWeaponType == WEAPONTYPE_LASERSCOPE) {
if (padUsed) if (padUsed)
PlayerControlM16(padUsed);
} else if (padUsed) {
PlayerControlSniper(padUsed); PlayerControlSniper(padUsed);
} else if (padUsed) {
PlayerControlM16(padUsed);
} }
break; break;
case PED_SEEK_CAR: case PED_SEEK_CAR:

View File

@ -194,9 +194,13 @@ CWeapon::Fire(CEntity *shooter, CVector *fireSource)
if ( GetInfo()->m_eWeaponFire != WEAPON_FIRE_MELEE ) if ( GetInfo()->m_eWeaponFire != WEAPON_FIRE_MELEE )
{ {
if ( m_nAmmoInClip <= 0 ) if (m_nAmmoInClip <= 0) {
if (m_nAmmoTotal <= 0 || m_eWeaponState == WEAPONSTATE_RELOADING)
return false; return false;
Reload();
}
switch ( m_eWeaponType ) switch ( m_eWeaponType )
{ {
case WEAPONTYPE_SHOTGUN: case WEAPONTYPE_SHOTGUN:
@ -223,10 +227,10 @@ CWeapon::Fire(CEntity *shooter, CVector *fireSource)
{ {
if ((TheCamera.PlayerWeaponMode.Mode == CCam::MODE_HELICANNON_1STPERSON || TheCamera.PlayerWeaponMode.Mode == CCam::MODE_M16_1STPERSON) if ((TheCamera.PlayerWeaponMode.Mode == CCam::MODE_HELICANNON_1STPERSON || TheCamera.PlayerWeaponMode.Mode == CCam::MODE_M16_1STPERSON)
&& shooter == FindPlayerPed()) { && shooter == FindPlayerPed()) {
addFireRateAsDelay = false; addFireRateAsDelay = true;
fired = FireM16_1stPerson(shooter); fired = FireM16_1stPerson(shooter);
} else { } else {
addFireRateAsDelay = true; addFireRateAsDelay = false;
fired = FireInstantHit(shooter, source); fired = FireInstantHit(shooter, source);
} }
break; break;
@ -235,8 +239,11 @@ CWeapon::Fire(CEntity *shooter, CVector *fireSource)
case WEAPONTYPE_SNIPERRIFLE: case WEAPONTYPE_SNIPERRIFLE:
case WEAPONTYPE_LASERSCOPE: case WEAPONTYPE_LASERSCOPE:
{ {
if (shooter == FindPlayerPed()) {
fired = FireSniper(shooter); fired = FireSniper(shooter);
} else {
fired = FireInstantHit(shooter, source);
}
break; break;
} }
@ -339,8 +346,12 @@ CWeapon::Fire(CEntity *shooter, CVector *fireSource)
if (m_nAmmoInClip == 0) if (m_nAmmoInClip == 0)
{ {
if (m_nAmmoTotal == 0) if (m_nAmmoTotal == 0) {
if (TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_CAMERA)
CPad::GetPad(0)->Clear(false);
return true; return true;
}
m_eWeaponState = WEAPONSTATE_RELOADING; m_eWeaponState = WEAPONSTATE_RELOADING;
m_nTimer = CTimer::GetTimeInMilliseconds() + GetInfo()->m_nReload; m_nTimer = CTimer::GetTimeInMilliseconds() + GetInfo()->m_nReload;
@ -1026,7 +1037,7 @@ CWeapon::FireInstantHit(CEntity *shooter, CVector *fireSource)
{ {
static uint8 counter = 0; static uint8 counter = 0;
if ( info->m_nFiringRate >= 50 && !(++counter & 1) ) if ( info->m_nFiringRate >= 50 || !(++counter & 1) )
{ {
AddGunFlashBigGuns(*fireSource, *fireSource + target); AddGunFlashBigGuns(*fireSource, *fireSource + target);
@ -2586,9 +2597,10 @@ CWeapon::Update(int32 audioEntity, CPed *pedToAdjustSound)
if ( CTimer::GetTimeInMilliseconds() > m_nTimer ) if ( CTimer::GetTimeInMilliseconds() > m_nTimer )
{ {
if ( GetInfo()->m_eWeaponFire != WEAPON_FIRE_MELEE && m_nAmmoTotal == 0 ) if ( GetInfo()->m_eWeaponFire != WEAPON_FIRE_MELEE && m_nAmmoTotal == 0 ) {
m_eWeaponState = WEAPONSTATE_OUT_OF_AMMO; m_eWeaponState = WEAPONSTATE_OUT_OF_AMMO;
else // TODO(Miami): CPickups::RemoveAllPickupsOfACertainWeaponGroupWithNoAmmo
} else
m_eWeaponState = WEAPONSTATE_READY; m_eWeaponState = WEAPONSTATE_READY;
} }