public override void Use()
        {
            List <Thing> corpses = Map.listerThings.ThingsInGroup(ThingRequestGroup.Corpse).ToList();

            for (int i = 0; i < corpses.Count; i++)
            {
                Thing corpseThing = corpses[i];

                Corpse corpse = corpseThing as Corpse;
                if (corpse != null)
                {
                    Pawn pawn = corpse.InnerPawn;
                    if (pawn != null && pawn.RaceProps.IsFlesh)
                    {
                        ResurrectionUtility.ResurrectWithSideEffects(pawn);

                        Hediff hediff = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.ResurrectionSickness);
                        if (hediff != null)
                        {
                            pawn.health.RemoveHediff(hediff);
                        }

                        HealthUtility.AdjustSeverity(pawn, HediffDefOfLocal.SphereOfResurrection, 0.1f);
                    }
                }
            }

            Destroy();
        }
Example #2
0
        private void AgeCorpse(Thing thing)
        {
            CompRottable compRot = thing.TryGetComp <CompRottable>();

            if (compRot != null)
            {
                if (compRot.RotProgress <= (5000 + (5000 * pwrVal)))
                {
                    Corpse corpse = thing as Corpse;
                    if (corpse != null && verVal >= 3)
                    {
                        TransmutateEffects(corpse.Position, 10);
                        Pawn innerPawn = corpse.InnerPawn;
                        ResurrectionUtility.ResurrectWithSideEffects(innerPawn);
                        AgePawn(innerPawn, Mathf.RoundToInt(6 * 2500 * (1 + (.1f * verVal))), false);
                        HealthUtility.AdjustSeverity(innerPawn, TorannMagicDefOf.TM_DeathReversalHD, 1f);
                        Projectile_Resurrection.ApplyHealthDefects(innerPawn, .25f, .3f);
                        Projectile_Resurrection.ReduceSkillsOfPawn(innerPawn, Rand.Range(.30f, .40f));
                        HealthUtility.AdjustSeverity(this.CasterPawn, TorannMagicDefOf.TM_DeathReversalHD, Rand.Range(.4f, .6f));
                        //Projectile_Resurrection.ApplyHealthDefects(this.CasterPawn, .15f, .2f);
                        Projectile_Resurrection.ReduceSkillsOfPawn(this.CasterPawn, Rand.Range(.15f, .25f));
                    }
                }
                else
                {
                    compRot.RotProgress = compRot.RotProgress * (.4f - (.125f * pwrVal));
                    if (compRot.RotProgress <= 20000)
                    {
                        compRot.RotProgress = 20001;
                    }
                }
            }
        }
 public override void TryExecute()
 {
     try
     {
         if (pawn.SpawnedParentOrMe != pawn.Corpse)
         {
             // Someone is holding the corpse, try to drop it
             if (pawn.SpawnedParentOrMe is Pawn carryingPawn)
             {
                 if (!carryingPawn.carryTracker.TryDropCarriedThing(carryingPawn.Position, ThingPlaceMode.Near, out Thing droppedThing))
                 {
                     // Failed to drop carried thing.
                     Log.Error($"Submit this bug to TwitchToolkit Discord: Could not drop {pawn} at {carryingPawn.Position} from {carryingPawn}");
                     return;
                 }
             }
         }
         pawn.ClearAllReservations();
         ResurrectionUtility.ResurrectWithSideEffects(pawn);
         PawnTracker.pawnsToRevive.Remove(pawn);
         Find.LetterStack.ReceiveLetter("Pawn Revived", $"{pawn.Name} has been revived but is experiencing some side effects.", LetterDefOf.PositiveEvent, pawn);
     }
     catch (Exception e)
     {
         Log.Error("Submit this bug to TwitchToolkit Discord: " + e.Message);
     }
 }
Example #4
0
        private void AgeCorpse(Thing thing)
        {
            CompRottable compRot = thing.TryGetComp <CompRottable>();

            if (compRot != null)
            {
                if (compRot.RotProgress <= (5000 + (5000 * pwrVal)))
                {
                    Corpse corpse = thing as Corpse;
                    if (corpse != null && verVal >= 3)
                    {
                        TransmutateEffects(corpse.Position, 10);
                        Pawn innerPawn = corpse.InnerPawn;
                        ResurrectionUtility.ResurrectWithSideEffects(innerPawn);
                        AgePawn(innerPawn, Mathf.RoundToInt((6 * 2500) * (1 + (.1f * verVal))), false);
                        HealthUtility.AdjustSeverity(innerPawn, HediffDef.Named("TM_ResurrectionHD"), 1f);
                        HealthUtility.AdjustSeverity(this.CasterPawn, HediffDef.Named("TM_ResurrectionHD"), 1f);
                    }
                }
                else
                {
                    compRot.RotProgress = compRot.RotProgress * (.4f - (.125f * pwrVal));
                    if (compRot.RotProgress <= 20000)
                    {
                        compRot.RotProgress = 20001;
                    }
                }
            }
        }
        public override void Notify_PawnDied()
        {
            base.Notify_PawnDied();
            Pawn pawn = parent.pawn;

            ResurrectionUtility.ResurrectWithSideEffects(pawn);
            Messages.Message("MessagePawnResurrected".Translate(pawn), pawn, MessageTypeDefOf.PositiveEvent);
            resurrected = true;
        }
 public override void TryExecute()
 {
     try
     {
         pawn.ClearAllReservations();
         ResurrectionUtility.ResurrectWithSideEffects(pawn);
         PawnTracker.pawnsToRevive.Remove(pawn);
         Find.LetterStack.ReceiveLetter("Pawn Revived", $"{pawn.Name} has been revived but is experiencing some side effects.", LetterDefOf.PositiveEvent, pawn);
     }
     catch (Exception e)
     {
         Log.Error("Submit this bug to TwitchToolkit Discord: " + e.Message);
     }
 }
Example #7
0
        private static void Resurrect(this Pawn pawn)
        {
            try
            {
                ResurrectionUtility.ResurrectWithSideEffects(pawn);
            }
            catch (NullReferenceException)
            {
                TkUtils.Logger.Warn("Failed to revive with side effects -- falling back to a regular revive");
                ResurrectionUtility.Resurrect(pawn);
            }

            PawnTracker.pawnsToRevive.Remove(pawn);
        }
Example #8
0
        public override void CompTickRare()
        {
            base.CompTickRare();

            if (!_activated || !parent.Spawned)
            {
                return;
            }

            _progress -= 250;
            if (_progress < 0 && InnerPawn != null)
            {
                if (Props.hediffCondition != null && Props.removeHediffAfterResurrect)
                {
                    var hediff = InnerPawn.health?.hediffSet?.GetFirstHediffOfDef(Props.hediffCondition);
                    InnerPawn.health.RemoveHediff(hediff);
                }

                ResurrectionUtility.ResurrectWithSideEffects(InnerPawn);
                _activated = false;
            }
        }
Example #9
0
 public override void TryExecute()
 {
     ResurrectionUtility.ResurrectWithSideEffects(pawn);
     PawnTracker.pawnsToRevive.Remove(pawn);
     Find.LetterStack.ReceiveLetter("Pawn Revived", $"{pawn.Name} has been revived but is experiencing some side effects.", LetterDefOf.PositiveEvent, pawn);
 }
Example #10
0
        protected override void Impact(Thing hitThing)
        {
            Map map = base.Map;

            base.Impact(hitThing);
            ThingDef def = this.def;

            if (!this.initialized)
            {
                if (this.launcher is Pawn)
                {
                    caster = this.launcher as Pawn;
                    CompAbilityUserMagic comp = caster.GetComp <CompAbilityUserMagic>();
                    MagicPowerSkill      ver  = caster.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Resurrection.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Resurrection_ver");
                    MagicPowerSkill      pwr  = caster.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Resurrection.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Resurrection_eff");
                    verVal = ver.level;
                    pwrVal = pwr.level;
                }
                this.angle = Rand.Range(-12f, 12f);

                IntVec3 curCell = base.Position;

                this.CheckSpawnSustainer();

                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;
                                CompRottable compRot = corpse.GetComp <CompRottable>();

                                deadPawn         = corpse.InnerPawn;
                                deadPawnPosition = corpse.Position;
                                if (deadPawn.RaceProps.IsFlesh && !TM_Calc.IsUndead(deadPawn) && compRot != null)
                                {
                                    if (!corpse.IsNotFresh())
                                    {
                                        z = thingList.Count;
                                        this.validTarget = true;
                                        corpse.SetForbidden(true);
                                    }
                                    else
                                    {
                                        Messages.Message("TM_ResurrectionTargetExpired".Translate(), MessageTypeDefOf.RejectInput);
                                    }
                                }
                                if (TM_Calc.IsUndead(deadPawn))
                                {
                                    z = thingList.Count;
                                    this.validTarget = true;
                                }
                            }
                        }
                        z++;
                    }
                }
                this.initialized = true;
            }

            if (corpseThing.Position != this.deadPawnPosition || corpseThing.Map == null)
            {
                Log.Message("Corpse was moved or destroyed during resurrection process.");
                this.age = this.timeToRaise;
            }

            if (this.validTarget)
            {
                if (this.sustainer != null)
                {
                    this.sustainer.info.volumeFactor = this.age / this.timeToRaise;
                    this.sustainer.Maintain();
                    if (this.TicksLeft <= 0)
                    {
                        this.sustainer.End();
                        this.sustainer = null;
                    }
                }

                if (this.age + 1 == this.timeToRaise)
                {
                    TM_MoteMaker.MakePowerBeamMoteColor(base.Position, base.Map, this.radius * 3f, 2f, 2f, .1f, 1.5f, colorInt.ToColor);
                    if (this.deadPawn == null)
                    {
                        if (corpseThing != null)
                        {
                            Corpse corpse = corpseThing as Corpse;
                            if (corpse != null)
                            {
                                this.deadPawn = corpse.InnerPawn;
                            }
                        }
                    }
                    if (deadPawn != null)
                    {
                        if (TM_Calc.IsUndead(deadPawn))
                        {
                            if (deadPawn.RaceProps.Humanlike)
                            {
                                GenExplosion.DoExplosion(base.Position, this.Map, Rand.Range(10, 16), TMDamageDefOf.DamageDefOf.TM_Holy, this.launcher, Mathf.RoundToInt(Rand.Range(20, 32)), 6, TMDamageDefOf.DamageDefOf.TM_Holy.soundExplosion);
                            }
                            else
                            {
                                GenExplosion.DoExplosion(base.Position, this.Map, Rand.Range(10, 16), TMDamageDefOf.DamageDefOf.TM_Holy, this.launcher, Mathf.RoundToInt(Rand.Range(16, 24)), 3, TMDamageDefOf.DamageDefOf.TM_Holy.soundExplosion);
                            }
                        }
                        else
                        {
                            if (!deadPawn.kindDef.RaceProps.Animal && deadPawn.kindDef.RaceProps.Humanlike)
                            {
                                ResurrectionUtility.ResurrectWithSideEffects(deadPawn);
                                SoundDef.Named("Thunder_OffMap").PlayOneShot(null);
                                SoundDef.Named("Thunder_OffMap").PlayOneShot(null);
                                using (IEnumerator <Hediff> enumerator = deadPawn.health.hediffSet.GetHediffs <Hediff>().GetEnumerator())
                                {
                                    while (enumerator.MoveNext())
                                    {
                                        Hediff rec = enumerator.Current;
                                        if (rec.def.defName == "ResurrectionPsychosis")
                                        {
                                            if (Rand.Chance(verVal * .33f))
                                            {
                                                deadPawn.health.RemoveHediff(rec);
                                            }
                                        }
                                    }
                                }
                                HealthUtility.AdjustSeverity(deadPawn, HediffDef.Named("TM_ResurrectionHD"), 1f);
                                ReduceSkillsOfPawn(deadPawn, (.35f - .035f * pwrVal));
                                ApplyHealthDefects(deadPawn, .6f - (.06f * verVal), .3f - .03f * verVal);
                            }
                            if (deadPawn.kindDef.RaceProps.Animal)
                            {
                                ResurrectionUtility.Resurrect(deadPawn);
                                HealthUtility.AdjustSeverity(deadPawn, HediffDef.Named("TM_ResurrectionHD"), 1f);
                            }
                        }
                    }
                }
            }
            else
            {
                Messages.Message("TM_InvalidResurrection".Translate(
                                     caster.LabelShort
                                     ), MessageTypeDefOf.RejectInput);
                this.age = this.timeToRaise;
            }
        }
Example #11
0
        protected override void Impact(Thing hitThing)
        {
            Map map = base.Map;

            base.Impact(hitThing);
            ThingDef def = this.def;

            if (!this.initialized)
            {
                caster = this.launcher as Pawn;
                CompAbilityUserMagic comp = caster.GetComp <CompAbilityUserMagic>();
                MagicPowerSkill      ver  = caster.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Resurrection.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Resurrection_ver");
                verVal     = ver.level;
                this.angle = Rand.Range(-12f, 12f);

                Thing   corpseThing = null;
                IntVec3 curCell     = base.Position;

                this.CheckSpawnSustainer();

                if (curCell.InBounds(map) && curCell.IsValid)
                {
                    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;
                                deadPawn = corpse.InnerPawn;
                                if (deadPawn.RaceProps.IsFlesh)
                                {
                                    if (!corpse.IsNotFresh())
                                    {
                                        z = thingList.Count;
                                        this.validTarget = true;
                                    }
                                    else
                                    {
                                        Messages.Message("TM_ResurrectionTargetExpired".Translate(), MessageTypeDefOf.RejectInput);
                                    }
                                }
                            }
                        }
                        z++;
                    }
                }
                this.initialized = true;
            }

            if (this.validTarget)
            {
                if (this.sustainer != null)
                {
                    this.sustainer.info.volumeFactor = this.age / this.timeToRaise;
                    this.sustainer.Maintain();
                    if (this.TicksLeft <= 0)
                    {
                        this.sustainer.End();
                        this.sustainer = null;
                    }
                }

                if (this.age + 1 == this.timeToRaise)
                {
                    TM_MoteMaker.MakePowerBeamMoteColor(base.Position, base.Map, this.radius * 3f, 2f, 2f, .1f, 1.5f, colorInt.ToColor);
                    if (!deadPawn.kindDef.RaceProps.Animal && deadPawn.kindDef.RaceProps.Humanlike)
                    {
                        ResurrectionUtility.ResurrectWithSideEffects(deadPawn);
                        SoundDef.Named("Thunder_OffMap").PlayOneShot(null);
                        SoundDef.Named("Thunder_OffMap").PlayOneShot(null);
                        using (IEnumerator <Hediff> enumerator = deadPawn.health.hediffSet.GetHediffs <Hediff>().GetEnumerator())
                        {
                            while (enumerator.MoveNext())
                            {
                                Hediff rec = enumerator.Current;
                                if (rec.def.defName == "ResurrectionPsychosis" || rec.def.defName == "Blindness")
                                {
                                    if (Rand.Chance(verVal * .33f))
                                    {
                                        deadPawn.health.RemoveHediff(rec);
                                    }
                                }
                            }
                        }
                        HealthUtility.AdjustSeverity(deadPawn, HediffDef.Named("TM_ResurrectionHD"), 1f);
                    }
                    if (deadPawn.kindDef.RaceProps.Animal)
                    {
                        ResurrectionUtility.Resurrect(deadPawn);
                        HealthUtility.AdjustSeverity(deadPawn, HediffDef.Named("TM_ResurrectionHD"), 1f);
                    }
                }
            }
            else
            {
                Messages.Message("TM_InvalidResurrection".Translate(new object[]
                {
                    caster.LabelShort
                }), MessageTypeDefOf.RejectInput);
                this.age = this.timeToRaise;
            }
            this.age++;
        }