Skip to content

Commit

Permalink
Resolved issue with Arachnids crash
Browse files Browse the repository at this point in the history
Arachnids no longer crashes when paired with Vampires.
  • Loading branch information
jecrell committed Jan 8, 2018
1 parent 24a0958 commit da1852b
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 25 deletions.
Binary file modified Assemblies/Vampire.dll
Binary file not shown.
8 changes: 0 additions & 8 deletions Defs/NeedDefs/ROMV_Needs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,5 @@
<fallPerDay>0.1</fallPerDay>
<listPriority>50</listPriority>
</NeedDef>


<NeedDef Name="ROMV_DrugAddictionNeedBase" Abstract="True">
<onlyIfCausedByHediff>true</onlyIfCausedByHediff>
<tutorHighlightTag>NeedAddiction</tutorHighlightTag>
<showForCaravanMembers>true</showForCaravanMembers>
</NeedDef>


</Defs>
2 changes: 1 addition & 1 deletion Source/Vampires/AI_Jobs/JobDriver_Feed.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ protected override IEnumerable<Toil> MakeNewToils()
public static IEnumerable<Toil> MakeFeedToils(JobDef job, JobDriver thisDriver, Pawn actor, LocalTargetInfo TargetA, ThoughtDef victimThoughtDef, ThoughtDef actorThoughtDef, float workLeft, Action effect, Func<Pawn, Pawn, bool> stopCondition, bool needsGrapple = true, bool cleansWound = true, bool neverGiveUp = false)
{
yield return Toils_Reserve.Reserve(TargetIndex.A);
Toil gotoToil = actor?.Faction == TargetA.Thing?.Faction ? Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.ClosestTouch) : Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch);
Toil gotoToil = actor?.Faction == TargetA.Thing?.Faction && (!actor.InAggroMentalState && !((Pawn)TargetA.Thing).InAggroMentalState) ? Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.ClosestTouch) : Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch);
yield return gotoToil;
Toil grappleToil = new Toil()
{
Expand Down
5 changes: 3 additions & 2 deletions Source/Vampires/Buildings/Building_Coffin.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using RimWorld;
using Verse;

Expand Down Expand Up @@ -31,8 +32,8 @@ public override IEnumerable<Gizmo> GetGizmos()
foreach (Gizmo g in base.GetGizmos())
yield return g;

var p = this?.Corpse?.InnerPawn ?? this?.ContainedThing as Pawn ?? null;
if (p?.IsVampire() ?? false)
var p = Corpse?.InnerPawn ?? (Pawn)(innerContainer.FirstOrDefault()) ?? null;
if ((p?.IsVampire() ?? false) || (p?.HasVampireHediffs() ?? false))
{
foreach (Gizmo y in HarmonyPatches.GraveGizmoGetter(p, this))
yield return y;
Expand Down
41 changes: 27 additions & 14 deletions Source/Vampires/HarmonyPatches/HarmonyPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ static HarmonyPatches()
x.GetName().Name != "AnimalRangedVerbsUnlocker" &&
x.GetName().Name != "ExplosionTypes" &&
x.GetName().Name != "NewAnimalSubproducts" &&
x.GetName().Name != "NewHatcher")
x.GetName().Name != "NewHatcher" &&
x.GetName().Name != "SmurfeRims" &&
x.GetName().Name != "Bugs")
from assemblyType in domainAssembly.GetTypes()
where typeof(ThinkNode_JobGiver).IsAssignableFrom(assemblyType)
select assemblyType).ToArray();
Expand Down Expand Up @@ -107,7 +109,9 @@ where typeof(ThinkNode_JobGiver).IsAssignableFrom(assemblyType)
x.GetName().Name != "AnimalRangedVerbsUnlocker" &&
x.GetName().Name != "ExplosionTypes" &&
x.GetName().Name != "NewAnimalSubproducts" &&
x.GetName().Name != "NewHatcher")
x.GetName().Name != "NewHatcher" &&
x.GetName().Name != "SmurfeRims" &&
x.GetName().Name != "Bugs")
from assemblyType in domainAssembly.GetTypes()
where typeof(JoyGiver).IsAssignableFrom(assemblyType)
select assemblyType).ToArray();
Expand Down Expand Up @@ -138,7 +142,9 @@ where typeof(JoyGiver).IsAssignableFrom(assemblyType)
x.GetName().Name != "AnimalRangedVerbsUnlocker" &&
x.GetName().Name != "ExplosionTypes" &&
x.GetName().Name != "NewAnimalSubproducts" &&
x.GetName().Name != "NewHatcher")
x.GetName().Name != "NewHatcher" &&
x.GetName().Name != "SmurfeRims" &&
x.GetName().Name != "Bugs")
from assemblyType in domainAssembly.GetTypes()
where typeof(WorkGiver).IsAssignableFrom(assemblyType)
select assemblyType).ToArray();
Expand Down Expand Up @@ -460,21 +466,28 @@ where typeof(WorkGiver).IsAssignableFrom(assemblyType)

public static void Vamp_CalculatePain(HediffSet __instance, ref float __result)
{
if (!this.pawn.RaceProps.IsFlesh || this.pawn.Dead)
{
return 0f;
}
float num = 0f;
for (int i = 0; i < this.hediffs.Count; i++)
if (__instance?.pawn == null) return;
if (!__instance.pawn.IsVampire()) return;
if (!__instance.pawn.RaceProps.IsFlesh || __instance.pawn.Dead)
return;

var num = 0f;
for (int i = 0; i < __instance.hediffs.Count; i++)
{
num += this.hediffs[i].PainOffset;
if (__instance?.hediffs[i]?.Part?.depth == BodyPartDepth.Inside)
{
num += __instance.hediffs[i].PainOffset;
}
}
float num2 = num / this.pawn.HealthScale;
for (int j = 0; j < this.hediffs.Count; j++)
float num2 = num / __instance.pawn.HealthScale;
for (int j = 0; j < __instance.hediffs.Count; j++)
{
num2 *= this.hediffs[j].PainFactor;
if (__instance?.hediffs[j]?.Part?.depth == BodyPartDepth.Inside)
{
num2 *= __instance.hediffs[j].PainFactor;
}
}
return Mathf.Clamp(num2, 0f, 1f);
__result = Mathf.Clamp01(__result - num2);
}

// Verse.Pawn_InventoryTracker
Expand Down
12 changes: 12 additions & 0 deletions Source/Vampires/Utilities/VampireUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@ public static bool IsVampire(this Pawn pawn)
return true;
return false;
}

public static bool HasVampireHediffs(this Pawn pawn)
{
if (pawn == null) return false;
return pawn.health.hediffSet.HasHediff(VampDefOf.ROM_Vampirism) ||
pawn.health.hediffSet.HasHediff(VampDefOf.ROM_VampirismRandom) ||
pawn.health.hediffSet.HasHediff(VampDefOf.ROM_VampirismGargoyle) ||
pawn.health.hediffSet.HasHediff(VampDefOf.ROM_VampirismLasombra) ||
pawn.health.hediffSet.HasHediff(VampDefOf.ROM_VampirismPijavica) ||
pawn.health.hediffSet.HasHediff(VampDefOf.ROM_VampirismTremere) ||
pawn.health.hediffSet.HasHediff(VampDefOf.ROM_VampirismTzimisce);
}

public static bool IsAndroid(this Pawn pawn)
{
Expand Down

0 comments on commit da1852b

Please sign in to comment.