diff --git a/Source/CombatExtended/CombatExtended/Projectiles/ProjectileCE.cs b/Source/CombatExtended/CombatExtended/Projectiles/ProjectileCE.cs
index b4c10532cb..6599cf711e 100644
--- a/Source/CombatExtended/CombatExtended/Projectiles/ProjectileCE.cs
+++ b/Source/CombatExtended/CombatExtended/Projectiles/ProjectileCE.cs
@@ -1509,7 +1509,27 @@ protected float GetHeightAtTicks(int ticks)
/// Height from which the projectile is fired in vertical cells.
/// Distance in cells that the projectile will fly at the given arc.
protected float DistanceTraveled => TrajectoryWorker.DistanceTraveled(shotHeight, shotSpeed, shotAngle, GravityFactor);
-
+ ///
+ /// Calculates the shot angle necessary to reach range with a projectile of speed velocity at a height difference of heightDifference, returning either the upper or lower arc in radians. Does not take into account air resistance.
+ ///
+ /// Projectile velocity in cells per second.
+ /// Cells between shooter and target.
+ /// Difference between initial shot height and target height in vertical cells.
+ /// Whether to take the lower (False) or upper (True) arc angle.
+ /// Arc angle in radians off the ground.
+ public static float GetShotAngle(float velocity, float range, float heightDifference, bool flyOverhead, float gravity)
+ {
+ Log.WarningOnce("ProjectileCE.GetShotAngle is obsolete and will be removed in future updates. Please, use TrajectoryWorker.GetShotAngle, that can be obtained from ProjectilePropertiesCE", 58606596);
+ float squareRootCheck = Mathf.Sqrt(Mathf.Pow(velocity, 4f) - gravity * (gravity * Mathf.Pow(range, 2f) + 2f * heightDifference * Mathf.Pow(velocity, 2f)));
+ if (float.IsNaN(squareRootCheck))
+ {
+ //Target is too far to hit with given velocity/range/gravity params
+ //set firing angle for maximum distance
+ Log.Warning("[CE] Tried to fire projectile to unreachable target cell, truncating to maximum distance.");
+ return 45.0f * Mathf.Deg2Rad;
+ }
+ return Mathf.Atan((Mathf.Pow(velocity, 2f) + (flyOverhead ? 1f : -1f) * squareRootCheck) / (gravity * range));
+ }
#endregion