diff --git a/Source/CombatExtended/CombatExtended/Projectiles/ProjectileCE.cs b/Source/CombatExtended/CombatExtended/Projectiles/ProjectileCE.cs index d75c85b226..e6461d8ca1 100644 --- a/Source/CombatExtended/CombatExtended/Projectiles/ProjectileCE.cs +++ b/Source/CombatExtended/CombatExtended/Projectiles/ProjectileCE.cs @@ -112,6 +112,7 @@ public virtual float DamageAmount public bool canTargetSelf; public bool castShadow = true; public bool logMisses = true; + protected bool ignoreRoof; public GlobalTargetInfo globalTargetInfo = GlobalTargetInfo.Invalid; public GlobalTargetInfo globalSourceInfo = GlobalTargetInfo.Invalid; @@ -358,6 +359,7 @@ public override void ExposeData() Scribe_Values.Look(ref logMisses, "logMisses", true); Scribe_Values.Look(ref castShadow, "castShadow", true); Scribe_Values.Look(ref lerpPosition, "lerpPosition", true); + Scribe_Values.Look(ref ignoreRoof, "ignoreRoof", true); //To fix landed grenades sl problem Scribe_Values.Look(ref exactPosition, "exactPosition"); @@ -563,6 +565,10 @@ public virtual void Launch(Thing launcher, Vector2 origin, float shotAngle, floa this.lerpPosition = props.lerpPosition; this.GravityFactor = props.Gravity; } + if (shotHeight >= CollisionVertical.WallCollisionHeight && Position.Roofed(launcher.Map)) + { + ignoreRoof = true; + } Launch(launcher, origin, equipment); } @@ -879,7 +885,7 @@ protected bool CheckCellForCollision(IntVec3 cell) protected virtual bool TryCollideWithRoof(IntVec3 cell) { - if (!cell.Roofed(Map)) + if (!cell.Roofed(Map) || ignoreRoof) { return false; } @@ -1215,6 +1221,11 @@ public override void Tick() { DangerTracker?.Notify_BulletAt(Position, def.projectile.damageAmountBase * dangerFactor); } + //If a flyoverhead ignore roof projectile is descending, enable roof check. + if (ignoreRoof && def.projectile.flyOverhead && shotAngle < 0) + { + ignoreRoof = false; + } } ///