protected override void Impact(Thing hitThing) { Map map = base.Map; base.Impact(hitThing); ThingDef def = this.def; int raisedPawns = 0; Pawn pawn = this.launcher as Pawn; Pawn victim = hitThing as Pawn; CompAbilityUserMagic comp = pawn.GetComp <CompAbilityUserMagic>(); pwr = comp.MagicData.MagicPowerSkill_RaiseUndead.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_RaiseUndead_pwr"); ver = comp.MagicData.MagicPowerSkill_RaiseUndead.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_RaiseUndead_ver"); Thing corpseThing = null; IntVec3 curCell; IEnumerable <IntVec3> targets = GenRadial.RadialCellsAround(base.Position, this.def.projectile.explosionRadius, true); for (int i = 0; i < targets.Count(); i++) { curCell = targets.ToArray <IntVec3>()[i]; TM_MoteMaker.ThrowPoisonMote(curCell.ToVector3Shifted(), map, .3f); if (curCell.InBounds(map)) { Corpse corpse = null; List <Thing> thingList; thingList = curCell.GetThingList(map); int z = 0; while (z < thingList.Count) { corpseThing = thingList[z]; if (corpseThing != null) { bool validator = corpseThing is Corpse; if (validator) { corpse = corpseThing as Corpse; Pawn undeadPawn = corpse.InnerPawn; CompRottable compRottable = corpse.GetComp <CompRottable>(); float rotStage = 0; if (compRottable != null && compRottable.Stage == RotStage.Dessicated) { rotStage = 1f; } if (compRottable != null) { rotStage += compRottable.RotProgressPct; } bool flag_SL = false; if (undeadPawn.def.defName == "SL_Runner" || undeadPawn.def.defName == "SL_Peon" || undeadPawn.def.defName == "SL_Archer" || undeadPawn.def.defName == "SL_Hero") { PawnGenerationRequest pgr = new PawnGenerationRequest(PawnKindDef.Named("Tribesperson"), pawn.Faction, PawnGenerationContext.NonPlayer, -1, true, false, false, false, false, true, 0, false, false, false, false, false, false, false, false, 0, null, 0); Pawn newUndeadPawn = PawnGenerator.GeneratePawn(pgr); GenSpawn.Spawn(newUndeadPawn, corpse.Position, corpse.Map, WipeMode.Vanish); corpse.Strip(); corpse.Destroy(DestroyMode.Vanish); rotStage = 1f; flag_SL = true; undeadPawn = newUndeadPawn; } if (!undeadPawn.def.defName.Contains("ROM_") && undeadPawn.RaceProps.IsFlesh && (undeadPawn.Dead || flag_SL) && undeadPawn.def.thingClass.FullName != "TorannMagic.TMPawnSummoned") { bool wasVampire = false; IEnumerable <ThingDef> enumerable = from hd in DefDatabase <HediffDef> .AllDefs where (def.defName == "ROM_Vampirism") select def; if (enumerable.Count() > 0) { bool hasVampHediff = undeadPawn.health.hediffSet.HasHediff(HediffDef.Named("ROM_Vampirism")) || undeadPawn.health.hediffSet.HasHediff(HediffDef.Named("ROM_GhoulHediff")); if (hasVampHediff) { wasVampire = true; } } if (!wasVampire) { undeadPawn.SetFaction(pawn.Faction); if (undeadPawn.Dead) { ResurrectionUtility.Resurrect(undeadPawn); } raisedPawns++; comp.supportedUndead.Add(undeadPawn); if (undeadPawn.kindDef != null && undeadPawn.kindDef.RaceProps != null && undeadPawn.kindDef.RaceProps.Animal) { RemoveHediffsAddictionsAndPermanentInjuries(undeadPawn); HealthUtility.AdjustSeverity(undeadPawn, TorannMagicDefOf.TM_UndeadAnimalHD, -4f); HealthUtility.AdjustSeverity(undeadPawn, TorannMagicDefOf.TM_UndeadAnimalHD, .5f + ver.level); undeadPawn.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_UndeadAnimalHD).TryGetComp <HediffComp_Undead>().linkedPawn = pawn; HealthUtility.AdjustSeverity(undeadPawn, HediffDef.Named("TM_UndeadStageHD"), -2f); HealthUtility.AdjustSeverity(undeadPawn, HediffDef.Named("TM_UndeadStageHD"), rotStage); if (undeadPawn.training.CanAssignToTrain(TrainableDefOf.Tameness).Accepted) { while (!undeadPawn.training.HasLearned(TrainableDefOf.Tameness)) { undeadPawn.training.Train(TrainableDefOf.Tameness, pawn); } } if (undeadPawn.training.CanAssignToTrain(TrainableDefOf.Obedience).Accepted) { while (!undeadPawn.training.HasLearned(TrainableDefOf.Obedience)) { undeadPawn.training.Train(TrainableDefOf.Obedience, pawn); } } if (undeadPawn.training.CanAssignToTrain(TrainableDefOf.Release).Accepted) { while (!undeadPawn.training.HasLearned(TrainableDefOf.Release)) { undeadPawn.training.Train(TrainableDefOf.Release, pawn); } } if (undeadPawn.training.CanAssignToTrain(TorannMagicDefOf.Haul).Accepted) { while (!undeadPawn.training.HasLearned(TorannMagicDefOf.Haul)) { undeadPawn.training.Train(TorannMagicDefOf.Haul, pawn); } } if (undeadPawn.training.CanAssignToTrain(TorannMagicDefOf.Rescue).Accepted) { while (!undeadPawn.training.HasLearned(TorannMagicDefOf.Rescue)) { undeadPawn.training.Train(TorannMagicDefOf.Rescue, pawn); } } undeadPawn.playerSettings.medCare = MedicalCareCategory.NoMeds; undeadPawn.def.tradeability = Tradeability.None; } else if (undeadPawn.story != null && undeadPawn.story.traits != null && undeadPawn.needs != null && undeadPawn.playerSettings != null) { CompAbilityUserMagic compMagic = undeadPawn.GetComp <CompAbilityUserMagic>(); if (compMagic != null && TM_Calc.IsMagicUser(undeadPawn)) //(compMagic.IsMagicUser && !undeadPawn.story.traits.HasTrait(TorannMagicDefOf.Faceless)) || { compMagic.Initialize(); compMagic.RemovePowers(true); } CompAbilityUserMight compMight = undeadPawn.GetComp <CompAbilityUserMight>(); if (compMight != null && TM_Calc.IsMightUser(undeadPawn)) //compMight.IsMightUser || { compMight.Initialize(); compMight.RemovePowers(true); } RemoveHediffsAddictionsAndPermanentInjuries(undeadPawn); RemovePsylinkAbilities(undeadPawn); HealthUtility.AdjustSeverity(undeadPawn, TorannMagicDefOf.TM_UndeadHD, -4f); HealthUtility.AdjustSeverity(undeadPawn, TorannMagicDefOf.TM_UndeadHD, .5f + ver.level); undeadPawn.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_UndeadHD).TryGetComp <HediffComp_Undead>().linkedPawn = pawn; HealthUtility.AdjustSeverity(undeadPawn, HediffDef.Named("TM_UndeadStageHD"), -2f); HealthUtility.AdjustSeverity(undeadPawn, HediffDef.Named("TM_UndeadStageHD"), rotStage); RedoSkills(undeadPawn, pawn.health.hediffSet.HasHediff(HediffDef.Named("TM_LichHD"))); if (undeadPawn.story.traits.HasTrait(TorannMagicDefOf.ChaosMage)) { compMagic.RemovePawnAbility(TorannMagicDefOf.TM_ChaosTradition); } RemoveTraits(undeadPawn, undeadPawn.story.traits.allTraits); undeadPawn.story.traits.GainTrait(new Trait(TraitDef.Named("Undead"), 0, false)); undeadPawn.story.traits.GainTrait(new Trait(TraitDef.Named("Psychopath"), 0, false)); undeadPawn.needs.AddOrRemoveNeedsAsAppropriate(); RemoveClassHediff(undeadPawn); if (undeadPawn.health.hediffSet.HasHediff(HediffDef.Named("DeathAcidifier"))) { Hediff hd = undeadPawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("DeathAcidifier")); undeadPawn.health.RemoveHediff(hd); } //Color undeadColor = new Color(.2f, .4f, 0); //undeadPawn.story.hairColor = undeadColor; //CompAbilityUserMagic undeadComp = undeadPawn.GetComp<CompAbilityUserMagic>(); //if (undeadComp.IsMagicUser) //{ // undeadComp.ClearPowers(); //} List <SkillRecord> skills = undeadPawn.skills.skills; for (int j = 0; j < skills.Count; j++) { skills[j].passion = Passion.None; } undeadPawn.playerSettings.hostilityResponse = HostilityResponseMode.Attack; undeadPawn.playerSettings.medCare = MedicalCareCategory.NoMeds; for (int h = 0; h < 24; h++) { undeadPawn.timetable.SetAssignment(h, TimeAssignmentDefOf.Work); } } } else { Messages.Message("Vampiric powers have prevented undead reanimation of " + undeadPawn.LabelShort, MessageTypeDefOf.RejectInput); } } } else if (corpseThing is Pawn) { Pawn undeadPawn = corpseThing as Pawn; if (undeadPawn != pawn && !TM_Calc.IsNecromancer(undeadPawn) && TM_Calc.IsUndead(corpseThing as Pawn)) { RemoveHediffsAddictionsAndPermanentInjuries(undeadPawn); TM_MoteMaker.ThrowPoisonMote(curCell.ToVector3Shifted(), map, .6f); } } } z++; } } if (raisedPawns > pwr.level + 1) { i = targets.Count(); } } }