Exemplo n.º 1
0
        protected override bool TryCastShot()
        {
            Pawn       caster     = base.CasterPawn;
            Pawn       pawn       = this.currentTarget.Thing as Pawn;
            MagicPower magicPower = caster.GetComp <CompAbilityUserMagic>().MagicData.MagicPowersB.FirstOrDefault <MagicPower>((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_Entertain);
            bool       flag       = pawn != null && !pawn.Dead;

            if (flag)
            {
                if (pawn.health.hediffSet.HasHediff(HediffDef.Named("TM_EntertainingHD")))
                {
                    using (IEnumerator <Hediff> enumerator = pawn.health.hediffSet.GetHediffs <Hediff>().GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            Hediff rec = enumerator.Current;
                            if (rec.def.defName.Contains("TM_EntertainingHD"))
                            {
                                pawn.health.RemoveHediff(rec);
                            }
                        }
                    }

                    magicPower.AutoCast = false;
                }
                else
                {
                    HealthUtility.AdjustSeverity(pawn, HediffDef.Named("TM_EntertainingHD"), .95f);
                    TM_MoteMaker.ThrowNoteMote(pawn.DrawPos, pawn.Map, .8f);
                    magicPower.AutoCast = true;
                }
            }
            return(true);
        }
Exemplo n.º 2
0
        private void ToggleAbilityAutocast()
        {
            MagicPower magicPower = null;

            if (this.Ability.Def == TorannMagicDefOf.TM_Shadow)
            {
                magicPower = this.CasterPawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowersA.FirstOrDefault <MagicPower>((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_Shadow);
            }
            else if (this.Ability.Def == TorannMagicDefOf.TM_Shadow_I)
            {
                magicPower = this.CasterPawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowersA.FirstOrDefault <MagicPower>((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_Shadow);
            }
            else if (this.Ability.Def == TorannMagicDefOf.TM_Shadow_II)
            {
                magicPower = this.CasterPawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowersA.FirstOrDefault <MagicPower>((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_Shadow_I);
            }
            else if (this.Ability.Def == TorannMagicDefOf.TM_Shadow_III)
            {
                magicPower = this.CasterPawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowersA.FirstOrDefault <MagicPower>((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_Shadow_II);
            }
            else if (this.Ability.Def == TorannMagicDefOf.TM_RayofHope)
            {
                magicPower = this.CasterPawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowersIF.FirstOrDefault <MagicPower>((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_RayofHope);
            }
            else if (this.Ability.Def == TorannMagicDefOf.TM_RayofHope_I)
            {
                magicPower = this.CasterPawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowersIF.FirstOrDefault <MagicPower>((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_RayofHope);
            }
            else if (this.Ability.Def == TorannMagicDefOf.TM_RayofHope_II)
            {
                magicPower = this.CasterPawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowersIF.FirstOrDefault <MagicPower>((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_RayofHope_I);
            }
            else if (this.Ability.Def == TorannMagicDefOf.TM_RayofHope_III)
            {
                magicPower = this.CasterPawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowersIF.FirstOrDefault <MagicPower>((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_RayofHope_II);
            }
            else if (this.Ability.Def == TorannMagicDefOf.TM_Soothe)
            {
                magicPower = this.CasterPawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowersHoF.FirstOrDefault <MagicPower>((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_Soothe);
            }
            else if (this.Ability.Def == TorannMagicDefOf.TM_Soothe_I)
            {
                magicPower = this.CasterPawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowersHoF.FirstOrDefault <MagicPower>((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_Soothe);
            }
            else if (this.Ability.Def == TorannMagicDefOf.TM_Soothe_II)
            {
                magicPower = this.CasterPawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowersHoF.FirstOrDefault <MagicPower>((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_Soothe_I);
            }
            else if (this.Ability.Def == TorannMagicDefOf.TM_Soothe_III)
            {
                magicPower = this.CasterPawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowersHoF.FirstOrDefault <MagicPower>((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_Soothe_II);
            }

            if (magicPower != null)
            {
                magicPower.autocast = !magicPower.autocast;
            }
        }
Exemplo n.º 3
0
        protected override bool TryCastShot()
        {
            Pawn caster = base.CasterPawn;
            Pawn pawn   = this.currentTarget.Thing as Pawn;

            bool flag = caster != null && !caster.Dead;

            if (flag)
            {
                TMAbilityDef ability = (TMAbilityDef)this.Ability.Def;
                if (ability != null && ability.abilityHediff != null)
                {
                    HediffDef hdDef = ability.abilityHediff;
                    if (caster.health.hediffSet.HasHediff(hdDef))
                    {
                        Hediff hd = caster.health.hediffSet.GetFirstHediffOfDef(hdDef);
                        caster.health.RemoveHediff(hd);
                    }
                    else
                    {
                        HealthUtility.AdjustSeverity(caster, hdDef, hdDef.initialSeverity);
                        if (caster.Map != null)
                        {
                            MoteMaker.ThrowLightningGlow(caster.DrawPos, caster.Map, 1f);
                            MoteMaker.ThrowDustPuff(caster.Position, caster.Map, 1f);
                        }
                    }

                    CompAbilityUserMagic magicComp = caster.TryGetComp <CompAbilityUserMagic>();
                    if (magicComp != null && magicComp.MagicData != null)
                    {
                        MagicPower mp = magicComp.MagicData.ReturnMatchingMagicPower(ability);
                        if (mp != null)
                        {
                            mp.autocast = caster.health.hediffSet.HasHediff(hdDef);
                        }
                    }
                    CompAbilityUserMight mightComp = caster.TryGetComp <CompAbilityUserMight>();
                    if (mightComp != null && mightComp.MightData != null)
                    {
                        MightPower mp = mightComp.MightData.ReturnMatchingMightPower(ability);
                        if (mp != null)
                        {
                            mp.autocast = caster.health.hediffSet.HasHediff(hdDef);
                        }
                    }
                }
                else
                {
                    Log.Warning("Unrecognized ability or no hediff assigned for this ability.");
                }
            }
            return(true);
        }
        public override void DoEffect(Pawn user)
        {
            CompAbilityUserMagic compMagic = user.GetComp <CompAbilityUserMagic>();
            CompAbilityUserMight compMight = user.GetComp <CompAbilityUserMight>();
            int essenceXP = 0;

            if (compMagic != null && compMagic.IsMagicUser && compMagic.MagicUserXP != 0 && compMagic.MagicData != null)
            {
                essenceXP += Rand.Range(300, 500);
                for (int i = 0; i < compMagic.MagicData.MagicPowersStandalone.Count; i++)
                {
                    MagicPower mp = compMagic.MagicData.MagicPowersStandalone[i];
                    if (mp.learned)
                    {
                        essenceXP += Rand.Range(80, 120);
                    }
                }
                essenceXP += Mathf.RoundToInt(compMagic.MagicUserXP / Rand.Range(1.7f, 2.3f));
                Thing             mes      = ThingMaker.MakeThing(TorannMagicDefOf.TM_MagicArtifact_MagicEssence, null);
                CompEnchantedItem itemComp = mes.TryGetComp <CompEnchantedItem>();
                if (itemComp != null && itemComp.HasEnchantment)
                {
                    itemComp.magicEssence = essenceXP;
                }
                GenPlace.TryPlaceThing(mes, this.parent.Position, this.parent.Map, ThingPlaceMode.Near);
                essenceXP = 0;
            }
            if (compMight != null && compMight.IsMightUser && compMight.MightUserXP != 0 && compMight.MightData != null)
            {
                essenceXP += Rand.Range(300, 500);
                for (int i = 0; i < compMight.MightData.MightPowersStandalone.Count; i++)
                {
                    MightPower mp = compMight.MightData.MightPowersStandalone[i];
                    if (mp.learned)
                    {
                        essenceXP += Rand.Range(80, 120);
                    }
                }
                essenceXP += Mathf.RoundToInt(compMight.MightUserXP / Rand.Range(1.7f, 2.3f));
                Thing             mes      = ThingMaker.MakeThing(TorannMagicDefOf.TM_MagicArtifact_MightEssence, null);
                CompEnchantedItem itemComp = mes.TryGetComp <CompEnchantedItem>();
                if (itemComp != null && itemComp.HasEnchantment)
                {
                    itemComp.mightEssence = essenceXP;
                }
                GenPlace.TryPlaceThing(mes, this.parent.Position, this.parent.Map, ThingPlaceMode.Near);
                essenceXP = 0;
            }

            ModOptions.TM_DebugTools.RemoveClass(user);
            TM_Action.TransmutateEffects(user.Position, user);
            TM_Action.TransmutateEffects(parent.Position, user);
        }
Exemplo n.º 5
0
        protected override bool TryCastShot()
        {
            Pawn caster = base.CasterPawn;
            Pawn pawn   = this.currentTarget.Thing as Pawn;
            CompAbilityUserMagic comp       = caster.GetComp <CompAbilityUserMagic>();
            MagicPower           magicPower = comp.MagicData.MagicPowersB.FirstOrDefault <MagicPower>((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_Entertain);
            bool flag = pawn != null && !pawn.Dead;

            if (flag)
            {
                if (pawn.health.hediffSet.HasHediff(HediffDef.Named("TM_EntertainingHD")))
                {
                    using (IEnumerator <Hediff> enumerator = pawn.health.hediffSet.GetHediffs <Hediff>().GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            Hediff rec = enumerator.Current;
                            if (rec.def.defName.Contains("TM_EntertainingHD"))
                            {
                                pawn.health.RemoveHediff(rec);
                            }
                        }
                    }

                    magicPower.AutoCast = false;
                }
                else
                {
                    if (comp.maxMP >= TorannMagicDefOf.TM_Entertain.upkeepEnergyCost)
                    {
                        HealthUtility.AdjustSeverity(pawn, HediffDef.Named("TM_EntertainingHD"), .95f);
                        TM_MoteMaker.ThrowNoteMote(pawn.DrawPos, pawn.Map, .8f);
                        magicPower.AutoCast = true;
                    }
                    else
                    {
                        Messages.Message("TM_NotEnoughManaToSustain".Translate(
                                             pawn.LabelShort,
                                             TorannMagicDefOf.TM_Entertain.label
                                             ), MessageTypeDefOf.RejectInput);
                    }
                }
            }
            return(true);
        }
Exemplo n.º 6
0
        protected override bool TryCastShot()
        {
            Pawn            caster     = base.CasterPawn;
            Pawn            pawn       = this.currentTarget.Thing as Pawn;
            MagicPower      magicPower = caster.GetComp <CompAbilityUserMagic>().MagicData.MagicPowersC.FirstOrDefault <MagicPower>((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_Prediction);
            MagicPowerSkill pwr        = base.CasterPawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Prediction.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Prediction_pwr");

            pwrVal = pwr.level;
            CompAbilityUserMagic comp = base.CasterPawn.GetComp <CompAbilityUserMagic>();

            ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef();
            if (settingsRef.AIHardMode && !this.CasterPawn.IsColonist)
            {
                pwrVal = 4;
            }
            else if (!this.CasterPawn.IsColonist && this.CasterPawn.Faction != null && this.CasterPawn.Faction.HostileTo(Faction.OfPlayerSilentFail))
            {
                pwrVal = 5;
            }
            bool flag = pawn != null && !pawn.Dead;

            if (flag)
            {
                if (pawn.health.hediffSet.HasHediff(TorannMagicDefOf.TM_PredictionHD))
                {
                    Hediff hediff = pawn.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_PredictionHD);
                    pawn.health.RemoveHediff(hediff);
                    magicPower.AutoCast = false;
                }
                else
                {
                    HealthUtility.AdjustSeverity(pawn, TorannMagicDefOf.TM_PredictionHD, .5f + pwrVal);
                    //TM_MoteMaker.ThrowNoteMote(pawn.DrawPos, pawn.Map, .8f);
                    magicPower.AutoCast = true;
                }
            }
            return(true);
        }
Exemplo n.º 7
0
        public void DetermineHediff()
        {
            MagicPower           abilityPower = null;
            CompAbilityUserMagic comp         = this.Pawn.GetComp <CompAbilityUserMagic>();

            if (parent.def == TorannMagicDefOf.TM_Shadow_AuraHD && comp != null)
            {
                abilityPower = comp.MagicData.MagicPowersA.FirstOrDefault((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_Shadow);
                if (abilityPower == null)
                {
                    abilityPower = comp.MagicData.MagicPowersA.FirstOrDefault((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_Shadow_I);
                    if (abilityPower == null)
                    {
                        abilityPower = comp.MagicData.MagicPowersA.FirstOrDefault((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_Shadow_II);
                        if (abilityPower == null)
                        {
                            abilityPower = comp.MagicData.MagicPowersA.FirstOrDefault((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_Shadow_III);
                        }
                    }
                }
                if (abilityPower.level == 0)
                {
                    this.hediffDef = TorannMagicDefOf.Shadow;
                }
                else if (abilityPower.level == 1)
                {
                    this.hediffDef = TorannMagicDefOf.Shadow_I;
                }
                else if (abilityPower.level == 2)
                {
                    this.hediffDef = TorannMagicDefOf.Shadow_II;
                }
                else
                {
                    this.hediffDef = TorannMagicDefOf.Shadow_III;
                }
            }
            if (parent.def == TorannMagicDefOf.TM_RayOfHope_AuraHD && comp != null)
            {
                abilityPower = comp.MagicData.MagicPowersIF.FirstOrDefault((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_RayofHope);
                if (abilityPower == null)
                {
                    abilityPower = comp.MagicData.MagicPowersIF.FirstOrDefault((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_RayofHope_I);
                    if (abilityPower == null)
                    {
                        abilityPower = comp.MagicData.MagicPowersIF.FirstOrDefault((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_RayofHope_II);
                        if (abilityPower == null)
                        {
                            abilityPower = comp.MagicData.MagicPowersIF.FirstOrDefault((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_RayofHope_III);
                        }
                    }
                }
                if (abilityPower.level == 0)
                {
                    this.hediffDef = TorannMagicDefOf.RayofHope;
                }
                else if (abilityPower.level == 1)
                {
                    this.hediffDef = TorannMagicDefOf.RayofHope_I;
                }
                else if (abilityPower.level == 2)
                {
                    this.hediffDef = TorannMagicDefOf.RayofHope_II;
                }
                else
                {
                    this.hediffDef = TorannMagicDefOf.RayofHope_III;
                }
            }
            if (parent.def == TorannMagicDefOf.TM_SoothingBreeze_AuraHD && comp != null)
            {
                abilityPower = comp.MagicData.MagicPowersHoF.FirstOrDefault((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_Soothe);
                if (abilityPower == null)
                {
                    abilityPower = comp.MagicData.MagicPowersHoF.FirstOrDefault((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_Soothe_I);
                    if (abilityPower == null)
                    {
                        abilityPower = comp.MagicData.MagicPowersHoF.FirstOrDefault((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_Soothe_II);
                        if (abilityPower == null)
                        {
                            abilityPower = comp.MagicData.MagicPowersHoF.FirstOrDefault((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_Soothe_III);
                        }
                    }
                }
                if (abilityPower.level == 0)
                {
                    this.hediffDef = TorannMagicDefOf.SoothingBreeze;
                }
                else if (abilityPower.level == 1)
                {
                    this.hediffDef = TorannMagicDefOf.SoothingBreeze_I;
                }
                else if (abilityPower.level == 2)
                {
                    this.hediffDef = TorannMagicDefOf.SoothingBreeze_II;
                }
                else
                {
                    this.hediffDef = TorannMagicDefOf.SoothingBreeze_III;
                }
            }
            if (abilityPower != null)
            {
                this.parent.Severity = .5f + abilityPower.level;
            }
            else
            {
                this.Pawn.health.RemoveHediff(this.parent);
            }
        }
Exemplo n.º 8
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);
        }
Exemplo n.º 9
0
        public static List <MagicPowerSkill> GetAssociatedMagicPowerSkill(CompAbilityUserMagic comp, MagicPower power)
        {
            string str = power.TMabilityDefs.FirstOrDefault().defName.ToString() + "_";
            List <MagicPowerSkill> skills = new List <MagicPowerSkill>();

            skills.Clear();
            for (int i = 0; i < comp.MagicData.AllMagicPowerSkills.Count; i++)
            {
                MagicPowerSkill mps = comp.MagicData.AllMagicPowerSkills[i];
                if (mps.label.Contains(str))
                {
                    skills.Add(mps);
                }
            }
            return(skills);
        }