diff options
author | eray orçunus <erayorcunus@gmail.com> | 2019-07-25 17:06:24 +0200 |
---|---|---|
committer | eray orçunus <erayorcunus@gmail.com> | 2019-07-25 22:37:50 +0200 |
commit | 8fd63e5ca6288e0f16c63fa9f378682b31dbaf88 (patch) | |
tree | 0351cb51adcacf2cdf0f006d23e2ce7bd8081e3c /src/weapons | |
parent | implemented CAutomobile::TankControl (diff) | |
download | re3-8fd63e5ca6288e0f16c63fa9f378682b31dbaf88.tar re3-8fd63e5ca6288e0f16c63fa9f378682b31dbaf88.tar.gz re3-8fd63e5ca6288e0f16c63fa9f378682b31dbaf88.tar.bz2 re3-8fd63e5ca6288e0f16c63fa9f378682b31dbaf88.tar.lz re3-8fd63e5ca6288e0f16c63fa9f378682b31dbaf88.tar.xz re3-8fd63e5ca6288e0f16c63fa9f378682b31dbaf88.tar.zst re3-8fd63e5ca6288e0f16c63fa9f378682b31dbaf88.zip |
Diffstat (limited to 'src/weapons')
-rw-r--r-- | src/weapons/Weapon.cpp | 37 | ||||
-rw-r--r-- | src/weapons/Weapon.h | 2 |
2 files changed, 38 insertions, 1 deletions
diff --git a/src/weapons/Weapon.cpp b/src/weapons/Weapon.cpp index 056c584a..f83f2271 100644 --- a/src/weapons/Weapon.cpp +++ b/src/weapons/Weapon.cpp @@ -3,6 +3,8 @@ #include "Weapon.h" #include "Timer.h" #include "WeaponInfo.h" +#include "Ped.h" +#include "World.h" WRAPPER bool CWeapon::Fire(CEntity*, CVector*) { EAXJMP(0x55C380); } WRAPPER void CWeapon::FireFromCar(CAutomobile *car, bool left) { EAXJMP(0x55C940); } @@ -50,7 +52,42 @@ CWeapon::IsTypeMelee(void) return m_eWeaponType == WEAPONTYPE_UNARMED || m_eWeaponType == WEAPONTYPE_BASEBALLBAT; } +bool +CWeapon::HitsGround(CEntity *holder, CVector *firePos, CEntity *aimingTo) +{ + if (!holder->IsPed() || !((CPed*)holder)->m_pSeekTarget) + return false; + + CWeaponInfo *ourType = CWeaponInfo::GetWeaponInfo(m_eWeaponType); + CVector adjustedOffset = ourType->m_vecFireOffset; + adjustedOffset.z += 0.6f; + + CVector point1, point2; + CEntity *foundEnt = nil; + CColPoint foundCol; + + if (firePos) + point1 = *firePos; + else + point1 = holder->GetMatrix() * adjustedOffset; + + CEntity *aimEntity = aimingTo ? aimingTo : ((CPed*)holder)->m_pSeekTarget; + point2 = aimEntity->GetPosition(); + point2.z += 0.6f; + + CWorld::ProcessLineOfSight(point1, point2, foundCol, foundEnt, true, false, false, false, false, false, false); + if (foundEnt && foundEnt->IsBuilding()) { + // That was supposed to be Magnitude, according to leftover code in assembly + float diff = (foundCol.point.z - point1.z); + if (diff < 0.0f && diff > -3.0f) + return true; + } + + return false; +} + STARTPATCHES InjectHook(0x55C330, &CWeapon::Initialise, PATCH_JUMP); InjectHook(0x5639D0, &CWeapon::Reload, PATCH_JUMP); + InjectHook(0x564890, &CWeapon::HitsGround, PATCH_JUMP); ENDPATCHES
\ No newline at end of file diff --git a/src/weapons/Weapon.h b/src/weapons/Weapon.h index 71c1f344..4916284f 100644 --- a/src/weapons/Weapon.h +++ b/src/weapons/Weapon.h @@ -70,7 +70,7 @@ public: void AddGunshell(CEntity*, CVector const&, CVector2D const&, float); bool IsTypeMelee(void); bool IsType2Handed(void); - static void DoTankDoomAiming(CEntity *playerVehicle, CEntity *playerPed, CVector *start, CVector *end); + bool HitsGround(CEntity* holder, CVector* firePos, CEntity* aimingTo); }; static_assert(sizeof(CWeapon) == 0x18, "CWeapon: error"); |