Skip to content

Commit

Permalink
[Minor] Fix two issues of enhanced straight trajectory (#1500)
Browse files Browse the repository at this point in the history
- Fix when `Trajectory=Straight` bullet with
`Trajectory.Straight.ProximityMedial=true` is attacking a large
building, the warhead may snap to the center of the building. #1499
- Fix when `Trajectory=Straight` bullet with a large
`Trajectory.Straight.ProximityRadius` and a low `Trajectory.Speed`, the
final speed may suddenly increase and rush out of range.
  • Loading branch information
CrimRecya authored Jan 20, 2025
1 parent 53e0684 commit 5a9a0ef
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Ext/Bullet/Trajectories/StraightTrajectory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ void StraightTrajectory::BulletDetonateLastCheck(BulletClass* pBullet, HouseClas
pBullet->SetTarget(pDetonateAt);
pBullet->TargetCoords = position;

if (std::abs(velocity) > 1e-10)
if (std::abs(velocity) > 1e-10 && distance < velocity)
pBullet->Velocity *= distance / velocity;

if (this->ProximityImpact != 0)
Expand All @@ -634,7 +634,7 @@ void StraightTrajectory::BulletDetonateLastCheck(BulletClass* pBullet, HouseClas
if (pType->ProximityDirect)
pDetonateAt->ReceiveDamage(&damage, 0, pWH, pBullet->Owner, false, false, pOwner);
else
WarheadTypeExt::DetonateAt(pWH, pType->ProximityMedial ? pBullet->Location : position, pBullet->Owner, damage, pOwner, pDetonateAt);
WarheadTypeExt::DetonateAt(pWH, pType->ProximityMedial ? pBullet->Location : position, pBullet->Owner, damage, pOwner, pType->ProximityMedial ? nullptr : pDetonateAt);

this->CalculateNewDamage(pBullet);
}
Expand Down Expand Up @@ -923,7 +923,7 @@ void StraightTrajectory::PrepareForDetonateAt(BulletClass* pBullet, HouseClass*
if (pType->ProximityDirect)
pTechno->ReceiveDamage(&damage, 0, pWH, pBullet->Owner, false, false, pOwner);
else
WarheadTypeExt::DetonateAt(pWH, pType->ProximityMedial ? pBullet->Location : pTechno->GetCoords(), pBullet->Owner, damage, pOwner, pTechno);
WarheadTypeExt::DetonateAt(pWH, pType->ProximityMedial ? pBullet->Location : pTechno->GetCoords(), pBullet->Owner, damage, pOwner, pType->ProximityMedial ? nullptr : pTechno);

this->CalculateNewDamage(pBullet);

Expand Down

0 comments on commit 5a9a0ef

Please sign in to comment.