Skip to content

Commit d159cfb

Browse files
authored
Merge pull request CombatExtended-Continued#4186 from CombatExtended-Continued/FragHeightAngleTweaks
Shift frags downwards for explosions at big heights
2 parents 3a070fd + c98038b commit d159cfb

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Source/CombatExtended/CombatExtended/Comps/CompFragments.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,16 @@ public void Throw(Vector3 pos, Map map, Thing instigator, float scaleFactor = 1)
9898

9999
float height;
100100
FloatRange fragXZAngleRange;
101+
FloatRange fragYAngleRange = PropsCE.fragAngleRange;
101102
if (parent is ProjectileCE projCE)
102103
{
103104
height = projCE.ExactPosition.y;
105+
//if the fragments use default value, shift the min angle lower to make it not fly over pawns when exploding at building heights
106+
if (height > 0.1f && Mathf.Approximately(PropsCE.fragAngleRange.min, 0.5f))
107+
{
108+
//launch with -30 angle at height of 1 vertical cell
109+
fragYAngleRange.min = -30f * height;
110+
}
104111
fragXZAngleRange = new FloatRange(projCE.shotRotation + PropsCE.fragXZAngleRange.min, projCE.shotRotation + PropsCE.fragXZAngleRange.max);
105112
}
106113
else
@@ -119,7 +126,7 @@ public void Throw(Vector3 pos, Map map, Thing instigator, float scaleFactor = 1)
119126
var newCount = fragment;
120127
newCount.count = Mathf.RoundToInt(newCount.count * scaleFactor);
121128

122-
var routine = FragRoutine(pos, map, height, instigator, fragment, PropsCE.fragSpeedFactor, PropsCE.fragShadowChance, PropsCE.fragAngleRange, fragXZAngleRange);
129+
var routine = FragRoutine(pos, map, height, instigator, fragment, PropsCE.fragSpeedFactor, PropsCE.fragShadowChance, fragYAngleRange, fragXZAngleRange);
123130
if (!Compatibility.Multiplayer.InMultiplayer)
124131
{
125132
_monoDummy.GetComponent<MonoDummy>().StartCoroutine(routine);

0 commit comments

Comments
 (0)