diff options
author | aap <aap@papnet.eu> | 2020-04-13 00:02:11 +0200 |
---|---|---|
committer | aap <aap@papnet.eu> | 2020-04-13 00:20:44 +0200 |
commit | 3aae52d220e163243c2ee47fde354687f16acb03 (patch) | |
tree | 435ed474802361aca3ac7969bfc5477a729a14c3 /src/vehicles/Vehicle.cpp | |
parent | Merge pull request #409 from erorcun/erorcun (diff) | |
download | re3-3aae52d220e163243c2ee47fde354687f16acb03.tar re3-3aae52d220e163243c2ee47fde354687f16acb03.tar.gz re3-3aae52d220e163243c2ee47fde354687f16acb03.tar.bz2 re3-3aae52d220e163243c2ee47fde354687f16acb03.tar.lz re3-3aae52d220e163243c2ee47fde354687f16acb03.tar.xz re3-3aae52d220e163243c2ee47fde354687f16acb03.tar.zst re3-3aae52d220e163243c2ee47fde354687f16acb03.zip |
Diffstat (limited to '')
-rw-r--r-- | src/vehicles/Vehicle.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/vehicles/Vehicle.cpp b/src/vehicles/Vehicle.cpp index adeba19e..f47fd131 100644 --- a/src/vehicles/Vehicle.cpp +++ b/src/vehicles/Vehicle.cpp @@ -482,6 +482,55 @@ CVehicle::InflictDamage(CEntity* damagedBy, eWeaponType weaponType, float damage } void +CVehicle::DoFixedMachineGuns(void) +{ + if(CPad::GetPad(0)->GetCarGunFired() && !bGunSwitchedOff){ + if(CTimer::GetTimeInMilliseconds() > m_nGunFiringTime + 150){ + CVector source, target; + float dx, dy, len; + + dx = GetForward().x; + dy = GetForward().y; + len = Sqrt(SQR(dx) + SQR(dy)); + if(len < 0.1f) len = 0.1f; + dx /= len; + dy /= len; + + m_nGunFiringTime = CTimer::GetTimeInMilliseconds(); + + source = GetMatrix() * CVector(2.0f, 2.5f, 1.0f); + target = source + CVector(dx, dy, 0.0f)*60.0f; + target += CVector( + ((CGeneral::GetRandomNumber()&0xFF)-128) * 0.015f, + ((CGeneral::GetRandomNumber()&0xFF)-128) * 0.015f, + ((CGeneral::GetRandomNumber()&0xFF)-128) * 0.02f); + CWeapon::DoTankDoomAiming(this, pDriver, &source, &target); + FireOneInstantHitRound(&source, &target, 15); + + source = GetMatrix() * CVector(-2.0f, 2.5f, 1.0f); + target = source + CVector(dx, dy, 0.0f)*60.0f; + target += CVector( + ((CGeneral::GetRandomNumber()&0xFF)-128) * 0.015f, + ((CGeneral::GetRandomNumber()&0xFF)-128) * 0.015f, + ((CGeneral::GetRandomNumber()&0xFF)-128) * 0.02f); + CWeapon::DoTankDoomAiming(this, pDriver, &source, &target); + FireOneInstantHitRound(&source, &target, 15); + + DMAudio.PlayOneShot(m_audioEntityId, SOUND_WEAPON_SHOT_FIRED, 0.0f); + + m_nAmmoInClip--; + if(m_nAmmoInClip == 0){ + m_nAmmoInClip = 20; + m_nGunFiringTime = CTimer::GetTimeInMilliseconds() + 1400; + } + } + }else{ + if(CTimer::GetTimeInMilliseconds() > m_nGunFiringTime + 1400) + m_nAmmoInClip = 20; + } +} + +void CVehicle::ExtinguishCarFire(void) { m_fHealth = max(m_fHealth, 300.0f); |