Skip to content

Commit

Permalink
Enhance comments
Browse files Browse the repository at this point in the history
Clarifies both that ship velocity is not used in any inaccuracy calculations and the purpose of the speed variable.

Co-Authored-By: Amazinite <jsteck2000@gmail.com>
  • Loading branch information
DeBlister and Amazinite committed Apr 21, 2022
1 parent 09fee89 commit e7a8cfb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions source/Projectile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ Projectile::Projectile(const Ship &parent, Point position, Angle angle, const We
if(inaccuracy)
this->angle += Angle::Random(inaccuracy) - Angle::Random(inaccuracy);

// Inaccuracy is only applied to the velocity of the projectile, not the velocity of the ship,
// so we don't include the firing ship's velocity in the recorded speed of the projectile.
speed = weapon->Velocity() + Random::Real() * weapon->RandomVelocity();
velocity += this->angle.Unit() * speed;

Expand Down
3 changes: 2 additions & 1 deletion source/Projectile.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ class Projectile : public Body {
const Ship *cachedTarget = nullptr;
const Government *targetGovernment = nullptr;

// How much speed has been added by all stages of this projectile.
// How much speed has been added by all stages of this projectile
// relative to the firing ship.
double speed = 0.;
double clip = 1.;
int lifetime = 0;
Expand Down

0 comments on commit e7a8cfb

Please sign in to comment.