Пример #1
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);
            }
        }
Пример #2
0
        protected override void Impact(Thing hitThing)
        {
            Map map = base.Map;

            base.Impact(hitThing);
            ThingDef def         = this.def;
            int      raisedPawns = 0;

            Pawn pawn   = this.launcher as Pawn;
            Pawn victim = hitThing as Pawn;
            CompAbilityUserMagic comp = pawn.GetComp <CompAbilityUserMagic>();

            pwr = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_RaiseUndead.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_RaiseUndead_pwr");
            ver = pawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_RaiseUndead.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_RaiseUndead_ver");

            Thing corpseThing = null;

            IntVec3 curCell;
            IEnumerable <IntVec3> targets = GenRadial.RadialCellsAround(base.Position, this.def.projectile.explosionRadius, true);

            for (int i = 0; i < targets.Count(); i++)
            {
                curCell = targets.ToArray <IntVec3>()[i];

                TM_MoteMaker.ThrowPoisonMote(curCell.ToVector3Shifted(), map, .3f);
                if (curCell.InBounds(map) && curCell.IsValid)
                {
                    Corpse       corpse = null;
                    List <Thing> thingList;
                    thingList = curCell.GetThingList(map);
                    int z = 0;
                    while (z < thingList.Count)
                    {
                        corpseThing = thingList[z];
                        if (corpseThing != null)
                        {
                            bool validator = corpseThing is Corpse;
                            if (validator)
                            {
                                corpse = corpseThing as Corpse;
                                Pawn undeadPawn = corpse.InnerPawn;
                                if (undeadPawn.RaceProps.IsFlesh)
                                {
                                    undeadPawn.SetFaction(pawn.Faction);
                                    ResurrectionUtility.Resurrect(undeadPawn);
                                    raisedPawns++;
                                    if (!undeadPawn.kindDef.RaceProps.Animal && undeadPawn.kindDef.RaceProps.Humanlike)
                                    {
                                        HealthUtility.AdjustSeverity(undeadPawn, TorannMagicDefOf.TM_UndeadHD, -4f);
                                        HealthUtility.AdjustSeverity(undeadPawn, TorannMagicDefOf.TM_UndeadHD, .5f + ver.level);
                                        RemoveTraits(undeadPawn, undeadPawn.story.traits.allTraits);
                                        RedoSkills(undeadPawn);
                                        undeadPawn.story.traits.GainTrait(new Trait(TraitDef.Named("Undead"), 0, false));
                                        undeadPawn.needs.AddOrRemoveNeedsAsAppropriate();
                                        CompAbilityUserMagic undeadComp = undeadPawn.GetComp <CompAbilityUserMagic>();
                                        if (undeadComp.IsMagicUser)
                                        {
                                            undeadComp.ClearPowers();
                                        }
                                        List <SkillRecord> skills = undeadPawn.skills.skills;
                                        for (int j = 0; j < skills.Count; j++)
                                        {
                                            skills[j].passion = Passion.None;
                                        }
                                        undeadPawn.playerSettings.hostilityResponse = HostilityResponseMode.Attack;
                                        undeadPawn.playerSettings.medCare           = MedicalCareCategory.NoMeds;
                                        for (int h = 0; h < 24; h++)
                                        {
                                            undeadPawn.timetable.SetAssignment(h, TimeAssignmentDefOf.Work);
                                        }
                                    }
                                    if (undeadPawn.kindDef.RaceProps.Animal)
                                    {
                                        HealthUtility.AdjustSeverity(undeadPawn, TorannMagicDefOf.TM_UndeadAnimalHD, -4f);
                                        HealthUtility.AdjustSeverity(undeadPawn, TorannMagicDefOf.TM_UndeadAnimalHD, .5f + ver.level);

                                        if (undeadPawn.RaceProps.TrainableIntelligence == TrainableIntelligenceDefOf.Intermediate)
                                        {
                                            while (!undeadPawn.training.IsCompleted(TrainableDefOf.Obedience))
                                            {
                                                undeadPawn.training.Train(TrainableDefOf.Obedience, pawn);
                                            }
                                            while (!undeadPawn.training.IsCompleted(TrainableDefOf.Release))
                                            {
                                                undeadPawn.training.Train(TrainableDefOf.Release, pawn);
                                            }
                                        }

                                        if (undeadPawn.RaceProps.TrainableIntelligence == TrainableIntelligenceDefOf.Advanced)
                                        {
                                            while (!undeadPawn.training.IsCompleted(TrainableDefOf.Obedience))
                                            {
                                                undeadPawn.training.Train(TrainableDefOf.Obedience, pawn);
                                            }
                                            while (!undeadPawn.training.IsCompleted(TrainableDefOf.Release))
                                            {
                                                undeadPawn.training.Train(TrainableDefOf.Release, pawn);
                                            }
                                            if (undeadPawn.BodySize > .4)
                                            {
                                                while (!undeadPawn.training.IsCompleted(TorannMagicDefOf.Haul))
                                                {
                                                    undeadPawn.training.Train(TorannMagicDefOf.Haul, pawn);
                                                }
                                            }
                                        }
                                        undeadPawn.playerSettings.medCare = MedicalCareCategory.NoMeds;
                                    }
                                }
                            }
                        }
                        z++;
                    }
                }
                if (raisedPawns > pwr.level + 1)
                {
                    i = targets.Count();
                }
            }
        }
Пример #3
0
        public void Reanimate(Pawn undeadPawn, Pawn instigator)
        {
            if (!instigator.Dead && !instigator.Downed)
            {
                MagicPowerSkill ver = instigator.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_RaiseUndead.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_RaiseUndead_ver");
                undeadPawn.SetFaction(instigator.Faction);
                IntVec3 screamPos = undeadPawn.Position;
                screamPos.z += 2;
                screamPos.x -= 1;
                TM_MoteMaker.ThrowScreamMote(screamPos.ToVector3(), undeadPawn.Map, 2f, 216, 255, 0);

                if (!undeadPawn.kindDef.RaceProps.Animal && undeadPawn.kindDef.RaceProps.Humanlike)
                {
                    HealthUtility.AdjustSeverity(undeadPawn, TorannMagicDefOf.TM_UndeadHD, -4f);
                    HealthUtility.AdjustSeverity(undeadPawn, TorannMagicDefOf.TM_UndeadHD, .5f + ver.level);
                    //RemoveTraits(undeadPawn, undeadPawn.story.traits.allTraits);
                    //RedoSkills(undeadPawn);
                    undeadPawn.story.traits.GainTrait(new Trait(TraitDef.Named("Undead"), 0, false));
                    CompAbilityUserMagic undeadComp = undeadPawn.GetComp <CompAbilityUserMagic>();
                    if (undeadComp.IsMagicUser)
                    {
                        undeadComp.ClearPowers();
                    }
                    List <SkillRecord> skills = undeadPawn.skills.skills;
                    for (int j = 0; j < skills.Count; j++)
                    {
                        skills[j].passion = Passion.None;
                    }
                    undeadPawn.playerSettings.hostilityResponse = HostilityResponseMode.Attack;
                    if (!undeadPawn.IsColonist)
                    {
                        undeadPawn.ClearMind();
                        undeadPawn.mindState.enemyTarget = instigator.TargetCurrentlyAimingAt.Thing;
                        undeadPawn.HostileTo(Faction.OfPlayer);
                        undeadPawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.ManhunterPermanent, null, true, false, null);
                    }
                }
                if (undeadPawn.kindDef.RaceProps.Animal)
                {
                    HealthUtility.AdjustSeverity(undeadPawn, TorannMagicDefOf.TM_UndeadAnimalHD, -4f);
                    HealthUtility.AdjustSeverity(undeadPawn, TorannMagicDefOf.TM_UndeadAnimalHD, .5f + ver.level);

                    //if (undeadPawn.RaceProps.TrainableIntelligence == TrainableIntelligenceDefOf.Intermediate)
                    //{
                    //    while (!undeadPawn.training.IsCompleted(TrainableDefOf.Obedience))
                    //    {
                    //        undeadPawn.training.Train(TrainableDefOf.Obedience, instigator);
                    //    }
                    //    while (!undeadPawn.training.IsCompleted(TrainableDefOf.Release))
                    //    {
                    //        undeadPawn.training.Train(TrainableDefOf.Release, instigator);
                    //    }
                    //}

                    //if (undeadPawn.RaceProps.TrainableIntelligence == TrainableIntelligenceDefOf.Advanced)
                    //{
                    //    while (!undeadPawn.training.IsCompleted(TrainableDefOf.Obedience))
                    //    {
                    //        undeadPawn.training.Train(TrainableDefOf.Obedience, instigator);
                    //    }
                    //    while (!undeadPawn.training.IsCompleted(TrainableDefOf.Release))
                    //    {
                    //        undeadPawn.training.Train(TrainableDefOf.Release, instigator);
                    //    }
                    //    if (undeadPawn.BodySize > .4)
                    //    {
                    //        while (!undeadPawn.training.IsCompleted(TorannMagicDefOf.Haul))
                    //        {
                    //            undeadPawn.training.Train(TorannMagicDefOf.Haul, instigator);
                    //        }
                    //    }
                    //}
                }
            }
        }