Skip to content

Commit

Permalink
v1.18.1.6 fixes and adjustments
Browse files Browse the repository at this point in the history
-Tooltips are shortened for generation bonus to improve legibility.
-Added extra tutor information on Diablerie and Generations.
-Eclipses no longer cause problems for vampires.
-Vampires no longer have alerts sent out if they are not wearing the right clothes for winter.
-Vampires no longer get thought moodlets about sleeping out in the cold / heat.
-Vampires can no longer try to consume corpses only to throw lots of weird errors.
  • Loading branch information
jecrell committed Jan 13, 2018
1 parent 1ebd2b5 commit 248ce66
Show file tree
Hide file tree
Showing 7 changed files with 160 additions and 6 deletions.
Binary file modified Assemblies/Vampire.dll
Binary file not shown.
17 changes: 17 additions & 0 deletions Defs/Tutor/ROMV_Tutor.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<Defs>

<!-- 1/13/17 -->

<ConceptDef>
<defName>ROMV_VampDiablerie</defName>
<label>Vampires: Diablerie</label>
<priority>50</priority>
<helpText>Diablerie is when one vampire drains another vampire of not just all its vitae, but its very soul. If the victim had a lower generation than the attacker, the consumer will lower its generation to match the generation of the soul it devoured. This is the only way to further empower your vampires.</helpText>
</ConceptDef>

<ConceptDef>
<defName>ROMV_VampGenerations</defName>
<label>Vampires: Generations</label>
<priority>50</priority>
<helpText>Vampires have a long and sordid history that extends back to the very first vampire. Generations represent how far removed a vampire is from the first vampire. The higher the number, the less powerful the vampiric curse. The only way to lower one's generation and become more powerful is to commit Diablerie.</helpText>
</ConceptDef>


<!-- 12/26/17 -->

<ConceptDef>
Expand Down
7 changes: 6 additions & 1 deletion Languages/English/Keyed/EngROMV.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<?xml version="1.0" encoding="utf-8" ?>
<LanguageData>

<!-- 1-13-18 -->
<ROMV_HI_Pain>Pain: x{0}</ROMV_HI_Pain>
<ROMV_HI_Senses>Senses: +{0}</ROMV_HI_Senses>
<ROMV_HI_Vigor>Vigor: +{0}</ROMV_HI_Vigor>

<!-- 1-4-18 -->
<ROMV_LevelUpGhoul>{0} has gained a level in ghoul disciplines.</ROMV_LevelUpGhoul>

Expand Down Expand Up @@ -77,7 +82,7 @@
<!-- 11-4-17 x2-->
<ROMV_HI_UnusedCapacities>NAME is one with the dead. HISCAP corpse has no need for most bodily functions. HECAP CAN still force them to function, to pass for being one of the living or when absolutely necessary.</ROMV_HI_UnusedCapacities>
<ROMV_HI_Unused>Unused</ROMV_HI_Unused>
<ROMV_HI_Immunities>Prevents: aging effects, disease, infections, temperature effects.</ROMV_HI_Immunities>
<ROMV_HI_Immunities>Prevents: aging effects, disease,\ninfections, temperature effects.</ROMV_HI_Immunities>
<ROMV_HI_Vampirism>Vampirism</ROMV_HI_Vampirism>

<!-- 11-4-17 -->
Expand Down
3 changes: 2 additions & 1 deletion Source/Vampires/AI_Jobs/JobGiver_SeekShelterFromSunlight.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ protected override Job TryGiveJob(Pawn pawn)
{
try
{
if (pawn.MapHeld is Map map && pawn.PositionHeld is IntVec3 pos && pos.IsValid && !pos.Roofed(map))
if (pawn.MapHeld is Map map && pawn.PositionHeld is IntVec3 pos && pos.IsValid &&
!pos.Roofed(map) && VampireUtility.IsForcedDarknessConditionInactive(map))
{
if (VampSunlightPathUtility.GetSunlightPathJob(pawn) is Job j)
return j;
Expand Down
82 changes: 81 additions & 1 deletion Source/Vampires/HarmonyPatches/HarmonyPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,10 @@ where typeof(WorkGiver).IsAssignableFrom(assemblyType)
//Vampires should tire very much during the daylight hours.
harmony.Patch(AccessTools.Method(typeof(Need_Rest), "NeedInterval"), null,
new HarmonyMethod(typeof(HarmonyPatches), nameof(Vamp_SleepyDuringDaylight)));
//Vampires should not have memories like SleptInCold and SleptInHeat
harmony.Patch(AccessTools.Method(typeof(Toils_LayDown), "ApplyBedThoughts"), null,
new HarmonyMethod(typeof(HarmonyPatches), nameof(Vamp_ApplyBedThoughts)));


#endregion

Expand Down Expand Up @@ -429,6 +433,9 @@ where typeof(WorkGiver).IsAssignableFrom(assemblyType)
// //Vampires should not calculate the pain of their internal organs.
// harmony.Patch(AccessTools.Method(typeof(HediffSet), "CalculatePain"), null,
// new HarmonyMethod(typeof(HarmonyPatches), nameof(Vamp_CalculatePain)));
//Vampires do not need warm clothes alerts.
harmony.Patch(AccessTools.Method(typeof(Alert_NeedWarmClothes), "GetReport"), null,
new HarmonyMethod(typeof(HarmonyPatches), nameof(Vamp_DontNeedWarmClothesReports)));

#endregion

Expand Down Expand Up @@ -464,6 +471,54 @@ where typeof(WorkGiver).IsAssignableFrom(assemblyType)
#endregion
}

//Alert_NeedWarmClothes
public static void Vamp_DontNeedWarmClothesReports(Alert_NeedWarmClothes __instance, ref AlertReport __result )
{
if (__result.culprit.Thing is Pawn p && p.IsVampire())
{
float num = AlertNeedWarmClothes_LowestTemperatureComing(p.MapHeld);
var colonists = new List<Pawn>(p.MapHeld.mapPawns.FreeColonistsSpawned.Where(x => !x.IsVampire()));
if (!colonists.NullOrEmpty())
{
foreach (Pawn pawn in colonists)
{
if (pawn.GetStatValue(StatDefOf.ComfyTemperatureMin, true) > num)
{
__result = pawn;
return;
}
}
}
__result = false;
return;
}
}
private static float AlertNeedWarmClothes_LowestTemperatureComing(Map map)
{
Twelfth twelfth = GenLocalDate.Twelfth(map);
float a = GenTemperature.AverageTemperatureAtTileForTwelfth(map.Tile, twelfth);
for (int i = 0; i < 3; i++)
{
twelfth = twelfth.NextTwelfth();
a = Mathf.Min(a, GenTemperature.AverageTemperatureAtTileForTwelfth(map.Tile, twelfth));
}
return Mathf.Min(a, map.mapTemperature.OutdoorTemp);
}

// RimWorld.Toils_LayDown
public static void Vamp_ApplyBedThoughts(Pawn actor)
{
if (actor.needs.mood == null)
{
return;
}
if (actor.IsVampire())
{
actor.needs.mood.thoughts.memories.RemoveMemoriesOfDef(ThoughtDefOf.SleptInCold);
actor.needs.mood.thoughts.memories.RemoveMemoriesOfDef(ThoughtDefOf.SleptInHeat);
}
}

public static void Vamp_CalculatePain(HediffSet __instance, ref float __result)
{
if (__instance?.pawn == null) return;
Expand Down Expand Up @@ -1809,6 +1864,31 @@ private static void AddHumanlikeOrders_Vamp(Vector3 clickPos, Pawn pawn, ref Lis

}

//Hide corpse consumption from menus.
Thing corpse = c.GetThingList(pawn.Map).FirstOrDefault(t => t is Corpse);
if (corpse != null)
{
string text;
if (corpse.def.ingestible.ingestCommandString.NullOrEmpty())
{
text = "ConsumeThing".Translate(new object[]
{
corpse.LabelShort
});
}
else
{
text = string.Format(corpse.def.ingestible.ingestCommandString, corpse.LabelShort);
}

FloatMenuOption o = opts.FirstOrDefault(x => x.Label.Contains(text));
if (o != null)
{
opts.Remove(o);
}

}

//Add blood consumption
Thing bloodItem = c.GetThingList(pawn.Map).FirstOrDefault(t => t.def.GetCompProperties<CompProperties_BloodItem>() != null);
if (bloodItem != null)
Expand All @@ -1818,7 +1898,7 @@ private static void AddHumanlikeOrders_Vamp(Vector3 clickPos, Pawn pawn, ref Lis
{
text = "ConsumeThing".Translate(new object[]
{
food.LabelShort
bloodItem.LabelShort
});
}
if (!bloodItem.IsSociallyProper(pawn))
Expand Down
31 changes: 30 additions & 1 deletion Source/Vampires/Hediffs/HediffVampirismGenerationBonus.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using Verse;
using System;
using System.Linq;
using System.Text;
using Verse;

namespace Vampire
{
Expand All @@ -18,6 +21,32 @@ public override string LabelBase
}


public override string TipStringExtra
{
get
{
var s = new StringBuilder();
try
{
string painFactor = this.def.stages[0].painFactor.ToStringPercent();
string sensesFactor = this.def.stages[0].capMods.First().offset.ToStringPercent();
s.AppendLine("ROMV_HI_Pain".Translate(painFactor));
s.AppendLine("ROMV_HI_Senses".Translate(sensesFactor));
s.AppendLine("ROMV_HI_Vigor".Translate(sensesFactor));
s.AppendLine("ROMV_HI_Immunities".Translate());
if (!this.comps.NullOrEmpty())
foreach (HediffComp compProps in this.comps)
if (compProps is JecsTools.HediffComp_DamageSoak dmgSoak)
s.AppendLine(dmgSoak.CompTipStringExtra);
}
catch (NullReferenceException)
{
//Log.Message(e.ToString());
}
return s.ToString();
}
}

public override bool ShouldRemove => this.def != pawn.GenerationDef();

public override void PostRemoved()
Expand Down
26 changes: 24 additions & 2 deletions Source/Vampires/Utilities/VampireUtility.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using RimWorld;
using System;
using RimWorld;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
Expand Down Expand Up @@ -63,13 +64,34 @@ public static CompVampire VampComp(this Pawn pawn)
public static bool IsDaylight(Map m)
{
float num = GenCelestial.CurCelestialSunGlow(m);
if (GenCelestial.IsDaytime(num))
if (GenCelestial.IsDaytime(num) &&
IsForcedDarknessConditionInactive(m))
{
return true;
}
return false;
}

public static bool IsForcedDarknessConditionInactive(Map m)
{
return (!m.gameConditionManager.ConditionIsActive(GameConditionDefOf.Eclipse) &&
!BloodMoonConditionActive(m));
}


public static bool BloodMoonConditionActive(Map m)
{
try
{
if (DefDatabase<GameConditionDef>.GetNamedSilentFail("HPLovecraft_BloodMoon") is GameConditionDef def)
return m.gameConditionManager.ConditionIsActive(def);
}
catch
{
}
return false;
}

//Checks for sunrise conditions.
public static bool IsSunRisingOrDaylight(this Pawn p)
{
Expand Down

0 comments on commit 248ce66

Please sign in to comment.