mirror of
https://github.com/rei-2/Amalgam
synced 2026-10-10 12:53:10 +08:00
fix non-player targeting issue
This commit is contained in:
@@ -260,15 +260,26 @@ int CAimbotHitscan::CanHit(Target_t& target, CTFPlayer* pLocal, CTFWeaponBase* p
|
||||
}
|
||||
if (!pRecords || vRecords.empty())
|
||||
{
|
||||
auto aBones = H::Entities.GetBones(target.m_pEntity->entindex());
|
||||
if (!aBones)
|
||||
return false;
|
||||
if (auto pBones = H::Entities.GetBones(target.m_pEntity->entindex()))
|
||||
{
|
||||
vRecords.push_front({
|
||||
target.m_pEntity->m_flSimulationTime(),
|
||||
*reinterpret_cast<BoneMatrix*>(pBones),
|
||||
target.m_pEntity->m_vecOrigin()
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
matrix3x4 aBones[MAXSTUDIOBONES];
|
||||
if (!target.m_pEntity->SetupBones(aBones, MAXSTUDIOBONES, BONE_USED_BY_ANYTHING, target.m_pEntity->m_flSimulationTime()))
|
||||
return false;
|
||||
|
||||
vRecords.push_front({
|
||||
target.m_pEntity->m_flSimulationTime(),
|
||||
*reinterpret_cast<BoneMatrix*>(aBones),
|
||||
target.m_pEntity->m_vecOrigin()
|
||||
});
|
||||
vRecords.push_front({
|
||||
target.m_pEntity->m_flSimulationTime(),
|
||||
*reinterpret_cast<BoneMatrix*>(&aBones),
|
||||
target.m_pEntity->m_vecOrigin()
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -297,15 +297,26 @@ int CAimbotMelee::CanHit(Target_t& target, CTFPlayer* pLocal, CTFWeaponBase* pWe
|
||||
}
|
||||
if (!pRecords || vRecords.empty())
|
||||
{
|
||||
auto aBones = H::Entities.GetBones(target.m_pEntity->entindex());
|
||||
if (!aBones)
|
||||
return false;
|
||||
if (auto pBones = H::Entities.GetBones(target.m_pEntity->entindex()))
|
||||
{
|
||||
vRecords.push_front({
|
||||
target.m_pEntity->m_flSimulationTime(),
|
||||
*reinterpret_cast<BoneMatrix*>(pBones),
|
||||
target.m_pEntity->m_vecOrigin()
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
matrix3x4 aBones[MAXSTUDIOBONES];
|
||||
if (!target.m_pEntity->SetupBones(aBones, MAXSTUDIOBONES, BONE_USED_BY_ANYTHING, target.m_pEntity->m_flSimulationTime()))
|
||||
return false;
|
||||
|
||||
vRecords.push_front({
|
||||
target.m_pEntity->m_flSimulationTime(),
|
||||
*reinterpret_cast<BoneMatrix*>(aBones),
|
||||
target.m_pEntity->m_vecOrigin()
|
||||
});
|
||||
vRecords.push_front({
|
||||
target.m_pEntity->m_flSimulationTime(),
|
||||
*reinterpret_cast<BoneMatrix*>(&aBones),
|
||||
target.m_pEntity->m_vecOrigin()
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!newRecords.empty())
|
||||
|
||||
@@ -872,8 +872,8 @@ bool CAimbotProjectile::TestAngle(CTFPlayer* pLocal, CTFWeaponBase* pWeapon, Tar
|
||||
auto pSet = pHDR->pHitboxSet(target.m_pEntity->As<CTFPlayer>()->m_nHitboxSet());
|
||||
if (!pSet) break;
|
||||
|
||||
auto aBones = H::Entities.GetBones(target.m_pEntity->entindex());
|
||||
if (!aBones)
|
||||
auto pBones = H::Entities.GetBones(target.m_pEntity->entindex());
|
||||
if (!pBones)
|
||||
break;
|
||||
|
||||
Vec3 vForward = vOld - vNew; vForward.Normalize();
|
||||
@@ -889,7 +889,7 @@ bool CAimbotProjectile::TestAngle(CTFPlayer* pLocal, CTFWeaponBase* pWeapon, Tar
|
||||
if (!pBox)
|
||||
continue;
|
||||
|
||||
Vec3 vCenter; Math::VectorTransform((pBox->bbmin + pBox->bbmax) / 2, aBones[pBox->bone], vCenter);
|
||||
Vec3 vCenter; Math::VectorTransform((pBox->bbmin + pBox->bbmax) / 2, pBones[pBox->bone], vCenter);
|
||||
|
||||
const float flDist = vPos.DistTo(vCenter);
|
||||
if (closestId != -1 && flDist < closestDist || closestId == -1)
|
||||
@@ -1118,11 +1118,11 @@ int CAimbotProjectile::CanHit(Target_t& target, CTFPlayer* pLocal, CTFWeaponBase
|
||||
{
|
||||
const Vec3 vOriginOffset = target.m_pEntity->m_vecOrigin() - vPredicted;
|
||||
|
||||
auto aBones = H::Entities.GetBones(target.m_pEntity->entindex());
|
||||
if (!aBones)
|
||||
auto pBones = H::Entities.GetBones(target.m_pEntity->entindex());
|
||||
if (!pBones)
|
||||
return true;
|
||||
|
||||
auto vBoxes = F::Visuals.GetHitboxes(aBones, target.m_pEntity->As<CTFPlayer>(), { HITBOX_HEAD });
|
||||
auto vBoxes = F::Visuals.GetHitboxes(pBones, target.m_pEntity->As<CTFPlayer>(), { HITBOX_HEAD });
|
||||
for (auto& bBox : vBoxes)
|
||||
{
|
||||
bBox.m_vecPos -= vOriginOffset;
|
||||
@@ -1134,11 +1134,11 @@ int CAimbotProjectile::CanHit(Target_t& target, CTFPlayer* pLocal, CTFWeaponBase
|
||||
{
|
||||
const Vec3 vOriginOffset = target.m_pEntity->m_vecOrigin() - vPredicted;
|
||||
|
||||
auto aBones = H::Entities.GetBones(target.m_pEntity->entindex());
|
||||
if (!aBones)
|
||||
auto pBones = H::Entities.GetBones(target.m_pEntity->entindex());
|
||||
if (!pBones)
|
||||
return true;
|
||||
|
||||
auto vBoxes = F::Visuals.GetHitboxes(aBones, target.m_pEntity->As<CTFPlayer>(), { HITBOX_HEAD });
|
||||
auto vBoxes = F::Visuals.GetHitboxes(pBones, target.m_pEntity->As<CTFPlayer>(), { HITBOX_HEAD });
|
||||
for (auto& bBox : vBoxes)
|
||||
{
|
||||
bBox.m_vecPos -= vOriginOffset;
|
||||
|
||||
@@ -842,11 +842,11 @@ void CVisuals::Event(IGameEvent* pEvent, uint32_t uHash)
|
||||
case EWeaponType::HITSCAN:
|
||||
case EWeaponType::MELEE:
|
||||
{
|
||||
matrix3x4* aBones = H::Entities.GetBones(pEntity->entindex());
|
||||
if (!aBones)
|
||||
auto pBones = H::Entities.GetBones(pEntity->entindex());
|
||||
if (!pBones)
|
||||
return;
|
||||
|
||||
auto vBoxes = F::Visuals.GetHitboxes(aBones, pEntity);
|
||||
auto vBoxes = F::Visuals.GetHitboxes(pBones, pEntity);
|
||||
G::BoxStorage.insert(G::BoxStorage.end(), vBoxes.begin(), vBoxes.end());
|
||||
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user