diff options
author | Fire-Head <Fire-Head@users.noreply.github.com> | 2019-08-02 22:23:05 +0200 |
---|---|---|
committer | Fire-Head <Fire-Head@users.noreply.github.com> | 2019-08-02 22:23:05 +0200 |
commit | 73e2a4b035e19ace0ad5c55c58a15ee1d8265fee (patch) | |
tree | eafd98b48c650c84139804ca89259ae61e00e3ea /src/weapons/Weapon.cpp | |
parent | fix (diff) | |
parent | restore original shadows fading (diff) | |
download | re3-73e2a4b035e19ace0ad5c55c58a15ee1d8265fee.tar re3-73e2a4b035e19ace0ad5c55c58a15ee1d8265fee.tar.gz re3-73e2a4b035e19ace0ad5c55c58a15ee1d8265fee.tar.bz2 re3-73e2a4b035e19ace0ad5c55c58a15ee1d8265fee.tar.lz re3-73e2a4b035e19ace0ad5c55c58a15ee1d8265fee.tar.xz re3-73e2a4b035e19ace0ad5c55c58a15ee1d8265fee.tar.zst re3-73e2a4b035e19ace0ad5c55c58a15ee1d8265fee.zip |
Diffstat (limited to 'src/weapons/Weapon.cpp')
-rw-r--r-- | src/weapons/Weapon.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/weapons/Weapon.cpp b/src/weapons/Weapon.cpp index 0fc89637..f83f2271 100644 --- a/src/weapons/Weapon.cpp +++ b/src/weapons/Weapon.cpp @@ -3,11 +3,14 @@ #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); } WRAPPER void CWeapon::AddGunshell(CEntity*, CVector const&, CVector2D const&, float) { EAXJMP(0x55F770); } WRAPPER void CWeapon::Update(int32 audioEntity) { EAXJMP(0x563A10); } +WRAPPER void CWeapon::DoTankDoomAiming(CEntity *playerVehicle, CEntity *playerPed, CVector *start, CVector *end) { EAXJMP(0x563200); } void CWeapon::Initialise(eWeaponType type, int ammo) @@ -49,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 |