示例#1
0
        private void RemoveMimicAbility(Verb_UseAbility verbCast)
        {
            CompAbilityUserMight mightComp = this.pawn.GetComp <CompAbilityUserMight>();
            CompAbilityUserMagic magicComp = this.pawn.GetComp <CompAbilityUserMagic>();

            if (mightComp.mimicAbility != null && mightComp.mimicAbility.MainVerb.verbClass == verbCast.verbProps.verbClass)
            {
                mightComp.RemovePawnAbility(mightComp.mimicAbility);
            }
            if (magicComp.mimicAbility != null && magicComp.mimicAbility.MainVerb.verbClass == verbCast.verbProps.verbClass)
            {
                magicComp.RemovePawnAbility(magicComp.mimicAbility);
            }
        }
示例#2
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            CompAbilityUserMight comp = this.pawn.GetComp <CompAbilityUserMight>();
            float radius = 2f;

            radius = 2 + (.5f * TM_Calc.GetMightSkillLevel(pawn, comp.MightData.MightPowerSkill_PsionicBarrier, "TM_PsionicBarrier", "_ver", true));
            //if (this.pawn.story.traits.HasTrait(TorannMagicDefOf.TM_Psionic))
            //{
            //    radius = 2 + (.5f * comp.MightData.MightPowerSkill_PsionicBarrier.FirstOrDefault((MightPowerSkill x) => x.label == "TM_PsionicBarrier_ver").level);
            //}
            //else if(this.pawn.story.traits.HasTrait(TorannMagicDefOf.Faceless))
            //{
            //    radius = 2 + (.5f * comp.MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_ver").level);
            //}
            this.psiFlag = this.pawn.health.hediffSet.HasHediff(HediffDef.Named("TM_PsionicHD"), false);
            Toil psionicBarrier = new Toil();

            psionicBarrier.initAction = delegate
            {
                if (age > duration)
                {
                    this.EndJobWith(JobCondition.Succeeded);
                }
                Map map = this.pawn.Map;
                this.barrierCells = new List <IntVec3>();
                this.barrierCells.Clear();
                this.GetCellList(radius);
                ticksLeftThisToil = 10;
            };
            psionicBarrier.tickAction = delegate
            {
                DrawBarrier(radius);
                if (Find.TickManager.TicksGame % this.barrierSearchFrequency == 0)
                {
                    if (psiFlag)
                    {
                        if (Rand.Chance(.15f * comp.MightData.MightPowerSkill_PsionicBarrier.FirstOrDefault((MightPowerSkill x) => x.label == "TM_PsionicBarrier_pwr").level))
                        {
                            RepelProjectiles(false);
                        }
                        else
                        {
                            RepelProjectiles(psiFlag);
                        }
                        if (this.pawn.IsColonist)
                        {
                            HealthUtility.AdjustSeverity(this.pawn, HediffDef.Named("TM_PsionicHD"), -.005f);
                        }
                        else
                        {
                            HealthUtility.AdjustSeverity(this.pawn, HediffDef.Named("TM_PsionicHD"), -.05f);
                        }

                        psiEnergy = this.pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("TM_PsionicHD"), false).Severity;
                        if (psiEnergy < 1)
                        {
                            this.EndJobWith(JobCondition.Succeeded);
                        }
                        if (this.psiFlag)
                        {
                            ticksLeftThisToil = (int)psiEnergy;
                        }
                    }
                    else
                    {
                        RepelProjectiles(false);
                        comp.Stamina.CurLevel -= .0004f;
                    }
                }
                age++;
                if (!psiFlag)
                {
                    ticksLeftThisToil = Mathf.RoundToInt(((float)(duration - age) / (float)duration) * 100f);
                    if (age > duration)
                    {
                        this.EndJobWith(JobCondition.Succeeded);
                    }
                    if (comp.Stamina.CurLevel < .01f)
                    {
                        this.EndJobWith(JobCondition.Succeeded);
                    }
                }
            };
            psionicBarrier.defaultCompleteMode = ToilCompleteMode.Delay;
            psionicBarrier.defaultDuration     = this.duration;
            psionicBarrier.WithProgressBar(TargetIndex.A, delegate
            {
                if (this.pawn.DestroyedOrNull() || this.pawn.Dead || this.pawn.Downed)
                {
                    return(1f);
                }
                return(1f - (float)psionicBarrier.actor.jobs.curDriver.ticksLeftThisToil / 100);
            }, false, 0f);
            psionicBarrier.AddFinishAction(delegate
            {
                if (this.pawn.story.traits.HasTrait(TorannMagicDefOf.Faceless))
                {
                    CompAbilityUserMight mightComp = this.pawn.GetComp <CompAbilityUserMight>();
                    if (mightComp.mimicAbility != null)
                    {
                        mightComp.RemovePawnAbility(mightComp.mimicAbility);
                    }
                }
                //do soemthing?
            });
            yield return(psionicBarrier);
        }
示例#3
0
        protected override bool TryCastShot()
        {
            bool result = false;

            if (this.currentTarget != null && base.CasterPawn != null && this.currentTarget.Thing is Pawn)
            {
                Pawn targetPawn = this.currentTarget.Thing as Pawn;
                if (targetPawn.RaceProps.Humanlike)
                {
                    CompAbilityUserMagic magicPawn = targetPawn.GetComp <CompAbilityUserMagic>();
                    CompAbilityUserMight mightPawn = targetPawn.GetComp <CompAbilityUserMight>();
                    bool copyMagic = false;
                    bool copyMight = false;
                    if (magicPawn != null && magicPawn.IsMagicUser)
                    {
                        copyMagic = true;
                    }
                    if (mightPawn != null && mightPawn.IsMightUser)
                    {
                        copyMight = true;
                    }

                    if (copyMight && copyMagic && Rand.Chance(.5f))
                    {
                        copyMagic = false;
                    }
                    TMAbilityDef         tempAbility = null;
                    CompAbilityUserMight mightComp   = this.CasterPawn.GetComp <CompAbilityUserMight>();
                    CompAbilityUserMagic magicComp   = this.CasterPawn.GetComp <CompAbilityUserMagic>();

                    if (copyMagic)
                    {
                        tempAbility = TM_Calc.GetCopiedMagicAbility(targetPawn, base.CasterPawn);

                        if (tempAbility != null)
                        {
                            if (mightComp.mimicAbility != null)
                            {
                                if (mightComp.mimicAbility.manaCost > 0)
                                {
                                    MagicPower mp = magicComp.MagicData.AllMagicPowers.FirstOrDefault((MagicPower x) => x.abilityDef == mightComp.mimicAbility);
                                    if (mp != null)
                                    {
                                        mp.autocast = false;
                                    }
                                }
                                else if (mightComp.mimicAbility.staminaCost > 0)
                                {
                                    MightPower mp = mightComp.MightData.AllMightPowers.FirstOrDefault((MightPower x) => x.abilityDef == mightComp.mimicAbility);
                                    if (mp != null)
                                    {
                                        mp.autocast = false;
                                    }
                                }
                                mightComp.RemovePawnAbility(mightComp.mimicAbility);
                            }
                            mightComp.mimicAbility = tempAbility;
                            mightComp.AddPawnAbility(tempAbility);
                        }
                        else
                        {
                            //invalid target
                            Messages.Message("TM_MimicFailed".Translate(
                                                 this.CasterPawn.LabelShort
                                                 ), MessageTypeDefOf.RejectInput);
                        }
                    }
                    else if (copyMight)
                    {
                        tempAbility = TM_Calc.GetCopiedMightAbility(targetPawn, base.CasterPawn);

                        if (tempAbility != null)
                        {
                            if (mightComp.mimicAbility != null)
                            {
                                if (mightComp.mimicAbility.manaCost > 0)
                                {
                                    MagicPower mp = magicComp.MagicData.AllMagicPowers.FirstOrDefault((MagicPower x) => x.abilityDef == mightComp.mimicAbility);
                                    if (mp != null)
                                    {
                                        mp.autocast = false;
                                    }
                                }
                                else if (mightComp.mimicAbility.staminaCost > 0)
                                {
                                    MightPower mp = mightComp.MightData.AllMightPowers.FirstOrDefault((MightPower x) => x.abilityDef == mightComp.mimicAbility);
                                    if (mp != null)
                                    {
                                        mp.autocast = false;
                                    }
                                }
                                mightComp.RemovePawnAbility(mightComp.mimicAbility);
                            }
                            if (magicComp.mimicAbility != null)
                            {
                                magicComp.RemovePawnAbility(magicComp.mimicAbility);
                            }
                            mightComp.mimicAbility = tempAbility;
                            mightComp.AddPawnAbility(tempAbility);
                        }
                        else
                        {
                            //invalid target
                            Messages.Message("TM_MimicFailed".Translate(
                                                 this.CasterPawn.LabelShort
                                                 ), MessageTypeDefOf.RejectInput);
                        }
                    }
                }
            }
            else
            {
                Log.Warning("failed to TryCastShot");
            }
            this.burstShotsLeft = 0;
            return(result);
        }
示例#4
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            bool flag;

            yield return(Toils_Misc.ThrowColonistAttackingMote(TargetIndex.A));

            Verb_UseAbility curJob = this.pawn.CurJob.verbToUse as Verb_UseAbility;

            if (base.TargetA.HasThing)
            {
                flag = (!base.GetActor().IsFighting() ? true : !curJob.UseAbilityProps.canCastInMelee);
                if (flag)
                {
                    Toil toil = Toils_Combat.GotoCastPosition(TargetIndex.A, false);
                    yield return(toil);

                    toil = null;
                }
            }
            if (this.Context == AbilityContext.Player)
            {
                Find.Targeter.targetingVerb = curJob;
            }
            Pawn targetPawn = null;

            if (this.TargetThingA != null)
            {
                targetPawn = TargetThingA as Pawn;
            }

            if (targetPawn != null)
            {
                //yield return Toils_Combat.CastVerb(TargetIndex.A, false);
                Toil combatToil = new Toil();
                combatToil.FailOnDestroyedOrNull(TargetIndex.A);
                combatToil.FailOnDespawnedOrNull(TargetIndex.A);
                //combatToil.FailOnDowned(TargetIndex.A);
                //CompAbilityUserMagic comp = this.pawn.GetComp<CompAbilityUserMagic>();
                this.duration = (int)((curJob.verbProps.warmupTime * 60) * this.pawn.GetStatValue(StatDefOf.AimingDelayFactor, false));
                //JobDriver curDriver = this.pawn.jobs.curDriver;
                combatToil.initAction = delegate
                {
                    arg_45_0 = combatToil.actor.jobs.curJob.verbToUse;
                    if (this.pawn.RaceProps.Humanlike)
                    {
                        if (this.pawn.story.traits.HasTrait(TorannMagicDefOf.Faceless))
                        {
                            CompAbilityUserMight mightComp = this.pawn.GetComp <CompAbilityUserMight>();
                            CompAbilityUserMagic magicComp = this.pawn.GetComp <CompAbilityUserMagic>();
                            if (mightComp.mimicAbility != null && mightComp.mimicAbility.MainVerb.verbClass == arg_45_0.verbProps.verbClass)
                            {
                                mightComp.RemovePawnAbility(mightComp.mimicAbility);
                            }
                            if (magicComp.mimicAbility != null && magicComp.mimicAbility.MainVerb.verbClass == arg_45_0.verbProps.verbClass)
                            {
                                magicComp.RemovePawnAbility(magicComp.mimicAbility);
                            }
                        }
                    }

                    LocalTargetInfo target = combatToil.actor.jobs.curJob.GetTarget(TargetIndex.A);
                    // bool canFreeIntercept2 = false;
                    arg_45_0.TryStartCastOn(target, false, false);
                    using (IEnumerator <Hediff> enumerator = this.pawn.health.hediffSet.GetHediffs <Hediff>().GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            Hediff rec = enumerator.Current;
                            if (rec.def == TorannMagicDefOf.TM_PossessionHD || rec.def == TorannMagicDefOf.TM_DisguiseHD || rec.def == TorannMagicDefOf.TM_DisguiseHD_I || rec.def == TorannMagicDefOf.TM_DisguiseHD_II || rec.def == TorannMagicDefOf.TM_DisguiseHD_III)
                            {
                                this.pawn.health.RemoveHediff(rec);
                            }
                        }
                    }
                };
                combatToil.tickAction = delegate
                {
                    if (Find.TickManager.TicksGame % 12 == 0)
                    {
                        TM_MoteMaker.ThrowCastingMote(pawn.DrawPos, pawn.Map, Rand.Range(1.2f, 2f));
                    }

                    this.duration--;
                };
                combatToil.AddFinishAction(delegate
                {
                    if (this.duration <= 5)
                    {
                        curJob.Ability.PostAbilityAttempt();
                    }
                });
                //if (combatToil.actor.CurJob != this.job)
                //{
                //    curDriver.ReadyForNextToil();
                //}
                combatToil.defaultCompleteMode = ToilCompleteMode.FinishedBusy;
                yield return(combatToil);
                //Toil toil2 = new Toil()
                //{
                //    initAction = () =>
                //    {
                //        if (curJob.UseAbilityProps.isViolent)
                //        {
                //            JobDriver_CastAbilityVerb.CheckForAutoAttack(this.pawn);
                //        }
                //    },
                //    defaultCompleteMode = ToilCompleteMode.Instant
                //};
                //yield return toil2;
                //Toil toil1 = new Toil()
                //{
                //    initAction = () => curJob.Ability.PostAbilityAttempt(),
                //    defaultCompleteMode = ToilCompleteMode.Instant
                //};
                //yield return toil1;
            }
            else
            {
                if ((pawn.Position - TargetLocA).LengthHorizontal < curJob.verbProps.range)
                {
                    if (TargetLocA.IsValid && TargetLocA.InBounds(pawn.Map) && !TargetLocA.Fogged(pawn.Map) && TargetLocA.Walkable(pawn.Map))
                    {
                        ShootLine shootLine;
                        bool      validTarg = curJob.TryFindShootLineFromTo(pawn.Position, TargetLocA, out shootLine);
                        if (validTarg)
                        {
                            //yield return Toils_Combat.CastVerb(TargetIndex.A, false);
                            //Toil toil2 = new Toil()
                            //{
                            //    initAction = () =>
                            //    {
                            //        if (curJob.UseAbilityProps.isViolent)
                            //        {
                            //            JobDriver_CastAbilityVerb.CheckForAutoAttack(this.pawn);
                            //        }

                            //    },
                            //    defaultCompleteMode = ToilCompleteMode.Instant
                            //};
                            //yield return toil2;
                            this.duration = (int)((curJob.verbProps.warmupTime * 60) * this.pawn.GetStatValue(StatDefOf.AimingDelayFactor, false));
                            Toil toil = new Toil();
                            toil.initAction = delegate
                            {
                                arg_45_0 = toil.actor.jobs.curJob.verbToUse;
                                if (this.pawn.RaceProps.Humanlike)
                                {
                                    if (this.pawn.story.traits.HasTrait(TorannMagicDefOf.Faceless))
                                    {
                                        CompAbilityUserMight mightComp = this.pawn.GetComp <CompAbilityUserMight>();
                                        CompAbilityUserMagic magicComp = this.pawn.GetComp <CompAbilityUserMagic>();
                                        if (mightComp.mimicAbility != null && mightComp.mimicAbility.MainVerb.verbClass == arg_45_0.verbProps.verbClass)
                                        {
                                            mightComp.RemovePawnAbility(mightComp.mimicAbility);
                                        }
                                        if (magicComp.mimicAbility != null && magicComp.mimicAbility.MainVerb.verbClass == arg_45_0.verbProps.verbClass)
                                        {
                                            magicComp.RemovePawnAbility(magicComp.mimicAbility);
                                        }
                                    }
                                }

                                LocalTargetInfo target            = toil.actor.jobs.curJob.GetTarget(TargetIndex.A);
                                bool            canFreeIntercept2 = false;
                                arg_45_0.TryStartCastOn(target, false, canFreeIntercept2);

                                using (IEnumerator <Hediff> enumerator = this.pawn.health.hediffSet.GetHediffs <Hediff>().GetEnumerator())
                                {
                                    while (enumerator.MoveNext())
                                    {
                                        Hediff rec = enumerator.Current;
                                        if (rec.def == TorannMagicDefOf.TM_PossessionHD || rec.def == TorannMagicDefOf.TM_DisguiseHD || rec.def == TorannMagicDefOf.TM_DisguiseHD_I || rec.def == TorannMagicDefOf.TM_DisguiseHD_II || rec.def == TorannMagicDefOf.TM_DisguiseHD_III)
                                        {
                                            this.pawn.health.RemoveHediff(rec);
                                        }
                                    }
                                }
                            };
                            toil.tickAction = delegate
                            {
                                if (Find.TickManager.TicksGame % 12 == 0)
                                {
                                    TM_MoteMaker.ThrowCastingMote(pawn.DrawPos, pawn.Map, Rand.Range(1.2f, 2f));
                                }
                                this.duration--;
                            };
                            toil.AddFinishAction(delegate
                            {
                                if (this.duration <= 5)
                                {
                                    curJob.Ability.PostAbilityAttempt();
                                }
                            });
                            toil.defaultCompleteMode = ToilCompleteMode.FinishedBusy;
                            yield return(toil);

                            //Toil toil1 = new Toil()
                            //{
                            //    initAction = () => curJob.Ability.PostAbilityAttempt(),
                            //    defaultCompleteMode = ToilCompleteMode.Instant
                            //};
                            //yield return toil1;
                        }
                        else
                        {
                            //No LoS
                            if (pawn.IsColonist)
                            {
                                Messages.Message("TM_OutOfLOS".Translate(new object[]
                                {
                                    pawn.LabelShort
                                }), MessageTypeDefOf.RejectInput);
                            }
                        }
                    }
                }
                else
                {
                    if (pawn.IsColonist)
                    {
                        //out of range
                        Messages.Message("TM_OutOfRange".Translate(), MessageTypeDefOf.RejectInput);
                    }
                }
            }
        }
示例#5
0
        protected override bool TryCastShot()
        {
            bool result = false;

            if (this.currentTarget != null && base.CasterPawn != null && this.currentTarget.Thing is Pawn)
            {
                Pawn targetPawn = this.currentTarget.Thing as Pawn;
                if (targetPawn.RaceProps.Humanlike)
                {
                    CompAbilityUserMagic magicPawn = targetPawn.GetComp <CompAbilityUserMagic>();
                    CompAbilityUserMight mightPawn = targetPawn.GetComp <CompAbilityUserMight>();

                    TMAbilityDef         tempAbility = null;
                    CompAbilityUserMight mightComp   = this.CasterPawn.GetComp <CompAbilityUserMight>();
                    CompAbilityUserMagic magicComp   = this.CasterPawn.GetComp <CompAbilityUserMagic>();

                    if (magicPawn.IsMagicUser)
                    {
                        if (targetPawn.story.traits.HasTrait(TorannMagicDefOf.Arcanist))
                        {
                            for (int i = 0; i < 5; i++)
                            {
                                int rnd = Rand.RangeInclusive(0, 3);
                                if (rnd == 0 && magicPawn.MagicData.MagicPowersA[rnd].learned)
                                {
                                    int level = magicPawn.MagicData.MagicPowersA[rnd].level;
                                    switch (level)
                                    {
                                    case 0:
                                        tempAbility = TorannMagicDefOf.TM_Shadow;
                                        break;

                                    case 1:
                                        tempAbility = TorannMagicDefOf.TM_Shadow_I;
                                        break;

                                    case 2:
                                        tempAbility = TorannMagicDefOf.TM_Shadow_II;
                                        break;

                                    case 3:
                                        tempAbility = TorannMagicDefOf.TM_Shadow_III;
                                        break;
                                    }
                                    i = 5;
                                }
                                else if (rnd == 1 && magicPawn.MagicData.MagicPowersA[rnd].learned && !magicPawn.Pawn.story.WorkTagIsDisabled(WorkTags.Violent))
                                {
                                    int level = magicPawn.MagicData.MagicPowersA[rnd].level;
                                    switch (level)
                                    {
                                    case 0:
                                        tempAbility = TorannMagicDefOf.TM_MagicMissile;
                                        break;

                                    case 1:
                                        tempAbility = TorannMagicDefOf.TM_MagicMissile_I;
                                        break;

                                    case 2:
                                        tempAbility = TorannMagicDefOf.TM_MagicMissile_II;
                                        break;

                                    case 3:
                                        tempAbility = TorannMagicDefOf.TM_MagicMissile_III;
                                        break;
                                    }
                                    i = 5;
                                }
                                else if (rnd == 2 && magicPawn.MagicData.MagicPowersA[rnd].learned)
                                {
                                    int level = magicPawn.MagicData.MagicPowersA[rnd].level;
                                    switch (level)
                                    {
                                    case 0:
                                        tempAbility = TorannMagicDefOf.TM_Blink;
                                        break;

                                    case 1:
                                        tempAbility = TorannMagicDefOf.TM_Blink_I;
                                        break;

                                    case 2:
                                        tempAbility = TorannMagicDefOf.TM_Blink_II;
                                        break;

                                    case 3:
                                        tempAbility = TorannMagicDefOf.TM_Blink_III;
                                        break;
                                    }
                                    i = 5;
                                }
                                else if (rnd == 3 && magicPawn.MagicData.MagicPowersA[rnd].learned)
                                {
                                    int level = magicPawn.MagicData.MagicPowersA[rnd].level;
                                    switch (level)
                                    {
                                    case 0:
                                        tempAbility = TorannMagicDefOf.TM_Summon;
                                        break;

                                    case 1:
                                        tempAbility = TorannMagicDefOf.TM_Summon_I;
                                        break;

                                    case 2:
                                        tempAbility = TorannMagicDefOf.TM_Summon_II;
                                        break;

                                    case 3:
                                        tempAbility = TorannMagicDefOf.TM_Summon_III;
                                        break;
                                    }
                                    i = 5;
                                }
                            }
                        }
                        else if (targetPawn.story.traits.HasTrait(TorannMagicDefOf.StormBorn))
                        {
                            for (int i = 0; i < 5; i++)
                            {
                                int rnd = Rand.RangeInclusive(0, 3);
                                if (rnd == 0 && magicPawn.MagicData.MagicPowersSB[rnd].learned)
                                {
                                    int level = magicPawn.MagicData.MagicPowersSB[rnd].level;
                                    switch (level)
                                    {
                                    case 0:
                                        tempAbility = TorannMagicDefOf.TM_AMP;
                                        break;

                                    case 1:
                                        tempAbility = TorannMagicDefOf.TM_AMP_I;
                                        break;

                                    case 2:
                                        tempAbility = TorannMagicDefOf.TM_AMP_II;
                                        break;

                                    case 3:
                                        tempAbility = TorannMagicDefOf.TM_AMP_III;
                                        break;
                                    }
                                    i = 5;
                                }
                                else if (rnd == 1 && magicPawn.MagicData.MagicPowersSB[rnd].learned && !magicPawn.Pawn.story.WorkTagIsDisabled(WorkTags.Violent))
                                {
                                    tempAbility = TorannMagicDefOf.TM_LightningBolt;
                                    i           = 5;
                                }
                                else if (rnd == 2 && magicPawn.MagicData.MagicPowersSB[rnd].learned && !magicPawn.Pawn.story.WorkTagIsDisabled(WorkTags.Violent))
                                {
                                    tempAbility = TorannMagicDefOf.TM_LightningCloud;
                                    i           = 5;
                                }
                                else if (rnd == 3 && magicPawn.MagicData.MagicPowersSB[rnd].learned && !magicPawn.Pawn.story.WorkTagIsDisabled(WorkTags.Violent))
                                {
                                    tempAbility = TorannMagicDefOf.TM_LightningStorm;
                                    i           = 5;
                                }
                            }
                        }
                        else if (targetPawn.story.traits.HasTrait(TorannMagicDefOf.InnerFire))
                        {
                            for (int i = 0; i < 5; i++)
                            {
                                int rnd = Rand.RangeInclusive(0, 3);
                                if (rnd == 0 && magicPawn.MagicData.MagicPowersIF[rnd].learned)
                                {
                                    int level = magicPawn.MagicData.MagicPowersIF[rnd].level;
                                    switch (level)
                                    {
                                    case 0:
                                        tempAbility = TorannMagicDefOf.TM_RayofHope;
                                        break;

                                    case 1:
                                        tempAbility = TorannMagicDefOf.TM_RayofHope_I;
                                        break;

                                    case 2:
                                        tempAbility = TorannMagicDefOf.TM_RayofHope_II;
                                        break;

                                    case 3:
                                        tempAbility = TorannMagicDefOf.TM_RayofHope_III;
                                        break;
                                    }
                                    i = 5;
                                }
                                else if (rnd == 1 && magicPawn.MagicData.MagicPowersIF[rnd].learned && !magicPawn.Pawn.story.WorkTagIsDisabled(WorkTags.Violent))
                                {
                                    tempAbility = TorannMagicDefOf.TM_Firebolt;
                                    i           = 5;
                                }
                                else if (rnd == 2 && magicPawn.MagicData.MagicPowersIF[rnd].learned && !magicPawn.Pawn.story.WorkTagIsDisabled(WorkTags.Violent))
                                {
                                    tempAbility = TorannMagicDefOf.TM_Fireclaw;
                                    i           = 5;
                                }
                                else if (rnd == 3 && magicPawn.MagicData.MagicPowersIF[rnd].learned && !magicPawn.Pawn.story.WorkTagIsDisabled(WorkTags.Violent))
                                {
                                    tempAbility = TorannMagicDefOf.TM_Fireball;
                                    i           = 5;
                                }
                            }
                        }
                        else if (targetPawn.story.traits.HasTrait(TorannMagicDefOf.HeartOfFrost))
                        {
                            for (int i = 0; i < 5; i++)
                            {
                                int rnd = Rand.RangeInclusive(0, 4);
                                if (rnd == 0 && magicPawn.MagicData.MagicPowersHoF[rnd].learned)
                                {
                                    int level = magicPawn.MagicData.MagicPowersHoF[rnd].level;
                                    switch (level)
                                    {
                                    case 0:
                                        tempAbility = TorannMagicDefOf.TM_Soothe;
                                        break;

                                    case 1:
                                        tempAbility = TorannMagicDefOf.TM_Soothe_I;
                                        break;

                                    case 2:
                                        tempAbility = TorannMagicDefOf.TM_Soothe_II;
                                        break;

                                    case 3:
                                        tempAbility = TorannMagicDefOf.TM_Soothe_III;
                                        break;
                                    }
                                    i = 5;
                                }
                                else if (rnd == 1 && magicPawn.MagicData.MagicPowersHoF[rnd].learned)
                                {
                                    tempAbility = TorannMagicDefOf.TM_Rainmaker;
                                    i           = 5;
                                }
                                else if (rnd == 2 && magicPawn.MagicData.MagicPowersHoF[rnd].learned && !magicPawn.Pawn.story.WorkTagIsDisabled(WorkTags.Violent))
                                {
                                    tempAbility = TorannMagicDefOf.TM_Icebolt;
                                    i           = 5;
                                }
                                else if (rnd == 3 && magicPawn.MagicData.MagicPowersHoF[rnd].learned && !magicPawn.Pawn.story.WorkTagIsDisabled(WorkTags.Violent))
                                {
                                    int level = magicPawn.MagicData.MagicPowersHoF[rnd].level;
                                    switch (level)
                                    {
                                    case 0:
                                        tempAbility = TorannMagicDefOf.TM_FrostRay;
                                        break;

                                    case 1:
                                        tempAbility = TorannMagicDefOf.TM_FrostRay_I;
                                        break;

                                    case 2:
                                        tempAbility = TorannMagicDefOf.TM_FrostRay_II;
                                        break;

                                    case 3:
                                        tempAbility = TorannMagicDefOf.TM_FrostRay_III;
                                        break;
                                    }
                                    i = 5;
                                }
                                else if (rnd == 4 && magicPawn.MagicData.MagicPowersHoF[rnd].learned && !magicPawn.Pawn.story.WorkTagIsDisabled(WorkTags.Violent))
                                {
                                    tempAbility = TorannMagicDefOf.TM_Snowball;
                                    i           = 5;
                                }
                            }
                        }
                        else if (targetPawn.story.traits.HasTrait(TorannMagicDefOf.Druid))
                        {
                            for (int i = 0; i < 5; i++)
                            {
                                int rnd = Rand.RangeInclusive(0, 3);
                                if (rnd == 0 && magicPawn.MagicData.MagicPowersD[rnd].learned && !magicPawn.Pawn.story.WorkTagIsDisabled(WorkTags.Violent))
                                {
                                    tempAbility = TorannMagicDefOf.TM_Poison;
                                    i           = 5;
                                }
                                else if (rnd == 1 && magicPawn.MagicData.MagicPowersD[rnd].learned)
                                {
                                    int level = magicPawn.MagicData.MagicPowersD[rnd].level;
                                    switch (level)
                                    {
                                    case 0:
                                        tempAbility = TorannMagicDefOf.TM_SootheAnimal;
                                        break;

                                    case 1:
                                        tempAbility = TorannMagicDefOf.TM_SootheAnimal_I;
                                        break;

                                    case 2:
                                        tempAbility = TorannMagicDefOf.TM_SootheAnimal_II;
                                        break;

                                    case 3:
                                        tempAbility = TorannMagicDefOf.TM_SootheAnimal_III;
                                        break;
                                    }
                                    i = 5;
                                }
                                else if (rnd == 2 && magicPawn.MagicData.MagicPowersD[rnd].learned)
                                {
                                    tempAbility = TorannMagicDefOf.TM_Regenerate;
                                    i           = 5;
                                }
                                else if (rnd == 3 && magicPawn.MagicData.MagicPowersD[rnd].learned)
                                {
                                    tempAbility = TorannMagicDefOf.TM_CureDisease;
                                    i           = 5;
                                }
                            }
                        }
                        else if (targetPawn.story.traits.HasTrait(TorannMagicDefOf.Necromancer))
                        {
                            for (int i = 0; i < 5; i++)
                            {
                                int rnd = Rand.RangeInclusive(1, 3);
                                if (rnd == 1 && magicPawn.MagicData.MagicPowersN[rnd].learned && !magicPawn.Pawn.story.WorkTagIsDisabled(WorkTags.Violent))
                                {
                                    int level = magicPawn.MagicData.MagicPowersN[rnd].level;
                                    switch (level)
                                    {
                                    case 0:
                                        tempAbility = TorannMagicDefOf.TM_DeathMark;
                                        break;

                                    case 1:
                                        tempAbility = TorannMagicDefOf.TM_DeathMark_I;
                                        break;

                                    case 2:
                                        tempAbility = TorannMagicDefOf.TM_DeathMark_II;
                                        break;

                                    case 3:
                                        tempAbility = TorannMagicDefOf.TM_DeathMark_III;
                                        break;
                                    }
                                    i = 5;
                                }
                                else if (rnd == 2 && magicPawn.MagicData.MagicPowersN[rnd].learned && !magicPawn.Pawn.story.WorkTagIsDisabled(WorkTags.Violent))
                                {
                                    tempAbility = TorannMagicDefOf.TM_FogOfTorment;
                                    i           = 5;
                                }
                                else if (rnd == 3 && magicPawn.MagicData.MagicPowersN[rnd + 1].learned && !magicPawn.Pawn.story.WorkTagIsDisabled(WorkTags.Violent))
                                {
                                    int level = magicPawn.MagicData.MagicPowersN[rnd + 1].level;
                                    switch (level)
                                    {
                                    case 0:
                                        tempAbility = TorannMagicDefOf.TM_CorpseExplosion;
                                        break;

                                    case 1:
                                        tempAbility = TorannMagicDefOf.TM_CorpseExplosion_I;
                                        break;

                                    case 2:
                                        tempAbility = TorannMagicDefOf.TM_CorpseExplosion_II;
                                        break;

                                    case 3:
                                        tempAbility = TorannMagicDefOf.TM_CorpseExplosion_III;
                                        break;
                                    }
                                    i = 5;
                                }
                            }
                        }
                        else if (targetPawn.story.traits.HasTrait(TorannMagicDefOf.Paladin))
                        {
                            for (int i = 0; i < 5; i++)
                            {
                                int rnd = Rand.RangeInclusive(0, 3);
                                if (rnd == 1 && magicPawn.MagicData.MagicPowersP[rnd].learned)
                                {
                                    int level = magicPawn.MagicData.MagicPowersP[rnd].level;
                                    switch (level)
                                    {
                                    case 0:
                                        tempAbility = TorannMagicDefOf.TM_Shield;
                                        break;

                                    case 1:
                                        tempAbility = TorannMagicDefOf.TM_Shield_I;
                                        break;

                                    case 2:
                                        tempAbility = TorannMagicDefOf.TM_Shield_II;
                                        break;

                                    case 3:
                                        tempAbility = TorannMagicDefOf.TM_Shield_III;
                                        break;
                                    }
                                    i = 5;
                                }
                                else if (rnd == 0 && magicPawn.MagicData.MagicPowersP[rnd].learned)
                                {
                                    tempAbility = TorannMagicDefOf.TM_Heal;
                                    i           = 5;
                                }
                                else if (rnd == 2 && magicPawn.MagicData.MagicPowersP[rnd].learned && !magicPawn.Pawn.story.WorkTagIsDisabled(WorkTags.Violent))
                                {
                                    tempAbility = TorannMagicDefOf.TM_ValiantCharge;
                                    i           = 5;
                                }
                                else if (rnd == 3 && magicPawn.MagicData.MagicPowersP[rnd].learned && !magicPawn.Pawn.story.WorkTagIsDisabled(WorkTags.Violent))
                                {
                                    tempAbility = TorannMagicDefOf.TM_Overwhelm;
                                    i           = 5;
                                }
                            }
                        }
                        else if (targetPawn.story.traits.HasTrait(TorannMagicDefOf.Priest))
                        {
                            for (int i = 0; i < 5; i++)
                            {
                                int rnd = Rand.RangeInclusive(0, 3);
                                if (rnd == 3 && magicPawn.MagicData.MagicPowersPR[rnd].learned)
                                {
                                    int level = magicPawn.MagicData.MagicPowersPR[rnd].level;
                                    switch (level)
                                    {
                                    case 0:
                                        tempAbility = TorannMagicDefOf.TM_BestowMight;
                                        break;

                                    case 1:
                                        tempAbility = TorannMagicDefOf.TM_BestowMight_I;
                                        break;

                                    case 2:
                                        tempAbility = TorannMagicDefOf.TM_BestowMight_II;
                                        break;

                                    case 3:
                                        tempAbility = TorannMagicDefOf.TM_BestowMight_III;
                                        break;
                                    }
                                    i = 5;
                                }
                                else if (rnd == 2 && magicPawn.MagicData.MagicPowersPR[rnd].learned)
                                {
                                    int level = magicPawn.MagicData.MagicPowersPR[rnd].level;
                                    switch (level)
                                    {
                                    case 0:
                                        tempAbility = TorannMagicDefOf.TM_HealingCircle;
                                        break;

                                    case 1:
                                        tempAbility = TorannMagicDefOf.TM_HealingCircle_I;
                                        break;

                                    case 2:
                                        tempAbility = TorannMagicDefOf.TM_HealingCircle_II;
                                        break;

                                    case 3:
                                        tempAbility = TorannMagicDefOf.TM_HealingCircle_III;
                                        break;
                                    }
                                    i = 5;
                                }
                                else if (rnd == 1 && magicPawn.MagicData.MagicPowersPR[rnd].learned)
                                {
                                    tempAbility = TorannMagicDefOf.TM_Purify;
                                    i           = 5;
                                }
                                else if (rnd == 0 && magicPawn.MagicData.MagicPowersPR[rnd].learned)
                                {
                                    tempAbility = TorannMagicDefOf.TM_AdvancedHeal;
                                    i           = 5;
                                }
                            }
                        }
                        else if (targetPawn.story.traits.HasTrait(TorannMagicDefOf.Summoner))
                        {
                            for (int i = 0; i < 5; i++)
                            {
                                int rnd = Rand.RangeInclusive(1, 3);
                                if (rnd == 1 && magicPawn.MagicData.MagicPowersS[rnd].learned)
                                {
                                    tempAbility = TorannMagicDefOf.TM_SummonPylon;
                                    i           = 5;
                                }
                                else if (rnd == 2 && magicPawn.MagicData.MagicPowersS[rnd].learned)
                                {
                                    tempAbility = TorannMagicDefOf.TM_SummonExplosive;
                                    i           = 5;
                                }
                                else if (rnd == 3 && magicPawn.MagicData.MagicPowersS[rnd].learned)
                                {
                                    tempAbility = TorannMagicDefOf.TM_SummonElemental;
                                    i           = 5;
                                }
                            }
                        }
                        else if (targetPawn.story.traits.HasTrait(TorannMagicDefOf.TM_Bard))
                        {
                            int level = magicPawn.MagicData.MagicPowersB[3].level;
                            switch (level)
                            {
                            case 0:
                                tempAbility = TorannMagicDefOf.TM_Lullaby;
                                break;

                            case 1:
                                tempAbility = TorannMagicDefOf.TM_Lullaby_I;
                                break;

                            case 2:
                                tempAbility = TorannMagicDefOf.TM_Lullaby_II;
                                break;

                            case 3:
                                tempAbility = TorannMagicDefOf.TM_Lullaby_III;
                                break;
                            }
                        }
                        else if (targetPawn.story.traits.HasTrait(TorannMagicDefOf.Warlock))
                        {
                            for (int i = 0; i < 5; i++)
                            {
                                int rnd = Rand.RangeInclusive(1, 3);
                                if (rnd == 1 && magicPawn.MagicData.MagicPowersWD[rnd].learned && !magicPawn.Pawn.story.WorkTagIsDisabled(WorkTags.Violent))
                                {
                                    int level = magicPawn.MagicData.MagicPowersWD[rnd].level;
                                    switch (level)
                                    {
                                    case 0:
                                        tempAbility = TorannMagicDefOf.TM_ShadowBolt;
                                        break;

                                    case 1:
                                        tempAbility = TorannMagicDefOf.TM_ShadowBolt_I;
                                        break;

                                    case 2:
                                        tempAbility = TorannMagicDefOf.TM_ShadowBolt_II;
                                        break;

                                    case 3:
                                        tempAbility = TorannMagicDefOf.TM_ShadowBolt_III;
                                        break;
                                    }
                                    i = 5;
                                }
                                else if (rnd == 2 && magicPawn.MagicData.MagicPowersWD[rnd].learned && !magicPawn.Pawn.story.WorkTagIsDisabled(WorkTags.Violent))
                                {
                                    tempAbility = TorannMagicDefOf.TM_Dominate;
                                    i           = 5;
                                }
                                else if (rnd == 3 && magicPawn.MagicData.MagicPowersWD[rnd].learned)
                                {
                                    int level = magicPawn.MagicData.MagicPowersWD[rnd].level;
                                    switch (level)
                                    {
                                    case 0:
                                        tempAbility = TorannMagicDefOf.TM_Repulsion;
                                        break;

                                    case 1:
                                        tempAbility = TorannMagicDefOf.TM_Repulsion_I;
                                        break;

                                    case 2:
                                        tempAbility = TorannMagicDefOf.TM_Repulsion_II;
                                        break;

                                    case 3:
                                        tempAbility = TorannMagicDefOf.TM_Repulsion_III;
                                        break;
                                    }
                                    i = 5;
                                }
                            }
                        }
                        else if (targetPawn.story.traits.HasTrait(TorannMagicDefOf.Succubus))
                        {
                            for (int i = 0; i < 5; i++)
                            {
                                int rnd = Rand.RangeInclusive(1, 3);
                                if (rnd == 1 && magicPawn.MagicData.MagicPowersSD[rnd].learned && !magicPawn.Pawn.story.WorkTagIsDisabled(WorkTags.Violent))
                                {
                                    int level = magicPawn.MagicData.MagicPowersSD[rnd].level;
                                    switch (level)
                                    {
                                    case 0:
                                        tempAbility = TorannMagicDefOf.TM_ShadowBolt;
                                        break;

                                    case 1:
                                        tempAbility = TorannMagicDefOf.TM_ShadowBolt_I;
                                        break;

                                    case 2:
                                        tempAbility = TorannMagicDefOf.TM_ShadowBolt_II;
                                        break;

                                    case 3:
                                        tempAbility = TorannMagicDefOf.TM_ShadowBolt_III;
                                        break;
                                    }
                                    i = 5;
                                }
                                else if (rnd == 2 && magicPawn.MagicData.MagicPowersSD[rnd].learned && !magicPawn.Pawn.story.WorkTagIsDisabled(WorkTags.Violent))
                                {
                                    tempAbility = TorannMagicDefOf.TM_Dominate;
                                    i           = 5;
                                }
                                else if (rnd == 3 && magicPawn.MagicData.MagicPowersSD[rnd].learned)
                                {
                                    int level = magicPawn.MagicData.MagicPowersSD[rnd].level;
                                    switch (level)
                                    {
                                    case 0:
                                        tempAbility = TorannMagicDefOf.TM_Attraction;
                                        break;

                                    case 1:
                                        tempAbility = TorannMagicDefOf.TM_Attraction_I;
                                        break;

                                    case 2:
                                        tempAbility = TorannMagicDefOf.TM_Attraction_II;
                                        break;

                                    case 3:
                                        tempAbility = TorannMagicDefOf.TM_Attraction_III;
                                        break;
                                    }
                                    i = 5;
                                }
                            }
                        }
                        else if (targetPawn.story.traits.HasTrait(TorannMagicDefOf.Geomancer))
                        {
                            for (int i = 0; i < 5; i++)
                            {
                                int rnd = Rand.RangeInclusive(0, 2);
                                if (rnd == 2)
                                {
                                    rnd = 3;
                                }
                                if (rnd == 0 && magicPawn.MagicData.MagicPowersG[rnd].learned)
                                {
                                    tempAbility = TorannMagicDefOf.TM_Stoneskin;
                                    i           = 5;
                                }
                                else if (rnd == 1 && magicPawn.MagicData.MagicPowersG[rnd].learned)
                                {
                                    int level = magicPawn.MagicData.MagicPowersPR[rnd].level;
                                    switch (level)
                                    {
                                    case 0:
                                        tempAbility = TorannMagicDefOf.TM_Encase;
                                        break;

                                    case 1:
                                        tempAbility = TorannMagicDefOf.TM_Encase_I;
                                        break;

                                    case 2:
                                        tempAbility = TorannMagicDefOf.TM_Encase_II;
                                        break;

                                    case 3:
                                        tempAbility = TorannMagicDefOf.TM_Encase_III;
                                        break;
                                    }
                                    i = 5;
                                }
                                else if (rnd == 3 && magicPawn.MagicData.MagicPowersG[rnd].learned && !magicPawn.Pawn.story.WorkTagIsDisabled(WorkTags.Violent))
                                {
                                    tempAbility = TorannMagicDefOf.TM_EarthernHammer;
                                    i           = 5;
                                }
                            }
                        }

                        if (tempAbility != null)
                        {
                            if (mightComp.mimicAbility != null)
                            {
                                mightComp.RemovePawnAbility(mightComp.mimicAbility);
                            }
                            if (magicComp.mimicAbility != null)
                            {
                                magicComp.RemovePawnAbility(magicComp.mimicAbility);
                            }
                            mightComp.mimicAbility = tempAbility;
                            mightComp.AddPawnAbility(tempAbility);
                        }
                        else
                        {
                            //invalid target
                            Messages.Message("TM_MimicFailed".Translate(new object[]
                            {
                                this.CasterPawn.LabelShort
                            }), MessageTypeDefOf.RejectInput);
                        }
                    }
                    else if (mightPawn.IsMightUser)
                    {
                        if (targetPawn.story.traits.HasTrait(TorannMagicDefOf.Gladiator) && !magicPawn.Pawn.story.WorkTagIsDisabled(WorkTags.Violent))
                        {
                            int rnd = Rand.RangeInclusive(0, 1);
                            if (rnd == 0)
                            {
                                int level = mightPawn.MightData.MightPowersG[2].level;
                                switch (level)
                                {
                                case 0:
                                    tempAbility = TorannMagicDefOf.TM_Grapple;
                                    break;

                                case 1:
                                    tempAbility = TorannMagicDefOf.TM_Grapple_I;
                                    break;

                                case 2:
                                    tempAbility = TorannMagicDefOf.TM_Grapple_II;
                                    break;

                                case 3:
                                    tempAbility = TorannMagicDefOf.TM_Grapple_III;
                                    break;
                                }
                            }
                            else
                            {
                                tempAbility = TorannMagicDefOf.TM_Whirlwind;
                            }
                        }
                        else if (targetPawn.story.traits.HasTrait(TorannMagicDefOf.TM_Sniper) && !magicPawn.Pawn.story.WorkTagIsDisabled(WorkTags.Violent))
                        {
                            int rnd = Rand.RangeInclusive(0, 2);
                            if (rnd == 0)
                            {
                                tempAbility = TorannMagicDefOf.TM_AntiArmor;
                            }
                            else if (rnd == 1)
                            {
                                int level = mightPawn.MightData.MightPowersS[2].level;
                                switch (level)
                                {
                                case 0:
                                    tempAbility = TorannMagicDefOf.TM_DisablingShot;
                                    break;

                                case 1:
                                    tempAbility = TorannMagicDefOf.TM_DisablingShot_I;
                                    break;

                                case 2:
                                    tempAbility = TorannMagicDefOf.TM_DisablingShot_II;
                                    break;

                                case 3:
                                    tempAbility = TorannMagicDefOf.TM_DisablingShot_III;
                                    break;
                                }
                            }
                            else
                            {
                                tempAbility = TorannMagicDefOf.TM_Headshot;
                            }
                        }
                        else if (targetPawn.story.traits.HasTrait(TorannMagicDefOf.Bladedancer) && !magicPawn.Pawn.story.WorkTagIsDisabled(WorkTags.Violent))
                        {
                            int rnd = Rand.RangeInclusive(0, 2);
                            if (rnd == 0)
                            {
                                tempAbility = TorannMagicDefOf.TM_SeismicSlash;
                            }
                            else if (rnd == 1)
                            {
                                int level = mightPawn.MightData.MightPowersB[4].level;
                                switch (level)
                                {
                                case 0:
                                    tempAbility = TorannMagicDefOf.TM_PhaseStrike;
                                    break;

                                case 1:
                                    tempAbility = TorannMagicDefOf.TM_PhaseStrike_I;
                                    break;

                                case 2:
                                    tempAbility = TorannMagicDefOf.TM_PhaseStrike_II;
                                    break;

                                case 3:
                                    tempAbility = TorannMagicDefOf.TM_PhaseStrike_III;
                                    break;
                                }
                            }
                            else
                            {
                                tempAbility = TorannMagicDefOf.TM_BladeSpin;
                            }
                        }
                        else if (targetPawn.story.traits.HasTrait(TorannMagicDefOf.Ranger) && !magicPawn.Pawn.story.WorkTagIsDisabled(WorkTags.Violent))
                        {
                            int rnd = Rand.RangeInclusive(0, 1);
                            if (rnd == 0)
                            {
                                int level = mightPawn.MightData.MightPowersB[4].level;
                                switch (level)
                                {
                                case 0:
                                    tempAbility = TorannMagicDefOf.TM_ArrowStorm;
                                    break;

                                case 1:
                                    tempAbility = TorannMagicDefOf.TM_ArrowStorm_I;
                                    break;

                                case 2:
                                    tempAbility = TorannMagicDefOf.TM_ArrowStorm_II;
                                    break;

                                case 3:
                                    tempAbility = TorannMagicDefOf.TM_ArrowStorm_III;
                                    break;
                                }
                            }
                            else
                            {
                                tempAbility = TorannMagicDefOf.TM_PoisonTrap;
                            }
                        }
                        else if (targetPawn.story.traits.HasTrait(TorannMagicDefOf.TM_Psionic))
                        {
                            int rnd = Rand.RangeInclusive(0, 3);
                            if ((rnd == 0 || rnd == 3) && !magicPawn.Pawn.story.WorkTagIsDisabled(WorkTags.Violent))
                            {
                                int level = mightPawn.MightData.MightPowersP[1].level;
                                switch (level)
                                {
                                case 0:
                                    tempAbility = TorannMagicDefOf.TM_PsionicBlast;
                                    break;

                                case 1:
                                    tempAbility = TorannMagicDefOf.TM_PsionicBlast_I;
                                    break;

                                case 2:
                                    tempAbility = TorannMagicDefOf.TM_PsionicBlast_II;
                                    break;

                                case 3:
                                    tempAbility = TorannMagicDefOf.TM_PsionicBlast_III;
                                    break;
                                }
                            }
                            else if (rnd == 1 && !magicPawn.Pawn.story.WorkTagIsDisabled(WorkTags.Violent))
                            {
                                tempAbility = TorannMagicDefOf.TM_PsionicDash;
                            }
                            else
                            {
                                int level = mightPawn.MightData.MightPowersP[3].level;
                                switch (level)
                                {
                                case 0:
                                    tempAbility = TorannMagicDefOf.TM_PsionicBarrier;
                                    break;

                                case 1:
                                    tempAbility = TorannMagicDefOf.TM_PsionicBarrier_Projected;
                                    break;
                                }
                            }
                        }
                        else if (targetPawn.story.traits.HasTrait(TorannMagicDefOf.Faceless))
                        {
                        }

                        if (tempAbility != null)
                        {
                            if (mightComp.mimicAbility != null)
                            {
                                mightComp.RemovePawnAbility(mightComp.mimicAbility);
                            }
                            if (magicComp.mimicAbility != null)
                            {
                                magicComp.RemovePawnAbility(magicComp.mimicAbility);
                            }
                            mightComp.mimicAbility = tempAbility;
                            mightComp.AddPawnAbility(tempAbility);
                        }
                        else
                        {
                            //invalid target
                            Messages.Message("TM_MimicFailed".Translate(new object[]
                            {
                                this.CasterPawn.LabelShort
                            }), MessageTypeDefOf.RejectInput);
                        }
                    }
                }
            }
            else
            {
                Log.Warning("failed to TryCastShot");
            }
            this.burstShotsLeft = 0;
            return(result);
        }