Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Neck BodyPart for melee targeting #3206

Merged
merged 3 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ public BodyPartHeight finalHeight(Pawn target)
if (PawnParent.skills.GetSkill(SkillDefOf.Melee).Level >= 16)
{
//TODO: 1.5 Should be neck?
targetBodyPart = BodyPartDefOf.Eye;
targetBodyPart = CE_BodyPartDefOf.Neck;

var neck = target.health.hediffSet.GetNotMissingParts(BodyPartHeight.Top).Where(y => y.def == BodyPartDefOf.Eye).FirstOrFallback();
var neck = target.health.hediffSet.GetNotMissingParts(BodyPartHeight.Top).Where(y => y.def == CE_BodyPartDefOf.Neck).FirstOrFallback();

if (neck != null)
{
Expand Down
12 changes: 12 additions & 0 deletions Source/CombatExtended/CombatExtended/DefOfs/CE_BodyPartDefOf.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;
using Verse;
using RimWorld;

namespace CombatExtended
{
[DefOf]
public static class CE_BodyPartDefOf
{
public static BodyPartDef Neck;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ private void RebuildArmorCache(Dictionary<BodyPartRecord, float> armorCache, Sta
foreach (BodyPartRecord part in SelPawnForGear.RaceProps.body.AllParts)
{
//TODO: 1.5 should be Neck
if (part.depth == BodyPartDepth.Outside && (part.coverage >= 0.1 || (part.def == BodyPartDefOf.Eye || part.def == BodyPartDefOf.Eye)))
if (part.depth == BodyPartDepth.Outside && (part.coverage >= 0.1 || (part.def == CE_BodyPartDefOf.Neck || part.def == CE_BodyPartDefOf.Neck)))
{
float armorValue = part.IsInGroup(CE_BodyPartGroupDefOf.CoveredByNaturalArmor) ? naturalArmor : 0f;
if (wornApparel != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ private IEnumerable<DamageInfo> DamageInfosToApply(LocalTargetInfo target, bool
{
//TODO: 1.5 Should be neck?
var neck = pawn.health.hediffSet.GetNotMissingParts(BodyPartHeight.Top, BodyPartDepth.Outside)
.FirstOrDefault(r => r.def == BodyPartDefOf.Eye);
.FirstOrDefault(r => r.def == CE_BodyPartDefOf.Neck);
damageInfo.SetHitPart(neck);
}
//for some reason, when all parts of height are missing their incode count is 3
Expand Down
Loading