Example #1
0
        public static void TransferSoulBond(Pawn bondedPawn, Pawn polymorphedPawn)
        {
            Hediff bondHediff = null;

            bondHediff = bondedPawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("TM_SoulBondPhysicalHD"), false);
            if (bondHediff != null)
            {
                HediffComp_SoulBondHost comp = bondHediff.TryGetComp <HediffComp_SoulBondHost>();
                if (comp != null)
                {
                    comp.polyHost = polymorphedPawn;
                }
            }
            bondHediff = null;

            bondHediff = bondedPawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("TM_SoulBondMentalHD"), false);
            if (bondHediff != null)
            {
                HediffComp_SoulBondHost comp = bondHediff.TryGetComp <HediffComp_SoulBondHost>();
                if (comp != null)
                {
                    comp.polyHost = polymorphedPawn;
                }
            }
        }
Example #2
0
 private void ApplyHediffs()
 {
     if (flagSD)
     {
         HealthUtility.AdjustSeverity(caster, HediffDef.Named("TM_SDSoulBondPhysicalHD"), .5f + pwrVal);
         HealthUtility.AdjustSeverity(pawn, HediffDef.Named("TM_SoulBondPhysicalHD"), .5f + verVal);
         Hediff hediff = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("TM_SoulBondPhysicalHD"));
         HediffComp_SoulBondHost comp = hediff.TryGetComp <HediffComp_SoulBondHost>();
         comp.BonderPawn = caster;
     }
     if (flagWD)
     {
         HealthUtility.AdjustSeverity(caster, HediffDef.Named("TM_WDSoulBondMentalHD"), .5f + pwrVal);
         HealthUtility.AdjustSeverity(pawn, HediffDef.Named("TM_SoulBondMentalHD"), .5f + verVal);
         Hediff hediff = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("TM_SoulBondMentalHD"));
         HediffComp_SoulBondHost comp = hediff.TryGetComp <HediffComp_SoulBondHost>();
         comp.BonderPawn = caster;
     }
 }
Example #3
0
        protected override bool TryCastShot()
        {
            bool result = false;
            CompAbilityUserMagic comp = this.CasterPawn.GetComp <CompAbilityUserMagic>();
            Pawn soulPawn             = comp.soulBondPawn;

            if (soulPawn != null && !soulPawn.Dead && !soulPawn.Destroyed)
            {
                Pawn p       = this.CasterPawn;
                bool drafted = this.CasterPawn.Drafted;
                Map  map     = this.CasterPawn.Map;
                Map  sMap    = soulPawn.Map;
                if (sMap == null)
                {
                    Hediff bondHediff = null;
                    bondHediff = soulPawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("TM_SoulBondPhysicalHD"), false);
                    if (bondHediff != null)
                    {
                        HediffComp_SoulBondHost compS = bondHediff.TryGetComp <HediffComp_SoulBondHost>();
                        if (compS != null && compS.polyHost != null && !compS.polyHost.DestroyedOrNull() && !compS.polyHost.Dead)
                        {
                            soulPawn = compS.polyHost;
                        }
                    }
                    bondHediff = null;

                    bondHediff = soulPawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("TM_SoulBondMentalHD"), false);
                    if (bondHediff != null)
                    {
                        HediffComp_SoulBondHost compS = bondHediff.TryGetComp <HediffComp_SoulBondHost>();
                        if (compS != null && compS.polyHost != null && !compS.polyHost.DestroyedOrNull() && !compS.polyHost.Dead)
                        {
                            soulPawn = compS.polyHost;
                        }
                    }
                    if (soulPawn.ParentHolder != null && soulPawn.ParentHolder is Caravan)
                    {
                        //Log.Message("caravan detected");
                        //p.DeSpawn();
                        Caravan van = soulPawn.ParentHolder as Caravan;
                        van.AddPawn(p, true);
                        Find.WorldPawns.PassToWorld(p);
                        p.Notify_PassedToWorld();
                        Messages.Message("" + p.LabelShort + " has shadow stepped to a caravan with " + soulPawn.LabelShort, MessageTypeDefOf.NeutralEvent);
                        goto fin;
                    }
                }
                IntVec3 casterCell = this.CasterPawn.Position;
                IntVec3 targetCell = soulPawn.Position;
                if (p.Spawned)
                {
                    try
                    {
                        p.DeSpawn();
                        GenSpawn.Spawn(p, targetCell, soulPawn.Map);
                        if (drafted)
                        {
                            p.drafter.Drafted = true;
                        }
                        CameraJumper.TryJumpAndSelect(p);
                    }
                    catch
                    {
                        Log.Message("Exception occured when trying to shadow step to soul bound pawn - recovered caster at original position");
                        GenSpawn.Spawn(p, casterCell, map);
                    }
                }
                this.Ability.PostAbilityAttempt();
                result = true;
            }
            else
            {
                Log.Warning("No soul bond found to shadow call.");
            }

            //this.ability.TicksUntilCasting = (int)base.UseAbilityProps.SecondsToRecharge * 60;
            fin :;
            this.burstShotsLeft = 0;
            return(result);
        }
Example #4
0
        protected override bool TryCastShot()
        {
            bool result = false;
            CompAbilityUserMagic comp = this.CasterPawn.GetComp <CompAbilityUserMagic>();
            Pawn soulPawn             = comp.soulBondPawn;

            if (soulPawn != null && !soulPawn.Dead && !soulPawn.Destroyed)
            {
                if (ModCheck.Validate.GiddyUp.Core_IsInitialized())
                {
                    ModCheck.GiddyUp.ForceDismount(soulPawn);
                }
                bool drafted         = soulPawn.Drafted;
                bool soulPawnSpawned = soulPawn.Spawned;
                Map  map             = soulPawn.Map;
                if (map == null)
                {
                    Hediff bondHediff = soulPawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("TM_SoulBondPhysicalHD"), false);
                    if (bondHediff != null)
                    {
                        HediffComp_SoulBondHost compS = bondHediff.TryGetComp <HediffComp_SoulBondHost>();
                        if (compS != null && compS.polyHost != null && !compS.polyHost.DestroyedOrNull() && !compS.polyHost.Dead)
                        {
                            soulPawnSpawned = true;
                            soulPawn        = compS.polyHost;
                        }
                    }

                    bondHediff = soulPawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("TM_SoulBondMentalHD"), false);
                    if (bondHediff != null)
                    {
                        HediffComp_SoulBondHost compS = bondHediff.TryGetComp <HediffComp_SoulBondHost>();
                        if (compS != null && compS.polyHost != null && !compS.polyHost.DestroyedOrNull() && !compS.polyHost.Dead)
                        {
                            soulPawnSpawned = true;
                            soulPawn        = compS.polyHost;
                        }
                    }
                    if (soulPawn.ParentHolder != null && soulPawn.ParentHolder is Caravan)
                    {
                        //Log.Message("caravan detected");
                        //p.DeSpawn();
                        Caravan van = soulPawn.ParentHolder as Caravan;
                        van.RemovePawn(soulPawn);
                        GenPlace.TryPlaceThing(soulPawn, this.CasterPawn.Position, this.CasterPawn.Map, ThingPlaceMode.Near);
                        if (van.PawnsListForReading != null && van.PawnsListForReading.Count <= 0)
                        {
                            CaravanEnterMapUtility.Enter(van, this.CasterPawn.Map, CaravanEnterMode.Center, CaravanDropInventoryMode.DropInstantly, false);
                        }

                        //Messages.Message("" + p.LabelShort + " has shadow stepped to a caravan with " + soulPawn.LabelShort, MessageTypeDefOf.NeutralEvent);
                        goto fin;
                    }
                }
                IntVec3 casterCell = this.CasterPawn.Position;
                IntVec3 targetCell = soulPawn.Position;
                if (soulPawnSpawned)
                {
                    try
                    {
                        soulPawn.DeSpawn();
                        GenSpawn.Spawn(soulPawn, casterCell, this.CasterPawn.Map);
                        if (drafted)
                        {
                            soulPawn.drafter.Drafted = true;
                        }
                    }
                    catch
                    {
                        Log.Message("Exception occured when trying to summon soul bound pawn - recovered pawn at original position");
                        GenSpawn.Spawn(soulPawn, targetCell, map);
                    }
                }
                else
                {
                    Messages.Message("TM_BondedPawnNotSpawned".Translate(
                                         soulPawn.LabelShort), MessageTypeDefOf.RejectInput);
                }
                //this.Ability.PostAbilityAttempt();
                result = true;
            }
            else
            {
                Log.Warning("No soul bond found to shadow call.");
            }
            fin :;
            this.burstShotsLeft = 0;
            //this.ability.TicksUntilCasting = (int)base.UseAbilityProps.SecondsToRecharge * 60;
            return(result);
        }