protected override bool TryCastShot() { bool flag = false; this.TargetsAoE.Clear(); this.UpdateTargets(); MagicPowerSkill pwr = base.CasterPawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Polymorph.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Polymorph_pwr"); MagicPowerSkill ver = base.CasterPawn.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Polymorph.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Polymorph_ver"); verVal = ver.level; pwrVal = pwr.level; CompAbilityUserMagic comp = base.CasterPawn.GetComp <CompAbilityUserMagic>(); this.arcaneDmg = base.CasterPawn.GetComp <CompAbilityUserMagic>().arcaneDmg; this.duration += Mathf.RoundToInt(600 * verVal * this.arcaneDmg); if (base.CasterPawn.story.traits.HasTrait(TorannMagicDefOf.Faceless)) { MightPowerSkill mpwr = base.CasterPawn.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_pwr"); MightPowerSkill mver = base.CasterPawn.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_ver"); pwrVal = mpwr.level; verVal = mver.level; } ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef(); if (settingsRef.AIHardMode && !this.CasterPawn.IsColonist) { verVal = 2; pwrVal = 3; } bool flag2 = this.UseAbilityProps.AbilityTargetCategory != AbilityTargetCategory.TargetAoE && this.TargetsAoE.Count > 1; if (flag2) { this.TargetsAoE.RemoveRange(0, this.TargetsAoE.Count - 1); } for (int i = 0; i < this.TargetsAoE.Count; i++) { Pawn newPawn = this.TargetsAoE[i].Thing as Pawn; if (newPawn != this.CasterPawn) { CompPolymorph compPoly = newPawn.GetComp <CompPolymorph>(); if (compPoly != null && compPoly.Original != null && compPoly.TicksLeft > 0) { compPoly.Temporary = true; compPoly.TicksLeft = 0; } else { float enchantChance = .5f; if (!TM_Calc.IsRobotPawn(newPawn)) { enchantChance = (.5f + (.1f * pwrVal) * TM_Calc.GetSpellSuccessChance(this.CasterPawn, newPawn)); } else { enchantChance = (.0f + (.2f * pwrVal) * TM_Calc.GetSpellSuccessChance(this.CasterPawn, newPawn)); } if (Rand.Chance(enchantChance) && newPawn.GetComp <CompPolymorph>() != null) { FactionDef fDef = null; if (newPawn.Faction != null) { fDef = newPawn.Faction.def; } SpawnThings spawnThing = new SpawnThings(); spawnThing.factionDef = fDef; spawnThing.spawnCount = 1; spawnThing.temporary = false; GetPolyMinMax(newPawn); spawnThing = TM_Action.AssignRandomCreatureDef(spawnThing, this.min, this.max); if (spawnThing.def == null || spawnThing.kindDef == null) { spawnThing.def = ThingDef.Named("Rat"); spawnThing.kindDef = PawnKindDef.Named("Rat"); Log.Message("random creature was null"); } Pawn polymorphedPawn = TM_Action.PolymorphPawn(this.CasterPawn, newPawn, newPawn, spawnThing, newPawn.Position, true, duration, newPawn.Faction); if (polymorphedPawn.Faction != this.CasterPawn.Faction && polymorphedPawn.mindState != null && Rand.Chance(Mathf.Clamp((.2f * this.pwrVal), 0f, .5f))) { polymorphedPawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.Berserk, "wild beast!", true, false, null, true); } if (this.verVal >= 3) { polymorphedPawn.GetComp <CompPolymorph>().Temporary = false; } FleckMaker.ThrowSmoke(newPawn.DrawPos, newPawn.Map, 2); FleckMaker.ThrowMicroSparks(newPawn.DrawPos, newPawn.Map); FleckMaker.ThrowHeatGlow(newPawn.Position, newPawn.Map, 2); newPawn.DeSpawn(); if (polymorphedPawn.IsColonist && !base.CasterPawn.IsColonist) { TM_Action.SpellAffectedPlayerWarning(polymorphedPawn); } } else { MoteMaker.ThrowText(newPawn.DrawPos, newPawn.Map, "TM_ResistedSpell".Translate(), -1); } } } } this.PostCastShot(flag, out flag); return(flag); }
protected override bool TryCastShot() { Pawn caster = base.CasterPawn; CompAbilityUserMagic comp = caster.GetComp <CompAbilityUserMagic>(); verVal = comp.MagicData.MagicPowerSkill_Shapeshift.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Shapeshift_ver").level; pwrVal = comp.MagicData.MagicPowerSkill_Shapeshift.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Shapeshift_pwr").level; effVal = comp.MagicData.MagicPowerSkill_Shapeshift.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Shapeshift_eff").level; this.duration = Mathf.RoundToInt((this.duration + (360 * effVal)) * comp.arcaneDmg); bool flag = caster != null && !caster.Dead; if (flag) { CompPolymorph compPoly = caster.GetComp <CompPolymorph>(); if (compPoly != null && compPoly.Original != null && compPoly.TicksLeft > 0) { compPoly.Temporary = true; compPoly.TicksLeft = 0; } else { FactionDef fDef = TorannMagicDefOf.TM_SummonedFaction; if (caster.Faction != null) { fDef = caster.Faction.def; } SpawnThings spawnThing = new SpawnThings(); spawnThing.factionDef = fDef; spawnThing.spawnCount = 1; spawnThing.temporary = false; GetPolyMinMax(caster); spawnThing = TM_Action.AssignRandomCreatureDef(spawnThing, this.min, this.max); if (spawnThing.def == null || spawnThing.kindDef == null) { spawnThing.def = ThingDef.Named("Rat"); spawnThing.kindDef = PawnKindDef.Named("Rat"); Log.Message("random creature was null"); } Pawn polymorphedPawn = TM_Action.PolymorphPawn(this.CasterPawn, caster, caster, spawnThing, caster.Position, true, duration, caster.Faction); if (this.effVal >= 3) { polymorphedPawn.GetComp <CompPolymorph>().Temporary = false; } MoteMaker.ThrowSmoke(polymorphedPawn.DrawPos, caster.Map, 2); MoteMaker.ThrowMicroSparks(polymorphedPawn.DrawPos, caster.Map); MoteMaker.ThrowHeatGlow(polymorphedPawn.Position, caster.Map, 2); //caster.DeSpawn(); HealthUtility.AdjustSeverity(polymorphedPawn, HediffDef.Named("TM_ShapeshiftHD"), .5f + (1f * pwrVal)); } //SoundInfo info = SoundInfo.InMap(new TargetInfo(caster.Position, caster.Map, false), MaintenanceType.None); //info.pitchFactor = 1.0f; //info.volumeFactor = 1.0f; //TorannMagicDefOf.TM_FastReleaseSD.PlayOneShot(info); //TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_PowerWave"), caster.DrawPos, caster.Map, .8f, .2f, .1f, .1f, 0, 1f, 0, Rand.Chance(.5f) ? 0 : 180); } return(true); }