예제 #1
0
        public static bool Zombify(ReanimatedPawn pawn)
        {
            if (pawn.Drawer?.renderer?.graphics == null)
            {
                return(false);
            }

            if (!pawn.Drawer.renderer.graphics.AllResolved)
            {
                pawn.Drawer.renderer.graphics.ResolveAllGraphics();
            }

            if (pawn.Drawer.renderer.graphics.headGraphic == null)
            {
                return(false);
            }

            if (pawn.Drawer.renderer.graphics.nakedGraphic == null)
            {
                return(false);
            }

            if (pawn.Drawer.renderer.graphics.headGraphic.path == null)
            {
                return(false);
            }

            if (pawn.Drawer.renderer.graphics.nakedGraphic.path == null)
            {
                return(false);
            }

            GiveZombieSkinEffect(pawn);
            return(true);
        }
예제 #2
0
 public static void AddedPartFixer(ReanimatedPawn pawn, Pawn sourcePawn = null)
 {
     foreach (Hediff hediff in sourcePawn.health.hediffSet.hediffs)
     {
         if (hediff is Hediff_AddedPart || hediff is Hediff_Implant)
         {
             pawn.health.AddHediff(hediff);
         }
     }
 }
예제 #3
0
 public static void RelationshipFixer(ReanimatedPawn pawn, Pawn sourcePawn = null)
 {
     //Add in and fix all blood relationships
     if (sourcePawn.relations.DirectRelations != null && sourcePawn.relations.DirectRelations.Count > 0)
     {
         foreach (DirectPawnRelation pawnRel in sourcePawn.relations.DirectRelations)
         {
             if (pawnRel.otherPawn != null && pawnRel.def != null)
             {
                 pawn.relations.AddDirectRelation(pawnRel.def, pawnRel.otherPawn);
             }
         }
         sourcePawn.relations.ClearAllRelations();
     }
 }
예제 #4
0
        public static void GiveZombieSkinEffect(ReanimatedPawn pawn, ReanimatedPawn sourcePawn = null, bool oathOfHastur = false)
        {
            if (sourcePawn == null)
            {
                sourcePawn = pawn;
            }
            Color newSkin = oathOfHastur ? new Color(1, 1, 1) : zombieSkin;

            Graphic nakedBodyGraphic = GraphicDatabase.Get <Graphic_Multi>(sourcePawn.story.bodyType.bodyNakedGraphicPath, ShaderDatabase.CutoutSkin, Vector2.one, newSkin);
            Graphic headGraphic      = GraphicDatabase.Get <Graphic_Multi>(sourcePawn.story.HeadGraphicPath, ShaderDatabase.CutoutSkin, Vector2.one, newSkin);
            Graphic hairGraphic      = GraphicDatabase.Get <Graphic_Multi>(sourcePawn.story.hairDef.texPath, ShaderDatabase.Cutout, Vector2.one, sourcePawn.story.hairColor);

            pawn.Drawer.renderer.graphics.headGraphic  = headGraphic;
            pawn.Drawer.renderer.graphics.nakedGraphic = nakedBodyGraphic;
            pawn.Drawer.renderer.graphics.hairGraphic  = hairGraphic;
        }
예제 #5
0
 public static void SkillFixer(ReanimatedPawn pawn, Pawn sourcePawn = null)
 {
     //Add in and fix skill levels
     foreach (SkillRecord skill in sourcePawn.skills.skills)
     {
         SkillRecord pawnSkill = pawn.skills.GetSkill(skill.def);
         if (pawnSkill == null)
         {
             pawn.skills.skills.Add(skill);
         }
         else
         {
             pawnSkill.Level   = skill.Level;
             pawnSkill.passion = skill.passion;
         }
     }
 }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map map = parms.target as Map;

            //Generate the zombie
            ReanimatedPawn pawn   = ReanimatedPawnUtility.DoGenerateZombiePawnFromSource(innerSacrifice(map));
            IntVec3        intVec = innerSacrifice(map).Position.RandomAdjacentCell8Way();

            GenSpawn.Spawn(pawn, intVec, map);
            innerSacrifice(map).Corpse.Destroy(0);
            //Destroy the corpse
            //Replace the innerSacrifice with the new pawn just in-case
            //altar.innerSacrifice = thing;
            map.GetComponent <MapComponent_SacrificeTracker>().lastLocation = intVec;
            Messages.Message("The innerSacrifice reanimates and attacks.", MessageTypeDefOf.ThreatBig);
            Cthulhu.Utility.ApplyTaleDef("Cults_SpellReanimator", pawn);
            return(true);
        }
예제 #7
0
        public static void RelationshipFixer(ReanimatedPawn pawn, Pawn sourcePawn = null)
        {
            //Add in and fix all blood relationships
            if (sourcePawn != null && (sourcePawn.relations.DirectRelations == null ||
                                       sourcePawn.relations.DirectRelations.Count <= 0))
            {
                return;
            }

            if (sourcePawn == null)
            {
                return;
            }

            foreach (var pawnRel in sourcePawn.relations.DirectRelations)
            {
                if (pawnRel.otherPawn != null && pawnRel.def != null)
                {
                    pawn.relations.AddDirectRelation(pawnRel.def, pawnRel.otherPawn);
                }
            }

            sourcePawn.relations.ClearAllRelations();
        }
예제 #8
0
        public static ReanimatedPawn DoGenerateZombiePawnFromSource(Pawn sourcePawn, bool isBerserk = true, bool oathOfHastur = false)
        {
            PawnKindDef    pawnKindDef   = PawnKindDef.Named("ReanimatedCorpse");
            Faction        factionDirect = isBerserk ? Find.FactionManager.FirstFactionOfDef(FactionDefOf.AncientsHostile) : Faction.OfPlayer;
            ReanimatedPawn pawn          = (ReanimatedPawn)ThingMaker.MakeThing(pawnKindDef.race, null);

            try
            {
                pawn.kindDef = pawnKindDef;
                pawn.SetFactionDirect(factionDirect);
                PawnComponentsUtility.CreateInitialComponents(pawn);
                pawn.gender = sourcePawn.gender;
                pawn.ageTracker.AgeBiologicalTicks    = sourcePawn.ageTracker.AgeBiologicalTicks;
                pawn.ageTracker.AgeChronologicalTicks = sourcePawn.ageTracker.AgeChronologicalTicks;
                pawn.workSettings = new Pawn_WorkSettings(pawn);
                if (pawn.workSettings != null && sourcePawn.Faction.IsPlayer)
                {
                    pawn.workSettings.EnableAndInitialize();
                }

                pawn.needs.SetInitialLevels();
                //Add hediffs?
                //Add relationships?
                if (pawn.RaceProps.Humanlike)
                {
                    pawn.story.melanin   = sourcePawn.story.melanin;
                    pawn.story.crownType = sourcePawn.story.crownType;
                    pawn.story.hairColor = sourcePawn.story.hairColor;
                    pawn.story.childhood = sourcePawn.story.childhood;
                    pawn.story.adulthood = sourcePawn.story.adulthood;
                    pawn.story.bodyType  = sourcePawn.story.bodyType;
                    pawn.story.hairDef   = sourcePawn.story.hairDef;
                    if (!oathOfHastur)
                    {
                        foreach (Trait current in sourcePawn.story.traits.allTraits)
                        {
                            pawn.story.traits.GainTrait(current);
                        }
                    }
                    else
                    {
                        pawn.story.traits.GainTrait(new Trait(TraitDef.Named("Cults_OathtakerHastur2"), 0, true));
                        pawn.story.traits.GainTrait(new Trait(TraitDefOf.Psychopath, 0, true));

                        SkillFixer(pawn, sourcePawn);
                        RelationshipFixer(pawn, sourcePawn);
                        AddedPartFixer(pawn, sourcePawn);
                    }
                    //pawn.story.GenerateSkillsFromBackstory();
                    NameTriple nameTriple = sourcePawn.Name as NameTriple;
                    if (!oathOfHastur)
                    {
                        pawn.Name = new NameTriple(nameTriple.First, string.Concat(new string[]
                        {
                            "* ",
                            Translator.Translate("Reanimated"),
                            " ",
                            nameTriple.Nick,
                            " *"
                        }), nameTriple.Last);
                    }
                    else
                    {
                        pawn.Name = nameTriple;
                    }
                }
                string headGraphicPath = sourcePawn.story.HeadGraphicPath;
                typeof(Pawn_StoryTracker).GetField("headGraphicPath", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(pawn.story, headGraphicPath);
                GenerateZombieApparelFromSource(pawn, sourcePawn);
                PawnGenerationRequest con = new PawnGenerationRequest();
                PawnInventoryGenerator.GenerateInventoryFor(pawn, con);
                GiveZombieSkinEffect(pawn, sourcePawn as ReanimatedPawn, oathOfHastur);
                if (isBerserk)
                {
                    pawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.Berserk);
                }
                //Log.Message(pawn.Name.ToStringShort);
                return(pawn);
            }
            catch (Exception e)
            {
                Cthulhu.Utility.DebugReport(e.ToString());
            }
            return(null);
        }