Skip to content

Commit

Permalink
Corrected shoot position if no shootLine found
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxDorob committed Nov 17, 2024
1 parent 5bd107f commit c0694fd
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public class Verb_LaunchProjectileCE : Verb
private bool shootingAtDowned = false;
private LocalTargetInfo lastTarget = null;
protected IntVec3 lastTargetPos = IntVec3.Invalid;
protected Vector3 lastExactPos = Vector3.negativeInfinity;

protected float lastShotAngle;
protected float lastShotRotation;
Expand Down Expand Up @@ -1054,6 +1055,7 @@ protected virtual bool KeepBurstOnNoShootLine(bool suppressing, out ShootLine sh
}
shootLine = (ShootLine)lastShootLine;
currentTarget = new LocalTargetInfo(lastTargetPos);
lastExactPos = lastTargetPos.ToVector3Shifted();
}
else // case 4,5,8
{
Expand All @@ -1062,6 +1064,7 @@ protected virtual bool KeepBurstOnNoShootLine(bool suppressing, out ShootLine sh
if (currentTarget.IsValid && !currentTarget.ThingDestroyed)
{
lastShootLine = shootLine = new ShootLine(caster.Position, currentTarget.Cell);
lastExactPos = currentTarget.Cell.ToVector3Shifted();
}
else
{
Expand Down Expand Up @@ -1106,6 +1109,7 @@ public override bool TryCastShot()
if (TryFindCEShootLineFromTo(caster.Position, currentTarget, out var shootLine, out var targetLoc)) // Case 1
{
lastShootLine = shootLine;
lastExactPos = targetLoc;
}
else // We cannot hit the current target
{
Expand Down Expand Up @@ -1139,7 +1143,7 @@ public override bool TryCastShot()

ProjectileCE projectile = (ProjectileCE)ThingMaker.MakeThing(Projectile, null);
GenSpawn.Spawn(projectile, shootLine.Source, caster.Map);
ShiftTarget(report, targetLoc, pelletMechanicsOnly, instant);
ShiftTarget(report, lastExactPos, pelletMechanicsOnly, instant);

//New aiming algorithm
projectile.canTargetSelf = false;
Expand Down

0 comments on commit c0694fd

Please sign in to comment.