Skip to content

Commit

Permalink
Simplify the code and fix the manual for Straight
Browse files Browse the repository at this point in the history
  • Loading branch information
CrimRecya committed Feb 8, 2025
1 parent cf4dba5 commit a7ca25f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
3 changes: 1 addition & 2 deletions docs/New-or-Enhanced-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -817,8 +817,7 @@ Trajectory.Straight.CountAttenuation=1.0 ; floating point value

```{note}
- Make sure you set a low `Trajectory.Straight.ProximityRadius` value unless necessary.
- Note that if `Trajectory.Straight.ProximityFlight` is true, it will consume more CPU performance.
- Note that the listed Warheads in `Trajectory.Straight.PassDetonateWarhead` and `Trajectory.Straight.ProximityWarhead` must be listed in `[Warheads]` for them to work.
- The listed Warheads in `Trajectory.Straight.PassDetonateWarhead` and `Trajectory.Straight.ProximityWarhead` must be listed in `[Warheads]` for them to work.
```

#### Bombard trajectory
Expand Down
19 changes: 9 additions & 10 deletions src/Ext/Bullet/Trajectories/StraightTrajectory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,9 @@ void StraightTrajectoryType::Read(CCINIClass* const pINI, const char* pSection)
this->SubjectToGround.Read(exINI, pSection, "Trajectory.Straight.SubjectToGround");
this->ConfineAtHeight.Read(exINI, pSection, "Trajectory.Straight.ConfineAtHeight");
this->EdgeAttenuation.Read(exINI, pSection, "Trajectory.Straight.EdgeAttenuation");

if (this->EdgeAttenuation < 0.0)
this->EdgeAttenuation = 0.0;

this->EdgeAttenuation = Math::max(0.0, this->EdgeAttenuation);
this->CountAttenuation.Read(exINI, pSection, "Trajectory.Straight.CountAttenuation");

if (this->CountAttenuation < 0.0)
this->CountAttenuation = 0.0;
this->CountAttenuation = Math::max(0.0, this->CountAttenuation);
}

template<typename T>
Expand Down Expand Up @@ -663,8 +658,10 @@ void StraightTrajectory::BulletDetonateLastCheck(BulletClass* pBullet, HouseClas

if (pType->ProximityDirect)
pDetonateAt->ReceiveDamage(&damage, 0, pWH, pBullet->Owner, false, false, pOwner);
else if (pType->ProximityMedial)
WarheadTypeExt::DetonateAt(pWH, pBullet->Location, pBullet->Owner, damage, pOwner);
else
WarheadTypeExt::DetonateAt(pWH, pType->ProximityMedial ? pBullet->Location : position, pBullet->Owner, damage, pOwner, pType->ProximityMedial ? nullptr : pDetonateAt);
WarheadTypeExt::DetonateAt(pWH, position, pBullet->Owner, damage, pOwner, pDetonateAt);

this->CalculateNewDamage(pBullet);
}
Expand Down Expand Up @@ -790,7 +787,7 @@ void StraightTrajectory::PrepareForDetonateAt(BulletClass* pBullet, HouseClass*
return;

// Step 1: Find valid targets on the ground within range.
std::vector<CellClass*> recCellClass = PhobosTrajectoryType::GetCellsInProximityRadius(pBullet, this->Type->ProximityRadius.Get());
std::vector<CellClass*> recCellClass = PhobosTrajectoryType::GetCellsInProximityRadius(pBullet, pType->ProximityRadius.Get());
const size_t cellSize = recCellClass.size() * 2;
size_t vectSize = cellSize;
size_t thisSize = 0;
Expand Down Expand Up @@ -968,8 +965,10 @@ void StraightTrajectory::PrepareForDetonateAt(BulletClass* pBullet, HouseClass*

if (pType->ProximityDirect)
pTechno->ReceiveDamage(&damage, 0, pWH, pBullet->Owner, false, false, pOwner);
else if (pType->ProximityMedial)
WarheadTypeExt::DetonateAt(pWH, pBullet->Location, pBullet->Owner, damage, pOwner);
else
WarheadTypeExt::DetonateAt(pWH, pType->ProximityMedial ? pBullet->Location : pTechno->GetCoords(), pBullet->Owner, damage, pOwner, pType->ProximityMedial ? nullptr : pTechno);
WarheadTypeExt::DetonateAt(pWH, pTechno->GetCoords(), pBullet->Owner, damage, pOwner, pTechno);

this->CalculateNewDamage(pBullet);

Expand Down

0 comments on commit a7ca25f

Please sign in to comment.