Exemple #1
0
        public override void ExposeData()
        {
            base.ExposeData();
            string overheatString;
            float  jamsOn;

            StatPart_Overheat.GetOverheat(this, out overheatString, out jamsOn);

            Scribe_Values.Look <string>(ref overheatString, "overheat", "NA", false);
        }
Exemple #2
0
        public override string GetInspectString()
        {
            string result = base.GetInspectString();
            string overheatString;
            float  jamsOn;

            StatPart_Overheat.GetOverheat(this, out overheatString, out jamsOn);

            result += string.Format("\r\nOverheat: {0}\r\nChance of overheat: {1}%", overheatString, jamsOn);
            return(result);
        }
Exemple #3
0
        protected override bool TryCastShot()
        {
            string overheatString;
            float  overheatsOn;

            StatPart_Overheat.GetOverheat((ThingDef_GunOH)EquipmentSource, out overheatString, out overheatsOn);
            float overheatRoll = (Rand.Range(0, 1000)) / 10f;
            //float overheatRoll = Rand.Range(0, 100);
            Pawn launcherPawn = caster as Pawn;

            if (overheatRoll < overheatsOn)
            {
                int DamageAmount = 0;
                if (overheatRoll < overheatsOn * 2)
                {
                    DamageDef damageDef = Projectile.projectile.damageDef;
                    DamageAmount = Projectile.projectile.GetDamageAmount(EquipmentSource, null);
                    float  ArmorPenetration = Projectile.projectile.GetArmorPenetration(EquipmentSource, null);
                    string msg = string.Format("{0}'s {1} critically overheated. ({2}/{3}) causing {4} damage", caster.LabelCap, EquipmentSource.LabelCap, overheatRoll, overheatsOn, DamageAmount);
                    EquipmentSource.HitPoints--;
                    Messages.Message(msg, MessageTypeDefOf.NegativeHealthEvent);

                    var overheatOnPawn = launcherPawn?.health?.hediffSet?.GetFirstHediffOfDef(HediffToAdd);
                    if (overheatOnPawn != null)
                    {
                        overheatOnPawn.Severity += DamageAmount;
                    }
                    else
                    {
                        foreach (var part in launcherPawn.RaceProps.body.AllParts.Where(x => x.def.defName == "Hand"))
                        {
                            Hediff hediff = HediffMaker.MakeHediff(HediffToAdd, launcherPawn, null);
                            hediff.Severity = DamageAmount;
                            launcherPawn.health.AddHediff(hediff, part, null);
                        }
                    }
                }
                else
                {
                    DamageDef damageDef = Projectile.projectile.damageDef;
                    DamageAmount = Projectile.projectile.GetDamageAmount(EquipmentSource, null) / 10;
                    float  ArmorPenetration = Projectile.projectile.GetArmorPenetration(EquipmentSource, null);
                    string msg = string.Format("{0}'s {1} overheated. ({2}/{3}) causing {4} damage", caster.LabelCap, EquipmentSource.LabelCap, overheatRoll, overheatsOn, DamageAmount);
                    EquipmentSource.HitPoints--;
                    Messages.Message(msg, MessageTypeDefOf.NegativeHealthEvent);


                    var overheatOnPawn = launcherPawn?.health?.hediffSet?.GetFirstHediffOfDef(HediffToAdd);
                    if (overheatOnPawn != null)
                    {
                        overheatOnPawn.Severity += DamageAmount;
                    }
                    else
                    {
                        foreach (var part in launcherPawn.RaceProps.body.AllParts.Where(x => x.def.defName == "Hand"))
                        {
                            Hediff hediff = HediffMaker.MakeHediff(HediffToAdd, launcherPawn, null);
                            hediff.Severity = DamageAmount;
                            launcherPawn.health.AddHediff(hediff, part, null);
                        }
                    }
                }
                return(false);
            }
            return(base.TryCastShot());
        }