public static Pawn GenerateVampire(int generation, BloodlineDef bloodline, Pawn sire, Faction vampFaction = null, bool firstVampire = false) { //Lower generation vampires are impossibly old. float?math = sire != null ? sire.ageTracker.AgeChronologicalYearsFloat + new FloatRange(100, 300).RandomInRange : generation > 4 ? Mathf.Clamp(2000 - generation * Rand.Range(20, 200), 16, 2000) : 100000 - generation * Rand.Range(10000, 50000); Faction faction = vampFaction != null ? vampFaction : generation < 7 ? Find.FactionManager.FirstFactionOfDef(VampDefOf.ROMV_LegendaryVampires) : VampireUtility.RandVampFaction; PawnGenerationRequest request = new PawnGenerationRequest( PawnKindDefOf.SpaceRefugee, Faction.OfSpacer, PawnGenerationContext.NonPlayer, -1, false, false, false, false, true, true, 20f, false, true, true, false, false, false, false, null, null, null, null, null, null); Pawn pawn = PawnGenerator.GeneratePawn(request); if (firstVampire) { NameTriple caineName = new NameTriple("Caine", "Caine", "Darkfather"); pawn.Name = caineName; pawn.gender = Gender.Male; } pawn.story.hairColor = PawnHairColors.RandomHairColor(pawn.story.SkinColor, 20); if (!bloodline.allowsHair) { pawn.story.hairDef = DefDatabase <HairDef> .GetNamed("Shaved"); } pawn.VampComp().InitializeVampirism(sire, bloodline, generation, firstVampire); //TryGiveVampirismHediff(pawn, generation, bloodline, sire, firstVampire); return(pawn); }
public VampireRecord(Pawn originPawn, int originGeneration, BloodlineDef originBloodline, float originAge, string originSireId, Faction originFaction = null) { kindDef = originPawn.kindDef; nameInt = originPawn.Name; gender = originPawn.gender; generation = originGeneration; bloodline = originBloodline; age = originAge; sireId = originSireId; recordAge = Find.TickManager.TicksGame; faction = originFaction ?? Find.FactionManager.FirstFactionOfDef(VampDefOf.ROMV_LegendaryVampires); if (originPawn.story == null) { Log.Warning(originPawn.Name.ToStringFull + " has no story to copy."); return; } childhood = originPawn.story.childhood; adulthood = originPawn.story.adulthood; melanin = originPawn.story.melanin; hairColor = originPawn.story.hairColor; crownType = originPawn.story.crownType; bodyType = originPawn.story.bodyType; hairDef = originPawn.story.hairDef; traits = originPawn.story.traits; id = generation.ToString() + "_" + bloodline.ToString() + "_" + nameInt.ToStringFull + "_" + gender.ToString(); }
/// <summary> /// Similar method as GenerateVampire, except it initializes ghouls. /// </summary> /// <param name="generation"></param> /// <param name="bloodline"></param> /// <param name="domitor"></param> /// <param name="vampFaction"></param> /// <param name="isRevenant"></param> /// <returns></returns> public static Pawn GenerateGhoul(int generation, BloodlineDef bloodline, Pawn domitor, Faction vampFaction = null, bool isRevenant = false) { //Lower generation ghouls are impossibly old. float?math = domitor != null ? domitor.ageTracker.AgeChronologicalYearsFloat + new FloatRange(100, 300).RandomInRange : generation > 4 ? Mathf.Clamp(2000 - generation * Rand.Range(20, 200), 16, 2000) : 100000 - generation * Rand.Range(10000, 50000); Faction faction = vampFaction != null ? vampFaction : generation < 7 ? Find.FactionManager.FirstFactionOfDef(VampDefOf.ROMV_LegendaryVampires) : VampireUtility.RandVampFaction; PawnGenerationRequest request = new PawnGenerationRequest( PawnKindDefOf.SpaceRefugee, Faction.OfAncients, PawnGenerationContext.NonPlayer, -1, false, false, false, false, true, true, 20f, false, true, true, false, false, false, false, false, 0, null, 0, null, null, null, null, null); Pawn pawn = PawnGenerator.GeneratePawn(request); pawn.story.hairColor = PawnHairColors.RandomHairColor(pawn.story.SkinColor, 20); if (!bloodline.allowsHair) { pawn.story.hairDef = DefDatabase <HairDef> .GetNamed("Shaved"); } pawn.VampComp().InitializeGhoul(domitor, isRevenant); return(pawn); }
public List <Pawn> TryGeneratingBloodline(Pawn childe, BloodlineDef bloodline) { List <Pawn> tempOldGen = new List <Pawn>(DormantVampires); if (bloodline == null) { bloodline = VampireUtility.RandBloodline; } Pawn thirdGenVamp = tempOldGen.FirstOrDefault(x => x?.VampComp() is CompVampire v && v.Generation == 3 && v.Bloodline == bloodline); List <Pawn> futureGenerations = new List <Pawn>(); Pawn curSire = thirdGenVamp; if (curSire == null) { Log.Error("Cannot find third generation sire."); return(null); } for (int curGen = 4; curGen < 14; curGen++) { Pawn newVamp = VampireGen.GenerateVampire(curGen, bloodline, curSire); futureGenerations.Add(newVamp); curSire = newVamp; } activeVampires.AddRange(futureGenerations); PrintVampires(); return(futureGenerations); }
public static Pawn FindSireFor(Pawn pawn, BloodlineDef bloodline = null, int idealGeneration = -1) { Pawn result = null; result = Find.World.GetComponent <WorldComponent_VampireTracker>().GetLaterGenerationVampire(pawn, bloodline, idealGeneration); return(result); }
public override void Randomize() { base.Randomize(); vampChance = Rand.Range(0.2f, 0.8f); bloodline = PossibleBloodlines().RandomElement(); generationRange.max = Rand.Range(10, 15); generationRange.min = Rand.Range(8, generationRange.max); spawnInCoffins = Rand.Value > 0.3 ? true : false; }
public override void Randomize() { base.Randomize(); this.vampChance = Rand.Range(0.2f, 0.8f); this.bloodline = this.PossibleBloodlines().RandomElement <BloodlineDef>(); this.generationRange.max = Rand.Range(10, 15); this.generationRange.min = Rand.Range(8, this.generationRange.max); this.spawnInCoffins = (Rand.Value > 0.3) ? true : false; }
//private Dictionary<Hediff, int> carriedBloodInfectors = null; //private Dictionary<Hediff, int> carriedBloodDrugEffects = null; //public bool IsInfectionCarrier => carriedBloodInfectors != null; //public bool IsDrugCarrier => carriedBloodDrugEffects != null; public override void PostTick() { base.PostTick(); if (this.pawn.VampComp() is CompVampire v) { if (!initialized) { initialized = true; if (!firstVampire) { if (sire == null) { sire = VampireRelationUtility.FindSireFor(this.pawn, this.bloodline, this.generation).VampComp(); } if (generation < 0) { generation = sire.Generation + 1; } if (bloodline == null) { bloodline = sire.Bloodline; } } if (v.IsVampire && v.Sire == null) { v.InitializeVampirism(sire?.AbilityUser ?? null, bloodline, generation, firstVampire); } this.pawn.Drawer.renderer.graphics.ResolveAllGraphics(); } if (Find.TickManager.TicksGame % 60 == 0) { if (v.InSunlight) { HealthUtility.AdjustSeverity(pawn, VampDefOf.ROMV_SunExposure, 0.001f); } if (v.BloodPool?.CurLevelPercentage < 0.3f) { HealthUtility.AdjustSeverity(pawn, VampDefOf.ROMV_TheBeast, 0.001f); } if (this.pawn.health.hediffSet is HediffSet hdSet) { if (hdSet.GetFirstHediffOfDef(HediffDefOf.Hypothermia) is Hediff hypoThermia) { hdSet.hediffs.Remove(hypoThermia); } else if (hdSet.GetFirstHediffOfDef(HediffDefOf.Heatstroke) is Hediff heatStroke) { hdSet.hediffs.Remove(heatStroke); } } } } }
public override void Notify_PawnGenerated(Pawn pawn, PawnGenerationContext context) { if (Find.VisibleMap == null) { curVampires = Find.GameInitData.startingPawns.FindAll(x => x?.health?.hediffSet?.hediffs.FirstOrDefault(y => y.def.defName.Contains("Vampirism")) != null)?.Count() ?? 0; BloodlineDef def = (randomBloodline) ? PossibleBloodlines().RandomElement() : bloodline; if (pawn.RaceProps.Humanlike && context == PawnGenerationContext.PlayerStarter) { if (Rand.Value < vampChance && curVampires < maxVampires) { curVampires++; HediffDef hediffDefToApply = VampDefOf.ROM_VampirismRandom; if (def == VampDefOf.ROMV_ClanGargoyle) { hediffDefToApply = VampDefOf.ROM_VampirismGargoyle; } if (def == VampDefOf.ROMV_ClanLasombra) { hediffDefToApply = VampDefOf.ROM_VampirismLasombra; } if (def == VampDefOf.ROMV_ClanPijavica) { hediffDefToApply = VampDefOf.ROM_VampirismPijavica; } if (def == VampDefOf.ROMV_ClanTremere) { hediffDefToApply = VampDefOf.ROM_VampirismTremere; } if (def == VampDefOf.ROMV_ClanTzimize) { hediffDefToApply = VampDefOf.ROM_VampirismTzimisce; } HealthUtility.AdjustSeverity(pawn, hediffDefToApply, 0.5f); pawn.story.hairColor = PawnHairColors.RandomHairColor(pawn.story.SkinColor, 20); int ticksToAdd = Rand.Range(GenDate.TicksPerYear, GenDate.TicksPerYear * 200); pawn.ageTracker.AgeBiologicalTicks += ticksToAdd; pawn.ageTracker.AgeChronologicalTicks += ticksToAdd; if (pawn.health.hediffSet.hediffs is List <Hediff> hediffs) { hediffs.RemoveAll(x => x.IsOld() || x.def == HediffDefOf.BadBack || x.def == HediffDefOf.Frail || x.def == HediffDefOf.Cataract || x.def == HediffDef.Named("HearingLoss") || x.def == HediffDef.Named("HeartArteryBlockage")); } //VampireGen.TryGiveVampirismHediff(pawn, generationRange.RandomInRange, def, null, false); } } } }
public override void DoEditInterface(Listing_ScenEdit listing) { Rect scenPartRect = listing.GetScenPartRect(this, RowHeight * 4f + 31f); if (Widgets.ButtonText(scenPartRect.TopPartPixels(RowHeight), this?.bloodline?.LabelCap ?? "ROMV_UnknownBloodline".Translate())) { FloatMenuUtility.MakeMenu(PossibleBloodlines(), (BloodlineDef bl) => bl.LabelCap, (BloodlineDef bl) => delegate { bloodline = bl; }); } //Widgets.IntRange(new Rect(scenPartRect.x, scenPartRect.y + ScenPart.RowHeight, scenPartRect.width, 31f), listing.CurHeight.GetHashCode(), ref this.generationRange, 4, this.maxGeneration, "ROMV_VampireGeneration"); DoVampModifierEditInterface(new Rect(scenPartRect.x, scenPartRect.y, scenPartRect.width, 31f)); }
public static bool TryGiveVampirismHediff(Pawn pawn, int generation, BloodlineDef bloodline, Pawn sire, bool firstVampire = false) { try { HediffVampirism vampHediff = (HediffVampirism)HediffMaker.MakeHediff(VampDefOf.ROM_Vampirism, pawn); vampHediff.firstVampire = firstVampire; vampHediff.sire = sire?.VampComp() ?? null; vampHediff.generation = generation; vampHediff.bloodline = bloodline; pawn.health.AddHediff(vampHediff, null, null); return(true); } catch (Exception e) { Log.Error(e.ToString()); } return(false); }
public Pawn GetLaterGenerationVampire(Pawn childe, BloodlineDef bloodline, int idealGenerationOfChilde = -1) { if (idealGenerationOfChilde == -1) { idealGenerationOfChilde = GetNewlySpawnedVampireGeneration(childe); } if (!ActiveVampires.NullOrEmpty() && ActiveVampires?.FindAll(x => x.VampComp() is CompVampire v && !x.Spawned && v.Bloodline == bloodline && v.Generation == idealGenerationOfChilde - 1) is List <Pawn> vamps && !vamps.NullOrEmpty()) { return(vamps.RandomElement()); } List <Pawn> vampsGen = TryGeneratingBloodline(childe, bloodline); return(vampsGen.FirstOrDefault(x => x?.VampComp()?.Generation == idealGenerationOfChilde - 1)); }
private static List <DebugMenuOption> Options_Generation(Pawn p, BloodlineDef bloodline) { List <DebugMenuOption> list = new List <DebugMenuOption>(); for (int i = 1; i < 14; i++) { int curGen = i; list.Add(new DebugMenuOption(curGen.ToString(), DebugMenuOptionMode.Action, delegate { p.VampComp().InitializeVampirism(null, bloodline, curGen, curGen == 1); //Log.Message("0" + p.LabelShort + " " + i.ToString()); p.Drawer.Notify_DebugAffected(); MoteMaker.ThrowText(p.DrawPos, p.Map, p.LabelShort + " is now a vampire"); })); } return(list); }
public void AddVampire(Pawn pawn, Pawn sire, BloodlineDef bloodline, int generation, float?age) { try { //Log.Message("1"); //Log.Message(sire.LabelShort + " Gen: " + generation); var sireId = (generation == 1) ? "" : sire?.VampComp()?.Generation.ToString() + "_" + sire?.VampComp()?.Bloodline.ToString() + "_" + sire?.Name?.ToStringFull + "_" + sire?.gender.ToString(); //Log.Message("2"); //Make a temporary new record of the vampire. var newRecord = new VampireRecord(pawn, generation, bloodline, age ?? new FloatRange(18f, 100f).RandomInRange, sireId, pawn.Faction); //Log.Message("3"); //Check to make sure the record doesn't already exist. if (worldVampires?.Count > 0) { //Log.Message("4a"); if (worldVampires.FirstOrDefault(x => x.Key.Equals(newRecord)) is KeyValuePair <VampireRecord, Pawn> rec && rec.Key is VampireRecord vampRec) { worldVampires[vampRec] = pawn; return; } } //Log.Message("5"); //If not, add a new record worldVampires?.Add(newRecord, pawn); //Log.Message("6"); } catch (Exception e) { Log.Message(e.ToString()); } //Check all other vampire records for issues WorldVampiresCheck(); //Log.Message("7"); }
public static Pawn GenerateVampire(int generation, BloodlineDef bloodline, Pawn sire, Faction vampFaction = null, bool firstVampire = false) { //Lower generation vampires are impossibly old. float?math = sire != null ? sire.ageTracker.AgeChronologicalYearsFloat + new FloatRange(100, 300).RandomInRange : generation > 4 ? Mathf.Clamp(2000 - generation * Rand.Range(20, 200), 16, 2000) : 100000 - generation * Rand.Range(10000, 50000); Faction faction = vampFaction != null ? vampFaction : generation < 7 ? Find.FactionManager.FirstFactionOfDef(VampDefOf.ROMV_LegendaryVampires) : VampireUtility.RandVampFaction; HarmonyPatches.VampireGenInProgress = true; PawnGenerationRequest request = new PawnGenerationRequest( DetermineKindDef(generation), faction, PawnGenerationContext.NonPlayer, -1, true, false, false, false, true, true, 20f, false, true, true, false, false, false, false, false, 0, 0, null, 0, null, null, null, null, null, math, null, null); Pawn pawn = PawnGenerator.GeneratePawn(request); if (DebugSettings.godMode) { Log.Message(pawn.Name + " Age:" + pawn.ageTracker.AgeNumberString + " Generation:" + generation); } HarmonyPatches.VampireGenInProgress = false; if (firstVampire) { NameTriple caineName = new NameTriple("Caine", "Caine", "Darkfather"); pawn.Name = caineName; pawn.gender = Gender.Male; } pawn.story.hairColor = PawnHairColors.RandomHairColor(pawn.story.SkinColor, 20); if (!bloodline.allowsHair) { pawn.story.hairDef = DefDatabase <HairDef> .GetNamed("Shaved"); } pawn.VampComp().InitializeVampirism(sire, bloodline, generation, firstVampire); pawn.ageTracker.AgeBiologicalTicks = (long)(math * GenDate.TicksPerYear); //TryGiveVampirismHediff(pawn, generation, bloodline, sire, firstVampire); return(pawn); }
public static void SetSireChildeRelations(Pawn thisChilde, CompVampire sireComp, int optionalGeneration = -1) { //Log.Message("2" + thisChilde.LabelShort + " " + optionalGeneration.ToString()); if (sireComp == null) { if (thisChilde.relations.GetFirstDirectRelationPawn(VampDefOf.ROMV_Sire) is Pawn discoveredSire) { thisChilde.VampComp().Sire = discoveredSire; if (sireComp?.Childer is List <Pawn> childer && !childer.NullOrEmpty() && !childer.Contains(thisChilde)) { childer.Add(thisChilde); } return; } else { //Log.Warning("Vampires must have a sire. Choosing one."); BloodlineDef bloodlineToApply = thisChilde.VampComp().Bloodline; if (bloodlineToApply == null) { Log.Warning("Vampires must have a blood line. Choosing one."); bloodlineToApply = VampireUtility.RandBloodline; thisChilde.VampComp().Bloodline = bloodlineToApply; } Pawn sire = FindSireFor(thisChilde, bloodlineToApply, optionalGeneration); //Find.World.GetComponent<WorldComponent_VampireTracker>().GetLaterGenerationVampire(thisChilde, bloodlineToApply, optionalGeneration); sireComp = sire.VampComp(); thisChilde.VampComp().Sire = sire; } } CompVampire childeComp = thisChilde.GetComp <CompVampire>(); sireComp.AbilityUser.relations.AddDirectRelation(VampDefOf.ROMV_Childe, thisChilde); thisChilde.relations.AddDirectRelation(VampDefOf.ROMV_Sire, sireComp.AbilityUser); childeComp.Sire = sireComp.AbilityUser; sireComp.Childer.Add(thisChilde); }
public override void PostTick() { base.PostTick(); if (!(pawn.VampComp() is CompVampire v)) { return; } if (!initialized) { initialized = true; if (!firstVampire) { if (sire == null) { sire = VampireRelationUtility.FindSireFor(pawn, bloodline, generation).VampComp(); } if (generation < 0) { generation = sire.Generation + 1; } if (bloodline == null) { bloodline = sire.Bloodline; } } if (v.IsVampire && v.Sire == null) { v.InitializeVampirism(sire?.AbilityUser ?? null, bloodline, generation, firstVampire); } pawn.Drawer.renderer.graphics.ResolveAllGraphics(); } if (Find.TickManager.TicksGame % 60 != 0) { return; } if (v.InSunlight) { HealthUtility.AdjustSeverity(pawn, VampDefOf.ROMV_SunExposure, 0.001f); } if (v.BloodPool?.CurLevelPercentage < 0.3f) { HealthUtility.AdjustSeverity(pawn, VampDefOf.ROMV_TheBeast, 0.001f); } //Remove nonsensical hediffs if (pawn.health.hediffSet is HediffSet hdSet) { if (hdSet.GetFirstHediffOfDef(HediffDefOf.Hypothermia) is Hediff hypoThermia) { hdSet.hediffs.Remove(hypoThermia); } else if (hdSet.GetFirstHediffOfDef(HediffDefOf.Heatstroke) is Hediff heatStroke) { hdSet.hediffs.Remove(heatStroke); } else if (hdSet.GetFirstHediffOfDef(VampDefOfTwo.GutWorms) is Hediff gutWorms) { hdSet.hediffs.Remove(gutWorms); } else if (hdSet.GetFirstHediffOfDef(VampDefOfTwo.MuscleParasites) is Hediff muscleParasites) { hdSet.hediffs.Remove(muscleParasites); } else if (hdSet.GetFirstHediffOfDef(VampDefOfTwo.FibrousMechanites) is Hediff fibrousMechanites) { hdSet.hediffs.Remove(fibrousMechanites); } else if (hdSet.GetFirstHediffOfDef(VampDefOfTwo.SensoryMechanites) is Hediff sensoryMechanites) { hdSet.hediffs.Remove(sensoryMechanites); } } //If no generational bonus exists... if (!pawn.health.hediffSet.HasHediff(pawn.GenerationDef())) { HealthUtility.AdjustSeverity(pawn, pawn.GenerationDef(), 1.0f); } }