Ejemplo n.º 1
0
        private (List <NeedDef> pawnAnimalNeedDef, List <StatDef> pawnAnimalStatDef, List <StatDef> corpseStatDef) PopulateLists()
        {
            Pawn tmpPawn = PawnGenerator.GeneratePawn(PawnKindDefOf.Thrumbo);

            var pawnAnimalNeedDef = tmpPawn.needs.AllNeeds.Where(x => x.def.showOnNeedList).Select(x => x.def).ToList();

            var animalStatDef = ((IEnumerable <StatDrawEntry>)StatsToDraw?.Invoke(null, new[] { tmpPawn })) ?? Enumerable.Empty <StatDrawEntry>();

            var pawnAnimalStatDef = animalStatDef
                                    .Where(s => s.stat != null && s.ShouldDisplay && s.stat.Worker != null)
                                    .Select(s => s.stat)
                                    .OrderBy(stat => stat.LabelCap.Resolve()).ToList();

            Corpse corpse = (Corpse)ThingMaker.MakeThing(tmpPawn.RaceProps.corpseDef);

            corpse.InnerPawn = tmpPawn;

            var deadAnimalStatDef = ((IEnumerable <StatDrawEntry>)StatsToDraw?.Invoke(null, new[] { corpse })) ?? Enumerable.Empty <StatDrawEntry>();

            var corpseStatDef = deadAnimalStatDef
                                .Concat(tmpPawn.def.SpecialDisplayStats(StatRequest.For(tmpPawn)))
                                .Where(s => s.stat != null && s.ShouldDisplay && s.stat.Worker != null)
                                .Select(s => s.stat)
                                .OrderBy(stat => stat.LabelCap.Resolve()).ToList();

            tmpPawn.Destroy(DestroyMode.KillFinalize);
            corpse.Destroy();

            return(pawnAnimalNeedDef, pawnAnimalStatDef, corpseStatDef);
        }
        // Token: 0x060000BE RID: 190 RVA: 0x0000AE2C File Offset: 0x0000902C
        public override void PawnDied(Corpse corpse)
        {
            if (corpse == null)
            {
                return;
            }

            var map       = corpse.Map;
            var position  = corpse.Position;
            var innerPawn = corpse.InnerPawn;

            GenExplosion.DoExplosion(corpse.Position, corpse.Map, 1.9f, DamageDefOf.Extinguish, corpse.InnerPawn);
            corpse.Destroy();
            var thingOwner = new ThingOwner <Thing>();

            foreach (var thingDefCountClass in innerPawn.def.butcherProducts)
            {
                var thing = ThingMaker.MakeThing(thingDefCountClass.thingDef);
                thing.stackCount = thingDefCountClass.count;
                thingOwner.TryAdd(thing);
            }

            foreach (var thing in thingOwner)
            {
                GenPlace.TryPlaceThing(thing, position, map, ThingPlaceMode.Near);
            }
        }
 public void LoadCorpse(Corpse corpse)
 {
     // Initial mass should account for missing body parts
     corpseInitialMass   = corpse.InnerPawn.def.BaseMass * corpse.InnerPawn.health.hediffSet.GetCoverageOfNotMissingNaturalParts(corpse.InnerPawn.RaceProps.body.corePart);
     corpseRemainingMass = corpseInitialMass;
     corpse.Destroy();
 }
        public override void PawnDied(Corpse corpse)
        {
            //Corpse NullCheck
            if (corpse == null)
            {
                return;
            }
            //Get Corpse Properties
            map = corpse.Map;
            var pos  = corpse.Position;
            var pawn = corpse.InnerPawn;

            //Destroy Corpse
            corpse.Destroy();
            //Read through killedLeavings of the pawn
            var thingOwner = new ThingOwner <Thing>();

            for (var i = 0; i < pawn.def.killedLeavings.Count; i++)
            {
                var thing = ThingMaker.MakeThing(pawn.def.killedLeavings[i].thingDef, null);
                thing.stackCount = pawn.def.killedLeavings[i].count;
                thingOwner.TryAdd(thing, true);
            }
            //Generate items/amount in list
            for (var i = 0; i < thingOwner.Count; i++)
            {
                GenPlace.TryPlaceThing(thingOwner[i], pos, map, ThingPlaceMode.Near, null);
            }
        }
        public override void PawnDied(Corpse corpse)
        {
            if (corpse == null)
            {
                return;
            }
            if (corpse.Map == null || corpse.Position == null || corpse.Position == IntVec3.Invalid)
            {
                return;
            }
            Pawn    innerPawn = corpse.InnerPawn;
            IntVec3 position  = corpse.Position;

            Detonate(corpse, position);
            corpse.Destroy(0);
            ThingOwner <Thing> thingOwner = new ThingOwner <Thing>();

            if (innerPawn.def.killedLeavings != null)
            {
                for (int i = 0; i < innerPawn.def.killedLeavings.Count; i++)
                {
                    Thing thing = ThingMaker.MakeThing(innerPawn.def.killedLeavings[i].thingDef, null);
                    thing.stackCount = innerPawn.def.killedLeavings[i].count;
                    thingOwner.TryAdd(thing, true);
                }
                for (int j = 0; j < thingOwner.Count; j++)
                {
                    GenPlace.TryPlaceThing(thingOwner[j], position, this.map, ThingPlaceMode.Near, null, null, default(Rot4));
                }
            }
        }
Ejemplo n.º 6
0
        // Token: 0x06000005 RID: 5 RVA: 0x000020B4 File Offset: 0x000002B4
        public override void PawnDied(Corpse corpse)
        {
            float value  = (float)corpse.InnerPawn.ageTracker.AgeBiologicalYears;
            float value2 = (float)corpse.InnerPawn.ageTracker.AgeChronologicalYears;
            Name  name   = corpse.InnerPawn.Name;
            Pawn_PlayerSettings   playerSettings = corpse.InnerPawn.playerSettings;
            Pawn_TrainingTracker  training       = corpse.InnerPawn.training;
            Pawn_HealthTracker    health         = corpse.InnerPawn.health;
            Pawn_RecordsTracker   records        = corpse.InnerPawn.records;
            Pawn_RelationsTracker relations      = corpse.InnerPawn.relations;
            Pawn_SkillTracker     skills         = corpse.InnerPawn.skills;
            Faction       faction  = corpse.InnerPawn.Faction;
            Comp_TimeLord timeLord = corpse.InnerPawn.TryGetComp <Comp_TimeLord>();

            if (timeLord != null)
            {
                if (timeLord.TimesRegenerated < 13)
                {
                    int regens = timeLord.TimesRegenerated;
                    regens++;
                    Pawn pawn = PawnGenerator.GeneratePawn(new PawnGenerationRequest(corpse.InnerPawn.kindDef, faction, PawnGenerationContext.NonPlayer, -1, false, false, false, false, true, false, 0f, false, false, false, false, false, false, false, false, 0, null, 1, null, null, null));
                    pawn.TryGetComp <Comp_TimeLord>().TimesRegenerated = regens;
                    GenSpawn.Spawn(pawn, corpse.Position, corpse.Map, Rot4.Random);
                    pawn.Name           = name;
                    pawn.relations      = relations;
                    pawn.training       = training;
                    pawn.records        = records;
                    pawn.skills         = skills;
                    pawn.playerSettings = playerSettings;
                    corpse.Destroy(0);
                }
            }
        }
 public override void PawnDied(Corpse corpse)
 {
     if (corpse != null)
     {
         corpse.Destroy();
     }
 }
Ejemplo n.º 8
0
        public override void Notify_ReceivedThing(Thing newItem)
        {
            if (!(newItem is Corpse))
            {
                base.Notify_ReceivedThing(newItem);
                return;
            }

            Corpse shell  = (Corpse)newItem;
            Pawn   target = shell.innerPawn;

            //target.healthTracker.summaryHealth = 10;
            target.Position = shell.Position;
            shell.Destroy();
            this.Destroy();

            FieldInfo[] currentstate = typeof(Pawn).GetFields();

            foreach (FieldInfo f in currentstate)
            {
                Log.Warning(f.ToString() + " value is " + f.GetValue(target));
            }



            //target.SpawnSetup();
        }
Ejemplo n.º 9
0
 public void ConvertToJelly()
 {
     if (thing != null)
     {
         Corpse corpse = thing as Corpse;
         if (corpse != null)
         {
             ButcherProducts(corpse);
             if (!corpse.Destroyed)
             {
                 corpse.Destroy(DestroyMode.Vanish);
             }
         }
         else
         {
             Thing thing2 = ThingMaker.MakeThing(ThingDefOf.InsectJelly, null);
             thing2.stackCount = thing.stackCount;
             GenPlace.TryPlaceThing(thing2, thing.Position, thing.Map, ThingPlaceMode.Direct, out Thing jelly, null);
             if (jelly != null)
             {
                 jelly.SetForbidden(true);
             }
             if (!thing.Destroyed)
             {
                 thing.Destroy(DestroyMode.Vanish);
             }
         }
     }
 }
Ejemplo n.º 10
0
        public override void PawnDied(Corpse corpse)
        {
            Color color = new Color();

            if (corpse.InnerPawn.Faction == Faction.OfPlayer)
            {
                color = new Color(1, 1, 1); // White Smoke
            }
            else
            {
                color = new Color(0, 0, 0); // Black Smoke
                if (Rand.Chance(corpse.InnerPawn.RaceProps.AnyPawnKind.combatPower / 100000))
                {
                    ThingWithComps createdWeapon = (ThingWithComps)ThingMaker.MakeThing(RWBYDefOf.RWBY_Grimm_Glove);
                    createdWeapon.TryGetComp <CompQuality>().SetQuality((QualityCategory)Rand.RangeInclusive(0, 6), ArtGenerationContext.Colony);
                    GenSpawn.Spawn(createdWeapon, corpse.Position, corpse.Map);
                }
            }
            for (int i = 0; i < 5; i++)
            {
                MoteThrown moteThrown = (MoteThrown)ThingMaker.MakeThing(ThingDefOf.Mote_Smoke, null);
                moteThrown.Scale         = Rand.Range(2.5f, 4.5f);
                moteThrown.rotationRate  = Rand.Range(-30f, 30f);
                moteThrown.exactPosition = corpse.Position.ToVector3();
                moteThrown.instanceColor = color;
                moteThrown.SetVelocity((float)Rand.Range(0, 360), 0.2f);
                GenSpawn.Spawn(moteThrown, corpse.Position, corpse.Map, WipeMode.Vanish);
            }
            corpse.Destroy();
        }
 public override void PawnDied(Corpse corpse)
 {
     for (int i = 0; i < 3; i++)
     {
         MoteMaker.ThrowAirPuffUp(corpse.PositionHeld.ToVector3(), corpse.Map);
     }
     if (!corpse.Destroyed)
     {
         corpse.Destroy(DestroyMode.Vanish);
     }
 }
        /// <summary>
        /// Removes random body parts from the corpse. Has a chance of destroying the body.
        /// </summary>
        /// <param name="actor">The pawn performing the dissection. His skill determines the chance of destroying the body.</param>
        /// <param name="corpse">The corpse being dissected.</param>
        /// <returns>True if the body was destroyed, False otherwise.</returns>
        private static bool RemoveDissectedBodyParts(Pawn actor, Corpse corpse)
        {
            // There is a chance the whole body is destroyed in the process
            bool destroyBody = Dissection.Singleton.AlwaysDetroyBodies;

            if (!destroyBody)
            {
                float skillLevelMultiplier = 1.0f - (float)actor.skills.GetSkill(SkillDefOf.Medicine).Level / SkillRecord.MaxLevel;
                float chance = Dissection.Singleton.DestroyBodyChance * skillLevelMultiplier * skillLevelMultiplier;
                float rand   = Rand.Range(0.0f, 1.0f);
                destroyBody = rand <= chance;
            }
            if (destroyBody)
            {
                if (PawnUtility.ShouldSendNotificationAbout(corpse.InnerPawn) && corpse.InnerPawn.RaceProps.Humanlike)
                {
                    Messages.Message(
                        "Dissection_MessageDestroyedByDoctor"
                        .Translate(corpse.InnerPawn.LabelShort, actor.LabelIndefinite())
                        .CapitalizeFirst(),
                        actor, MessageTypeDefOf.NegativeEvent);
                }
                Log.Message($"Destroyed {corpse.InnerPawn.Name}'s body while dissecting.");
                corpse.Destroy();
                return(true);
            }


            IEnumerable <BodyPartRecord> source = from x in corpse.InnerPawn.health.hediffSet.GetNotMissingParts(BodyPartHeight.Undefined, BodyPartDepth.Undefined)
                                                  where DissectionUtility.DissectableBodyParts.Contains(x.def)
                                                  select x;
            int numBodyPartsToDissect =
                (Rand.RangeInclusive(0, DissectionUtility.DissectableBodyParts.Count)
                 + Rand.RangeInclusive(0, DissectionUtility.DissectableBodyParts.Count)
                 + Rand.RangeInclusive(0, DissectionUtility.DissectableBodyParts.Count));

            numBodyPartsToDissect = Mathf.RoundToInt(numBodyPartsToDissect / 3.0f);
            numBodyPartsToDissect = Mathf.Min(source.Count(), numBodyPartsToDissect);

            var bodyParts = source.InRandomOrder().ToArray();

            for (int i = 0; i < numBodyPartsToDissect; ++i)
            {
                Hediff_MissingPart hediff_MissingPart = (Hediff_MissingPart)HediffMaker.MakeHediff(HediffDefOf.MissingBodyPart, corpse.InnerPawn, bodyParts[i]);
                hediff_MissingPart.lastInjury = HediffDefOf.SurgicalCut;
                hediff_MissingPart.IsFresh    = true;
                corpse.InnerPawn.health.AddHediff(hediff_MissingPart);
            }

            Hediff dissectedHediff = HediffMaker.MakeHediff(DissectionDefOf.DissectedHediff, corpse.InnerPawn);

            corpse.InnerPawn.health.AddHediff(dissectedHediff);
            return(false);
        }
Ejemplo n.º 13
0
        public override void PawnDied(Corpse corpse)
        {
            for (int i = 0; i < 3; i++)
            {
                FleckMaker.ThrowSmoke(corpse.DrawPos, corpse.Map, Rand.Range(.5f, 1.1f));
            }
            TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_Ghost, corpse.DrawPos, corpse.Map, 1f, .25f, 0f, .25f, 0, Rand.Range(2f, 3f), 0, 0);
            Pawn innerPawn = corpse.InnerPawn;

            innerPawn.SetFaction(Faction.OfAncients, null);
            corpse.Destroy();
        }
Ejemplo n.º 14
0
        static bool Prefix(Corpse corpse)
        {
            if (Find.World.GetComponent <FactionFC>().militaryCustomizationUtil.AllMercenaryPawns
                .Contains(corpse.InnerPawn))
            {
                //corpse.InnerPawn.SetFaction(FactionColonies.getPlayerColonyFaction());
                corpse.Destroy();
                return(false);
            }

            return(true);
        }
Ejemplo n.º 15
0
        public override void PawnDied(Corpse corpse)
        {
            for (var i = 0; i < 3; i++)
            {
                FleckMaker.ThrowAirPuffUp(corpse.PositionHeld.ToVector3(), corpse.Map);
            }

            if (!corpse.Destroyed)
            {
                corpse.Destroy();
            }
        }
Ejemplo n.º 16
0
 public override void PawnDied(Corpse corpse)
 {
     if (corpse.InnerPawn.Faction == Faction.OfPlayer)
     {
         for (int i = 0; i < 3; i++)
         {
             FleckMaker.ThrowSmoke(corpse.DrawPos, corpse.Map, Rand.Range(.5f, 1.1f));
         }
         FleckMaker.ThrowHeatGlow(corpse.Position, corpse.Map, 1f);
         corpse.Destroy();
     }
 }
Ejemplo n.º 17
0
        public override void Notify_PawnDied()
        {
            base.Notify_PawnDied();
            Corpse corpse  = pawn.Corpse;
            Pawn   newBorg = PawnGenerator.GeneratePawn(PawnKindDef.Named("BorgDrone"), FactionUtility.DefaultFactionFrom(FactionDef.Named("BorgFaction")));

            newBorg.SpawnSetup(corpse.Map);
            newBorg.Position = corpse.Position;
            if (corpse != null)
            {
                corpse.Destroy();
            }
        }
Ejemplo n.º 18
0
        public Pawn ReanimateDeath(Corpse corpse)
        {
            var pawn = GenerateZombieFromSource(corpse.InnerPawn);

            pawn.IsRaiding = false;
            var position = corpse.Position;
            var building = corpse.StoringBuilding();

            ((Building_Storage)building)?.Notify_LostThing(corpse);
            GenSpawn.Spawn(pawn, position, corpse.Map);
            corpse.Destroy();
            return(pawn);
        }
Ejemplo n.º 19
0
        public override void PawnDied(Corpse corpse)
        {
            for (int i = 0; i < 3; i++)
            {
                MoteMaker.ThrowSmoke(corpse.DrawPos, corpse.Map, Rand.Range(.5f, 1.1f));
            }
            MoteMaker.ThrowHeatGlow(corpse.Position, corpse.Map, 1f);
            SingleSpawnLoop(corpse.Position, corpse.Map);
            Pawn innerPawn = corpse.InnerPawn;

            innerPawn.SetFaction(Faction.OfAncients, null);
            corpse.Destroy();
        }
Ejemplo n.º 20
0
        public override void PawnDied(Corpse corpse)
        {
            if (corpse.Map != null)
            {
                for (int i = 0; i < 3; i++)
                {
                    MoteMaker.ThrowSmoke(corpse.DrawPos, corpse.Map, Rand.Range(.5f, 1.1f));
                }
                TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_Ghost, corpse.DrawPos, corpse.Map, 1.3f, .25f, .1f, .45f, 0, Rand.Range(1f, 2f), 0, 0);
            }
            Pawn innerPawn = corpse.InnerPawn;

            innerPawn.SetFaction(Find.FactionManager.FirstFactionOfDef(TorannMagicDefOf.TM_SkeletalFaction), null);
            corpse.Destroy();
        }
Ejemplo n.º 21
0
        private void doChewCorpse()
        {
            Corpse corpse = base.TargetThingA as Corpse;
            bool   flag   = corpse != null;
            bool   flag2  = flag;

            if (flag2)
            {
                IntVec3      position = corpse.Position;
                List <Thing> list     = theThing_Utility.ButcherCorpseProducts(corpse, this.pawn).ToList <Thing>();
                Thing        thing    = null;
                int          num;
                for (int i = 0; i < list.Count; i = num + 1)
                {
                    bool flag3 = !GenPlace.TryPlaceThing(list[i], position, base.Map, ThingPlaceMode.Near, out thing, null);
                    bool flag4 = flag3;
                    if (flag4)
                    {
                        this.pawn.jobs.EndCurrentJob(JobCondition.Incompletable, true);
                    }
                    bool flag5 = thing != null;
                    bool flag6 = flag5;
                    if (flag6)
                    {
                        ForbidUtility.SetForbidden(thing, true, true);
                    }
                    num = i;
                }
                bool flag7 = this.pawn.needs.mood != null;
                bool flag8 = flag7;
                if (flag8)
                {
                    this.pawn.needs.mood.thoughts.memories.TryGainMemory(ThoughtDef.Named("AteCorpse"), null);
                }
                corpse.Destroy(0);
                IEnumerable <Faction> allFactions = Find.FactionManager.AllFactions;
                Func <Faction, bool>  predicate;
                bool flag9 = (predicate = JobDriver_Segmentation.segment.letSegment) == null;
                if (flag9)
                {
                    predicate = (JobDriver_Segmentation.segment.letSegment = new Func <Faction, bool>(JobDriver_Segmentation.segment.JobSegment.doChewCorpse));
                }
                Faction faction = GenCollection.RandomElement <Faction>(allFactions.Where(predicate));
                this.abom = PawnGenerator.GeneratePawn(MODefOf.MO_AbominationPawnKind, faction);
                GenSpawn.Spawn(this.abom, position, base.Map);
            }
            this.pawn.jobs.EndCurrentJob(JobCondition.Succeeded, true);
        }
Ejemplo n.º 22
0
        public override void PawnDied(Corpse corpse)
        {
            if (!AndroidsModSettings.Instance.androidExplodesOnDeath)
            {
                return;
            }

            //Pawn
            Pawn pawn = corpse.InnerPawn;

            //Try get energy tracker.
            EnergyTrackerComp energy = pawn.TryGetComp <EnergyTrackerComp>();

            bool shouldBeDeadByNaturalCauses = pawn.health.hediffSet.hediffs.Any(hediff => hediff.CauseDeathNow());

            Hediff overheatingHediff   = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.ChjOverheating);
            bool   deadFromOverheating = overheatingHediff != null ? overheatingHediff.Severity >= 1f : false;

            if (overheatingHediff != null || !shouldBeDeadByNaturalCauses)
            {
                float explosionRadius = AndroidsModSettings.Instance.androidExplosionRadius * energy.energy;

                if (deadFromOverheating)
                {
                    explosionRadius *= 2;
                }

                //Scale explosion strength from how much remaining energy we got.
                if (explosionRadius >= 1f)
                {
                    GenExplosion.DoExplosion(corpse.Position, corpse.Map, explosionRadius, RimWorld.DamageDefOf.Bomb, corpse.InnerPawn);
                }
            }

            //Remove corpse.
            if (!corpse.Destroyed)
            {
                ButcherUtility.SpawnDrops(corpse.InnerPawn, corpse.Position, corpse.Map);

                //Dump inventory.
                if (corpse.InnerPawn.apparel != null)
                {
                    corpse.InnerPawn.apparel.DropAll(corpse.PositionHeld);
                }

                corpse.Destroy(DestroyMode.Vanish);
            }
        }
        // Token: 0x060000ED RID: 237 RVA: 0x000097F0 File Offset: 0x000079F0
        public override void PawnDied(Corpse corpse)
        {
            base.PawnDied(corpse);
            bool flag = !corpse.Destroyed;

            if (flag)
            {
                ButcherUtility.SpawnDrops(corpse.InnerPawn, corpse.Position, corpse.Map);
                bool flag2 = corpse.InnerPawn.apparel != null;
                if (flag2)
                {
                    corpse.InnerPawn.apparel.DropAll(corpse.PositionHeld, true);
                }
                corpse.Destroy(DestroyMode.Vanish);
            }
        }
Ejemplo n.º 24
0
        public void SpawnSkeletonMinions(IntVec3 center, float radius, Faction faction)
        {
            IntVec3 curCell;
            Map     map = this.Pawn.Map;
            IEnumerable <IntVec3> targets = GenRadial.RadialCellsAround(center, radius, true);

            for (int j = 0; j < targets.Count(); j++)
            {
                curCell = targets.ToArray <IntVec3>()[j];
                List <Thing> cellList   = curCell.GetThingList(this.Pawn.Map);
                float        corpseMult = 0f;
                for (int i = 0; i < cellList.Count; i++)
                {
                    if (cellList[i] is Corpse)
                    {
                        corpseMult = .7f;
                        Corpse c = cellList[i] as Corpse;
                        c.Strip();
                        c.Destroy(DestroyMode.Vanish);
                    }
                }
                if (curCell.InBounds(map) && curCell.Walkable(map))
                {
                    SpawnThings skeleton = new SpawnThings();
                    if (Rand.Chance(geChance + corpseMult))
                    {
                        skeleton.def     = TorannMagicDefOf.TM_GiantSkeletonR;
                        skeleton.kindDef = PawnKindDef.Named("TM_GiantSkeleton");
                    }
                    else if (Rand.Chance(leChance))
                    {
                        skeleton.def     = TorannMagicDefOf.TM_SkeletonR;
                        skeleton.kindDef = PawnKindDef.Named("TM_Skeleton");
                    }
                    else
                    {
                        skeleton = null;
                    }
                    TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_Disease, curCell.ToVector3Shifted(), this.Pawn.Map, Rand.Range(1.5f, 2.4f), 1f, Rand.Range(.05f, .3f), Rand.Range(.8f, 2f), Rand.Range(0, 50), Rand.Range(.5f, 1f), 30, Rand.Range(0, 360));

                    if (skeleton != null)
                    {
                        TM_Action.SingleSpawnLoop(null, skeleton, curCell, map, 0, false, false, faction);
                    }
                }
            }
        }
Ejemplo n.º 25
0
        public static Toil SpawnProductDespawnCorpse(this CorpseRecipeSettings CRS, Pawn ParentPawn, Corpse corpse, bool MyDebug = false)
        {
            return(new Toil {
                initAction = delegate
                {
                    //CRS.product.SpawnConsumptionProduct(corpse, ParentPawn, SpawnPos, map, MyDebug);
                    CRS.product.SpawnConsumptionProduct(corpse, ParentPawn, corpse.Position, MyDebug);

                    if (CRS.HasWorkFlow && CRS.workFlow.MustStrip)
                    {
                        CRS.workFlow.strip.StripAndDamageBelongings(corpse);
                    }

                    corpse.Destroy(DestroyMode.KillFinalize);
                },
                atomicWithPrevious = true
            });
        }
Ejemplo n.º 26
0
        public static void ResurrectPawnFromVoid(Map map, IntVec3 loc, Pawn pawn)
        {
            Corpse corpse = pawn.Corpse;

            if (corpse != null)
            {
                corpse.Destroy(DestroyMode.Vanish);
            }
            if (pawn.IsWorldPawn())
            {
                Find.WorldPawns.RemovePawn(pawn);
            }
            pawn.ForceSetStateToUnspawned();
            PawnComponentsUtility.CreateInitialComponents(pawn);
            pawn.health.Notify_Resurrected();
            if (pawn.Faction != null && pawn.Faction.IsPlayer)
            {
                if (pawn.workSettings != null)
                {
                    pawn.workSettings.EnableAndInitialize();
                }
                Find.StoryWatcher.watcherPopAdaptation.Notify_PawnEvent(pawn, PopAdaptationEvent.GainedColonist);
            }
            GenSpawn.Spawn(pawn, loc, map, WipeMode.Vanish);
            for (int i = 0; i < 10; i++)
            {
                //MoteMaker.ThrowAirPuffUp(pawn.DrawPos, map);
                DebugActionsUtility.DustPuffFrom(pawn);
            }
            if (pawn.Faction != null && pawn.Faction != Faction.OfPlayer && pawn.HostileTo(Faction.OfPlayer))
            {
                LordMaker.MakeNewLord(pawn.Faction, new LordJob_AssaultColony(pawn.Faction, true, true, false, false, true), pawn.Map, Gen.YieldSingle <Pawn>(pawn));
            }
            if (pawn.apparel != null)
            {
                List <Apparel> wornApparel = pawn.apparel.WornApparel;
                for (int j = 0; j < wornApparel.Count; j++)
                {
                    wornApparel[j].Notify_PawnResurrected();
                }
            }
            PawnDiedOrDownedThoughtsUtility.RemoveDiedThoughts(pawn);
        }
Ejemplo n.º 27
0
        public override void PawnDied(Corpse corpse)
        {
            for (int i = 0; i < 3; i++)
            {
                MoteMaker.ThrowSmoke(corpse.DrawPos, corpse.Map, Rand.Range(.5f, 1.1f));
            }
            TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_Ghost, corpse.DrawPos, corpse.Map, 1f, .25f, 0f, .25f, 0, Rand.Range(2f, 3f), 0, 0);
            //MoteMaker.ThrowHeatGlow(corpse.Position, corpse.Map, 1f);
            List <Thing> rewards   = new List <Thing>();
            Thing        arcalleum = ThingMaker.MakeThing(TorannMagicDefOf.TM_Arcalleum, null);

            if (corpse.Faction != Faction.OfPlayer)
            {
                if (corpse.InnerPawn.def == TorannMagicDefOf.TM_SkeletonR)
                {
                    arcalleum.stackCount = Rand.Range(4, 8);
                    rewards.Add(arcalleum);
                }
                else if (corpse.InnerPawn.def == TorannMagicDefOf.TM_GiantSkeletonR)
                {
                    arcalleum.stackCount = Rand.Range(25, 60);
                    rewards.Add(arcalleum);
                }
                else if (corpse.InnerPawn.def == TorannMagicDefOf.TM_SkeletonLichR)
                {
                    arcalleum.stackCount = Rand.Range(40, 80);
                    rewards.Add(arcalleum);

                    Thing tome = ThingMaker.MakeThing(TM_Data.MageBookList().RandomElement(), null);
                    tome.stackCount = 1;
                    rewards.Add(tome);
                    ItemCollectionGenerator_Internal_Arcane icg = new ItemCollectionGenerator_Internal_Arcane();
                    List <Thing> icgThings = new List <Thing>();
                    icgThings = icg.Generate(2000, icgThings);
                    rewards.AddRange(icgThings);
                }
                for (int i = 0; i < rewards.Count; i++)
                {
                    GenPlace.TryPlaceThing(rewards[i], corpse.Position, corpse.Map, ThingPlaceMode.Near);
                }
            }
            corpse.Destroy();
        }
Ejemplo n.º 28
0
        public override void Notify_PawnDied()
        {
            base.Notify_PawnDied();

            if (pawn.def.race.Animal == false)
            {
                Corpse corpse  = pawn.Corpse;
                Pawn   newBorg = PawnGenerator.GeneratePawn(PawnKindDef.Named("BorgDrone3"), FactionUtility.DefaultFactionFrom(FactionDef.Named("BorgCollective")));
                newBorg.Position = corpse.Position;
                newBorg.SpawnSetup(corpse.Map, false);

                if (corpse != null)
                {
                    corpse.Destroy();
                }
            }
            else if (pawn.def.race.Animal == true)
            {
                Messages.Message("an animal has succumbed to nanite infection, and have been deemed inappropriate for assimilation. The nanites have consumed and destroyed the corpse.", MessageTypeDefOf.NeutralEvent);
                pawn.Corpse.Destroy();
            }
        }
Ejemplo n.º 29
0
        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();
                }
            }
        }
Ejemplo n.º 30
0
        protected override bool TryCastShot()
        {
            Pawn caster = this.CasterPawn;
            CompAbilityUserMagic comp      = caster.GetComp <CompAbilityUserMagic>();
            MagicPowerSkill      ver       = caster.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_ConsumeCorpse.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_ConsumeCorpse_ver");
            MagicPowerSkill      manaRegen = caster.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_global_regen.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_global_regen_pwr");

            Thing undeadThing = this.currentTarget.Thing;

            if (undeadThing is Pawn)
            {
                Pawn undead = (Pawn)undeadThing;

                bool flag = undead != null && !undead.Dead;
                if (flag)
                {
                    if (undead.health.hediffSet.HasHediff(TorannMagicDefOf.TM_UndeadHD))
                    {
                        comp.Mana.CurLevel += (.225f * (1 + (manaRegen.level * .02f) + (ver.level * .07f)) * comp.arcaneDmg);
                        ConsumeHumanoid(undead);
                        if (ver.level > 0)
                        {
                            HealCaster(caster, 2 + ver.level, 2, (5f + ver.level) * comp.arcaneDmg);
                        }
                        undead.Destroy();
                    }
                    else if (undead.health.hediffSet.HasHediff(TorannMagicDefOf.TM_UndeadAnimalHD))
                    {
                        comp.Mana.CurLevel += (.18f * (1 + (manaRegen.level * .02f) + (ver.level * .07f)) * comp.arcaneDmg);
                        ConsumeAnimalKind(undead);
                        if (ver.level > 0)
                        {
                            HealCaster(caster, 2, 2, (3 + ver.level) * comp.arcaneDmg);
                        }
                        undead.Destroy();
                    }
                    else
                    {
                        Messages.Message("TM_CannotUseOnLiving".Translate(), MessageTypeDefOf.RejectInput);
                    }
                }
            }


            IntVec3      target      = this.currentTarget.Cell;
            Thing        corpseThing = null;
            Corpse       corpse      = null;
            List <Thing> thingList;

            thingList = target.GetThingList(caster.Map);
            int i = 0;

            while (i < thingList.Count)
            {
                corpseThing = thingList[i];
                if (corpseThing != null)
                {
                    bool validator = corpseThing is Corpse;
                    if (validator)
                    {
                        corpse = corpseThing as Corpse;
                        Pawn undeadPawn = corpse.InnerPawn;
                        if ((undeadPawn.RaceProps.IsFlesh || TM_Calc.IsUndead(undeadPawn)) && (!TM_Calc.IsRobotPawn(undeadPawn)))
                        {
                            if (undeadPawn.RaceProps.Humanlike && !undeadPawn.RaceProps.Animal)
                            {
                                if (!corpse.IsNotFresh())
                                {
                                    comp.Mana.CurLevel += (.13f * (1 + (manaRegen.level * .02f) + (ver.level * .07f)) * comp.arcaneDmg);
                                    if (caster.needs != null && caster.needs.rest != null)
                                    {
                                        caster.needs.rest.CurLevel += .3f;
                                    }
                                    if (caster.needs != null && caster.needs.mood != null)
                                    {
                                        caster.needs.mood.CurLevel += .3f;
                                    }
                                    ConsumeHumanoid(corpse);
                                    if (ver.level > 0)
                                    {
                                        HealCaster(caster, 1 + ver.level, 1 + ver.level, (2f + ver.level) * comp.arcaneDmg);
                                    }
                                }
                                else
                                {
                                    comp.Mana.CurLevel += (.09f * (1 + (manaRegen.level * .02f) + (ver.level * .07f)) * comp.arcaneDmg);
                                    ConsumeHumanoid(corpse);
                                }
                                corpse.Destroy();
                            }
                            else if (undeadPawn.RaceProps.Animal || TM_Calc.IsUndead(undeadPawn))
                            {
                                if (!corpse.IsNotFresh())
                                {
                                    comp.Mana.CurLevel += (.09f * (1 + (manaRegen.level * .02f) + (ver.level * .07f)) * comp.arcaneDmg);
                                    if (caster.needs != null && caster.needs.food != null)
                                    {
                                        caster.needs.food.CurLevel += .4f;
                                    }
                                    ConsumeAnimalKind(corpse);
                                    if (ver.level > 0)
                                    {
                                        HealCaster(caster, 1, 1, (2f + ver.level) * comp.arcaneDmg);
                                    }
                                }
                                else
                                {
                                    comp.Mana.CurLevel += (.07f * (1 + (manaRegen.level * .02f) + (ver.level * .07f)) * comp.arcaneDmg);
                                    ConsumeAnimalKind(corpse);
                                }
                                corpse.Destroy();
                            }
                            else
                            {
                                Messages.Message("TM_CannontConsumeCorpseType".Translate(), MessageTypeDefOf.RejectInput);
                            }
                        }
                        else
                        {
                            Messages.Message("TM_InvalidCorpseType".Translate(), MessageTypeDefOf.RejectInput);
                        }
                    }
                }
                i++;
            }

            return(false);
        }