Skip to content

Commit

Permalink
Execution distance checking
Browse files Browse the repository at this point in the history
  • Loading branch information
XeoNovaDan committed Nov 27, 2018
1 parent 7e109c7 commit a4bc86e
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 6 deletions.
Binary file modified Assemblies/TargetingModes.dll
Binary file not shown.
Binary file modified Source/TargetingModes/.vs/TargetingModes/v15/.suo
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 2 additions & 2 deletions Source/TargetingModes/TargetingModeDef.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public bool TagsListContains(List<BodyPartTagDef> partTags)
return false;
}

public int RerollCount(Pawn pawn)
public int RerollCount(Pawn pawn, Thing instigator)
{
float finalizedRerollCount = rerollCount;

Expand All @@ -61,7 +61,7 @@ public int RerollCount(Pawn pawn)
finalizedRerollCount *= extensionValues.targetModeRerollCountFactors[this];

// Whether or not a reroll bonus is applied for the target being downed
if (pawn.Downed)
if (pawn.Downed && (pawn.Position - instigator.Position).LengthHorizontal <= ShootTuning.ExecutionMaxDistance)
finalizedRerollCount *= ShootTuning.ExecutionAccuracyFactor;

return GenMath.RoundRandom(finalizedRerollCount);
Expand Down
8 changes: 4 additions & 4 deletions Source/TargetingModes/TargetingModesUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public static BodyPartRecord ResolvePrioritizedPart_External(BodyPartRecord part
{
TargetingModeDef targetingMode = targetingComp.GetTargetingMode();
if (!part.IsPrioritizedPart(targetingMode))
newPart = RerollBodyPart(targetingMode, part, dinfo.Def, dinfo.Height, BodyPartDepth.Outside, pawn);
newPart = RerollBodyPart(targetingMode, part, dinfo.Def, dinfo.Height, BodyPartDepth.Outside, pawn, dinfo.Instigator);
}
return newPart;
}
Expand All @@ -81,11 +81,11 @@ public static bool IsPrioritizedPart(this BodyPartRecord part, TargetingModeDef


public static BodyPartRecord RerollBodyPart(TargetingModeDef targetingMode, BodyPartRecord bodyPart, DamageInfo dinfo, Pawn pawn) =>
RerollBodyPart(targetingMode, bodyPart, dinfo.Def, dinfo.Height, dinfo.Depth, pawn);
RerollBodyPart(targetingMode, bodyPart, dinfo.Def, dinfo.Height, dinfo.Depth, pawn, dinfo.Instigator);

public static BodyPartRecord RerollBodyPart(TargetingModeDef targetingMode, BodyPartRecord bodyPart, DamageDef damDef, BodyPartHeight height, BodyPartDepth depth, Pawn pawn)
public static BodyPartRecord RerollBodyPart(TargetingModeDef targetingMode, BodyPartRecord bodyPart, DamageDef damDef, BodyPartHeight height, BodyPartDepth depth, Pawn pawn, Thing instigator)
{
for (int i = 0; i < targetingMode.RerollCount(pawn); i++)
for (int i = 0; i < targetingMode.RerollCount(pawn, instigator); i++)
{
BodyPartRecord newPart = pawn.health.hediffSet.GetRandomNotMissingPart(damDef, height, depth);
if (newPart.IsPrioritizedPart(targetingMode))
Expand Down
Binary file modified Source/TargetingModes/obj/Debug/TargetingModes.dll
Binary file not shown.

0 comments on commit a4bc86e

Please sign in to comment.