예제 #1
0
        public void DoEffects(IEnumerable <IntVec3> effectRadial1)
        {
            IEnumerable <IntVec3> effectRadial2 = GenRadial.RadialCellsAround(this.ExactPosition.ToIntVec3(), 1, true);
            IEnumerable <IntVec3> effectRadial  = effectRadial1.Except(effectRadial2);
            IntVec3      curCell;
            List <Thing> hitList            = new List <Thing>();
            bool         shouldAddAbilities = false;
            bool         addAbilities       = false;

            if (pawn != null)
            {
                CompAbilityUserMagic comp = pawn.TryGetComp <CompAbilityUserMagic>();
                for (int i = 0; i < effectRadial.Count(); i++)
                {
                    curCell = effectRadial.ToArray <IntVec3>()[i];
                    if (curCell.InBounds(base.Map) && curCell.IsValid)
                    {
                        hitList = curCell.GetThingList(base.Map);
                        for (int j = 0; j < hitList.Count; j++)
                        {
                            if (hitList[j] is Pawn && hitList[j].Faction != pawn.Faction)
                            {
                                DamageEntities(hitList[j]);
                                if (verVal >= 3 && !hitList[j].DestroyedOrNull() && Rand.Chance(.5f))
                                {
                                    if (comp != null)
                                    {
                                        shouldAddAbilities = comp.HexedPawns.Count <= 0;
                                        Pawn newPawn = hitList[j] as Pawn;
                                        if (newPawn.RaceProps.IsFlesh && !TM_Calc.IsUndead(newPawn) && !newPawn.Destroyed && !newPawn.Dead)
                                        {
                                            if (Rand.Chance(.3f) && !newPawn.health.hediffSet.HasHediff(TorannMagicDefOf.TM_HexHD))
                                            {
                                                HealthUtility.AdjustSeverity(newPawn, TorannMagicDefOf.TM_HexHD, 1f);
                                                if (!comp.HexedPawns.Contains(newPawn))
                                                {
                                                    comp.HexedPawns.Add(newPawn);
                                                }
                                                addAbilities = true;
                                                TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_Hex, newPawn.DrawPos, newPawn.Map, .6f, .1f, .2f, .2f, 0, 0, 0, 0);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                if (shouldAddAbilities && addAbilities)
                {
                    comp.AddPawnAbility(TorannMagicDefOf.TM_Hex_CriticalFail);
                    comp.AddPawnAbility(TorannMagicDefOf.TM_Hex_Pain);
                    comp.AddPawnAbility(TorannMagicDefOf.TM_Hex_MentalAssault);
                }
            }
        }
예제 #2
0
        protected override bool TryCastShot()
        {
            bool flag = false;

            this.TargetsAoE.Clear();
            this.FindTargets();
            CompAbilityUserMagic comp = CasterPawn.GetComp <CompAbilityUserMagic>();

            if (comp != null && comp.MagicData != null)
            {
                pwrVal    = TM_Calc.GetMagicSkillLevel(CasterPawn, comp.MagicData.MagicPowerSkill_Hex, "TM_Hex", "_pwr", true);
                verVal    = TM_Calc.GetMagicSkillLevel(CasterPawn, comp.MagicData.MagicPowerSkill_Hex, "TM_Hex", "_ver", true);
                arcaneDmg = comp.arcaneDmg;
            }
            bool flag2 = this.UseAbilityProps.AbilityTargetCategory != AbilityTargetCategory.TargetAoE && this.TargetsAoE.Count > 1;

            if (flag2)
            {
                this.TargetsAoE.RemoveRange(0, this.TargetsAoE.Count - 1);
            }
            bool addAbilities       = false;
            bool shouldAddAbilities = comp.HexedPawns.Count <= 0;

            for (int i = 0; i < this.TargetsAoE.Count; i++)
            {
                Pawn newPawn = this.TargetsAoE[i].Thing as Pawn;
                if (newPawn.RaceProps.IsFlesh && !TM_Calc.IsUndead(newPawn))
                {
                    if (Rand.Chance(.4f + (.1f * pwrVal * TM_Calc.GetSpellSuccessChance(this.CasterPawn, newPawn, true))))
                    {
                        HealthUtility.AdjustSeverity(newPawn, TorannMagicDefOf.TM_HexHD, 1f);
                        var hexedPawns = comp.HexedPawns;
                        if (!hexedPawns.Contains(newPawn))
                        {
                            hexedPawns.Add(newPawn);
                        }
                        addAbilities = true;
                        TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_Hex, newPawn.DrawPos, newPawn.Map, .6f, .1f, .2f, .2f, 0, 0, 0, 0);
                    }
                    else
                    {
                        MoteMaker.ThrowText(newPawn.DrawPos, newPawn.Map, "TM_ResistedSpell".Translate(), -1);
                    }
                }
            }
            if (shouldAddAbilities && addAbilities)
            {
                comp.AddPawnAbility(TorannMagicDefOf.TM_Hex_CriticalFail);
                comp.AddPawnAbility(TorannMagicDefOf.TM_Hex_Pain);
                comp.AddPawnAbility(TorannMagicDefOf.TM_Hex_MentalAssault);
            }
            this.PostCastShot(flag, out flag);
            return(flag);
        }
        protected override bool TryCastShot()
        {
            Pawn pawn = this.currentTarget.Thing as Pawn;

            CompAbilityUserMagic comp = pawn.GetComp <CompAbilityUserMagic>();

            if (comp.IsMagicUser)
            {
                if (comp.fertileLands.Count > 0)
                {
                    for (int i = 0; i < comp.fertileLands.Count; i++)
                    {
                        ModOptions.Constants.RemoveGrowthCell(comp.fertileLands[i]);
                    }
                    comp.fertileLands.Clear();
                    comp.RemovePawnAbility(TorannMagicDefOf.TM_DismissFertileLands);
                    comp.AddPawnAbility(TorannMagicDefOf.TM_FertileLands);
                }
                else
                {
                    Log.Message("found no cells to remove");
                }
            }
            return(true);
        }
예제 #4
0
        protected override bool TryCastShot()
        {
            Map  map  = base.CasterPawn.Map;
            Pawn pawn = base.CasterPawn;
            CompAbilityUserMagic comp = pawn.GetComp <CompAbilityUserMagic>();

            List <Trait> traits = pawn.story.traits.allTraits;

            for (int i = 0; i < traits.Count; i++)
            {
                if (traits[i].def.defName == "Necromancer")
                {
                    FixTrait(pawn, pawn.story.traits.allTraits);
                    AdjustPlayerSettings(pawn);
                    pawn.story.traits.GainTrait(new Trait(TraitDef.Named("Lich"), 4, false));
                    HealthUtility.AdjustSeverity(pawn, HediffDef.Named("TM_LichHD"), .5f);
                    for (int h = 0; h < 24; h++)
                    {
                        pawn.timetable.SetAssignment(h, TimeAssignmentDefOf.Work);
                    }
                    pawn.needs.AddOrRemoveNeedsAsAppropriate();
                    comp.AddPawnAbility(TorannMagicDefOf.TM_DeathBolt, false);
                    comp.spell_Flight = true;
                    comp.InitializeSpell();
                    TM_MoteMaker.ThrowScreamMote(pawn.Position.ToVector3(), pawn.Map, 2f, 216, 255, 0);
                }
                else
                {
                    //Log.Message("Necromancer trait not found.");
                }
            }

            this.burstShotsLeft = 0;
            return(false);
        }
예제 #5
0
        protected override void Impact(Thing hitThing)
        {
            Map map = base.Map;

            base.Impact(hitThing);
            ThingDef def = this.def;

            this.caster = this.launcher as Pawn;

            if (!this.initialized)
            {
                this.initialized = true;
            }

            CompAbilityUserMagic comp = this.caster.GetComp <CompAbilityUserMagic>();

            comp.fertileLands = new List <IntVec3>();
            comp.fertileLands.Clear();
            IEnumerable <IntVec3> targetCells = GenRadial.RadialCellsAround(base.Position, 6, true);

            for (int i = 0; i < targetCells.Count(); i++)
            {
                comp.fertileLands.Add(targetCells.ToArray <IntVec3>()[i]);
            }
            TM_MoteMaker.ThrowTwinkle(base.Position.ToVector3Shifted(), map, 1f);
            ModOptions.Constants.SetGrowthCells(comp.fertileLands);
            comp.RemovePawnAbility(TorannMagicDefOf.TM_FertileLands);
            comp.AddPawnAbility(TorannMagicDefOf.TM_DismissFertileLands);
        }
예제 #6
0
        protected override void Impact(Thing hitThing)
        {
            Map map = base.Map;

            base.Impact(hitThing);
            this.caster = this.launcher as Pawn;

            if (!this.initialized)
            {
                this.initialized = true;
            }

            CompAbilityUserMagic comp = this.caster.GetComp <CompAbilityUserMagic>();

            comp.fertileLands = new List <IntVec3>();
            comp.fertileLands.Clear();
            List <IntVec3> affectedCells = new List <IntVec3>();

            affectedCells.Clear();
            affectedCells = ModOptions.Constants.GetGrowthCells();
            IEnumerable <IntVec3> targetCells = GenRadial.RadialCellsAround(base.Position, 6, true);

            foreach (IntVec3 targetCell in targetCells)
            {
                bool uniqueCell = true;
                for (int j = 0; j < affectedCells.Count; j++)
                {
                    if (affectedCells[j] == targetCell)
                    {
                        uniqueCell = false;
                    }
                }
                if (uniqueCell)
                {
                    comp.fertileLands.Add(targetCell);
                }
            }
            TM_MoteMaker.ThrowTwinkle(base.Position.ToVector3Shifted(), map, 1f);

            ModOptions.Constants.SetGrowthCells(comp.fertileLands);
            comp.RemovePawnAbility(TorannMagicDefOf.TM_FertileLands);
            comp.AddPawnAbility(TorannMagicDefOf.TM_DismissFertileLands);
        }
예제 #7
0
        protected override bool TryCastShot()
        {
            caster = base.CasterPawn;
            pawn   = this.currentTarget.Thing as Pawn;

            CompAbilityUserMagic comp = caster.GetComp <CompAbilityUserMagic>();
            MagicPowerSkill      pwr  = comp.MagicData.MagicPowerSkill_SoulBond.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_SoulBond_pwr");
            MagicPowerSkill      ver  = comp.MagicData.MagicPowerSkill_SoulBond.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_SoulBond_ver");

            verVal = ver.level;
            pwrVal = pwr.level;

            bool flag = pawn != null && !pawn.Dead && pawn.RaceProps.Humanlike && pawn != caster;

            if (flag)
            {
                if (!pawn.health.hediffSet.HasHediff(TorannMagicDefOf.TM_UndeadHD))
                {
                    if (pawn.Faction != this.CasterPawn.Faction)
                    {
                        Messages.Message("TM_CannotSoulBondUnwilling".Translate(
                                             caster.LabelShort,
                                             pawn.LabelShort
                                             ), MessageTypeDefOf.RejectInput);
                    }
                    else
                    {
                        flagSD = caster.gender == Gender.Female;
                        flagWD = caster.gender == Gender.Male;
                        if (comp.soulBondPawn != null)
                        {
                            oldBondPawn = comp.soulBondPawn;
                            RemoveHediffs();
                            if (oldBondPawn == pawn)
                            {
                                comp.soulBondPawn     = null;
                                comp.spell_ShadowCall = false;
                                comp.spell_ShadowStep = false;
                                comp.RemovePawnAbility(TorannMagicDefOf.TM_ShadowCall);
                                comp.RemovePawnAbility(TorannMagicDefOf.TM_ShadowStep);
                            }
                            else
                            {
                                if (pawn.health.hediffSet.HasHediff(HediffDef.Named("TM_SoulBondPhysicalHD")) && flagSD)
                                {
                                    Messages.Message("TM_CannotSoulBondAnother".Translate(
                                                         caster.LabelShort,
                                                         pawn.LabelShort
                                                         ), MessageTypeDefOf.RejectInput);
                                }
                                else if (pawn.health.hediffSet.HasHediff(HediffDef.Named("TM_SoulBondMentalHD")) && flagWD)
                                {
                                    Messages.Message("TM_CannotSoulBondAnother".Translate(
                                                         caster.LabelShort,
                                                         pawn.LabelShort
                                                         ), MessageTypeDefOf.RejectInput);
                                }
                                else
                                {
                                    ApplyHediffs();
                                    comp.soulBondPawn = pawn;
                                }
                            }
                        }
                        else
                        {
                            ApplyHediffs();
                            comp.spell_ShadowCall = true;
                            comp.spell_ShadowStep = true;
                            comp.AddPawnAbility(TorannMagicDefOf.TM_ShadowCall);
                            comp.AddPawnAbility(TorannMagicDefOf.TM_ShadowStep);
                            comp.soulBondPawn = pawn;
                        }
                    }
                }
                else
                {
                    Messages.Message("TM_CannotSoulBondUndead".Translate(
                                         caster.LabelShort
                                         ), MessageTypeDefOf.RejectInput);
                }
            }
            else
            {
                Messages.Message("TM_CannotSoulBondThing".Translate(
                                     caster.LabelShort
                                     ), MessageTypeDefOf.RejectInput);
            }
            return(true);
        }
예제 #8
0
        public override void CompTick()
        {
            if (this.age > 0)
            {
                if (!this.initialized)
                {
                    if (summonerPawn != null)
                    {
                        CompAbilityUserMagic comp = summonerPawn.TryGetComp <CompAbilityUserMagic>();
                        if (comp != null)
                        {
                            verVal                 = TM_Calc.GetMagicSkillLevel(summonerPawn, comp.MagicData.MagicPowerSkill_GuardianSpirit, "TM_GuardianSpirit", "_ver", true);
                            pwrVal                 = TM_Calc.GetMagicSkillLevel(summonerPawn, comp.MagicData.MagicPowerSkill_GuardianSpirit, "TM_GuardianSpirit", "_pwr", true);
                            tauntRange             = 15 + pwrVal;
                            tauntTargetsMax        = 4 + pwrVal;
                            tauntChance            = .6f + (.03f * pwrVal);
                            damageMitigation       = 4 + Mathf.RoundToInt((float)pwrVal / 1.5f);
                            shadowStrikeDamage     = 11 + pwrVal;
                            shadowStrikeCritChance = .4f + (.05f * pwrVal);
                            invisDuration          = 90 + (10 * pwrVal);
                            hasteDuration          = 120 + (10 * pwrVal);
                            hexChance              = .5f + (.05f * pwrVal);
                        }
                    }
                    this.initialized = true;
                }

                if (this.Pawn.Spawned && this.Props.abilities != null)
                {
                    if (!this.Pawn.Downed && Find.TickManager.TicksGame >= this.nextEvalTick)
                    {
                        this.nextEvalTick = Find.TickManager.TicksGame + Mathf.RoundToInt(Rand.Range(.8f, 1.2f) * this.Props.abilityAttemptFrequency);
                        DetermineThreats();
                        if (closeThreats != null && closeThreats.Count >= 1)
                        {
                            if (this.Props.abilities.Contains(TorannMagicDefOf.TM_Taunt) && this.Pawn.needs?.food?.CurLevel > .06f)
                            {
                                SoundInfo info = SoundInfo.InMap(new TargetInfo(this.Pawn.Position, this.Pawn.Map, false), MaintenanceType.None);
                                info.pitchFactor  = Rand.Range(.3f, .4f);
                                info.volumeFactor = .7f;
                                TorannMagicDefOf.TM_Roar.PlayOneShot(info);
                                Effecter RageWave = TorannMagicDefOf.TM_RageWaveED.Spawn();
                                RageWave.Trigger(new TargetInfo(this.Pawn.Position, this.Pawn.Map, false), new TargetInfo(this.Pawn.Position, this.Pawn.Map, false));
                                RageWave.Cleanup();
                                SearchAndTaunt();
                                this.Pawn.needs.food.CurLevel -= .3f;
                            }
                        }
                        if (farThreats != null && farThreats.Count >= 1 && this.Pawn.needs?.food?.CurLevel > .05f)
                        {
                            if (this.Props.abilities.Contains(TorannMagicDefOf.TM_ShadowStrike))
                            {
                                Thing target = farThreats.RandomElement();
                                if (DoMove(target))
                                {
                                    DoStrike(target);
                                    this.Pawn.needs.food.CurLevel -= .3f;
                                }
                            }
                        }
                        if (PawnThreatList != null && PawnThreatList.Count > 0 && this.Pawn.needs?.food?.CurLevel > .025f)
                        {
                            if (this.Props.abilities.Contains(TorannMagicDefOf.TM_Hex))
                            {
                                Pawn p = PawnThreatList.RandomElement();
                                if (p.health != null && p.health.hediffSet != null && !p.health.hediffSet.HasHediff(TorannMagicDefOf.TM_HexHD))
                                {
                                    if (Rand.Chance(hexChance))
                                    {
                                        HealthUtility.AdjustSeverity(p, TorannMagicDefOf.TM_HexHD, 1f);
                                        CompAbilityUserMagic bondedMagicComp = this.summonerPawn.TryGetComp <CompAbilityUserMagic>();

                                        if (bondedMagicComp != null && !bondedMagicComp.HexedPawns.Contains(p) && bondedMagicComp.MagicData != null && bondedMagicComp.MagicData.MagicPowersShaman.FirstOrDefault((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_Hex).learned)
                                        {
                                            bool addAbilities       = false;
                                            bool shouldAddAbilities = bondedMagicComp.HexedPawns.Count <= 0;
                                            if (!bondedMagicComp.HexedPawns.Contains(p))
                                            {
                                                bondedMagicComp.HexedPawns.Add(p);
                                                addAbilities = true;
                                            }
                                            if (shouldAddAbilities && addAbilities)
                                            {
                                                bondedMagicComp.AddPawnAbility(TorannMagicDefOf.TM_Hex_CriticalFail);
                                                bondedMagicComp.AddPawnAbility(TorannMagicDefOf.TM_Hex_Pain);
                                                bondedMagicComp.AddPawnAbility(TorannMagicDefOf.TM_Hex_MentalAssault);
                                            }
                                        }
                                        TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_Hex, p.DrawPos, p.Map, .6f, .1f, .2f, .2f, 0, 0, 0, 0);
                                    }
                                    this.Pawn.needs.food.CurLevel -= .1f;
                                }
                            }
                        }
                    }
                }
            }
            age++;
        }
        public override void DoEffect(Pawn user)
        {
            CompAbilityUserMagic comp = user.GetComp <CompAbilityUserMagic>();
            MagicPower           magicPower;

            if (parent.def != null && (user.story.traits.HasTrait(TorannMagicDefOf.Enchanter) || user.story.traits.HasTrait(TorannMagicDefOf.BloodMage) || user.story.traits.HasTrait(TorannMagicDefOf.Technomancer) || user.story.traits.HasTrait(TorannMagicDefOf.Geomancer) || user.story.traits.HasTrait(TorannMagicDefOf.Warlock) || user.story.traits.HasTrait(TorannMagicDefOf.Succubus) || user.story.traits.HasTrait(TorannMagicDefOf.TM_Bard) || user.story.traits.HasTrait(TorannMagicDefOf.Priest) || (user.story.traits.HasTrait(TorannMagicDefOf.Necromancer) || user.story.traits.HasTrait(TorannMagicDefOf.Lich)) || user.story.traits.HasTrait(TorannMagicDefOf.Druid) || parent.def != null && (user.story.traits.HasTrait(TorannMagicDefOf.Summoner) || user.story.traits.HasTrait(TorannMagicDefOf.InnerFire) || user.story.traits.HasTrait(TorannMagicDefOf.HeartOfFrost) || user.story.traits.HasTrait(TorannMagicDefOf.StormBorn) || user.story.traits.HasTrait(TorannMagicDefOf.Arcanist) || user.story.traits.HasTrait(TorannMagicDefOf.Paladin))))
            {
                if (parent.def.defName == "SpellOf_Rain" && comp.spell_Rain == false)
                {
                    comp.spell_Rain = true;
                    magicPower      = comp.MagicData.MagicPowersHoF.FirstOrDefault <MagicPower>((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_Rainmaker);
                    comp.AddPawnAbility(TorannMagicDefOf.TM_Rainmaker);
                    magicPower.learned = true;
                    comp.InitializeSpell();
                    this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_Blink" && comp.spell_Blink == false)
                {
                    comp.spell_Blink = true;
                    magicPower       = comp.MagicData.MagicPowersA.FirstOrDefault <MagicPower>((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_Blink);
                    comp.AddPawnAbility(TorannMagicDefOf.TM_Blink);
                    magicPower.learned = true;
                    comp.InitializeSpell();
                    this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_Teleport" && comp.spell_Teleport == false)
                {
                    comp.spell_Teleport = true;
                    magicPower          = comp.MagicData.MagicPowersA.FirstOrDefault <MagicPower>((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_Teleport);
                    comp.AddPawnAbility(TorannMagicDefOf.TM_Teleport);
                    magicPower.learned = true;
                    comp.InitializeSpell();
                    this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_Heal" && comp.spell_Heal == false)
                {
                    comp.spell_Heal = true;
                    magicPower      = comp.MagicData.MagicPowersP.FirstOrDefault <MagicPower>((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_Heal);
                    comp.AddPawnAbility(TorannMagicDefOf.TM_Heal);
                    magicPower.learned = true;
                    comp.InitializeSpell();
                    this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_Heater" && comp.spell_Heater == false)
                {
                    comp.spell_Heater = true;
                    comp.InitializeSpell();
                    this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_Cooler" && comp.spell_Cooler == false)
                {
                    comp.spell_Cooler = true;
                    comp.InitializeSpell();
                    this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_PowerNode" && comp.spell_PowerNode == false)
                {
                    comp.spell_PowerNode = true;
                    comp.InitializeSpell();
                    this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_Sunlight" && comp.spell_Sunlight == false)
                {
                    comp.spell_Sunlight = true;
                    comp.InitializeSpell();
                    this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_DryGround" && comp.spell_DryGround == false && user.story.traits.HasTrait(TorannMagicDefOf.InnerFire))
                {
                    comp.spell_DryGround = true;
                    comp.InitializeSpell();
                    this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_Firestorm" && comp.spell_Firestorm == false && user.story.traits.HasTrait(TorannMagicDefOf.InnerFire))
                {
                    comp.spell_Firestorm = true;
                    comp.InitializeSpell();
                    this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_WetGround" && comp.spell_WetGround == false && user.story.traits.HasTrait(TorannMagicDefOf.HeartOfFrost))
                {
                    comp.spell_WetGround = true;
                    comp.InitializeSpell();
                    this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_Blizzard" && comp.spell_Blizzard == false && user.story.traits.HasTrait(TorannMagicDefOf.HeartOfFrost))
                {
                    comp.spell_Blizzard = true;
                    comp.InitializeSpell();
                    this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_ChargeBattery" && comp.spell_ChargeBattery == false && user.story.traits.HasTrait(TorannMagicDefOf.StormBorn))
                {
                    comp.spell_ChargeBattery = true;
                    comp.InitializeSpell();
                    this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_SmokeCloud" && comp.spell_SmokeCloud == false)
                {
                    comp.spell_SmokeCloud = true;
                    comp.InitializeSpell();
                    this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_Extinguish" && comp.spell_Extinguish == false)
                {
                    comp.spell_Extinguish = true;
                    comp.InitializeSpell();
                    this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_EMP" && comp.spell_EMP == false)
                {
                    comp.spell_EMP = true;
                    comp.InitializeSpell();
                    this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_SummonMinion" && comp.spell_SummonMinion == false)
                {
                    comp.spell_SummonMinion = true;
                    magicPower = comp.MagicData.MagicPowersS.FirstOrDefault <MagicPower>((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_SummonMinion);
                    comp.AddPawnAbility(TorannMagicDefOf.TM_SummonMinion);
                    magicPower.learned = true;
                    comp.InitializeSpell();
                    this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_TransferMana" && comp.spell_TransferMana == false)
                {
                    comp.spell_TransferMana = true;
                    comp.InitializeSpell();
                    this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_SiphonMana" && comp.spell_SiphonMana == false)
                {
                    comp.spell_SiphonMana = true;
                    comp.InitializeSpell();
                    this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_RegrowLimb" && comp.spell_RegrowLimb == false && user.story.traits.HasTrait(TorannMagicDefOf.Druid))
                {
                    comp.spell_RegrowLimb = true;
                    comp.InitializeSpell();
                    this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_EyeOfTheStorm" && comp.spell_EyeOfTheStorm == false && user.story.traits.HasTrait(TorannMagicDefOf.StormBorn))
                {
                    comp.spell_EyeOfTheStorm = true;
                    magicPower         = comp.MagicData.MagicPowersSB.FirstOrDefault <MagicPower>((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_EyeOfTheStorm);
                    magicPower.learned = true;
                    comp.InitializeSpell();
                    this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_ManaShield" && comp.spell_ManaShield == false)
                {
                    comp.spell_ManaShield = true;
                    comp.InitializeSpell();
                    this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_FoldReality" && comp.spell_FoldReality == false && user.story.traits.HasTrait(TorannMagicDefOf.Arcanist))
                {
                    comp.spell_FoldReality = true;
                    comp.InitializeSpell();
                    this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_Resurrection" && comp.spell_Resurrection == false && user.story.traits.HasTrait(TorannMagicDefOf.Priest))
                {
                    comp.spell_Resurrection = true;
                    comp.InitializeSpell();
                    this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_BattleHymn" && comp.spell_BattleHymn == false && user.story.traits.HasTrait(TorannMagicDefOf.TM_Bard))
                {
                    comp.spell_BattleHymn = true;
                    comp.InitializeSpell();
                    this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_HolyWrath" && comp.spell_HolyWrath == false && user.story.traits.HasTrait(TorannMagicDefOf.Paladin))
                {
                    comp.spell_HolyWrath = true;
                    comp.InitializeSpell();
                    this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_LichForm" && comp.spell_LichForm == false && user.story.traits.HasTrait(TorannMagicDefOf.Necromancer))
                {
                    comp.spell_LichForm = true;
                    comp.InitializeSpell();
                    this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_SummonPoppi" && comp.spell_SummonPoppi == false && user.story.traits.HasTrait(TorannMagicDefOf.Summoner))
                {
                    comp.spell_SummonPoppi = true;
                    comp.InitializeSpell();
                    this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_Scorn" && comp.spell_Scorn == false && user.story.traits.HasTrait(TorannMagicDefOf.Succubus))
                {
                    comp.spell_Scorn = true;
                    comp.InitializeSpell();
                    this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_PsychicShock" && comp.spell_PsychicShock == false && user.story.traits.HasTrait(TorannMagicDefOf.Warlock))
                {
                    comp.spell_PsychicShock = true;
                    comp.InitializeSpell();
                    this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_Meteor" && comp.spell_Meteor == false && user.story.traits.HasTrait(TorannMagicDefOf.Geomancer))
                {
                    comp.spell_Meteor = true;
                    comp.InitializeSpell();
                    this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_OrbitalStrike" && comp.spell_OrbitalStrike == false && user.story.traits.HasTrait(TorannMagicDefOf.Technomancer))
                {
                    comp.spell_OrbitalStrike = true;
                    comp.InitializeSpell();
                    this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_CauterizeWound" && comp.spell_CauterizeWound == false && user.story.traits.HasTrait(TorannMagicDefOf.InnerFire))
                {
                    comp.spell_CauterizeWound = true;
                    comp.InitializeSpell();
                    this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_FertileLands" && comp.spell_FertileLands == false && user.story.traits.HasTrait(TorannMagicDefOf.Druid))
                {
                    comp.spell_FertileLands = true;
                    comp.InitializeSpell();
                    this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_SpellMending" && comp.spell_SpellMending == false)
                {
                    comp.spell_SpellMending = true;
                    comp.InitializeSpell();
                    this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_TechnoShield" && comp.MagicData.MagicPowersT.FirstOrDefault <MagicPower>((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_TechnoShield).learned == false && user.story.traits.HasTrait(TorannMagicDefOf.Technomancer))
                {
                    comp.MagicData.MagicPowersT.FirstOrDefault <MagicPower>((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_TechnoShield).learned = true;
                    comp.AddPawnAbility(TorannMagicDefOf.TM_TechnoShield);
                    this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_Sabotage" && comp.MagicData.MagicPowersT.FirstOrDefault <MagicPower>((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_Sabotage).learned == false && user.story.traits.HasTrait(TorannMagicDefOf.Technomancer))
                {
                    comp.MagicData.MagicPowersT.FirstOrDefault <MagicPower>((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_Sabotage).learned = true;
                    comp.AddPawnAbility(TorannMagicDefOf.TM_Sabotage);
                    this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_Overdrive" && comp.MagicData.MagicPowersT.FirstOrDefault <MagicPower>((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_Overdrive).learned == false && user.story.traits.HasTrait(TorannMagicDefOf.Technomancer))
                {
                    comp.MagicData.MagicPowersT.FirstOrDefault <MagicPower>((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_Overdrive).learned = true;
                    comp.AddPawnAbility(TorannMagicDefOf.TM_Overdrive);
                    this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_BloodMoon" && comp.spell_BloodMoon == false && user.story.traits.HasTrait(TorannMagicDefOf.BloodMage))
                {
                    comp.spell_BloodMoon = true;
                    comp.InitializeSpell();
                    this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                }
                else if (parent.def == TorannMagicDefOf.SpellOf_Shapeshift && comp.spell_Shapeshift == false && user.story.traits.HasTrait(TorannMagicDefOf.Enchanter))
                {
                    comp.spell_Shapeshift = true;
                    comp.InitializeSpell();
                    this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                }
                else if (parent.def == TorannMagicDefOf.SpellOf_Blur && comp.spell_Blur == false)
                {
                    comp.spell_Blur = true;
                    comp.InitializeSpell();
                    this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                }
                else if (parent.def == TorannMagicDefOf.SpellOf_BlankMind && comp.spell_BlankMind == false && user.story.traits.HasTrait(TorannMagicDefOf.Enchanter))
                {
                    comp.spell_BlankMind = true;
                    comp.InitializeSpell();
                    this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                }
                else if (parent.def == TorannMagicDefOf.SpellOf_DirtDevil && comp.spell_DirtDevil == false)
                {
                    comp.spell_DirtDevil = true;
                    comp.InitializeSpell();
                    this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                }
                else if (parent.def == TorannMagicDefOf.SpellOf_MechaniteReprogramming && comp.spell_MechaniteReprogramming == false && user.story.traits.HasTrait(TorannMagicDefOf.Technomancer))
                {
                    comp.spell_MechaniteReprogramming = true;
                    comp.InitializeSpell();
                    this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                }
                else if (parent.def == TorannMagicDefOf.SpellOf_ArcaneBolt && comp.spell_ArcaneBolt == false && !comp.Pawn.story.WorkTagIsDisabled(WorkTags.Violent))
                {
                    comp.spell_ArcaneBolt = true;
                    comp.InitializeSpell();
                    this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                }
                else if (parent.def == TorannMagicDefOf.SpellOf_LightningTrap && comp.spell_LightningTrap == false && !comp.Pawn.story.WorkTagIsDisabled(WorkTags.Violent))
                {
                    comp.spell_LightningTrap = true;
                    comp.InitializeSpell();
                    this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                }
                else if (parent.def == TorannMagicDefOf.SpellOf_Invisibility && comp.spell_Invisibility == false)
                {
                    comp.spell_Invisibility = true;
                    comp.InitializeSpell();
                    this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                }
                else if (parent.def == TorannMagicDefOf.SpellOf_BriarPatch && comp.spell_BriarPatch == false && user.story.traits.HasTrait(TorannMagicDefOf.Druid))
                {
                    comp.spell_BriarPatch = true;
                    comp.InitializeSpell();
                    this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                }
                else
                {
                    Messages.Message("CannotLearnSpell".Translate(), MessageTypeDefOf.RejectInput);
                }
            }
            else
            {
                Messages.Message("NotMageToLearnSpell".Translate(), MessageTypeDefOf.RejectInput);
            }
        }
예제 #10
0
        public override void DoEffect(Pawn user)
        {
            CompAbilityUserMagic comp = user.GetComp <CompAbilityUserMagic>();
            MagicPower           magicPower;

            if (parent.def != null && (TM_Calc.IsMagicUser(user) || TM_Calc.IsWanderer(user)))
            {
                if (comp.customClass != null)
                {
                    bool itemUsed = false;
                    for (int i = 0; i < comp.MagicData.AllMagicPowers.Count; i++)
                    {
                        TMAbilityDef ad = (TMAbilityDef)comp.MagicData.AllMagicPowers[i].abilityDef;
                        if (ad.learnItem == parent.def)
                        {
                            if (!TM_Data.RestrictedAbilities.Contains(parent.def) && !comp.MagicData.AllMagicPowers[i].learned)
                            {
                                itemUsed = true;
                                comp.MagicData.AllMagicPowers[i].learned = true;
                                if (ad.shouldInitialize)
                                {
                                    comp.RemovePawnAbility(ad);
                                    comp.AddPawnAbility(ad);
                                }
                                comp.InitializeSpell();
                                this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                                break;
                            }
                            else if (TM_Data.RestrictedAbilities.Contains(parent.def) && !comp.MagicData.AllMagicPowers[i].learned)
                            {
                                if (comp.customClass.learnableSpells.Contains(parent.def))
                                {
                                    itemUsed = true;
                                    comp.MagicData.AllMagicPowers[i].learned = true;
                                    if (ad.shouldInitialize)
                                    {
                                        comp.RemovePawnAbility(ad);
                                        comp.AddPawnAbility(ad);
                                    }
                                    comp.InitializeSpell();
                                    this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                                    break;
                                }
                                else
                                {
                                    Messages.Message("CannotLearnSpell".Translate(), MessageTypeDefOf.RejectInput);
                                    break;
                                }
                            }
                            else
                            {
                                Messages.Message("TM_AlreadyLearnedAbility".Translate(user.LabelShort, ad.label), MessageTypeDefOf.RejectInput);
                            }
                        }
                    }
                    if (!itemUsed)
                    {
                        Messages.Message("CannotLearnSpell".Translate(), MessageTypeDefOf.RejectInput);
                        return;
                    }
                }
                else
                {
                    TMAbilityDef customSkill = null;
                    for (int i = 0; i < comp.MagicData.MagicPowersCustom.Count; i++)
                    {
                        TMAbilityDef tempSkill = (TMAbilityDef)comp.MagicData.MagicPowersCustom[i].abilityDef;
                        if (tempSkill.learnItem != null && tempSkill.learnItem == parent.def)
                        {
                            if (!comp.MagicData.MagicPowersCustom[i].learned)
                            {
                                customSkill = tempSkill;
                                break;
                            }
                        }
                    }
                    if (parent.def.defName == "SpellOf_Rain" && comp.spell_Rain == false)
                    {
                        comp.spell_Rain = true;
                        magicPower      = comp.MagicData.MagicPowersHoF.FirstOrDefault <MagicPower>((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_Rainmaker);
                        comp.AddPawnAbility(TorannMagicDefOf.TM_Rainmaker);
                        magicPower.learned = true;
                        comp.InitializeSpell();
                        this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                    }
                    else if (parent.def.defName == "SpellOf_Blink" && comp.spell_Blink == false)
                    {
                        comp.spell_Blink = true;
                        magicPower       = comp.MagicData.MagicPowersA.FirstOrDefault <MagicPower>((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_Blink);
                        comp.AddPawnAbility(TorannMagicDefOf.TM_Blink);
                        if (!user.story.traits.HasTrait(TorannMagicDefOf.ChaosMage))
                        {
                            magicPower.learned = true;
                        }
                        comp.InitializeSpell();
                        this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                    }
                    else if (parent.def.defName == "SpellOf_Teleport" && comp.spell_Teleport == false)
                    {
                        comp.spell_Teleport = true;
                        magicPower          = comp.MagicData.MagicPowersA.FirstOrDefault <MagicPower>((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_Teleport);
                        comp.AddPawnAbility(TorannMagicDefOf.TM_Teleport);
                        if (!user.story.traits.HasTrait(TorannMagicDefOf.ChaosMage))
                        {
                            magicPower.learned = true;
                        }
                        comp.InitializeSpell();
                        this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                    }
                    else if (parent.def.defName == "SpellOf_Heal" && comp.spell_Heal == false)
                    {
                        comp.spell_Heal = true;
                        magicPower      = comp.MagicData.MagicPowersP.FirstOrDefault <MagicPower>((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_Heal);
                        comp.AddPawnAbility(TorannMagicDefOf.TM_Heal);
                        if (!user.story.traits.HasTrait(TorannMagicDefOf.ChaosMage))
                        {
                            magicPower.learned = true;
                        }
                        comp.InitializeSpell();
                        this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                    }
                    else if (parent.def.defName == "SpellOf_Heater" && comp.spell_Heater == false)
                    {
                        comp.spell_Heater = true;
                        comp.MagicData.ReturnMatchingMagicPower(TorannMagicDefOf.TM_Heater).learned = true;
                        comp.InitializeSpell();
                        this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                    }
                    else if (parent.def.defName == "SpellOf_Cooler" && comp.spell_Cooler == false)
                    {
                        comp.spell_Cooler = true;
                        comp.MagicData.ReturnMatchingMagicPower(TorannMagicDefOf.TM_Cooler).learned = true;
                        comp.InitializeSpell();
                        this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                    }
                    else if (parent.def.defName == "SpellOf_PowerNode" && comp.spell_PowerNode == false)
                    {
                        comp.spell_PowerNode = true;
                        comp.MagicData.ReturnMatchingMagicPower(TorannMagicDefOf.TM_PowerNode).learned = true;
                        comp.InitializeSpell();
                        this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                    }
                    else if (parent.def.defName == "SpellOf_Sunlight" && comp.spell_Sunlight == false)
                    {
                        comp.spell_Sunlight = true;
                        comp.MagicData.ReturnMatchingMagicPower(TorannMagicDefOf.TM_PowerNode).learned = true;
                        comp.InitializeSpell();
                        this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                    }
                    else if (parent.def.defName == "SpellOf_DryGround" && comp.spell_DryGround == false && user.story.traits.HasTrait(TorannMagicDefOf.InnerFire))
                    {
                        comp.spell_DryGround = true;
                        comp.MagicData.ReturnMatchingMagicPower(TorannMagicDefOf.TM_DryGround).learned = true;
                        comp.InitializeSpell();
                        this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                    }
                    else if (parent.def.defName == "SpellOf_Firestorm" && comp.spell_Firestorm == false && user.story.traits.HasTrait(TorannMagicDefOf.InnerFire))
                    {
                        comp.spell_Firestorm = true;
                        comp.MagicData.ReturnMatchingMagicPower(TorannMagicDefOf.TM_Firestorm).learned = true;
                        comp.InitializeSpell();
                        this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                    }
                    else if (parent.def.defName == "SpellOf_WetGround" && comp.spell_WetGround == false && user.story.traits.HasTrait(TorannMagicDefOf.HeartOfFrost))
                    {
                        comp.spell_WetGround = true;
                        comp.MagicData.ReturnMatchingMagicPower(TorannMagicDefOf.TM_WetGround).learned = true;
                        comp.InitializeSpell();
                        this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                    }
                    else if (parent.def.defName == "SpellOf_Blizzard" && comp.spell_Blizzard == false && user.story.traits.HasTrait(TorannMagicDefOf.HeartOfFrost))
                    {
                        comp.spell_Blizzard = true;
                        comp.MagicData.ReturnMatchingMagicPower(TorannMagicDefOf.TM_Blizzard).learned = true;
                        comp.InitializeSpell();
                        this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                    }
                    else if (parent.def.defName == "SpellOf_ChargeBattery" && comp.spell_ChargeBattery == false && user.story.traits.HasTrait(TorannMagicDefOf.StormBorn))
                    {
                        comp.spell_ChargeBattery = true;
                        comp.MagicData.ReturnMatchingMagicPower(TorannMagicDefOf.TM_ChargeBattery).learned = true;
                        comp.InitializeSpell();
                        this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                    }
                    else if (parent.def.defName == "SpellOf_SmokeCloud" && comp.spell_SmokeCloud == false)
                    {
                        comp.spell_SmokeCloud = true;
                        comp.MagicData.ReturnMatchingMagicPower(TorannMagicDefOf.TM_SmokeCloud).learned = true;
                        comp.InitializeSpell();
                        this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                    }
                    else if (parent.def.defName == "SpellOf_Extinguish" && comp.spell_Extinguish == false)
                    {
                        comp.spell_Extinguish = true;
                        comp.InitializeSpell();
                        this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                    }
                    else if (parent.def.defName == "SpellOf_EMP" && comp.spell_EMP == false)
                    {
                        comp.spell_EMP = true;
                        comp.MagicData.ReturnMatchingMagicPower(TorannMagicDefOf.TM_EMP).learned = true;
                        comp.InitializeSpell();
                        this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                    }
                    else if (parent.def.defName == "SpellOf_SummonMinion" && comp.spell_SummonMinion == false)
                    {
                        comp.spell_SummonMinion = true;
                        magicPower = comp.MagicData.MagicPowersS.FirstOrDefault <MagicPower>((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_SummonMinion);
                        comp.AddPawnAbility(TorannMagicDefOf.TM_SummonMinion);
                        if (!user.story.traits.HasTrait(TorannMagicDefOf.ChaosMage))
                        {
                            magicPower.learned = true;
                        }
                        comp.InitializeSpell();
                        this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                    }
                    else if (parent.def.defName == "SpellOf_TransferMana" && comp.spell_TransferMana == false)
                    {
                        comp.spell_TransferMana = true;
                        comp.MagicData.ReturnMatchingMagicPower(TorannMagicDefOf.TM_TransferMana).learned = true;
                        comp.InitializeSpell();
                        this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                    }
                    else if (parent.def.defName == "SpellOf_SiphonMana" && comp.spell_SiphonMana == false)
                    {
                        comp.spell_SiphonMana = true;
                        comp.MagicData.ReturnMatchingMagicPower(TorannMagicDefOf.TM_SiphonMana).learned = true;
                        comp.InitializeSpell();
                        this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                    }
                    else if (parent.def.defName == "SpellOf_RegrowLimb" && comp.spell_RegrowLimb == false && user.story.traits.HasTrait(TorannMagicDefOf.Druid))
                    {
                        comp.spell_RegrowLimb = true;
                        comp.InitializeSpell();
                        magicPower         = comp.MagicData.MagicPowersD.FirstOrDefault <MagicPower>((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_RegrowLimb);
                        magicPower.learned = true;
                        this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                    }
                    else if (parent.def.defName == "SpellOf_EyeOfTheStorm" && comp.spell_EyeOfTheStorm == false && user.story.traits.HasTrait(TorannMagicDefOf.StormBorn))
                    {
                        comp.spell_EyeOfTheStorm = true;
                        magicPower         = comp.MagicData.MagicPowersSB.FirstOrDefault <MagicPower>((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_EyeOfTheStorm);
                        magicPower.learned = true;
                        comp.InitializeSpell();
                        this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                    }
                    else if (parent.def.defName == "SpellOf_ManaShield" && comp.spell_ManaShield == false)
                    {
                        comp.spell_ManaShield = true;
                        comp.MagicData.ReturnMatchingMagicPower(TorannMagicDefOf.TM_ManaShield).learned = true;
                        comp.InitializeSpell();
                        this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                    }
                    else if (parent.def.defName == "SpellOf_FoldReality" && comp.spell_FoldReality == false && user.story.traits.HasTrait(TorannMagicDefOf.Arcanist))
                    {
                        comp.spell_FoldReality = true;
                        comp.MagicData.ReturnMatchingMagicPower(TorannMagicDefOf.TM_Firestorm).learned = true;
                        comp.InitializeSpell();
                        this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                    }
                    else if (parent.def.defName == "SpellOf_Resurrection" && comp.spell_Resurrection == false && user.story.traits.HasTrait(TorannMagicDefOf.Priest))
                    {
                        comp.spell_Resurrection = true;
                        comp.MagicData.ReturnMatchingMagicPower(TorannMagicDefOf.TM_Resurrection).learned = true;
                        comp.InitializeSpell();
                        this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                    }
                    else if (parent.def.defName == "SpellOf_BattleHymn" && comp.spell_BattleHymn == false && user.story.traits.HasTrait(TorannMagicDefOf.TM_Bard))
                    {
                        comp.spell_BattleHymn = true;
                        comp.MagicData.ReturnMatchingMagicPower(TorannMagicDefOf.TM_BattleHymn).learned = true;
                        comp.InitializeSpell();
                        this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                    }
                    else if (parent.def.defName == "SpellOf_HolyWrath" && comp.spell_HolyWrath == false && user.story.traits.HasTrait(TorannMagicDefOf.Paladin))
                    {
                        comp.spell_HolyWrath = true;
                        comp.MagicData.ReturnMatchingMagicPower(TorannMagicDefOf.TM_HolyWrath).learned = true;
                        comp.InitializeSpell();
                        this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                    }
                    else if (parent.def.defName == "SpellOf_LichForm" && comp.spell_LichForm == false && user.story.traits.HasTrait(TorannMagicDefOf.Necromancer))
                    {
                        comp.spell_LichForm = true;
                        comp.MagicData.ReturnMatchingMagicPower(TorannMagicDefOf.TM_LichForm).learned = true;
                        comp.InitializeSpell();
                        this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                    }
                    else if (parent.def.defName == "SpellOf_SummonPoppi" && comp.spell_SummonPoppi == false && user.story.traits.HasTrait(TorannMagicDefOf.Summoner))
                    {
                        comp.spell_SummonPoppi = true;
                        comp.MagicData.ReturnMatchingMagicPower(TorannMagicDefOf.TM_SummonPoppi).learned = true;
                        comp.InitializeSpell();
                        this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                    }
                    else if (parent.def.defName == "SpellOf_Scorn" && comp.spell_Scorn == false && user.story.traits.HasTrait(TorannMagicDefOf.Succubus))
                    {
                        comp.spell_Scorn = true;
                        comp.MagicData.ReturnMatchingMagicPower(TorannMagicDefOf.TM_Scorn).learned = true;
                        comp.InitializeSpell();
                        this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                    }
                    else if (parent.def.defName == "SpellOf_PsychicShock" && comp.spell_PsychicShock == false && user.story.traits.HasTrait(TorannMagicDefOf.Warlock))
                    {
                        comp.spell_PsychicShock = true;
                        comp.MagicData.ReturnMatchingMagicPower(TorannMagicDefOf.TM_PsychicShock).learned = true;
                        comp.InitializeSpell();
                        this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                    }
                    else if (parent.def.defName == "SpellOf_Meteor" && comp.spell_Meteor == false && user.story.traits.HasTrait(TorannMagicDefOf.Geomancer))
                    {
                        comp.spell_Meteor = true;
                        comp.MagicData.ReturnMatchingMagicPower(TorannMagicDefOf.TM_Meteor).learned = true;
                        comp.InitializeSpell();
                        this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                    }
                    else if (parent.def.defName == "SpellOf_OrbitalStrike" && comp.spell_OrbitalStrike == false && user.story.traits.HasTrait(TorannMagicDefOf.Technomancer))
                    {
                        comp.spell_OrbitalStrike = true;
                        comp.MagicData.ReturnMatchingMagicPower(TorannMagicDefOf.TM_OrbitalStrike).learned = true;
                        comp.InitializeSpell();
                        this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                    }
                    else if (parent.def.defName == "SpellOf_CauterizeWound" && comp.spell_CauterizeWound == false && user.story.traits.HasTrait(TorannMagicDefOf.InnerFire))
                    {
                        comp.spell_CauterizeWound = true;
                        comp.MagicData.ReturnMatchingMagicPower(TorannMagicDefOf.TM_CauterizeWound).learned = true;
                        comp.InitializeSpell();
                        this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                    }
                    else if (parent.def.defName == "SpellOf_FertileLands" && comp.spell_FertileLands == false && user.story.traits.HasTrait(TorannMagicDefOf.Druid))
                    {
                        comp.spell_FertileLands = true;
                        comp.MagicData.ReturnMatchingMagicPower(TorannMagicDefOf.TM_FertileLands).learned = true;
                        comp.InitializeSpell();
                        this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                    }
                    else if (parent.def.defName == "SpellOf_SpellMending" && comp.spell_SpellMending == false)
                    {
                        comp.spell_SpellMending = true;
                        comp.MagicData.ReturnMatchingMagicPower(TorannMagicDefOf.TM_SpellMending).learned = true;
                        comp.InitializeSpell();
                        this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                    }
                    else if (parent.def.defName == "SpellOf_TechnoShield" && comp.MagicData.MagicPowersT.FirstOrDefault <MagicPower>((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_TechnoShield).learned == false && user.story.traits.HasTrait(TorannMagicDefOf.Technomancer))
                    {
                        comp.MagicData.MagicPowersT.FirstOrDefault <MagicPower>((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_TechnoShield).learned = true;
                        comp.AddPawnAbility(TorannMagicDefOf.TM_TechnoShield);
                        this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                    }
                    else if (parent.def.defName == "SpellOf_Sabotage" && comp.MagicData.MagicPowersT.FirstOrDefault <MagicPower>((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_Sabotage).learned == false && user.story.traits.HasTrait(TorannMagicDefOf.Technomancer))
                    {
                        comp.MagicData.MagicPowersT.FirstOrDefault <MagicPower>((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_Sabotage).learned = true;
                        comp.AddPawnAbility(TorannMagicDefOf.TM_Sabotage);
                        this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                    }
                    else if (parent.def.defName == "SpellOf_Overdrive" && comp.MagicData.MagicPowersT.FirstOrDefault <MagicPower>((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_Overdrive).learned == false && user.story.traits.HasTrait(TorannMagicDefOf.Technomancer))
                    {
                        comp.MagicData.MagicPowersT.FirstOrDefault <MagicPower>((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_Overdrive).learned = true;
                        comp.AddPawnAbility(TorannMagicDefOf.TM_Overdrive);
                        this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                    }
                    else if (parent.def.defName == "SpellOf_BloodMoon" && comp.spell_BloodMoon == false && user.story.traits.HasTrait(TorannMagicDefOf.BloodMage))
                    {
                        comp.spell_BloodMoon = true;
                        comp.MagicData.ReturnMatchingMagicPower(TorannMagicDefOf.TM_BloodMoon).learned = true;
                        comp.InitializeSpell();
                        this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                    }
                    else if (parent.def == TorannMagicDefOf.SpellOf_Shapeshift && comp.spell_Shapeshift == false && user.story.traits.HasTrait(TorannMagicDefOf.Enchanter))
                    {
                        comp.spell_Shapeshift = true;
                        comp.MagicData.ReturnMatchingMagicPower(TorannMagicDefOf.TM_Shapeshift).learned = true;
                        comp.InitializeSpell();
                        this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                    }
                    else if (parent.def == TorannMagicDefOf.SpellOf_Blur && comp.spell_Blur == false)
                    {
                        comp.spell_Blur = true;
                        comp.MagicData.ReturnMatchingMagicPower(TorannMagicDefOf.TM_Blur).learned = true;
                        comp.InitializeSpell();
                        this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                    }
                    else if (parent.def == TorannMagicDefOf.SpellOf_BlankMind && comp.spell_BlankMind == false && user.story.traits.HasTrait(TorannMagicDefOf.Enchanter))
                    {
                        comp.spell_BlankMind = true;
                        comp.MagicData.ReturnMatchingMagicPower(TorannMagicDefOf.TM_BlankMind).learned = true;
                        comp.InitializeSpell();
                        this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                    }
                    else if (parent.def == TorannMagicDefOf.SpellOf_DirtDevil && comp.spell_DirtDevil == false)
                    {
                        comp.spell_DirtDevil = true;
                        comp.MagicData.ReturnMatchingMagicPower(TorannMagicDefOf.TM_DirtDevil).learned = true;
                        comp.InitializeSpell();
                        this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                    }
                    else if (parent.def == TorannMagicDefOf.SpellOf_MechaniteReprogramming && comp.spell_MechaniteReprogramming == false && user.story.traits.HasTrait(TorannMagicDefOf.Technomancer))
                    {
                        comp.spell_MechaniteReprogramming = true;
                        comp.MagicData.ReturnMatchingMagicPower(TorannMagicDefOf.TM_MechaniteReprogramming).learned = true;
                        comp.InitializeSpell();
                        this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                    }
                    else if (parent.def == TorannMagicDefOf.SpellOf_ArcaneBolt && comp.spell_ArcaneBolt == false && comp.Pawn.story.DisabledWorkTagsBackstoryAndTraits != WorkTags.Violent)
                    {
                        comp.spell_ArcaneBolt = true;
                        comp.MagicData.ReturnMatchingMagicPower(TorannMagicDefOf.TM_ArcaneBolt).learned = true;
                        comp.InitializeSpell();
                        this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                    }
                    else if (parent.def == TorannMagicDefOf.SpellOf_LightningTrap && comp.spell_LightningTrap == false && comp.Pawn.story.DisabledWorkTagsBackstoryAndTraits != WorkTags.Violent)
                    {
                        comp.spell_LightningTrap = true;
                        comp.MagicData.ReturnMatchingMagicPower(TorannMagicDefOf.TM_LightningTrap).learned = true;
                        comp.InitializeSpell();
                        this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                    }
                    else if (parent.def == TorannMagicDefOf.SpellOf_Invisibility && comp.spell_Invisibility == false)
                    {
                        comp.spell_Invisibility = true;
                        comp.MagicData.ReturnMatchingMagicPower(TorannMagicDefOf.TM_Invisibility).learned = true;
                        comp.InitializeSpell();
                        this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                    }
                    else if (parent.def == TorannMagicDefOf.SpellOf_BriarPatch && comp.spell_BriarPatch == false && user.story.traits.HasTrait(TorannMagicDefOf.Druid))
                    {
                        comp.spell_BriarPatch = true;
                        comp.MagicData.ReturnMatchingMagicPower(TorannMagicDefOf.TM_BriarPatch).learned = true;
                        comp.InitializeSpell();
                        this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                    }
                    else if (parent.def == TorannMagicDefOf.SpellOf_Recall && comp.spell_Recall == false && user.story.traits.HasTrait(TorannMagicDefOf.Chronomancer))
                    {
                        comp.spell_Recall = true;
                        comp.MagicData.ReturnMatchingMagicPower(TorannMagicDefOf.TM_Recall).learned = true;
                        comp.MagicData.MagicPowersStandalone.FirstOrDefault((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_TimeMark).learned = true;
                        comp.InitializeSpell();
                        this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                    }
                    else if (parent.def == TorannMagicDefOf.SpellOf_MageLight && comp.spell_MageLight == false)
                    {
                        comp.spell_MageLight = true;
                        comp.MagicData.ReturnMatchingMagicPower(TorannMagicDefOf.TM_MageLight).learned = true;
                        comp.InitializeSpell();
                        this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                    }
                    else if (parent.def == TorannMagicDefOf.SpellOf_Ignite && comp.spell_Ignite == false)
                    {
                        comp.spell_Ignite = true;
                        comp.MagicData.ReturnMatchingMagicPower(TorannMagicDefOf.TM_Ignite).learned = true;
                        comp.InitializeSpell();
                        this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                    }
                    else if (parent.def == TorannMagicDefOf.SpellOf_SnapFreeze && comp.spell_SnapFreeze == false)
                    {
                        comp.spell_SnapFreeze = true;
                        comp.MagicData.ReturnMatchingMagicPower(TorannMagicDefOf.TM_SnapFreeze).learned = true;
                        comp.InitializeSpell();
                        this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                    }
                    else if (customSkill != null)
                    {
                        comp.MagicData.ReturnMatchingMagicPower(customSkill).learned = true;
                        comp.AddPawnAbility(customSkill);
                        comp.InitializeSpell();
                        this.parent.SplitOff(1).Destroy(DestroyMode.Vanish);
                    }
                    else
                    {
                        Messages.Message("CannotLearnSpell".Translate(), MessageTypeDefOf.RejectInput);
                    }
                }
            }
            else
            {
                Messages.Message("NotMageToLearnSpell".Translate(), MessageTypeDefOf.RejectInput);
            }
        }
예제 #11
0
        public override void DoEffect(Pawn user)
        {
            CompAbilityUserMagic comp = user.GetComp <CompAbilityUserMagic>();
            MagicPower           magicPower;

            if (parent.def != null && (user.story.traits.HasTrait(TorannMagicDefOf.TM_Bard) || user.story.traits.HasTrait(TorannMagicDefOf.Priest) || (user.story.traits.HasTrait(TorannMagicDefOf.Necromancer) || user.story.traits.HasTrait(TorannMagicDefOf.Lich)) || user.story.traits.HasTrait(TorannMagicDefOf.Druid) || parent.def != null && (user.story.traits.HasTrait(TorannMagicDefOf.Summoner) || user.story.traits.HasTrait(TorannMagicDefOf.InnerFire) || user.story.traits.HasTrait(TorannMagicDefOf.HeartOfFrost) || user.story.traits.HasTrait(TorannMagicDefOf.StormBorn) || user.story.traits.HasTrait(TorannMagicDefOf.Arcanist) || user.story.traits.HasTrait(TorannMagicDefOf.Paladin))))
            {
                if (parent.def.defName == "SpellOf_Rain" && comp.spell_Rain == false)
                {
                    comp.spell_Rain = true;
                    magicPower      = comp.MagicData.MagicPowersHoF.FirstOrDefault <MagicPower>((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_Rainmaker);
                    comp.AddPawnAbility(TorannMagicDefOf.TM_Rainmaker);
                    magicPower.learned = true;
                    comp.InitializeSpell();
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_Blink" && comp.spell_Blink == false)
                {
                    comp.spell_Blink = true;
                    magicPower       = comp.MagicData.MagicPowersA.FirstOrDefault <MagicPower>((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_Blink);
                    comp.AddPawnAbility(TorannMagicDefOf.TM_Blink);
                    magicPower.learned = true;
                    comp.InitializeSpell();
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_Teleport" && comp.spell_Teleport == false)
                {
                    comp.spell_Teleport = true;
                    magicPower          = comp.MagicData.MagicPowersA.FirstOrDefault <MagicPower>((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_Teleport);
                    comp.AddPawnAbility(TorannMagicDefOf.TM_Teleport);
                    magicPower.learned = true;
                    comp.InitializeSpell();
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_Heal" && comp.spell_Heal == false)
                {
                    comp.spell_Heal = true;
                    magicPower      = comp.MagicData.MagicPowersP.FirstOrDefault <MagicPower>((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_Heal);
                    comp.AddPawnAbility(TorannMagicDefOf.TM_Heal);
                    magicPower.learned = true;
                    comp.InitializeSpell();
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_Heater" && comp.spell_Heater == false)
                {
                    comp.spell_Heater = true;
                    comp.InitializeSpell();
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_Cooler" && comp.spell_Cooler == false)
                {
                    comp.spell_Cooler = true;
                    comp.InitializeSpell();
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_PowerNode" && comp.spell_PowerNode == false)
                {
                    comp.spell_PowerNode = true;
                    comp.InitializeSpell();
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_Sunlight" && comp.spell_Sunlight == false)
                {
                    comp.spell_Sunlight = true;
                    comp.InitializeSpell();
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_DryGround" && comp.spell_DryGround == false && user.story.traits.HasTrait(TorannMagicDefOf.InnerFire))
                {
                    comp.spell_DryGround = true;
                    comp.InitializeSpell();
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_Firestorm" && comp.spell_Firestorm == false && user.story.traits.HasTrait(TorannMagicDefOf.InnerFire))
                {
                    comp.spell_Firestorm = true;
                    comp.InitializeSpell();
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_WetGround" && comp.spell_WetGround == false && user.story.traits.HasTrait(TorannMagicDefOf.HeartOfFrost))
                {
                    comp.spell_WetGround = true;
                    comp.InitializeSpell();
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_Blizzard" && comp.spell_Blizzard == false && user.story.traits.HasTrait(TorannMagicDefOf.HeartOfFrost))
                {
                    comp.spell_Blizzard = true;
                    comp.InitializeSpell();
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_ChargeBattery" && comp.spell_ChargeBattery == false && user.story.traits.HasTrait(TorannMagicDefOf.StormBorn))
                {
                    comp.spell_ChargeBattery = true;
                    comp.InitializeSpell();
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_SmokeCloud" && comp.spell_SmokeCloud == false)
                {
                    comp.spell_SmokeCloud = true;
                    comp.InitializeSpell();
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_Extinguish" && comp.spell_Extinguish == false)
                {
                    comp.spell_Extinguish = true;
                    comp.InitializeSpell();
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_EMP" && comp.spell_EMP == false)
                {
                    comp.spell_EMP = true;
                    comp.InitializeSpell();
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_SummonMinion" && comp.spell_SummonMinion == false)
                {
                    comp.spell_SummonMinion = true;
                    magicPower = comp.MagicData.MagicPowersS.FirstOrDefault <MagicPower>((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_SummonMinion);
                    comp.AddPawnAbility(TorannMagicDefOf.TM_SummonMinion);
                    magicPower.learned = true;
                    comp.InitializeSpell();
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_TransferMana" && comp.spell_TransferMana == false)
                {
                    comp.spell_TransferMana = true;
                    comp.InitializeSpell();
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_SiphonMana" && comp.spell_SiphonMana == false)
                {
                    comp.spell_SiphonMana = true;
                    comp.InitializeSpell();
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_RegrowLimb" && comp.spell_RegrowLimb == false && user.story.traits.HasTrait(TorannMagicDefOf.Druid))
                {
                    comp.spell_RegrowLimb = true;
                    comp.InitializeSpell();
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_EyeOfTheStorm" && comp.spell_EyeOfTheStorm == false && user.story.traits.HasTrait(TorannMagicDefOf.StormBorn))
                {
                    comp.spell_EyeOfTheStorm = true;
                    magicPower         = comp.MagicData.MagicPowersSB.FirstOrDefault <MagicPower>((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_EyeOfTheStorm);
                    magicPower.learned = true;
                    comp.InitializeSpell();
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_ManaShield" && comp.spell_ManaShield == false)
                {
                    comp.spell_ManaShield = true;
                    comp.InitializeSpell();
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_FoldReality" && comp.spell_FoldReality == false && user.story.traits.HasTrait(TorannMagicDefOf.Arcanist))
                {
                    comp.spell_FoldReality = true;
                    comp.InitializeSpell();
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_Resurrection" && comp.spell_Resurrection == false && user.story.traits.HasTrait(TorannMagicDefOf.Priest))
                {
                    comp.spell_Resurrection = true;
                    comp.InitializeSpell();
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_BattleHymn" && comp.spell_BattleHymn == false && user.story.traits.HasTrait(TorannMagicDefOf.TM_Bard))
                {
                    comp.spell_BattleHymn = true;
                    comp.InitializeSpell();
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_HolyWrath" && comp.spell_HolyWrath == false && user.story.traits.HasTrait(TorannMagicDefOf.Paladin))
                {
                    if (comp.MagicData.magicPowerP.Count < 5)
                    {
                        comp.ClearPowers();
                        Messages.Message("The paladin class for " + user.LabelShort + " has been reset to allow the use of Holy Wrath - please re-assign ability points.", MessageTypeDefOf.NeutralEvent);
                    }
                    comp.spell_HolyWrath = true;
                    comp.InitializeSpell();
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_LichForm" && comp.spell_LichForm == false && user.story.traits.HasTrait(TorannMagicDefOf.Necromancer))
                {
                    if (comp.MagicData.magicPowerN.Count < 6)
                    {
                        comp.ClearPowers();
                        Messages.Message("The necromancer class for " + user.LabelShort + " has been reset to allow the use of Lich Form - please re-assign ability points.", MessageTypeDefOf.NeutralEvent);
                    }
                    comp.spell_LichForm = true;
                    comp.InitializeSpell();
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_SummonPoppi" && comp.spell_SummonPoppi == false && user.story.traits.HasTrait(TorannMagicDefOf.Summoner))
                {
                    if (comp.MagicData.magicPowerS.Count < 5)
                    {
                        comp.ClearPowers();
                        Messages.Message("The summoner class for " + user.LabelShort + " has been reset to allow the use of Summon Poppi - please re-assign ability points.", MessageTypeDefOf.NeutralEvent);
                    }
                    comp.spell_SummonPoppi = true;
                    comp.InitializeSpell();
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_CauterizeWound" && comp.spell_CauterizeWound == false && user.story.traits.HasTrait(TorannMagicDefOf.InnerFire))
                {
                    try
                    {
                        comp.spell_CauterizeWound = true;
                        comp.InitializeSpell();
                        this.parent.Destroy(DestroyMode.Vanish);
                    }
                    catch
                    {
                        comp.ClearPowers();
                        Messages.Message("The magic class for " + user.LabelShort + " has been reset for updates, please reassign skills.", MessageTypeDefOf.NeutralEvent);
                        comp.spell_CauterizeWound = true;
                        comp.InitializeSpell();
                        this.parent.Destroy(DestroyMode.Vanish);
                    }
                }
                else if (parent.def.defName == "SpellOf_FertileLands" && comp.spell_FertileLands == false && user.story.traits.HasTrait(TorannMagicDefOf.Druid))
                {
                    comp.ClearPowers();
                    Messages.Message("The magic class for " + user.LabelShort + " has been reset for updates, please reassign skills.", MessageTypeDefOf.NeutralEvent);
                    comp.spell_FertileLands = true;
                    comp.InitializeSpell();
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_SpellMending" && comp.spell_SpellMending == false)
                {
                    try
                    {
                        comp.spell_SpellMending = true;
                        comp.InitializeSpell();
                        this.parent.Destroy(DestroyMode.Vanish);
                    }
                    catch
                    {
                        comp.ClearPowers();
                        Messages.Message("The magic class for " + user.LabelShort + " has been reset for updates, please reassign skills.", MessageTypeDefOf.NeutralEvent);
                        comp.spell_SpellMending = true;
                        comp.InitializeSpell();
                        this.parent.Destroy(DestroyMode.Vanish);
                    }
                }
                else
                {
                    Messages.Message("CannotLearnSpell".Translate(), MessageTypeDefOf.RejectInput);
                }
            }
            else
            {
                Messages.Message("NotMageToLearnSpell".Translate(), MessageTypeDefOf.RejectInput);
            }
        }
예제 #12
0
        public override void DoEffect(Pawn user)
        {
            CompAbilityUserMagic comp = user.GetComp <CompAbilityUserMagic>();
            MagicPower           magicPower;

            if (parent.def != null && (user.story.traits.HasTrait(TorannMagicDefOf.Priest) || user.story.traits.HasTrait(TorannMagicDefOf.Necromancer) || user.story.traits.HasTrait(TorannMagicDefOf.Druid) || parent.def != null && (user.story.traits.HasTrait(TorannMagicDefOf.Summoner) || user.story.traits.HasTrait(TorannMagicDefOf.InnerFire) || user.story.traits.HasTrait(TorannMagicDefOf.HeartOfFrost) || user.story.traits.HasTrait(TorannMagicDefOf.StormBorn) || user.story.traits.HasTrait(TorannMagicDefOf.Arcanist) || user.story.traits.HasTrait(TorannMagicDefOf.Paladin))))
            {
                if (parent.def.defName == "SpellOf_Rain" && comp.spell_Rain == false)
                {
                    comp.spell_Rain = true;
                    magicPower      = comp.MagicData.MagicPowersHoF.FirstOrDefault <MagicPower>((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_Rainmaker);
                    comp.AddPawnAbility(TorannMagicDefOf.TM_Rainmaker);
                    magicPower.learned = true;
                    comp.InitializeSpell();
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_Blink" && comp.spell_Blink == false)
                {
                    comp.spell_Blink = true;
                    magicPower       = comp.MagicData.MagicPowersA.FirstOrDefault <MagicPower>((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_Blink);
                    comp.AddPawnAbility(TorannMagicDefOf.TM_Blink);
                    magicPower.learned = true;
                    comp.InitializeSpell();
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_Teleport" && comp.spell_Teleport == false)
                {
                    comp.spell_Teleport = true;
                    magicPower          = comp.MagicData.MagicPowersA.FirstOrDefault <MagicPower>((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_Teleport);
                    comp.AddPawnAbility(TorannMagicDefOf.TM_Teleport);
                    magicPower.learned = true;
                    comp.InitializeSpell();
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_Heal" && comp.spell_Heal == false)
                {
                    comp.spell_Heal = true;
                    magicPower      = comp.MagicData.MagicPowersP.FirstOrDefault <MagicPower>((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_Heal);
                    comp.AddPawnAbility(TorannMagicDefOf.TM_Heal);
                    magicPower.learned = true;
                    comp.InitializeSpell();
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_Heater" && comp.spell_Heater == false)
                {
                    comp.spell_Heater = true;
                    comp.InitializeSpell();
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_Cooler" && comp.spell_Cooler == false)
                {
                    comp.spell_Cooler = true;
                    comp.InitializeSpell();
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_PowerNode" && comp.spell_PowerNode == false)
                {
                    comp.spell_PowerNode = true;
                    comp.InitializeSpell();
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_DryGround" && comp.spell_DryGround == false && user.story.traits.HasTrait(TorannMagicDefOf.InnerFire))
                {
                    comp.spell_DryGround = true;
                    comp.InitializeSpell();
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_Firestorm" && comp.spell_Firestorm == false && user.story.traits.HasTrait(TorannMagicDefOf.InnerFire))
                {
                    comp.spell_Firestorm = true;
                    comp.InitializeSpell();
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_WetGround" && comp.spell_WetGround == false && user.story.traits.HasTrait(TorannMagicDefOf.HeartOfFrost))
                {
                    comp.spell_WetGround = true;
                    comp.InitializeSpell();
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_Blizzard" && comp.spell_Blizzard == false && user.story.traits.HasTrait(TorannMagicDefOf.HeartOfFrost))
                {
                    comp.spell_Blizzard = true;
                    comp.InitializeSpell();
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_ChargeBattery" && comp.spell_ChargeBattery == false && user.story.traits.HasTrait(TorannMagicDefOf.StormBorn))
                {
                    comp.spell_ChargeBattery = true;
                    comp.InitializeSpell();
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_SmokeCloud" && comp.spell_SmokeCloud == false)
                {
                    comp.spell_SmokeCloud = true;
                    comp.InitializeSpell();
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_Extinguish" && comp.spell_Extinguish == false)
                {
                    comp.spell_Extinguish = true;
                    comp.InitializeSpell();
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_EMP" && comp.spell_EMP == false)
                {
                    comp.spell_EMP = true;
                    comp.InitializeSpell();
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_SummonMinion" && comp.spell_SummonMinion == false)
                {
                    comp.spell_SummonMinion = true;
                    magicPower = comp.MagicData.MagicPowersS.FirstOrDefault <MagicPower>((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_SummonMinion);
                    comp.AddPawnAbility(TorannMagicDefOf.TM_SummonMinion);
                    magicPower.learned = true;
                    comp.InitializeSpell();
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_TransferMana" && comp.spell_TransferMana == false)
                {
                    comp.spell_TransferMana = true;
                    comp.InitializeSpell();
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_SiphonMana" && comp.spell_SiphonMana == false)
                {
                    comp.spell_SiphonMana = true;
                    comp.InitializeSpell();
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_RegrowLimb" && comp.spell_RegrowLimb == false && user.story.traits.HasTrait(TorannMagicDefOf.Druid))
                {
                    comp.spell_RegrowLimb = true;
                    comp.InitializeSpell();
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_EyeOfTheStorm" && comp.spell_EyeOfTheStorm == false && user.story.traits.HasTrait(TorannMagicDefOf.StormBorn))
                {
                    comp.spell_EyeOfTheStorm = true;
                    magicPower         = comp.MagicData.MagicPowersSB.FirstOrDefault <MagicPower>((MagicPower x) => x.abilityDef == TorannMagicDefOf.TM_EyeOfTheStorm);
                    magicPower.learned = true;
                    comp.InitializeSpell();
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_ManaShield" && comp.spell_ManaShield == false)
                {
                    comp.spell_ManaShield = true;
                    comp.InitializeSpell();
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_FoldReality" && comp.spell_FoldReality == false && user.story.traits.HasTrait(TorannMagicDefOf.Arcanist))
                {
                    comp.spell_FoldReality = true;
                    comp.InitializeSpell();
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else if (parent.def.defName == "SpellOf_Resurrection" && comp.spell_Resurrection == false && user.story.traits.HasTrait(TorannMagicDefOf.Priest))
                {
                    comp.spell_Resurrection = true;
                    comp.InitializeSpell();
                    this.parent.Destroy(DestroyMode.Vanish);
                }
                else
                {
                    Messages.Message("CannotLearnSpell".Translate(), MessageTypeDefOf.RejectInput);
                }
            }
            else
            {
                Messages.Message("NotMageToLearnSpell".Translate(), MessageTypeDefOf.RejectInput);
            }
        }