public override void ExposeData() { base.ExposeData(); string reliabilityString; float jamsOn; StatPart_Reliability.GetReliability(this, out reliabilityString, out jamsOn); Scribe_Values.Look <string>(ref reliabilityString, "reliability", "NA", false); }
public override string GetInspectString() { string result = base.GetInspectString(); string reliabilityString; float jamsOn; StatPart_Reliability.GetReliability(this, out reliabilityString, out jamsOn); result += string.Format("\r\nReliability: {0}\r\nChance of jam: {1}%", reliabilityString, jamsOn); return(result); }
protected override bool TryCastShot() { int logcount = 0; bool logging = VerbPropsOG.logging; // logging = true; // bool canDamageWeapon = VerbPropsOG.canDamageWeapon; // float extraWeaponDamage = VerbPropsOG.extraWeaponDamage; bool canJam = VerbPropsOG.canJam; string msg; string lmsg = string.Format("log {0} Reliable:{1}", logcount, Reliable); string reliabilityString; float jamsOn; StatPart_Reliability.GetReliability((ThingDef_GunOG)EquipmentSource, out reliabilityString, out jamsOn); logcount++; if (logging == true) { Log.Message(lmsg); } jamsOn = jamsOn++; float jamRoll = 0; logcount++; lmsg = string.Format("log {0} jamsOn {1}", logcount, jamsOn); if (logging == true) { Log.Message(lmsg); } if (VerbPropsOG.overheat == true) { jamRoll = (Rand.Range(0, 100)); } else { jamRoll = (Rand.Range(0, 1000)) / 10f; } logcount++; lmsg = string.Format("log {0} jamRoll {1}", logcount, jamRoll); if (logging == true) { Log.Message(lmsg); } if (jamRoll < jamsOn && canJam == true) { logcount++; lmsg = string.Format("log {0} VerbPropsOG.overheat {1}", logcount, VerbPropsOG.overheat); if (logging == true) { Log.Message(lmsg); } if (VerbPropsOG.overheat == true) { DamageDef damageDef = projectilePropsCE.damageDef; if (damageDef != null) { lmsg = string.Format("log {0} damageDef is null?:{1}", logcount, projectilePropsCE.damageDef.hediff); if (logging == true) { Log.Message(lmsg); } } HediffDef HediffToAdd = damageDef.hediff; float ArmorPenetration = projectilePropsCE.GetArmorPenetration(EquipmentSource, null); float overheatsOn = VerbPropsOG.overheatsOn; logcount++; lmsg = string.Format("log {0} overheatsOn {1}", logcount, overheatsOn); if (logging == true) { Log.Message(lmsg); } int DamageAmount = 0; float overheatRoll = (Rand.Range(0, 1000)) / 10f; logcount++; lmsg = string.Format("log {0} overheatRoll {1}", logcount, overheatRoll); if (logging == true) { Log.Message(lmsg); } Pawn launcherPawn = CasterPawn; if (overheatRoll < overheatsOn) { DamageAmount = Projectile.projectile.GetDamageAmount(EquipmentSource, null); msg = string.Format("{0}'s {1} critically overheated. ({2}/{3}) causing {4} damage", caster.LabelCap, EquipmentSource.LabelCap, jamRoll, jamsOn, DamageAmount); if (VerbPropsOG.criticaloverheatExplosion == true) { CriticalOverheatExplosion(); } } else { DamageAmount = Projectile.projectile.GetDamageAmount(EquipmentSource, null) / 10; msg = string.Format("{0}'s {1} overheated. ({2}/{3}) causing {4} damage", caster.LabelCap, EquipmentSource.LabelCap, jamRoll, jamsOn, DamageAmount); } bool hashediff = launcherPawn.health.hediffSet.HasHediff(HediffToAdd); logcount++; lmsg = string.Format("log {0} hashediff {1}", logcount, hashediff); if (logging == true) { Log.Message(lmsg); } var overheatOnPawn = launcherPawn?.health?.hediffSet?.GetFirstHediffOfDef(HediffToAdd); logcount++; lmsg = string.Format("log {0} overheatOnPawn {1}", logcount, overheatOnPawn); if (logging == true) { Log.Message(lmsg); } if (hashediff == true) { logcount++; lmsg = string.Format("log {0} overheatOnPawn Severity? {1}", logcount, overheatOnPawn.Severity); if (logging == true) { Log.Message(lmsg); } overheatOnPawn.Severity += DamageAmount; logcount++; lmsg = string.Format("log {0} overheatOnPawn.Severity {1}", logcount, overheatOnPawn.Severity); if (logging == true) { Log.Message(lmsg); } } else { logcount++; lmsg = string.Format("log {0} hashediff {1}", logcount, hashediff); if (logging == true) { Log.Message(lmsg); } logcount++; lmsg = string.Format("log {0} overheatOnPawn null?:{1}", logcount, overheatOnPawn); if (logging == true) { Log.Message(lmsg); } int affected = 0; foreach (var part in launcherPawn.RaceProps.body.AllParts.Where(x => x.def.defName.Contains("Hand") || x.def.defName.Contains("hand"))) { logcount++; lmsg = string.Format("log {0} part.def.hitPoints {1}", logcount, launcherPawn.health.hediffSet.PartIsMissing(part)); if (logging == true) { Log.Message(lmsg); } if (launcherPawn.health.hediffSet.PartIsMissing(part) == false && Rand.Chance(0.5f)) { logcount++; lmsg = string.Format("log {0} part.customLabel {1}", logcount, part.def.hitPoints); if (logging == true) { Log.Message(lmsg); } Hediff hediff = HediffMaker.MakeHediff(HediffToAdd, launcherPawn, null); hediff.Severity = Rand.Range(0, DamageAmount); launcherPawn.health.AddHediff(hediff, part, null); affected++; } } /* */ } Messages.Message(msg, MessageTypeDefOf.NegativeHealthEvent); } else { msg = string.Format("{0}'s {1} had a weapon jam. ({2}/{3})", caster.LabelCap, EquipmentSource.LabelCap, jamRoll, jamsOn); Messages.Message(msg, MessageTypeDefOf.SilentInput); } if (EquipmentSource.HitPoints > 0) { EquipmentSource.HitPoints--; } float defaultCooldownTime = this.verbProps.defaultCooldownTime * 2; return(false); } /* */ if (VerbPropsOG.canDamageWeapon) { if (VerbPropsOG.extraWeaponDamage != 0f) { if (EquipmentSource.HitPoints - (int)VerbPropsOG.extraWeaponDamage >= 0) { EquipmentSource.HitPoints = EquipmentSource.HitPoints - (int)VerbPropsOG.extraWeaponDamage; } else if (EquipmentSource.HitPoints - (int)VerbPropsOG.extraWeaponDamage < 0) { EquipmentSource.HitPoints = 0; } } else { if (EquipmentSource.HitPoints > 0) { EquipmentSource.HitPoints--; } } } bool flag = base.TryCastShot(); if (flag && base.CasterIsPawn) { base.CasterPawn.records.Increment(RecordDefOf.ShotsFired); } bool flag2 = flag && VerbPropsOG.pelletCount - 1 > 0; bool flag3 = flag2; if (flag3) { for (int i = 0; i < VerbPropsOG.pelletCount - 1; i++) { base.TryCastShot(); } } return(flag); }