public override void PostPreApplyDamage(DamageInfo dinfo, out bool absorbed) { bool flag = dinfo.Weapon != null; if (flag) { bool flag2 = !dinfo.Weapon.IsMeleeWeapon && dinfo.WeaponBodyPartGroup == null && GetPawn != null; if (flag2) { bool hasCompActivatableEffect = this.HasCompActivatableEffect; if (hasCompActivatableEffect) { bool?flag3 = new bool?((bool)AccessTools.Method(this.GetActivatableEffect.GetType(), "IsActive", null, null).Invoke(this.GetActivatableEffect, null)); bool flag4 = flag3 == false; if (flag4) { absorbed = false; return; } } float deflectionChance = this.DeflectionChance; CompAbilityUserMagic holder = GetPawn.GetComp <CompAbilityUserMagic>(); if (holder != null && !holder.IsMagicUser) { deflectionChance = 0; } int num = (int)(deflectionChance * 100f); bool flag5 = Rand.Range(1, 100) > num; if (flag5) { absorbed = false; this.lastShotReflected = false; return; } //splicing in TM handling of reflection Thing instigator = dinfo.Instigator; Vector3 drawPos = this.GetPawn.DrawPos; drawPos.x += ((instigator.DrawPos.x - drawPos.x) / 20f) + Rand.Range(-.2f, .2f); drawPos.z += ((instigator.DrawPos.z - drawPos.z) / 20f) + Rand.Range(-.2f, .2f); TM_MoteMaker.ThrowSparkFlashMote(drawPos, this.GetPawn.Map, 2f); Thing thing = new Thing(); thing.def = dinfo.Weapon; if (instigator is Pawn) { Pawn shooterPawn = instigator as Pawn; if (!dinfo.Weapon.IsMeleeWeapon && dinfo.WeaponBodyPartGroup == null) { TM_CopyAndLaunchProjectile.CopyAndLaunchThing(shooterPawn.equipment.PrimaryEq.PrimaryVerb.verbProps.defaultProjectile, this.GetPawn, instigator, shooterPawn, ProjectileHitFlags.IntendedTarget, null); } } //no longer using comp deflector handling //this.ResolveDeflectVerb(); //this.GiveDeflectJob(dinfo); dinfo.SetAmount(0); absorbed = true; // true; return; } } absorbed = false; }
public override void Init() { base.Init(); if (this.SingleMap != null) { List <Thing> allThings = (from x in this.SingleMap.listerThings.AllThings where true select x).ToList <Thing>(); potentialResurrection.Clear(); for (int i = 0; i < allThings.Count; i++) { Thing t = allThings[i]; if (t != null && t is Corpse) { Corpse c = t as Corpse; if (c.InnerPawn.IsColonist && !c.IsDessicated()) { potentialResurrection.Add(c); } } } if (Rand.Chance(.15f)) { Corpse c = this.potentialResurrection.RandomElement(); LocalTargetInfo targ = c; TM_CopyAndLaunchProjectile.CopyAndLaunchThing(ThingDef.Named("Projectile_Resurrection"), c, targ, targ, ProjectileHitFlags.All); } for (int i = 0; i < this.SingleMap.mapPawns.FreeColonistsSpawned.Count; i++) { Pawn p = this.SingleMap.mapPawns.FreeColonistsSpawned[i]; if (TM_Calc.IsPawnInjured(p, 0)) { this.injuredPawns.Add(p); } } foreach (var injuredPawn in injuredPawns) { if (Rand.Chance(.6f)) { HealthUtility.AdjustSeverity(injuredPawn, TorannMagicDefOf.TM_Regeneration_I, 2f); } if (Rand.Chance(.7f)) { HealthUtility.AdjustSeverity(injuredPawn, TorannMagicDefOf.TM_DiseaseImmunityHD, 2f); } } } }
public override void Init() { base.Init(); if (this.SingleMap != null) { List <Thing> allThings = (from x in this.SingleMap.listerThings.AllThings where true select x).ToList <Thing>(); List <Corpse> potentialCorpses = new List <Corpse>(); potentialCorpses.Clear(); potentialResurrection.Clear(); for (int i = 0; i < allThings.Count; i++) { Thing t = allThings[i]; if (t != null && t is Corpse) { Corpse c = t as Corpse; if (c.InnerPawn.IsColonist && !c.IsDessicated()) { potentialResurrection.Add(c); } } } if (Rand.Chance(.15f)) { Corpse c = this.potentialResurrection.RandomElement(); LocalTargetInfo targ = c; TM_CopyAndLaunchProjectile.CopyAndLaunchThing(ThingDef.Named("Projectile_Resurrection"), c, targ, targ, ProjectileHitFlags.All); } for (int i = 0; i < this.SingleMap.mapPawns.FreeColonistsSpawned.Count; i++) { Pawn p = this.SingleMap.mapPawns.FreeColonistsSpawned[i]; if (TM_Calc.IsPawnInjured(p, 0)) { this.injuredPawns.AddDistinct(p); } List <Hediff> healthConditions = null; healthConditions = TM_Calc.GetPawnAfflictions(p); if (healthConditions != null && healthConditions.Count > 0) { bool treatableCondition = false; for (int j = 0; j < healthConditions.Count; j++) { if (healthConditions[j].def.tendable) { treatableCondition = true; } } if (treatableCondition) { diseasedPawns.AddDistinct(p); } } } for (int i = 0; i < injuredPawns.Count; i++) { if (Rand.Chance(.6f)) { HealthUtility.AdjustSeverity(injuredPawns[i], TorannMagicDefOf.TM_Regeneration_I, 2f); } } for (int i = 0; i < injuredPawns.Count; i++) { if (Rand.Chance(.7f)) { HealthUtility.AdjustSeverity(injuredPawns[i], TorannMagicDefOf.TM_DiseaseImmunityHD, 2f); } } } }