public static void PostFix(ref StunHandler __instance, ref int ___EMPAdaptedTicksLeft, DamageInfo dinfo) { var pawn = __instance.parent as Pawn; if (pawn != null && (pawn.Downed || pawn.Dead)) { return; } var Haywire = DefDatabase <DamageDef> .GetNamed("GGHaywireEMP"); if (dinfo.Def != Haywire || !EMPAffects(pawn)) { return; } if (___EMPAdaptedTicksLeft <= 0 || HaywireUtility.Rnd100() < (int)Controller.Settings.HWChance) { __instance.StunFor(Mathf.RoundToInt(dinfo.Amount * 15f), dinfo.Instigator); if (pawn != null && pawn.RaceProps.IsMechanoid) { ___EMPAdaptedTicksLeft = 2000; } HaywireUtility.DoHaywireEffect(pawn); return; } var position = __instance.parent.Position; MoteMaker.ThrowText(new Vector3(position.x + 1f, position.y, position.z + 1f), __instance.parent.Map, "Adapted".Translate(), Color.white); }
public override void PostPostMake() { base.PostPostMake(); if (Props.chargeIntervalTicks > 0) { nextChargeTick = Find.TickManager.TicksGame + Rand.Range(0, Props.chargeIntervalTicks); } stunner = new StunHandler(parent); }
static void Prefix(StunHandler __instance, ref int ticks, ref bool addBattleLog) { if ((__instance.parent as Pawn)?.story?.traits?.HasTrait(GMT_DefOf.GMT_Juggernaut) ?? false) { ticks = 0; // Also hide the stun from the battle log addBattleLog = false; } }
public Vehicle_Turret() { // current spin degree wheelRotation = 0; //Inventory Initialize. It should be moved in constructor //storage = new ThingContainer(this); //allowances = new ThingFilter(); //allowances.SetFromPreset(StorageSettingsPreset.DefaultStockpile); //allowances.SetFromPreset(StorageSettingsPreset.DumpingStockpile); stunner = new StunHandler(this); }
public static void Postfix(StunHandler __instance, DamageInfo dinfo, bool affectedByEMP) { if (dinfo.Def == DamageDefOf.EMP) { var dmgAmount = dinfo.Amount; if (!affectedByEMP) { dmgAmount = Mathf.RoundToInt(dmgAmount * 0.25f); } var newDinfo = new DamageInfo(CE_DamageDefOf.Electrical, dmgAmount, dinfo.Angle, dinfo.Instigator, dinfo.HitPart, dinfo.Weapon, dinfo.Category); __instance.parent.TakeDamage(newDinfo); } }
public static void Postfix(StunHandler __instance, DamageInfo dinfo) { if (dinfo.Def == DamageDefOf.EMP) { var dmgAmount = dinfo.Amount; if (__instance.parent is Pawn p && (p.RaceProps?.IsFlesh ?? false)) { dmgAmount = Mathf.RoundToInt(dmgAmount * 0.25f); } var newDinfo = new DamageInfo(CE_DamageDefOf.Electrical, dmgAmount, 9999, // Hack to avoid double-armor application (EMP damage reduced -> proportional electric damage reduced again) dinfo.Angle, dinfo.Instigator, dinfo.HitPart, dinfo.Weapon, dinfo.Category); __instance.parent.TakeDamage(newDinfo); } }
public override void PostExposeData() { base.PostExposeData(); Scribe_Values.Look(ref lastInterceptTicks, "lastInterceptTicks", -999999); Scribe_Values.Look(ref shutDown, "shutDown", defaultValue: false); Scribe_Values.Look(ref nextChargeTick, "nextChargeTick", -1); Scribe_Deep.Look(ref stunner, "stunner", parent); if (Scribe.mode == LoadSaveMode.PostLoadInit) { if (Props.chargeIntervalTicks > 0 && nextChargeTick <= 0) { nextChargeTick = Find.TickManager.TicksGame + Rand.Range(0, Props.chargeIntervalTicks); } if (stunner == null) { stunner = new StunHandler(parent); } } }
public Building_AirDefense() { this.top = new TurretTop_CustomSize(this); this.stunner = new StunHandler(this); this.nowTarget = null; }
public Pawn_StanceTracker(Pawn newPawn) { this.pawn = newPawn; this.stunner = new StunHandler(this.pawn); }
public Building_SuperWeapon() { this.stunner = new StunHandler(this); // this.type = getType(); }
public static bool Prefix(StunHandler __instance, DamageInfo dinfo, ref int ___EMPAdaptedTicksLeft, ref int ___stunTicksLeft, ref bool ___stunFromEMP) { Pawn pawn = __instance.parent as Pawn; float bodySize = 1.0f; if (pawn != null) { if (pawn.Downed || pawn.Dead) { return(false); } bodySize = pawn.BodySize; } if (dinfo.Def == DamageDefOf.EMP && __instance.parent is Pawn p && !(p.RaceProps?.IsFlesh ?? false)) { if (___EMPAdaptedTicksLeft > 0) { int newStunAdaptedTicks = Mathf.RoundToInt(dinfo.Amount * 45 * bodySize); int newStunTicks = Mathf.RoundToInt(dinfo.Amount * 30); float stunResistChance = ((float)___EMPAdaptedTicksLeft / (float)newStunAdaptedTicks) * 15; if (UnityEngine.Random.value > stunResistChance) { ___EMPAdaptedTicksLeft += Mathf.RoundToInt(dinfo.Amount * 45 * bodySize); if (___stunTicksLeft > 0 && newStunTicks > ___stunTicksLeft) { ___stunTicksLeft = newStunTicks; } else { __instance.StunFor(newStunTicks, dinfo.Instigator, true, true); } } else { MoteMaker.ThrowText(new Vector3((float)__instance.parent.Position.x + 1f, (float)__instance.parent.Position.y, (float)__instance.parent.Position.z + 1f), __instance.parent.Map, "Adapted".Translate(), Color.white, -1f); int adaptationReduction = Mathf.RoundToInt(Mathf.Sqrt(dinfo.Amount * 45)); if (adaptationReduction < ___EMPAdaptedTicksLeft) { ___EMPAdaptedTicksLeft -= adaptationReduction; } else { float adaptationReductionRatio = (adaptationReduction - ___EMPAdaptedTicksLeft) / adaptationReduction; newStunAdaptedTicks = Mathf.RoundToInt(newStunAdaptedTicks * adaptationReductionRatio); newStunTicks = Mathf.RoundToInt(newStunTicks * adaptationReductionRatio); if (___stunTicksLeft > 0 && newStunTicks > ___stunTicksLeft) { ___stunTicksLeft = newStunTicks; } else { __instance.StunFor(newStunTicks, dinfo.Instigator, true, true); } } } } else { __instance.StunFor(Mathf.RoundToInt(dinfo.Amount * 30f), dinfo.Instigator, true, true); ___EMPAdaptedTicksLeft = Mathf.RoundToInt(dinfo.Amount * 45 * bodySize); ___stunFromEMP = true; } } return(true); }
public Pawn_StanceTracker(Pawn newPawn) { pawn = newPawn; stunner = new StunHandler(pawn); }
public WeaponSystem() { this.stunner = new StunHandler(this); }
public Parts_Turret() { this.forcedTarget = TargetInfo.Invalid; this.stunner = new StunHandler((Thing)parent); }