protected override bool TryCastShot()
        {
            bool result = false;
            Map map = this.CasterPawn.Map;
            CompAbilityUserMagic comp = this.CasterPawn.GetComp<CompAbilityUserMagic>();

            if (this.CasterPawn != null && !this.CasterPawn.Downed && comp != null && comp.MagicData != null)
            {
                pwrVal = comp.MagicData.MagicPowerSkill_ChaosTradition.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_ChaosTradition_pwr").level;
                verVal = comp.MagicData.MagicPowerSkill_ChaosTradition.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_ChaosTradition_ver").level;
                effVal = comp.MagicData.MagicPowerSkill_ChaosTradition.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_ChaosTradition_eff").level;

                gRegen = comp.MagicData.MagicPowerSkill_global_regen.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_global_regen_pwr").level;
                gEff = comp.MagicData.MagicPowerSkill_global_eff.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_global_eff_pwr").level;
                gSpirit = comp.MagicData.MagicPowerSkill_global_spirit.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_global_spirit_pwr").level;

                TM_Action.ClearSustainedMagicHediffs(comp);
                TM_Calc.AssignChaosMagicPowers(comp);

                if (effVal >= 3)
                {
                    HealthUtility.AdjustSeverity(this.CasterPawn, TorannMagicDefOf.TM_ChaosTraditionHD, 8f);
                }
                if (effVal >= 2)
                {
                    comp.Mana.CurLevel += .25f * comp.mpRegenRate;
                }
                if (effVal >= 1)
                {
                    HealthUtility.AdjustSeverity(this.CasterPawn, TorannMagicDefOf.TM_ChaoticMindHD, 24f);
                }

                comp.MagicData.MagicAbilityPoints -= (2 * (pwrVal + verVal + effVal)) + gSpirit + gRegen + gEff;
                comp.MagicData.MagicPowerSkill_ChaosTradition.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_ChaosTradition_pwr").level = pwrVal;
                comp.MagicData.MagicPowerSkill_ChaosTradition.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_ChaosTradition_ver").level = verVal;
                comp.MagicData.MagicPowerSkill_ChaosTradition.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_ChaosTradition_eff").level = effVal;

                comp.MagicData.MagicPowerSkill_global_regen.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_global_regen_pwr").level = gRegen;
                comp.MagicData.MagicPowerSkill_global_eff.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_global_eff_pwr").level = gEff;
                comp.MagicData.MagicPowerSkill_global_spirit.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_global_spirit_pwr").level = gSpirit;

                if (comp.MagicData.MagicAbilityPoints < 0)
                {
                    comp.MagicData.MagicAbilityPoints = 0;
                }

                ClearSpellRemnants(comp);

            }
            else
            {
                Log.Warning("failed to TryCastShot");
            }

            this.burstShotsLeft = 0;
            return result;
        }
Exemple #2
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);
                            }
                            TM_Action.ClearSustainedMagicHediffs(magicComp);
                            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);
                            }
                            TM_Action.ClearSustainedMagicHediffs(magicComp);
                            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);
        }