Esempio n. 1
0
        public override bool CanCastPowerCheck(AbilityContext context, out string reason)
        {
            bool flag = base.CanCastPowerCheck(context, out reason);
            bool result;

            if (flag)
            {
                reason = "";
                TMAbilityDef tmAbilityDef;
                bool         flag1 = base.Def != null && (tmAbilityDef = (base.Def as TMAbilityDef)) != null;
                if (flag1)
                {
                    bool flag4 = this.MightUser.Stamina != null;
                    if (flag4)
                    {
                        bool flag5 = mightDef.staminaCost > 0f && this.ActualStaminaCost > this.MightUser.Stamina.CurLevel;
                        if (flag5)
                        {
                            reason = "TM_NotEnoughStamina".Translate(
                                base.Pawn.LabelShort
                                );
                            result = false;
                            return(result);
                        }
                        if (mightDef.chiCost > 0f)
                        {
                            bool flag6 = this.MightUser.Pawn.health.hediffSet.HasHediff(TorannMagicDefOf.TM_ChiHD, false) ? (this.ActualChiCost * 100) > this.MightUser.Pawn.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_ChiHD, false).Severity : true;
                            if (flag6)
                            {
                                reason = "TM_NotEnoughChi".Translate(
                                    base.Pawn.LabelShort
                                    );
                                result = false;
                                return(result);
                            }
                        }
                        bool flagNeed = mightDef.requiredNeed != null && this.MightUser.Pawn.needs.TryGetNeed(mightDef.requiredNeed) != null && this.MightUser.Pawn.needs.TryGetNeed(mightDef.requiredNeed).CurLevel > this.ActualNeedCost;
                        if (flagNeed)
                        {
                            reason = "TM_NotEnoughEnergy".Translate(
                                base.Pawn.LabelShort,
                                mightDef.requiredNeed.label
                                );
                            result = false;
                            return(result);
                        }
                        bool flagHediff = mightDef.requiredHediff != null && this.MightUser.Pawn.health.hediffSet.HasHediff(mightDef.requiredHediff) && this.MightUser.Pawn.health.hediffSet.GetFirstHediffOfDef(mightDef.requiredHediff).Severity > this.ActualHediffCost;
                        if (flagHediff)
                        {
                            reason = "TM_NotEnoughEnergy".Translate(
                                base.Pawn.LabelShort,
                                mightDef.requiredHediff.label
                                );
                            result = false;
                            return(result);
                        }
                    }
                }
                if (MightUser.specWpnRegNum == -1 &&
                    (this.mightDef == TorannMagicDefOf.TM_PistolWhip || this.mightDef == TorannMagicDefOf.TM_SuppressingFire || this.mightDef == TorannMagicDefOf.TM_Mk203GL ||
                     this.mightDef == TorannMagicDefOf.TM_Buckshot || this.mightDef == TorannMagicDefOf.TM_BreachingCharge))
                {
                    if (MightUser.Pawn.equipment != null && MightUser.Pawn.equipment.Primary != null)
                    {
                        reason = "TM_MustHaveWeaponType".Translate(
                            base.Pawn.LabelShort,
                            base.Pawn.equipment.Primary.def.label,
                            "specialized weapon"
                            );
                    }
                    else
                    {
                        reason = "TM_IncompatibleWeapon".Translate();
                    }
                    return(false);
                }
                List <Apparel> wornApparel = base.Pawn.apparel.WornApparel;
                for (int i = 0; i < wornApparel.Count; i++)
                {
                    if (!wornApparel[i].AllowVerbCast(base.Pawn.Position, base.Pawn.Map, base.abilityUser.Pawn.TargetCurrentlyAimingAt, this.Verb) &&
                        (this.mightDef.defName == "TM_Headshot" ||
                         this.mightDef.defName == "TM_DisablingShot" || this.mightDef.defName == "TM_DisablingShot_I" || this.mightDef.defName == "TM_DisablingShot_II" || this.mightDef.defName == "TM_DisablingShot_III" ||
                         this.mightDef.defName == "TM_AntiArmor" ||
                         this.mightDef.defName == "TM_ArrowStorm" || this.mightDef.defName == "TM_ArrowStorm_I" || this.mightDef.defName == "TM_ArrowStorm_II" || this.mightDef.defName == "TM_ArrowStorm_III" ||
                         this.mightDef == TorannMagicDefOf.TM_PsionicStorm ||
                         this.mightDef.defName == "TM_PsionicBlast" || this.mightDef.defName == "TM_PsionicBlast_I" || this.mightDef.defName == "TM_PsionicBlast_II" || this.mightDef.defName == "TM_PsionicBlast_III" ||
                         this.mightDef == TorannMagicDefOf.TM_TempestStrike ||
                         this.mightDef == TorannMagicDefOf.TM_SuppressingFire || this.mightDef == TorannMagicDefOf.TM_Mk203GL ||
                         this.mightDef == TorannMagicDefOf.TM_Buckshot ||
                         this.mightDef.defName == "TM_Mimic"))
                    {
                        reason = "TM_ShieldBlockingPowers".Translate(
                            base.Pawn.Label,
                            wornApparel[i].Label
                            );
                        return(false);
                    }
                }
                if (TM_Calc.HasHateHediff(this.MightUser.Pawn) && this.MightUser.Pawn.story.traits.HasTrait(TorannMagicDefOf.DeathKnight))
                {
                    Hediff hediff = null;
                    for (int h = 0; h < this.MightUser.Pawn.health.hediffSet.hediffs.Count; h++)
                    {
                        if (this.MightUser.Pawn.health.hediffSet.hediffs[h].def.defName.Contains("TM_HateHD"))
                        {
                            hediff = this.MightUser.Pawn.health.hediffSet.hediffs[h];
                        }
                    }
                    if (hediff != null)
                    {
                        if ((this.mightDef == TorannMagicDefOf.TM_Spite || this.mightDef == TorannMagicDefOf.TM_Spite_I || this.mightDef == TorannMagicDefOf.TM_Spite_II || this.mightDef == TorannMagicDefOf.TM_Spite_III) && hediff.Severity < 20f)
                        {
                            reason = "TM_NotEnoughHate".Translate(
                                base.Pawn.LabelShort,
                                "Spite"
                                );
                            return(false);
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
                if (this.MightUser.Pawn.story.traits.HasTrait(TorannMagicDefOf.TM_Psionic))
                {
                    if (this.MightUser.Pawn.health.hediffSet.HasHediff(HediffDef.Named("TM_PsionicHD"), false))
                    {
                        float psiEnergy = this.MightUser.Pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("TM_PsionicHD"), false).Severity;
                        if ((this.mightDef.defName == "TM_PsionicBlast" || this.mightDef.defName == "TM_PsionicBlast_I" || this.mightDef.defName == "TM_PsionicBlast_II" || this.mightDef.defName == "TM_PsionicBlast_III") && psiEnergy < 20f)
                        {
                            reason = "TM_NotEnoughPsionicEnergy".Translate(
                                base.Pawn.Label,
                                "Psionic Blast"
                                );
                            return(false);
                        }
                        if ((this.mightDef == TorannMagicDefOf.TM_PsionicDash && psiEnergy < 8f))
                        {
                            reason = "TM_NotEnoughPsionicEnergy".Translate(
                                base.Pawn.Label,
                                "Psionic Dash"
                                );
                            return(false);
                        }
                        int stormCost = 65 - (5 * (this.MightUser.MightData.MightPowerSkill_PsionicStorm.FirstOrDefault((MightPowerSkill x) => x.label == "TM_PsionicStorm_eff").level));
                        if ((this.mightDef == TorannMagicDefOf.TM_PsionicStorm && psiEnergy < stormCost))
                        {
                            reason = "TM_NotEnoughPsionicEnergy".Translate(
                                base.Pawn.Label,
                                "Psionic Storm"
                                );
                            return(false);
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
                TMAbilityDef tmad = this.mightDef;
                if (tmad != null && tmad.requiredWeaponsOrCategories != null && tmad.IsRestrictedByEquipment(this.Pawn))
                {
                    reason = "TM_IncompatibleWeaponType".Translate(
                        base.Pawn.LabelShort,
                        tmad.label);
                    return(false);
                }
                result = true;
            }
            else
            {
                result = false;
            }
            return(result);
        }
Esempio n. 2
0
        public override bool CanCastPowerCheck(AbilityContext context, out string reason)
        {
            bool flag = base.CanCastPowerCheck(context, out reason);
            bool result;

            if (flag)
            {
                reason = "";
                TMAbilityDef tmAbilityDef;
                bool         flag1 = base.Def != null && (tmAbilityDef = (base.Def as TMAbilityDef)) != null;
                if (flag1)
                {
                    bool flag4 = this.MagicUser.Mana != null;
                    if (flag4)
                    {
                        bool flag5 = magicDef.manaCost > 0f && this.ActualManaCost > this.MagicUser.Mana.CurLevel;
                        if (flag5)
                        {
                            reason = "TM_NotEnoughMana".Translate(
                                base.Pawn.LabelShort
                                );
                            result = false;
                            return(result);
                        }
                        if (magicDef.bloodCost > 0f)
                        {
                            bool flag6 = this.MagicUser.Pawn.health.hediffSet.HasHediff(HediffDef.Named("TM_BloodHD"), false) ? (this.ActualBloodCost * 100) > this.MagicUser.Pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("TM_BloodHD"), false).Severity : true;
                            if (flag6)
                            {
                                reason = "TM_NotEnoughBlood".Translate(
                                    base.Pawn.LabelShort
                                    );
                                result = false;
                                return(result);
                            }
                        }
                        bool flagMute = this.MagicUser.Pawn.health.hediffSet.HasHediff(TorannMagicDefOf.TM_MuteHD);
                        if (flagMute)
                        {
                            reason = "TM_CasterMute".Translate(
                                base.Pawn.LabelShort
                                );
                            result = false;
                            return(result);
                        }
                        bool flagNeed = magicDef.requiredNeed != null && this.MagicUser.Pawn.needs.TryGetNeed(magicDef.requiredNeed) != null && this.MagicUser.Pawn.needs.TryGetNeed(magicDef.requiredNeed).CurLevel > this.ActualNeedCost;
                        if (flagNeed)
                        {
                            reason = "TM_NotEnoughEnergy".Translate(
                                base.Pawn.LabelShort,
                                magicDef.requiredNeed.label
                                );
                            result = false;
                            return(result);
                        }
                        bool flagHediff = magicDef.requiredHediff != null && this.MagicUser.Pawn.health.hediffSet.HasHediff(magicDef.requiredHediff) && this.MagicUser.Pawn.health.hediffSet.GetFirstHediffOfDef(magicDef.requiredHediff).Severity > this.ActualHediffCost;
                        if (flagHediff)
                        {
                            reason = "TM_NotEnoughEnergy".Translate(
                                base.Pawn.LabelShort,
                                magicDef.requiredHediff.label
                                );
                            result = false;
                            return(result);
                        }
                    }
                    else if (this.Pawn.story.traits.HasTrait(TorannMagicDefOf.Faceless))
                    {
                        CompAbilityUserMight mightComp = this.Pawn.GetComp <CompAbilityUserMight>();
                        bool flag7 = mightComp != null && mightComp.Stamina != null && magicDef.manaCost > 0f && this.magicDef.manaCost > mightComp.Stamina.CurLevel;
                        if (flag7)
                        {
                            reason = "TM_NotEnoughStamina".Translate(
                                base.Pawn.LabelShort
                                );
                            result = false;
                            return(result);
                        }
                    }
                    TMAbilityDef tmad = this.magicDef;
                    if (tmad != null && tmad.requiredWeaponsOrCategories != null && tmad.IsRestrictedByEquipment(this.Pawn))
                    {
                        reason = "TM_IncompatibleWeaponType".Translate(
                            base.Pawn.LabelShort,
                            tmad.label);
                        return(false);
                    }
                }
                List <Apparel> wornApparel = base.Pawn.apparel.WornApparel;
                for (int i = 0; i < wornApparel.Count; i++)
                {
                    if (!wornApparel[i].AllowVerbCast(this.Verb) &&
                        (this.magicDef.defName == "TM_LightningCloud" || this.magicDef.defName == "Laser_LightningBolt" || this.magicDef.defName == "TM_LightningStorm" || this.magicDef.defName == "TM_EyeOfTheStorm" ||
                         this.magicDef.defName.Contains("Laser_FrostRay") || this.magicDef.defName == "TM_Blizzard" || this.magicDef.defName == "TM_Snowball" || this.magicDef.defName == "TM_Icebolt" ||
                         this.magicDef.defName == "TM_Firestorm" || this.magicDef.defName == "TM_Fireball" || this.magicDef.defName == "TM_Fireclaw" || this.magicDef.defName == "TM_Firebolt" ||
                         this.magicDef.defName.Contains("TM_MagicMissile") ||
                         this.magicDef.defName.Contains("TM_DeathBolt") ||
                         this.magicDef.defName.Contains("TM_ShadowBolt") ||
                         this.magicDef.defName == "TM_BloodForBlood" || this.magicDef.defName == "TM_IgniteBlood" ||
                         this.magicDef.defName == "TM_Poison" ||
                         this.magicDef == TorannMagicDefOf.TM_ChainLightning ||
                         this.magicDef == TorannMagicDefOf.TM_ArcaneBolt))
                    {
                        reason = "TM_ShieldBlockingPowers".Translate(
                            base.Pawn.Label,
                            wornApparel[i].Label
                            );
                        return(false);
                    }
                }
                result = true;
            }
            else
            {
                result = false;
            }
            return(result);
        }