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); }
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); }
private void RemoveMimicAbility(Verb_UseAbility verbCast) { CompAbilityUserMight mightComp = this.pawn.GetComp <CompAbilityUserMight>(); CompAbilityUserMagic magicComp = this.pawn.GetComp <CompAbilityUserMagic>(); if (mightComp.mimicAbility != null && mightComp.mimicAbility.MainVerb.verbClass == verbCast.verbProps.verbClass) { mightComp.RemovePawnAbility(mightComp.mimicAbility); } if (magicComp.mimicAbility != null && magicComp.mimicAbility.MainVerb.verbClass == verbCast.verbProps.verbClass) { magicComp.RemovePawnAbility(magicComp.mimicAbility); } }
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); }
/// <summary> /// Actions used to perform Chronomancer ability "Recall" /// Loaded in static to allow immediate execution when downed or dead /// </summary> /// <param name="pawn"></param> /// <param name="comp"></param> /// <param name="deathTrigger"></param> public static void DoRecall(Pawn pawn, CompAbilityUserMagic comp, bool deathTrigger) { try { if (ModCheck.Validate.GiddyUp.Core_IsInitialized()) { ModCheck.GiddyUp.ForceDismount(pawn); } } catch { } MoteMaker.ThrowSmoke(pawn.DrawPos, pawn.Map, 1.4f); TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_AlterFate, pawn.DrawPos, pawn.Map, 1.6f, .2f, .1f, .8f, -500, 0, 0, Rand.Range(0, 360)); Effecter RecallFromEffect = TorannMagicDefOf.TM_RecallFromED.Spawn(); RecallFromEffect.Trigger(new TargetInfo(pawn), new TargetInfo(pawn)); RecallFromEffect.Cleanup(); RecallHediffs(pawn, comp); RecallNeeds(pawn, comp); RecallPosition(pawn, comp); ResetPowers(pawn, comp); comp.recallSet = false; comp.recallSpell = false; comp.RemovePawnAbility(TorannMagicDefOf.TM_Recall); TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_AlterFate, pawn.DrawPos, pawn.Map, 1.6f, .2f, .1f, .8f, 500, 0, 0, Rand.Range(0, 360)); Effecter RecallToEffect = TorannMagicDefOf.TM_RecallToED.Spawn(); RecallToEffect.Trigger(new TargetInfo(pawn), new TargetInfo(pawn)); RecallToEffect.Cleanup(); HealthUtility.AdjustSeverity(pawn, TorannMagicDefOf.TM_HediffInvulnerable, .02f); if (pawn.Dead) { ResurrectionUtility.Resurrect(pawn); deathTrigger = true; } if (deathTrigger && Rand.Chance(.5f)) { pawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.Wander_Psychotic); } }
protected override bool TryCastShot() { bool flag = false; CompAbilityUserMagic comp = this.CasterPawn.GetComp <CompAbilityUserMagic>(); if (comp.IsMagicUser) { if (comp.weaponEnchants.Count > 0) { for (int i = 0; i < comp.weaponEnchants.Count; i++) { Pawn dispellingPawn = comp.weaponEnchants[i]; RemoveExistingEnchantment(dispellingPawn); } comp.weaponEnchants.Clear(); comp.RemovePawnAbility(TorannMagicDefOf.TM_DispelEnchantWeapon); } } this.PostCastShot(flag, out flag); return(flag); }
public void PostCastShot(bool inResult) { if (inResult) { List <Apparel> apparel = this.CasterPawn.apparel.WornApparel; if (apparel != null) { for (int i = 0; i < apparel.Count; i++) { Apparel item = apparel[i]; if (item != null && item.def == TorannMagicDefOf.TM_Artifact_OrbOfConviction) { item.SplitOff(1).Destroy(DestroyMode.Vanish); } } } CompAbilityUserMagic comp = this.CasterPawn.GetComp <CompAbilityUserMagic>(); if (comp != null) { comp.RemovePawnAbility(TorannMagicDefOf.TM_Artifact_Conviction); } } }
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 = comp.MagicData.MagicPowerSkill_RaiseUndead.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_RaiseUndead_pwr"); ver = comp.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)) { 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; CompRottable compRottable = corpse.GetComp <CompRottable>(); float rotStage = 0; if (compRottable != null && compRottable.Stage == RotStage.Dessicated) { rotStage = 1f; } if (compRottable != null) { rotStage += compRottable.RotProgressPct; } bool flag_SL = false; if (undeadPawn.def.defName == "SL_Runner" || undeadPawn.def.defName == "SL_Peon" || undeadPawn.def.defName == "SL_Archer" || undeadPawn.def.defName == "SL_Hero") { PawnGenerationRequest pgr = new PawnGenerationRequest(PawnKindDef.Named("Tribesperson"), pawn.Faction, PawnGenerationContext.NonPlayer, -1, true, false, false, false, false, true, 0, false, false, false, false, false, false, false, false, 0, null, 0); Pawn newUndeadPawn = PawnGenerator.GeneratePawn(pgr); GenSpawn.Spawn(newUndeadPawn, corpse.Position, corpse.Map, WipeMode.Vanish); corpse.Strip(); corpse.Destroy(DestroyMode.Vanish); rotStage = 1f; flag_SL = true; undeadPawn = newUndeadPawn; } if (!undeadPawn.def.defName.Contains("ROM_") && undeadPawn.RaceProps.IsFlesh && (undeadPawn.Dead || flag_SL) && undeadPawn.def.thingClass.FullName != "TorannMagic.TMPawnSummoned") { bool wasVampire = false; IEnumerable <ThingDef> enumerable = from hd in DefDatabase <HediffDef> .AllDefs where (def.defName == "ROM_Vampirism") select def; if (enumerable.Count() > 0) { bool hasVampHediff = undeadPawn.health.hediffSet.HasHediff(HediffDef.Named("ROM_Vampirism")) || undeadPawn.health.hediffSet.HasHediff(HediffDef.Named("ROM_GhoulHediff")); if (hasVampHediff) { wasVampire = true; } } if (!wasVampire) { undeadPawn.SetFaction(pawn.Faction); if (undeadPawn.Dead) { ResurrectionUtility.Resurrect(undeadPawn); } raisedPawns++; comp.supportedUndead.Add(undeadPawn); if (undeadPawn.kindDef != null && undeadPawn.kindDef.RaceProps != null && undeadPawn.kindDef.RaceProps.Animal) { RemoveHediffsAddictionsAndPermanentInjuries(undeadPawn); HealthUtility.AdjustSeverity(undeadPawn, TorannMagicDefOf.TM_UndeadAnimalHD, -4f); HealthUtility.AdjustSeverity(undeadPawn, TorannMagicDefOf.TM_UndeadAnimalHD, .5f + ver.level); undeadPawn.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_UndeadAnimalHD).TryGetComp <HediffComp_Undead>().linkedPawn = pawn; HealthUtility.AdjustSeverity(undeadPawn, HediffDef.Named("TM_UndeadStageHD"), -2f); HealthUtility.AdjustSeverity(undeadPawn, HediffDef.Named("TM_UndeadStageHD"), rotStage); if (undeadPawn.training.CanAssignToTrain(TrainableDefOf.Tameness).Accepted) { while (!undeadPawn.training.HasLearned(TrainableDefOf.Tameness)) { undeadPawn.training.Train(TrainableDefOf.Tameness, pawn); } } if (undeadPawn.training.CanAssignToTrain(TrainableDefOf.Obedience).Accepted) { while (!undeadPawn.training.HasLearned(TrainableDefOf.Obedience)) { undeadPawn.training.Train(TrainableDefOf.Obedience, pawn); } } if (undeadPawn.training.CanAssignToTrain(TrainableDefOf.Release).Accepted) { while (!undeadPawn.training.HasLearned(TrainableDefOf.Release)) { undeadPawn.training.Train(TrainableDefOf.Release, pawn); } } if (undeadPawn.training.CanAssignToTrain(TorannMagicDefOf.Haul).Accepted) { while (!undeadPawn.training.HasLearned(TorannMagicDefOf.Haul)) { undeadPawn.training.Train(TorannMagicDefOf.Haul, pawn); } } if (undeadPawn.training.CanAssignToTrain(TorannMagicDefOf.Rescue).Accepted) { while (!undeadPawn.training.HasLearned(TorannMagicDefOf.Rescue)) { undeadPawn.training.Train(TorannMagicDefOf.Rescue, pawn); } } undeadPawn.playerSettings.medCare = MedicalCareCategory.NoMeds; undeadPawn.def.tradeability = Tradeability.None; } else if (undeadPawn.story != null && undeadPawn.story.traits != null && undeadPawn.needs != null && undeadPawn.playerSettings != null) { CompAbilityUserMagic compMagic = undeadPawn.GetComp <CompAbilityUserMagic>(); if (compMagic != null && TM_Calc.IsMagicUser(undeadPawn)) //(compMagic.IsMagicUser && !undeadPawn.story.traits.HasTrait(TorannMagicDefOf.Faceless)) || { compMagic.Initialize(); compMagic.RemovePowers(true); } CompAbilityUserMight compMight = undeadPawn.GetComp <CompAbilityUserMight>(); if (compMight != null && TM_Calc.IsMightUser(undeadPawn)) //compMight.IsMightUser || { compMight.Initialize(); compMight.RemovePowers(true); } RemoveHediffsAddictionsAndPermanentInjuries(undeadPawn); RemovePsylinkAbilities(undeadPawn); HealthUtility.AdjustSeverity(undeadPawn, TorannMagicDefOf.TM_UndeadHD, -4f); HealthUtility.AdjustSeverity(undeadPawn, TorannMagicDefOf.TM_UndeadHD, .5f + ver.level); undeadPawn.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_UndeadHD).TryGetComp <HediffComp_Undead>().linkedPawn = pawn; HealthUtility.AdjustSeverity(undeadPawn, HediffDef.Named("TM_UndeadStageHD"), -2f); HealthUtility.AdjustSeverity(undeadPawn, HediffDef.Named("TM_UndeadStageHD"), rotStage); RedoSkills(undeadPawn, pawn.health.hediffSet.HasHediff(HediffDef.Named("TM_LichHD"))); if (undeadPawn.story.traits.HasTrait(TorannMagicDefOf.ChaosMage)) { compMagic.RemovePawnAbility(TorannMagicDefOf.TM_ChaosTradition); } RemoveTraits(undeadPawn, undeadPawn.story.traits.allTraits); undeadPawn.story.traits.GainTrait(new Trait(TraitDef.Named("Undead"), 0, false)); undeadPawn.story.traits.GainTrait(new Trait(TraitDef.Named("Psychopath"), 0, false)); undeadPawn.needs.AddOrRemoveNeedsAsAppropriate(); RemoveClassHediff(undeadPawn); if (undeadPawn.health.hediffSet.HasHediff(HediffDef.Named("DeathAcidifier"))) { Hediff hd = undeadPawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("DeathAcidifier")); undeadPawn.health.RemoveHediff(hd); } //Color undeadColor = new Color(.2f, .4f, 0); //undeadPawn.story.hairColor = undeadColor; //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); } } } else { Messages.Message("Vampiric powers have prevented undead reanimation of " + undeadPawn.LabelShort, MessageTypeDefOf.RejectInput); } } } else if (corpseThing is Pawn) { Pawn undeadPawn = corpseThing as Pawn; if (undeadPawn != pawn && !TM_Calc.IsNecromancer(undeadPawn) && TM_Calc.IsUndead(corpseThing as Pawn)) { RemoveHediffsAddictionsAndPermanentInjuries(undeadPawn); TM_MoteMaker.ThrowPoisonMote(curCell.ToVector3Shifted(), map, .6f); } } } z++; } } if (raisedPawns > pwr.level + 1) { i = targets.Count(); } } }
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); }
protected override IEnumerable <Toil> MakeNewToils() { bool flag; yield return(Toils_Misc.ThrowColonistAttackingMote(TargetIndex.A)); Verb_UseAbility curJob = this.pawn.CurJob.verbToUse as Verb_UseAbility; if (base.TargetA.HasThing) { flag = (!base.GetActor().IsFighting() ? true : !curJob.UseAbilityProps.canCastInMelee); if (flag) { Toil toil = Toils_Combat.GotoCastPosition(TargetIndex.A, false); yield return(toil); toil = null; } } if (this.Context == AbilityContext.Player) { Find.Targeter.targetingVerb = curJob; } Pawn targetPawn = null; if (this.TargetThingA != null) { targetPawn = TargetThingA as Pawn; } if (targetPawn != null) { //yield return Toils_Combat.CastVerb(TargetIndex.A, false); Toil combatToil = new Toil(); combatToil.FailOnDestroyedOrNull(TargetIndex.A); combatToil.FailOnDespawnedOrNull(TargetIndex.A); //combatToil.FailOnDowned(TargetIndex.A); //CompAbilityUserMagic comp = this.pawn.GetComp<CompAbilityUserMagic>(); this.duration = (int)((curJob.verbProps.warmupTime * 60) * this.pawn.GetStatValue(StatDefOf.AimingDelayFactor, false)); //JobDriver curDriver = this.pawn.jobs.curDriver; combatToil.initAction = delegate { arg_45_0 = combatToil.actor.jobs.curJob.verbToUse; if (this.pawn.RaceProps.Humanlike) { if (this.pawn.story.traits.HasTrait(TorannMagicDefOf.Faceless)) { CompAbilityUserMight mightComp = this.pawn.GetComp <CompAbilityUserMight>(); CompAbilityUserMagic magicComp = this.pawn.GetComp <CompAbilityUserMagic>(); if (mightComp.mimicAbility != null && mightComp.mimicAbility.MainVerb.verbClass == arg_45_0.verbProps.verbClass) { mightComp.RemovePawnAbility(mightComp.mimicAbility); } if (magicComp.mimicAbility != null && magicComp.mimicAbility.MainVerb.verbClass == arg_45_0.verbProps.verbClass) { magicComp.RemovePawnAbility(magicComp.mimicAbility); } } } LocalTargetInfo target = combatToil.actor.jobs.curJob.GetTarget(TargetIndex.A); // bool canFreeIntercept2 = false; arg_45_0.TryStartCastOn(target, false, false); using (IEnumerator <Hediff> enumerator = this.pawn.health.hediffSet.GetHediffs <Hediff>().GetEnumerator()) { while (enumerator.MoveNext()) { Hediff rec = enumerator.Current; if (rec.def == TorannMagicDefOf.TM_PossessionHD || rec.def == TorannMagicDefOf.TM_DisguiseHD || rec.def == TorannMagicDefOf.TM_DisguiseHD_I || rec.def == TorannMagicDefOf.TM_DisguiseHD_II || rec.def == TorannMagicDefOf.TM_DisguiseHD_III) { this.pawn.health.RemoveHediff(rec); } } } }; combatToil.tickAction = delegate { if (Find.TickManager.TicksGame % 12 == 0) { TM_MoteMaker.ThrowCastingMote(pawn.DrawPos, pawn.Map, Rand.Range(1.2f, 2f)); } this.duration--; }; combatToil.AddFinishAction(delegate { if (this.duration <= 5) { curJob.Ability.PostAbilityAttempt(); } }); //if (combatToil.actor.CurJob != this.job) //{ // curDriver.ReadyForNextToil(); //} combatToil.defaultCompleteMode = ToilCompleteMode.FinishedBusy; yield return(combatToil); //Toil toil2 = new Toil() //{ // initAction = () => // { // if (curJob.UseAbilityProps.isViolent) // { // JobDriver_CastAbilityVerb.CheckForAutoAttack(this.pawn); // } // }, // defaultCompleteMode = ToilCompleteMode.Instant //}; //yield return toil2; //Toil toil1 = new Toil() //{ // initAction = () => curJob.Ability.PostAbilityAttempt(), // defaultCompleteMode = ToilCompleteMode.Instant //}; //yield return toil1; } else { if ((pawn.Position - TargetLocA).LengthHorizontal < curJob.verbProps.range) { if (TargetLocA.IsValid && TargetLocA.InBounds(pawn.Map) && !TargetLocA.Fogged(pawn.Map) && TargetLocA.Walkable(pawn.Map)) { ShootLine shootLine; bool validTarg = curJob.TryFindShootLineFromTo(pawn.Position, TargetLocA, out shootLine); if (validTarg) { //yield return Toils_Combat.CastVerb(TargetIndex.A, false); //Toil toil2 = new Toil() //{ // initAction = () => // { // if (curJob.UseAbilityProps.isViolent) // { // JobDriver_CastAbilityVerb.CheckForAutoAttack(this.pawn); // } // }, // defaultCompleteMode = ToilCompleteMode.Instant //}; //yield return toil2; this.duration = (int)((curJob.verbProps.warmupTime * 60) * this.pawn.GetStatValue(StatDefOf.AimingDelayFactor, false)); Toil toil = new Toil(); toil.initAction = delegate { arg_45_0 = toil.actor.jobs.curJob.verbToUse; if (this.pawn.RaceProps.Humanlike) { if (this.pawn.story.traits.HasTrait(TorannMagicDefOf.Faceless)) { CompAbilityUserMight mightComp = this.pawn.GetComp <CompAbilityUserMight>(); CompAbilityUserMagic magicComp = this.pawn.GetComp <CompAbilityUserMagic>(); if (mightComp.mimicAbility != null && mightComp.mimicAbility.MainVerb.verbClass == arg_45_0.verbProps.verbClass) { mightComp.RemovePawnAbility(mightComp.mimicAbility); } if (magicComp.mimicAbility != null && magicComp.mimicAbility.MainVerb.verbClass == arg_45_0.verbProps.verbClass) { magicComp.RemovePawnAbility(magicComp.mimicAbility); } } } LocalTargetInfo target = toil.actor.jobs.curJob.GetTarget(TargetIndex.A); bool canFreeIntercept2 = false; arg_45_0.TryStartCastOn(target, false, canFreeIntercept2); using (IEnumerator <Hediff> enumerator = this.pawn.health.hediffSet.GetHediffs <Hediff>().GetEnumerator()) { while (enumerator.MoveNext()) { Hediff rec = enumerator.Current; if (rec.def == TorannMagicDefOf.TM_PossessionHD || rec.def == TorannMagicDefOf.TM_DisguiseHD || rec.def == TorannMagicDefOf.TM_DisguiseHD_I || rec.def == TorannMagicDefOf.TM_DisguiseHD_II || rec.def == TorannMagicDefOf.TM_DisguiseHD_III) { this.pawn.health.RemoveHediff(rec); } } } }; toil.tickAction = delegate { if (Find.TickManager.TicksGame % 12 == 0) { TM_MoteMaker.ThrowCastingMote(pawn.DrawPos, pawn.Map, Rand.Range(1.2f, 2f)); } this.duration--; }; toil.AddFinishAction(delegate { if (this.duration <= 5) { curJob.Ability.PostAbilityAttempt(); } }); toil.defaultCompleteMode = ToilCompleteMode.FinishedBusy; yield return(toil); //Toil toil1 = new Toil() //{ // initAction = () => curJob.Ability.PostAbilityAttempt(), // defaultCompleteMode = ToilCompleteMode.Instant //}; //yield return toil1; } else { //No LoS if (pawn.IsColonist) { Messages.Message("TM_OutOfLOS".Translate(new object[] { pawn.LabelShort }), MessageTypeDefOf.RejectInput); } } } } else { if (pawn.IsColonist) { //out of range Messages.Message("TM_OutOfRange".Translate(), MessageTypeDefOf.RejectInput); } } } }
protected override bool TryCastShot() { bool result = false; if (this.currentTarget != null && base.CasterPawn != null && this.currentTarget.Thing is Pawn) { Pawn targetPawn = this.currentTarget.Thing as Pawn; if (targetPawn.RaceProps.Humanlike) { CompAbilityUserMagic magicPawn = targetPawn.GetComp <CompAbilityUserMagic>(); CompAbilityUserMight mightPawn = targetPawn.GetComp <CompAbilityUserMight>(); bool copyMagic = false; bool copyMight = false; if (magicPawn != null && magicPawn.IsMagicUser) { copyMagic = true; } if (mightPawn != null && mightPawn.IsMightUser) { copyMight = true; } if (copyMight && copyMagic && Rand.Chance(.5f)) { copyMagic = false; } TMAbilityDef tempAbility = null; CompAbilityUserMight mightComp = this.CasterPawn.GetComp <CompAbilityUserMight>(); CompAbilityUserMagic magicComp = this.CasterPawn.GetComp <CompAbilityUserMagic>(); if (copyMagic) { tempAbility = TM_Calc.GetCopiedMagicAbility(targetPawn, base.CasterPawn); if (tempAbility != null) { if (mightComp.mimicAbility != null) { if (mightComp.mimicAbility.manaCost > 0) { MagicPower mp = magicComp.MagicData.AllMagicPowers.FirstOrDefault((MagicPower x) => x.abilityDef == mightComp.mimicAbility); if (mp != null) { mp.autocast = false; } } else if (mightComp.mimicAbility.staminaCost > 0) { MightPower mp = mightComp.MightData.AllMightPowers.FirstOrDefault((MightPower x) => x.abilityDef == mightComp.mimicAbility); if (mp != null) { mp.autocast = false; } } mightComp.RemovePawnAbility(mightComp.mimicAbility); } mightComp.mimicAbility = tempAbility; mightComp.AddPawnAbility(tempAbility); } else { //invalid target Messages.Message("TM_MimicFailed".Translate( this.CasterPawn.LabelShort ), MessageTypeDefOf.RejectInput); } } else if (copyMight) { tempAbility = TM_Calc.GetCopiedMightAbility(targetPawn, base.CasterPawn); if (tempAbility != null) { if (mightComp.mimicAbility != null) { if (mightComp.mimicAbility.manaCost > 0) { MagicPower mp = magicComp.MagicData.AllMagicPowers.FirstOrDefault((MagicPower x) => x.abilityDef == mightComp.mimicAbility); if (mp != null) { mp.autocast = false; } } else if (mightComp.mimicAbility.staminaCost > 0) { MightPower mp = mightComp.MightData.AllMightPowers.FirstOrDefault((MightPower x) => x.abilityDef == mightComp.mimicAbility); if (mp != null) { mp.autocast = false; } } mightComp.RemovePawnAbility(mightComp.mimicAbility); } if (magicComp.mimicAbility != null) { magicComp.RemovePawnAbility(magicComp.mimicAbility); } mightComp.mimicAbility = tempAbility; mightComp.AddPawnAbility(tempAbility); } else { //invalid target Messages.Message("TM_MimicFailed".Translate( this.CasterPawn.LabelShort ), MessageTypeDefOf.RejectInput); } } } } else { Log.Warning("failed to TryCastShot"); } this.burstShotsLeft = 0; return(result); }
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); } }
protected override bool TryCastShot() { bool result = false; if (this.currentTarget != null && base.CasterPawn != null && this.currentTarget.Thing is Pawn) { Pawn targetPawn = this.currentTarget.Thing as Pawn; if (targetPawn.RaceProps.Humanlike) { CompAbilityUserMagic magicPawn = targetPawn.GetComp <CompAbilityUserMagic>(); CompAbilityUserMight mightPawn = targetPawn.GetComp <CompAbilityUserMight>(); TMAbilityDef tempAbility = null; CompAbilityUserMight mightComp = this.CasterPawn.GetComp <CompAbilityUserMight>(); CompAbilityUserMagic magicComp = this.CasterPawn.GetComp <CompAbilityUserMagic>(); if (magicPawn.IsMagicUser) { if (targetPawn.story.traits.HasTrait(TorannMagicDefOf.Arcanist)) { for (int i = 0; i < 5; i++) { int rnd = Rand.RangeInclusive(0, 3); if (rnd == 0 && magicPawn.MagicData.MagicPowersA[rnd].learned) { int level = magicPawn.MagicData.MagicPowersA[rnd].level; switch (level) { case 0: tempAbility = TorannMagicDefOf.TM_Shadow; break; case 1: tempAbility = TorannMagicDefOf.TM_Shadow_I; break; case 2: tempAbility = TorannMagicDefOf.TM_Shadow_II; break; case 3: tempAbility = TorannMagicDefOf.TM_Shadow_III; break; } i = 5; } else if (rnd == 1 && magicPawn.MagicData.MagicPowersA[rnd].learned && !magicPawn.Pawn.story.WorkTagIsDisabled(WorkTags.Violent)) { int level = magicPawn.MagicData.MagicPowersA[rnd].level; switch (level) { case 0: tempAbility = TorannMagicDefOf.TM_MagicMissile; break; case 1: tempAbility = TorannMagicDefOf.TM_MagicMissile_I; break; case 2: tempAbility = TorannMagicDefOf.TM_MagicMissile_II; break; case 3: tempAbility = TorannMagicDefOf.TM_MagicMissile_III; break; } i = 5; } else if (rnd == 2 && magicPawn.MagicData.MagicPowersA[rnd].learned) { int level = magicPawn.MagicData.MagicPowersA[rnd].level; switch (level) { case 0: tempAbility = TorannMagicDefOf.TM_Blink; break; case 1: tempAbility = TorannMagicDefOf.TM_Blink_I; break; case 2: tempAbility = TorannMagicDefOf.TM_Blink_II; break; case 3: tempAbility = TorannMagicDefOf.TM_Blink_III; break; } i = 5; } else if (rnd == 3 && magicPawn.MagicData.MagicPowersA[rnd].learned) { int level = magicPawn.MagicData.MagicPowersA[rnd].level; switch (level) { case 0: tempAbility = TorannMagicDefOf.TM_Summon; break; case 1: tempAbility = TorannMagicDefOf.TM_Summon_I; break; case 2: tempAbility = TorannMagicDefOf.TM_Summon_II; break; case 3: tempAbility = TorannMagicDefOf.TM_Summon_III; break; } i = 5; } } } else if (targetPawn.story.traits.HasTrait(TorannMagicDefOf.StormBorn)) { for (int i = 0; i < 5; i++) { int rnd = Rand.RangeInclusive(0, 3); if (rnd == 0 && magicPawn.MagicData.MagicPowersSB[rnd].learned) { int level = magicPawn.MagicData.MagicPowersSB[rnd].level; switch (level) { case 0: tempAbility = TorannMagicDefOf.TM_AMP; break; case 1: tempAbility = TorannMagicDefOf.TM_AMP_I; break; case 2: tempAbility = TorannMagicDefOf.TM_AMP_II; break; case 3: tempAbility = TorannMagicDefOf.TM_AMP_III; break; } i = 5; } else if (rnd == 1 && magicPawn.MagicData.MagicPowersSB[rnd].learned && !magicPawn.Pawn.story.WorkTagIsDisabled(WorkTags.Violent)) { tempAbility = TorannMagicDefOf.TM_LightningBolt; i = 5; } else if (rnd == 2 && magicPawn.MagicData.MagicPowersSB[rnd].learned && !magicPawn.Pawn.story.WorkTagIsDisabled(WorkTags.Violent)) { tempAbility = TorannMagicDefOf.TM_LightningCloud; i = 5; } else if (rnd == 3 && magicPawn.MagicData.MagicPowersSB[rnd].learned && !magicPawn.Pawn.story.WorkTagIsDisabled(WorkTags.Violent)) { tempAbility = TorannMagicDefOf.TM_LightningStorm; i = 5; } } } else if (targetPawn.story.traits.HasTrait(TorannMagicDefOf.InnerFire)) { for (int i = 0; i < 5; i++) { int rnd = Rand.RangeInclusive(0, 3); if (rnd == 0 && magicPawn.MagicData.MagicPowersIF[rnd].learned) { int level = magicPawn.MagicData.MagicPowersIF[rnd].level; switch (level) { case 0: tempAbility = TorannMagicDefOf.TM_RayofHope; break; case 1: tempAbility = TorannMagicDefOf.TM_RayofHope_I; break; case 2: tempAbility = TorannMagicDefOf.TM_RayofHope_II; break; case 3: tempAbility = TorannMagicDefOf.TM_RayofHope_III; break; } i = 5; } else if (rnd == 1 && magicPawn.MagicData.MagicPowersIF[rnd].learned && !magicPawn.Pawn.story.WorkTagIsDisabled(WorkTags.Violent)) { tempAbility = TorannMagicDefOf.TM_Firebolt; i = 5; } else if (rnd == 2 && magicPawn.MagicData.MagicPowersIF[rnd].learned && !magicPawn.Pawn.story.WorkTagIsDisabled(WorkTags.Violent)) { tempAbility = TorannMagicDefOf.TM_Fireclaw; i = 5; } else if (rnd == 3 && magicPawn.MagicData.MagicPowersIF[rnd].learned && !magicPawn.Pawn.story.WorkTagIsDisabled(WorkTags.Violent)) { tempAbility = TorannMagicDefOf.TM_Fireball; i = 5; } } } else if (targetPawn.story.traits.HasTrait(TorannMagicDefOf.HeartOfFrost)) { for (int i = 0; i < 5; i++) { int rnd = Rand.RangeInclusive(0, 4); if (rnd == 0 && magicPawn.MagicData.MagicPowersHoF[rnd].learned) { int level = magicPawn.MagicData.MagicPowersHoF[rnd].level; switch (level) { case 0: tempAbility = TorannMagicDefOf.TM_Soothe; break; case 1: tempAbility = TorannMagicDefOf.TM_Soothe_I; break; case 2: tempAbility = TorannMagicDefOf.TM_Soothe_II; break; case 3: tempAbility = TorannMagicDefOf.TM_Soothe_III; break; } i = 5; } else if (rnd == 1 && magicPawn.MagicData.MagicPowersHoF[rnd].learned) { tempAbility = TorannMagicDefOf.TM_Rainmaker; i = 5; } else if (rnd == 2 && magicPawn.MagicData.MagicPowersHoF[rnd].learned && !magicPawn.Pawn.story.WorkTagIsDisabled(WorkTags.Violent)) { tempAbility = TorannMagicDefOf.TM_Icebolt; i = 5; } else if (rnd == 3 && magicPawn.MagicData.MagicPowersHoF[rnd].learned && !magicPawn.Pawn.story.WorkTagIsDisabled(WorkTags.Violent)) { int level = magicPawn.MagicData.MagicPowersHoF[rnd].level; switch (level) { case 0: tempAbility = TorannMagicDefOf.TM_FrostRay; break; case 1: tempAbility = TorannMagicDefOf.TM_FrostRay_I; break; case 2: tempAbility = TorannMagicDefOf.TM_FrostRay_II; break; case 3: tempAbility = TorannMagicDefOf.TM_FrostRay_III; break; } i = 5; } else if (rnd == 4 && magicPawn.MagicData.MagicPowersHoF[rnd].learned && !magicPawn.Pawn.story.WorkTagIsDisabled(WorkTags.Violent)) { tempAbility = TorannMagicDefOf.TM_Snowball; i = 5; } } } else if (targetPawn.story.traits.HasTrait(TorannMagicDefOf.Druid)) { for (int i = 0; i < 5; i++) { int rnd = Rand.RangeInclusive(0, 3); if (rnd == 0 && magicPawn.MagicData.MagicPowersD[rnd].learned && !magicPawn.Pawn.story.WorkTagIsDisabled(WorkTags.Violent)) { tempAbility = TorannMagicDefOf.TM_Poison; i = 5; } else if (rnd == 1 && magicPawn.MagicData.MagicPowersD[rnd].learned) { int level = magicPawn.MagicData.MagicPowersD[rnd].level; switch (level) { case 0: tempAbility = TorannMagicDefOf.TM_SootheAnimal; break; case 1: tempAbility = TorannMagicDefOf.TM_SootheAnimal_I; break; case 2: tempAbility = TorannMagicDefOf.TM_SootheAnimal_II; break; case 3: tempAbility = TorannMagicDefOf.TM_SootheAnimal_III; break; } i = 5; } else if (rnd == 2 && magicPawn.MagicData.MagicPowersD[rnd].learned) { tempAbility = TorannMagicDefOf.TM_Regenerate; i = 5; } else if (rnd == 3 && magicPawn.MagicData.MagicPowersD[rnd].learned) { tempAbility = TorannMagicDefOf.TM_CureDisease; i = 5; } } } else if (targetPawn.story.traits.HasTrait(TorannMagicDefOf.Necromancer)) { for (int i = 0; i < 5; i++) { int rnd = Rand.RangeInclusive(1, 3); if (rnd == 1 && magicPawn.MagicData.MagicPowersN[rnd].learned && !magicPawn.Pawn.story.WorkTagIsDisabled(WorkTags.Violent)) { int level = magicPawn.MagicData.MagicPowersN[rnd].level; switch (level) { case 0: tempAbility = TorannMagicDefOf.TM_DeathMark; break; case 1: tempAbility = TorannMagicDefOf.TM_DeathMark_I; break; case 2: tempAbility = TorannMagicDefOf.TM_DeathMark_II; break; case 3: tempAbility = TorannMagicDefOf.TM_DeathMark_III; break; } i = 5; } else if (rnd == 2 && magicPawn.MagicData.MagicPowersN[rnd].learned && !magicPawn.Pawn.story.WorkTagIsDisabled(WorkTags.Violent)) { tempAbility = TorannMagicDefOf.TM_FogOfTorment; i = 5; } else if (rnd == 3 && magicPawn.MagicData.MagicPowersN[rnd + 1].learned && !magicPawn.Pawn.story.WorkTagIsDisabled(WorkTags.Violent)) { int level = magicPawn.MagicData.MagicPowersN[rnd + 1].level; switch (level) { case 0: tempAbility = TorannMagicDefOf.TM_CorpseExplosion; break; case 1: tempAbility = TorannMagicDefOf.TM_CorpseExplosion_I; break; case 2: tempAbility = TorannMagicDefOf.TM_CorpseExplosion_II; break; case 3: tempAbility = TorannMagicDefOf.TM_CorpseExplosion_III; break; } i = 5; } } } else if (targetPawn.story.traits.HasTrait(TorannMagicDefOf.Paladin)) { for (int i = 0; i < 5; i++) { int rnd = Rand.RangeInclusive(0, 3); if (rnd == 1 && magicPawn.MagicData.MagicPowersP[rnd].learned) { int level = magicPawn.MagicData.MagicPowersP[rnd].level; switch (level) { case 0: tempAbility = TorannMagicDefOf.TM_Shield; break; case 1: tempAbility = TorannMagicDefOf.TM_Shield_I; break; case 2: tempAbility = TorannMagicDefOf.TM_Shield_II; break; case 3: tempAbility = TorannMagicDefOf.TM_Shield_III; break; } i = 5; } else if (rnd == 0 && magicPawn.MagicData.MagicPowersP[rnd].learned) { tempAbility = TorannMagicDefOf.TM_Heal; i = 5; } else if (rnd == 2 && magicPawn.MagicData.MagicPowersP[rnd].learned && !magicPawn.Pawn.story.WorkTagIsDisabled(WorkTags.Violent)) { tempAbility = TorannMagicDefOf.TM_ValiantCharge; i = 5; } else if (rnd == 3 && magicPawn.MagicData.MagicPowersP[rnd].learned && !magicPawn.Pawn.story.WorkTagIsDisabled(WorkTags.Violent)) { tempAbility = TorannMagicDefOf.TM_Overwhelm; i = 5; } } } else if (targetPawn.story.traits.HasTrait(TorannMagicDefOf.Priest)) { for (int i = 0; i < 5; i++) { int rnd = Rand.RangeInclusive(0, 3); if (rnd == 3 && magicPawn.MagicData.MagicPowersPR[rnd].learned) { int level = magicPawn.MagicData.MagicPowersPR[rnd].level; switch (level) { case 0: tempAbility = TorannMagicDefOf.TM_BestowMight; break; case 1: tempAbility = TorannMagicDefOf.TM_BestowMight_I; break; case 2: tempAbility = TorannMagicDefOf.TM_BestowMight_II; break; case 3: tempAbility = TorannMagicDefOf.TM_BestowMight_III; break; } i = 5; } else if (rnd == 2 && magicPawn.MagicData.MagicPowersPR[rnd].learned) { int level = magicPawn.MagicData.MagicPowersPR[rnd].level; switch (level) { case 0: tempAbility = TorannMagicDefOf.TM_HealingCircle; break; case 1: tempAbility = TorannMagicDefOf.TM_HealingCircle_I; break; case 2: tempAbility = TorannMagicDefOf.TM_HealingCircle_II; break; case 3: tempAbility = TorannMagicDefOf.TM_HealingCircle_III; break; } i = 5; } else if (rnd == 1 && magicPawn.MagicData.MagicPowersPR[rnd].learned) { tempAbility = TorannMagicDefOf.TM_Purify; i = 5; } else if (rnd == 0 && magicPawn.MagicData.MagicPowersPR[rnd].learned) { tempAbility = TorannMagicDefOf.TM_AdvancedHeal; i = 5; } } } else if (targetPawn.story.traits.HasTrait(TorannMagicDefOf.Summoner)) { for (int i = 0; i < 5; i++) { int rnd = Rand.RangeInclusive(1, 3); if (rnd == 1 && magicPawn.MagicData.MagicPowersS[rnd].learned) { tempAbility = TorannMagicDefOf.TM_SummonPylon; i = 5; } else if (rnd == 2 && magicPawn.MagicData.MagicPowersS[rnd].learned) { tempAbility = TorannMagicDefOf.TM_SummonExplosive; i = 5; } else if (rnd == 3 && magicPawn.MagicData.MagicPowersS[rnd].learned) { tempAbility = TorannMagicDefOf.TM_SummonElemental; i = 5; } } } else if (targetPawn.story.traits.HasTrait(TorannMagicDefOf.TM_Bard)) { int level = magicPawn.MagicData.MagicPowersB[3].level; switch (level) { case 0: tempAbility = TorannMagicDefOf.TM_Lullaby; break; case 1: tempAbility = TorannMagicDefOf.TM_Lullaby_I; break; case 2: tempAbility = TorannMagicDefOf.TM_Lullaby_II; break; case 3: tempAbility = TorannMagicDefOf.TM_Lullaby_III; break; } } else if (targetPawn.story.traits.HasTrait(TorannMagicDefOf.Warlock)) { for (int i = 0; i < 5; i++) { int rnd = Rand.RangeInclusive(1, 3); if (rnd == 1 && magicPawn.MagicData.MagicPowersWD[rnd].learned && !magicPawn.Pawn.story.WorkTagIsDisabled(WorkTags.Violent)) { int level = magicPawn.MagicData.MagicPowersWD[rnd].level; switch (level) { case 0: tempAbility = TorannMagicDefOf.TM_ShadowBolt; break; case 1: tempAbility = TorannMagicDefOf.TM_ShadowBolt_I; break; case 2: tempAbility = TorannMagicDefOf.TM_ShadowBolt_II; break; case 3: tempAbility = TorannMagicDefOf.TM_ShadowBolt_III; break; } i = 5; } else if (rnd == 2 && magicPawn.MagicData.MagicPowersWD[rnd].learned && !magicPawn.Pawn.story.WorkTagIsDisabled(WorkTags.Violent)) { tempAbility = TorannMagicDefOf.TM_Dominate; i = 5; } else if (rnd == 3 && magicPawn.MagicData.MagicPowersWD[rnd].learned) { int level = magicPawn.MagicData.MagicPowersWD[rnd].level; switch (level) { case 0: tempAbility = TorannMagicDefOf.TM_Repulsion; break; case 1: tempAbility = TorannMagicDefOf.TM_Repulsion_I; break; case 2: tempAbility = TorannMagicDefOf.TM_Repulsion_II; break; case 3: tempAbility = TorannMagicDefOf.TM_Repulsion_III; break; } i = 5; } } } else if (targetPawn.story.traits.HasTrait(TorannMagicDefOf.Succubus)) { for (int i = 0; i < 5; i++) { int rnd = Rand.RangeInclusive(1, 3); if (rnd == 1 && magicPawn.MagicData.MagicPowersSD[rnd].learned && !magicPawn.Pawn.story.WorkTagIsDisabled(WorkTags.Violent)) { int level = magicPawn.MagicData.MagicPowersSD[rnd].level; switch (level) { case 0: tempAbility = TorannMagicDefOf.TM_ShadowBolt; break; case 1: tempAbility = TorannMagicDefOf.TM_ShadowBolt_I; break; case 2: tempAbility = TorannMagicDefOf.TM_ShadowBolt_II; break; case 3: tempAbility = TorannMagicDefOf.TM_ShadowBolt_III; break; } i = 5; } else if (rnd == 2 && magicPawn.MagicData.MagicPowersSD[rnd].learned && !magicPawn.Pawn.story.WorkTagIsDisabled(WorkTags.Violent)) { tempAbility = TorannMagicDefOf.TM_Dominate; i = 5; } else if (rnd == 3 && magicPawn.MagicData.MagicPowersSD[rnd].learned) { int level = magicPawn.MagicData.MagicPowersSD[rnd].level; switch (level) { case 0: tempAbility = TorannMagicDefOf.TM_Attraction; break; case 1: tempAbility = TorannMagicDefOf.TM_Attraction_I; break; case 2: tempAbility = TorannMagicDefOf.TM_Attraction_II; break; case 3: tempAbility = TorannMagicDefOf.TM_Attraction_III; break; } i = 5; } } } else if (targetPawn.story.traits.HasTrait(TorannMagicDefOf.Geomancer)) { for (int i = 0; i < 5; i++) { int rnd = Rand.RangeInclusive(0, 2); if (rnd == 2) { rnd = 3; } if (rnd == 0 && magicPawn.MagicData.MagicPowersG[rnd].learned) { tempAbility = TorannMagicDefOf.TM_Stoneskin; i = 5; } else if (rnd == 1 && magicPawn.MagicData.MagicPowersG[rnd].learned) { int level = magicPawn.MagicData.MagicPowersPR[rnd].level; switch (level) { case 0: tempAbility = TorannMagicDefOf.TM_Encase; break; case 1: tempAbility = TorannMagicDefOf.TM_Encase_I; break; case 2: tempAbility = TorannMagicDefOf.TM_Encase_II; break; case 3: tempAbility = TorannMagicDefOf.TM_Encase_III; break; } i = 5; } else if (rnd == 3 && magicPawn.MagicData.MagicPowersG[rnd].learned && !magicPawn.Pawn.story.WorkTagIsDisabled(WorkTags.Violent)) { tempAbility = TorannMagicDefOf.TM_EarthernHammer; i = 5; } } } if (tempAbility != null) { if (mightComp.mimicAbility != null) { mightComp.RemovePawnAbility(mightComp.mimicAbility); } if (magicComp.mimicAbility != null) { magicComp.RemovePawnAbility(magicComp.mimicAbility); } mightComp.mimicAbility = tempAbility; mightComp.AddPawnAbility(tempAbility); } else { //invalid target Messages.Message("TM_MimicFailed".Translate(new object[] { this.CasterPawn.LabelShort }), MessageTypeDefOf.RejectInput); } } else if (mightPawn.IsMightUser) { if (targetPawn.story.traits.HasTrait(TorannMagicDefOf.Gladiator) && !magicPawn.Pawn.story.WorkTagIsDisabled(WorkTags.Violent)) { int rnd = Rand.RangeInclusive(0, 1); if (rnd == 0) { int level = mightPawn.MightData.MightPowersG[2].level; switch (level) { case 0: tempAbility = TorannMagicDefOf.TM_Grapple; break; case 1: tempAbility = TorannMagicDefOf.TM_Grapple_I; break; case 2: tempAbility = TorannMagicDefOf.TM_Grapple_II; break; case 3: tempAbility = TorannMagicDefOf.TM_Grapple_III; break; } } else { tempAbility = TorannMagicDefOf.TM_Whirlwind; } } else if (targetPawn.story.traits.HasTrait(TorannMagicDefOf.TM_Sniper) && !magicPawn.Pawn.story.WorkTagIsDisabled(WorkTags.Violent)) { int rnd = Rand.RangeInclusive(0, 2); if (rnd == 0) { tempAbility = TorannMagicDefOf.TM_AntiArmor; } else if (rnd == 1) { int level = mightPawn.MightData.MightPowersS[2].level; switch (level) { case 0: tempAbility = TorannMagicDefOf.TM_DisablingShot; break; case 1: tempAbility = TorannMagicDefOf.TM_DisablingShot_I; break; case 2: tempAbility = TorannMagicDefOf.TM_DisablingShot_II; break; case 3: tempAbility = TorannMagicDefOf.TM_DisablingShot_III; break; } } else { tempAbility = TorannMagicDefOf.TM_Headshot; } } else if (targetPawn.story.traits.HasTrait(TorannMagicDefOf.Bladedancer) && !magicPawn.Pawn.story.WorkTagIsDisabled(WorkTags.Violent)) { int rnd = Rand.RangeInclusive(0, 2); if (rnd == 0) { tempAbility = TorannMagicDefOf.TM_SeismicSlash; } else if (rnd == 1) { int level = mightPawn.MightData.MightPowersB[4].level; switch (level) { case 0: tempAbility = TorannMagicDefOf.TM_PhaseStrike; break; case 1: tempAbility = TorannMagicDefOf.TM_PhaseStrike_I; break; case 2: tempAbility = TorannMagicDefOf.TM_PhaseStrike_II; break; case 3: tempAbility = TorannMagicDefOf.TM_PhaseStrike_III; break; } } else { tempAbility = TorannMagicDefOf.TM_BladeSpin; } } else if (targetPawn.story.traits.HasTrait(TorannMagicDefOf.Ranger) && !magicPawn.Pawn.story.WorkTagIsDisabled(WorkTags.Violent)) { int rnd = Rand.RangeInclusive(0, 1); if (rnd == 0) { int level = mightPawn.MightData.MightPowersB[4].level; switch (level) { case 0: tempAbility = TorannMagicDefOf.TM_ArrowStorm; break; case 1: tempAbility = TorannMagicDefOf.TM_ArrowStorm_I; break; case 2: tempAbility = TorannMagicDefOf.TM_ArrowStorm_II; break; case 3: tempAbility = TorannMagicDefOf.TM_ArrowStorm_III; break; } } else { tempAbility = TorannMagicDefOf.TM_PoisonTrap; } } else if (targetPawn.story.traits.HasTrait(TorannMagicDefOf.TM_Psionic)) { int rnd = Rand.RangeInclusive(0, 3); if ((rnd == 0 || rnd == 3) && !magicPawn.Pawn.story.WorkTagIsDisabled(WorkTags.Violent)) { int level = mightPawn.MightData.MightPowersP[1].level; switch (level) { case 0: tempAbility = TorannMagicDefOf.TM_PsionicBlast; break; case 1: tempAbility = TorannMagicDefOf.TM_PsionicBlast_I; break; case 2: tempAbility = TorannMagicDefOf.TM_PsionicBlast_II; break; case 3: tempAbility = TorannMagicDefOf.TM_PsionicBlast_III; break; } } else if (rnd == 1 && !magicPawn.Pawn.story.WorkTagIsDisabled(WorkTags.Violent)) { tempAbility = TorannMagicDefOf.TM_PsionicDash; } else { int level = mightPawn.MightData.MightPowersP[3].level; switch (level) { case 0: tempAbility = TorannMagicDefOf.TM_PsionicBarrier; break; case 1: tempAbility = TorannMagicDefOf.TM_PsionicBarrier_Projected; break; } } } else if (targetPawn.story.traits.HasTrait(TorannMagicDefOf.Faceless)) { } if (tempAbility != null) { if (mightComp.mimicAbility != null) { mightComp.RemovePawnAbility(mightComp.mimicAbility); } if (magicComp.mimicAbility != null) { magicComp.RemovePawnAbility(magicComp.mimicAbility); } mightComp.mimicAbility = tempAbility; mightComp.AddPawnAbility(tempAbility); } else { //invalid target Messages.Message("TM_MimicFailed".Translate(new object[] { this.CasterPawn.LabelShort }), MessageTypeDefOf.RejectInput); } } } } else { Log.Warning("failed to TryCastShot"); } this.burstShotsLeft = 0; return(result); }
public void ClearSpellRemnants(CompAbilityUserMagic comp) { if (comp != null) { if (comp.Pawn.equipment != null && comp.Pawn.equipment.Primary != null && comp.Pawn.equipment.Primary.def.defName.Contains("TM_TechnoWeapon_Base")) { comp.technoWeaponThing = null; comp.technoWeaponThingDef = null; comp.technoWeaponDefNum = -1; if (!comp.Pawn.equipment.Primary.DestroyedOrNull()) { comp.Pawn.equipment.Primary.Destroy(DestroyMode.Vanish); } } if (comp.MagicUserLevel >= 20) { PawnAbility pa = comp.AbilityData.Powers.FirstOrDefault((PawnAbility x) => x.Def == TorannMagicDefOf.TM_TeachMagic); if (pa != null) { pa.CooldownTicksLeft = Mathf.RoundToInt(pa.MaxCastingTicks * comp.coolDown); } } if (comp.earthSprites != IntVec3.Invalid || comp.earthSpriteType != 0) { comp.earthSpriteType = 0; comp.earthSpriteMap = null; comp.earthSprites = IntVec3.Invalid; comp.earthSpritesInArea = false; } if (comp.stoneskinPawns != null && comp.stoneskinPawns.Count > 0) { for (int i = 0; i < comp.stoneskinPawns.Count; i++) { if (comp.stoneskinPawns[i].health.hediffSet.HasHediff(TorannMagicDefOf.TM_StoneskinHD)) { Hediff hd = comp.stoneskinPawns[i].health?.hediffSet?.GetFirstHediffOfDef(TorannMagicDefOf.TM_StoneskinHD); if (hd != null) { comp.stoneskinPawns[i].health.RemoveHediff(hd); } } } } if (comp.weaponEnchants != null && comp.weaponEnchants.Count > 0) { for (int i = 0; i < comp.weaponEnchants.Count; i++) { Verb_DispelEnchantWeapon.RemoveExistingEnchantment(comp.weaponEnchants[i]); } comp.weaponEnchants.Clear(); comp.RemovePawnAbility(TorannMagicDefOf.TM_DispelEnchantWeapon); } if (comp.enchanterStones != null && comp.enchanterStones.Count > 0) { for (int i = 0; i < comp.enchanterStones.Count; i++) { if (comp.enchanterStones[i].Map != null) { TM_Action.TransmutateEffects(comp.enchanterStones[i].Position, comp.Pawn); } comp.enchanterStones[i].Destroy(DestroyMode.Vanish); } comp.enchanterStones.Clear(); comp.RemovePawnAbility(TorannMagicDefOf.TM_DismissEnchanterStones); } if (comp.summonedSentinels != null && comp.summonedSentinels.Count > 0) { for (int i = 0; i < comp.summonedSentinels.Count; i++) { if (comp.summonedSentinels[i].Map != null) { TM_Action.TransmutateEffects(comp.summonedSentinels[i].Position, comp.Pawn); } comp.summonedSentinels[i].Destroy(DestroyMode.Vanish); } comp.summonedSentinels.Clear(); comp.RemovePawnAbility(TorannMagicDefOf.TM_ShatterSentinel); } if (comp.soulBondPawn != null) { comp.soulBondPawn = null; } } }