Skip to content

Commit

Permalink
Merge pull request #3365 from CombatExtended-Continued/TallShooterUnd…
Browse files Browse the repository at this point in the history
…erRoofFix

Proj from tall shooter under roof ignore roof
  • Loading branch information
N7Huntsman authored Sep 21, 2024
2 parents 3946253 + 85e18c5 commit b920d2c
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion Source/CombatExtended/CombatExtended/Projectiles/ProjectileCE.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -358,6 +359,7 @@ public override void ExposeData()
Scribe_Values.Look<bool>(ref logMisses, "logMisses", true);
Scribe_Values.Look<bool>(ref castShadow, "castShadow", true);
Scribe_Values.Look<bool>(ref lerpPosition, "lerpPosition", true);
Scribe_Values.Look(ref ignoreRoof, "ignoreRoof", true);

//To fix landed grenades sl problem
Scribe_Values.Look(ref exactPosition, "exactPosition");
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
}

/// <summary>
Expand Down

0 comments on commit b920d2c

Please sign in to comment.