public void Search(Map map) { IntVec3 curCell; IEnumerable <IntVec3> targets = GenRadial.RadialCellsAround(base.Position, this.radius, true); IEnumerable <IntVec3> innerCircle = GenRadial.RadialCellsAround(base.Position, this.innerRing, true); IEnumerable <IntVec3> outerCircle = GenRadial.RadialCellsAround(base.Position, this.outerRing, true); for (int i = innerCircle.Count(); i < outerCircle.Count(); i++) { Pawn pawn = null; curCell = targets.ToArray <IntVec3>()[i]; if (curCell.InBounds(map) && curCell.IsValid) { pawn = curCell.GetFirstPawn(map); } if (pawn != null && (pawn.Faction == caster.Faction || pawn.Faction == null || (pawn.Faction != null && !pawn.Faction.HostileTo(caster.Faction))) && !TM_Calc.IsUndead(pawn)) { Heal(pawn); } if (pawn != null && TM_Calc.IsUndead(pawn)) { TM_Action.DamageUndead(pawn, (10.0f + (float)pwrVal * 3f) * this.arcaneDmg, this.launcher); } } }
public void Search(Map map) { int innerCircleSize = GenRadial.RadialCellsAround(base.Position, this.innerRing, true).Count(); int outerCircleSize = GenRadial.RadialCellsAround(base.Position, this.outerRing, true).Count(); IEnumerable <IntVec3> targets = GenRadial.RadialCellsAround(base.Position, this.radius, true).Skip(innerCircleSize).Take(outerCircleSize - innerCircleSize); foreach (var curCell in targets) { for (int i = innerCircleSize; i < outerCircleSize; i++) { Pawn pawn = null; if (curCell.InBounds(map) && curCell.IsValid) { pawn = curCell.GetFirstPawn(map); } if (pawn != null && (pawn.Faction == caster.Faction || pawn.IsPrisoner || pawn.Faction == null || (pawn.Faction != null && !pawn.Faction.HostileTo(caster.Faction))) && !TM_Calc.IsUndead(pawn)) { Heal(pawn); } if (pawn != null && TM_Calc.IsUndead(pawn)) { TM_Action.DamageUndead(pawn, (10.0f + ((float)pwrVal * 3f)) * this.arcaneDmg, this.launcher); } } } }
protected override bool TryCastShot() { // power affects enumerator //DamageWorker.DamageResult result = DamageWorker.DamageResult.MakeNew(); Pawn caster = this.CasterPawn; CompAbilityUserMagic comp = caster.GetComp <CompAbilityUserMagic>(); pwrVal = caster.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Heal.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Heal_pwr").level; verVal = caster.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Heal.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Heal_ver").level; if (caster.story.traits.HasTrait(TorannMagicDefOf.Priest)) { pwrVal = caster.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_AdvancedHeal.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_AdvancedHeal_pwr").level; verVal = caster.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_AdvancedHeal.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_AdvancedHeal_ver").level; } else if (caster.story.traits.HasTrait(TorannMagicDefOf.Faceless)) { MightPowerSkill mpwr = caster.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_pwr"); MightPowerSkill mver = caster.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_ver"); pwrVal = mpwr.level; verVal = mver.level; } else if (caster.story.traits.HasTrait(TorannMagicDefOf.TM_Wanderer) || (comp.customClass != null && comp.customClass.classMageAbilities.Contains(TorannMagicDefOf.TM_Cantrips))) { int tmpPwrVal = (int)((caster.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Cantrips.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Cantrips_pwr").level) / 5); int tmpVerVal = (int)((caster.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_Cantrips.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_Cantrips_ver").level) / 5); pwrVal = (tmpPwrVal > pwrVal) ? tmpPwrVal : pwrVal; verVal = (tmpVerVal > verVal) ? tmpVerVal : verVal; } Pawn pawn = (Pawn)this.currentTarget; bool flag = pawn != null && !pawn.Dead && !TM_Calc.IsUndead(pawn); bool flagUndead = pawn != null && !pawn.Dead && TM_Calc.IsUndead(pawn); if (flag) { int num = 3 + verVal; using (IEnumerator <BodyPartRecord> enumerator = pawn.health.hediffSet.GetInjuredParts().GetEnumerator()) { while (enumerator.MoveNext()) { BodyPartRecord rec = enumerator.Current; bool flag2 = num > 0; if (flag2) { int num2 = 1 + verVal; ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef(); if (!this.CasterPawn.IsColonist && settingsRef.AIHardMode) { num2 = 5; } IEnumerable <Hediff_Injury> arg_BB_0 = pawn.health.hediffSet.GetHediffs <Hediff_Injury>(); Func <Hediff_Injury, bool> arg_BB_1; arg_BB_1 = ((Hediff_Injury injury) => injury.Part == rec); foreach (Hediff_Injury current in arg_BB_0.Where(arg_BB_1)) { bool flag4 = num2 > 0; if (flag4) { bool flag5 = current.CanHealNaturally() && !current.IsPermanent(); if (flag5) { //current.Heal((float)((int)current.Severity + 1)); if (!this.CasterPawn.IsColonist) { current.Heal(20.0f + (float)pwrVal * 3f); // power affects how much to heal } else { current.Heal((8.0f + (float)pwrVal * 2f) * comp.arcaneDmg); // power affects how much to heal } TM_MoteMaker.ThrowRegenMote(pawn.Position.ToVector3Shifted(), pawn.Map, .6f); TM_MoteMaker.ThrowRegenMote(pawn.Position.ToVector3Shifted(), pawn.Map, .4f); num--; num2--; } } } } } } } if (flagUndead) { for (int i = 0; i < 2 + verVal; i++) { TM_Action.DamageUndead(pawn, (5f + (3f * pwrVal)) * comp.arcaneDmg, this.CasterPawn); } } return(true); }
protected override bool TryCastShot() { Pawn caster = this.CasterPawn; CompAbilityUserMagic comp = caster.GetComp <CompAbilityUserMagic>(); MagicPowerSkill ver = caster.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_ConsumeCorpse.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_ConsumeCorpse_ver"); MagicPowerSkill manaRegen = caster.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_global_regen.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_global_regen_pwr"); Thing undeadThing = this.currentTarget.Thing; if (undeadThing is Pawn) { Pawn undead = (Pawn)undeadThing; bool flag = undead != null && !undead.Dead; if (flag) { if (TM_Calc.IsUndead(undead)) { if (undead.health.hediffSet.HasHediff(TorannMagicDefOf.TM_UndeadHD)) { comp.Mana.CurLevel += (.225f * (1 + (manaRegen.level * .02f) + (ver.level * .07f)) * comp.arcaneDmg); ConsumeHumanoid(undead); if (ver.level > 0) { HealCaster(caster, 2 + ver.level, 2, (5f + ver.level) * comp.arcaneDmg); } undead.Destroy(); } else if (undead.health.hediffSet.HasHediff(TorannMagicDefOf.TM_UndeadAnimalHD)) { comp.Mana.CurLevel += (.18f * (1 + (manaRegen.level * .02f) + (ver.level * .07f)) * comp.arcaneDmg); ConsumeAnimalKind(undead); if (ver.level > 0) { HealCaster(caster, 2, 2, (3 + ver.level) * comp.arcaneDmg); } undead.Destroy(); } else if (undead.def == TorannMagicDefOf.TM_SkeletonLichR) { comp.Mana.CurLevel += (.15f * (1 + (manaRegen.level * .02f) + (ver.level * .07f)) * comp.arcaneDmg); TM_Action.DamageUndead(undead, Rand.Range(10, 20), caster); } else if (undead.def == TorannMagicDefOf.TM_GiantSkeletonR || undead.def == TorannMagicDefOf.TM_SkeletonR) { TM_Action.DamageUndead(undead, Rand.Range(15, 30), caster); } else { TM_Action.DamageUndead(undead, Rand.Range(10, 20), caster); } } else { Messages.Message("TM_CannotUseOnLiving".Translate(), MessageTypeDefOf.RejectInput); } } } IntVec3 target = this.currentTarget.Cell; Thing corpseThing = null; Corpse corpse = null; List <Thing> thingList; thingList = target.GetThingList(caster.Map); int i = 0; while (i < thingList.Count) { corpseThing = thingList[i]; if (corpseThing != null) { bool validator = corpseThing is Corpse; if (validator) { corpse = corpseThing as Corpse; Pawn undeadPawn = corpse.InnerPawn; if ((undeadPawn.RaceProps.IsFlesh || TM_Calc.IsUndead(undeadPawn)) && (!TM_Calc.IsRobotPawn(undeadPawn))) { if (undeadPawn.RaceProps.Humanlike && !undeadPawn.RaceProps.Animal) { if (!corpse.IsNotFresh()) { comp.Mana.CurLevel += (.13f * (1 + (manaRegen.level * .02f) + (ver.level * .07f)) * comp.arcaneDmg); if (caster.needs != null && caster.needs.rest != null) { caster.needs.rest.CurLevel += .3f; } if (caster.needs != null && caster.needs.mood != null) { caster.needs.mood.CurLevel += .3f; } ConsumeHumanoid(corpse); if (ver.level > 0) { HealCaster(caster, 1 + ver.level, 1 + ver.level, (2f + ver.level) * comp.arcaneDmg); } } else { comp.Mana.CurLevel += (.09f * (1 + (manaRegen.level * .02f) + (ver.level * .07f)) * comp.arcaneDmg); ConsumeHumanoid(corpse); } corpse.Destroy(); } else if (undeadPawn.RaceProps.Animal || TM_Calc.IsUndead(undeadPawn)) { if (!corpse.IsNotFresh()) { comp.Mana.CurLevel += (.09f * (1 + (manaRegen.level * .02f) + (ver.level * .07f)) * comp.arcaneDmg); if (caster.needs != null && caster.needs.food != null) { caster.needs.food.CurLevel += .4f; } ConsumeAnimalKind(corpse); if (ver.level > 0) { HealCaster(caster, 1, 1, (2f + ver.level) * comp.arcaneDmg); } } else { comp.Mana.CurLevel += (.07f * (1 + (manaRegen.level * .02f) + (ver.level * .07f)) * comp.arcaneDmg); ConsumeAnimalKind(corpse); } corpse.Destroy(); } else { Messages.Message("TM_CannontConsumeCorpseType".Translate(), MessageTypeDefOf.RejectInput); } } else { Messages.Message("TM_InvalidCorpseType".Translate(), MessageTypeDefOf.RejectInput); } } } i++; } return(false); }
public void GetAffectedPawns(IntVec3 center, Map map) { Pawn victim = null; IEnumerable <IntVec3> targets = GenRadial.RadialCellsAround(center, this.def.projectile.explosionRadius, true); foreach (var curCell in targets) { if (curCell.InBounds(map) && curCell.IsValid) { victim = curCell.GetFirstPawn(map); } if (victim != null && victim.Faction == this.caster.Faction && !victim.Dead) { if (verVal >= 1) { HealthUtility.AdjustSeverity(victim, TorannMagicDefOf.TM_HediffTimedInvulnerable, 1f); Hediff hd = victim.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_HediffTimedInvulnerable); HediffComp_Disappears hdc = hd.TryGetComp <HediffComp_Disappears>(); if (hdc != null) { hdc.ticksToDisappear += 360; } } if (verVal >= 2) { Pawn pawn = victim; bool flag = pawn != null && !pawn.Dead && !TM_Calc.IsUndead(pawn); bool undeadFlag = pawn != null && !pawn.Dead && TM_Calc.IsUndead(pawn); if (flag) { int num = 3; using (IEnumerator <BodyPartRecord> enumerator = pawn.health.hediffSet.GetInjuredParts().GetEnumerator()) { while (enumerator.MoveNext()) { BodyPartRecord rec = enumerator.Current; bool flag2 = num > 0; if (flag2) { int num2 = 1; IEnumerable <Hediff_Injury> arg_BB_0 = pawn.health.hediffSet.GetHediffs <Hediff_Injury>(); Func <Hediff_Injury, bool> arg_BB_1; arg_BB_1 = (Hediff_Injury injury) => injury.Part == rec; foreach (Hediff_Injury current in arg_BB_0.Where(arg_BB_1)) { bool flag4 = num2 > 0; if (flag4) { bool flag5 = current.CanHealNaturally() && !current.IsPermanent(); if (flag5) { //current.Heal((float)((int)current.Severity + 1)); if (!this.caster.IsColonist) { current.Heal(20.0f); // power affects how much to heal } else { current.Heal(5.0f * this.arcaneDmg); // power affects how much to heal } TM_MoteMaker.ThrowRegenMote(pawn.Position.ToVector3Shifted(), pawn.Map, .6f); TM_MoteMaker.ThrowRegenMote(pawn.Position.ToVector3Shifted(), pawn.Map, .4f); num--; num2--; } } } } } } } } if (verVal >= 3) { HealthUtility.AdjustSeverity(victim, HediffDef.Named("BestowMightHD"), 1f); } } if (victim != null && !victim.Dead && TM_Calc.IsUndead(victim)) { TM_Action.DamageUndead(victim, Rand.Range(5f, 12f) * this.arcaneDmg, this.launcher); } } }
protected override bool TryCastShot() { // power affects enumerator // DamageWorker.DamageResult result = DamageWorker.DamageResult.MakeNew(); Pawn caster = this.CasterPawn; CompAbilityUserMagic comp = caster.GetComp <CompAbilityUserMagic>(); MagicPowerSkill pwr = caster.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_AdvancedHeal.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_AdvancedHeal_pwr"); MagicPowerSkill ver = caster.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_AdvancedHeal.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_AdvancedHeal_ver"); pwrVal = pwr.level; verVal = ver.level; if (caster.story.traits.HasTrait(TorannMagicDefOf.Faceless)) { MightPowerSkill mpwr = caster.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_pwr"); MightPowerSkill mver = caster.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_ver"); pwrVal = mpwr.level; verVal = mver.level; } Pawn pawn = (Pawn)this.currentTarget; bool flag = pawn != null && !pawn.Dead && !TM_Calc.IsUndead(pawn); bool undeadFlag = pawn != null && !pawn.Dead && TM_Calc.IsUndead(pawn); if (flag) { int num = 3 + verVal; using (IEnumerator <BodyPartRecord> enumerator = pawn.health.hediffSet.GetInjuredParts().GetEnumerator()) { while (enumerator.MoveNext()) { BodyPartRecord rec = enumerator.Current; bool flag2 = num > 0; if (flag2) { int num2 = 1 + verVal; ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef(); if (!this.CasterPawn.IsColonist && settingsRef.AIHardMode) { num2 = 5; } IEnumerable <Hediff_Injury> arg_BB_0 = pawn.health.hediffSet.GetHediffs <Hediff_Injury>(); Func <Hediff_Injury, bool> arg_BB_1; arg_BB_1 = ((Hediff_Injury injury) => injury.Part == rec); foreach (Hediff_Injury current in arg_BB_0.Where(arg_BB_1)) { bool flag4 = num2 > 0; if (flag4) { bool flag5 = current.CanHealNaturally() && !current.IsPermanent(); if (flag5) { //current.Heal((float)((int)current.Severity + 1)); if (!this.CasterPawn.IsColonist) { current.Heal(30.0f + (float)pwrVal * 3f); // power affects how much to heal } else { current.Heal((14.0f + (float)pwrVal * 3f) * comp.arcaneDmg); // power affects how much to heal } TM_MoteMaker.ThrowRegenMote(pawn.Position.ToVector3Shifted(), pawn.Map, 1f + .2f * pwrVal); TM_MoteMaker.ThrowRegenMote(pawn.Position.ToVector3Shifted(), pawn.Map, .8f + .1f * pwrVal); num--; num2--; } } } using (IEnumerator <Hediff> enumerator1 = pawn.health.hediffSet.GetHediffsTendable().GetEnumerator()) { while (enumerator1.MoveNext()) { if (num > 0) { Hediff rec1 = enumerator1.Current; if (rec1.TendableNow() && rec1.Bleeding && rec1 is Hediff_MissingPart) { Traverse.Create(root: rec1).Field(name: "isFreshInt").SetValue(false); num--; } } } } } } } } if (undeadFlag) { for (int i = 0; i < 2 + verVal; i++) { TM_Action.DamageUndead(pawn, (8.0f + (float)pwrVal * 5f) * comp.arcaneDmg, this.CasterPawn); } } return(true); }
public override void CompPostTick(ref float severityAdjustment) { base.CompPostTick(ref severityAdjustment); if (base.Pawn != null & base.parent != null) { if (!initialized) { initialized = true; this.Initialize(); } } this.age++; if (!this.Pawn.DestroyedOrNull() && !this.Pawn.Dead) { if (age > lastRegen + regenRate) { HealthUtility.AdjustSeverity(base.Pawn, this.Def, -0.3f); this.lastRegen = this.age; Pawn pawn = this.Pawn; TM_MoteMaker.ThrowRegenMote(pawn.DrawPos, pawn.Map, 1f); bool flag = TM_Calc.IsUndead(pawn); if (!flag) { ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef(); int num = 1; // + ver.level; if (settingsRef.AIHardMode && !pawn.IsColonist) { num = 2; } using (IEnumerator <BodyPartRecord> enumerator = pawn.health.hediffSet.GetInjuredParts().GetEnumerator()) { while (enumerator.MoveNext()) { BodyPartRecord rec = enumerator.Current; bool flag2 = num > 0; if (flag2) { int num2 = 1; // + ver.level; if (settingsRef.AIHardMode && !pawn.IsColonist) { num2 = 2; } IEnumerable <Hediff_Injury> arg_BB_0 = pawn.health.hediffSet.GetHediffs <Hediff_Injury>(); Func <Hediff_Injury, bool> arg_BB_1; arg_BB_1 = (Hediff_Injury injury) => injury.Part == rec; foreach (Hediff_Injury current in arg_BB_0.Where(arg_BB_1)) { bool flag4 = num2 > 0; if (flag4) { bool flag5 = current.CanHealNaturally() && !current.IsPermanent(); if (flag5) { if (!pawn.IsColonist) { current.Heal(10f + (1.5f * hediffPwr)); } else { current.Heal(4f + (.5f * hediffPwr)); } num--; num2--; } } } } } } } else { TM_Action.DamageUndead(pawn, 2f + (1f * hediffPwr), null); } } } }