public static void Postfix(ref string __result, Thing target)
        {
            var selectedThing = Find.Selector.SingleSelectedThing;

            if (__result.NullOrEmpty() && selectedThing != null)
            {
                // Create CE Tooltip
                StringBuilder           stringBuilder = new StringBuilder();
                Verb_LaunchProjectileCE verbCE        = null;
                Pawn pawn = selectedThing as Pawn;
                if (pawn != null && pawn != target && pawn.equipment != null &&
                    pawn.equipment.Primary != null && pawn.equipment.PrimaryEq.PrimaryVerb is Verb_LaunchProjectileCE)
                {
                    verbCE = pawn.equipment.PrimaryEq.PrimaryVerb as Verb_LaunchProjectileCE;
                }
                Building_TurretGunCE turret = selectedThing as Building_TurretGunCE;
                if (turret != null && turret != target)
                {
                    verbCE = turret.AttackVerb as Verb_LaunchProjectileCE;
                }
                if (verbCE != null)
                {
                    stringBuilder.AppendLine();
                    stringBuilder.Append("ShotBy".Translate(selectedThing.LabelShort, selectedThing) + ":\n");
                    string obstructReport;
                    if (verbCE.CanHitTarget(target, out obstructReport))
                    {
                        ShiftVecReport report = verbCE.ShiftVecReportFor(target);
                        stringBuilder.Append(report.GetTextReadout());
                    }
                    else
                    {
                        stringBuilder.Append("CannotHit".Translate());
                        if (!obstructReport.NullOrEmpty())
                        {
                            stringBuilder.Append(" " + obstructReport + ".");
                        }
                    }
                    Pawn pawn2 = target as Pawn;
                    if (pawn2 != null && pawn2.Faction == null && !pawn2.InAggroMentalState)
                    {
                        float manhunterOnDamageChance;
                        if (verbCE.IsMeleeAttack)
                        {
                            manhunterOnDamageChance = PawnUtility.GetManhunterOnDamageChance(pawn2, 0f, selectedThing);
                        }
                        else
                        {
                            manhunterOnDamageChance = PawnUtility.GetManhunterOnDamageChance(pawn2, selectedThing);
                        }
                        if (manhunterOnDamageChance > 0f)
                        {
                            stringBuilder.AppendLine();
                            stringBuilder.AppendLine(string.Format("{0}: {1}", "ManhunterPerHit".Translate(), manhunterOnDamageChance.ToStringPercent()));
                        }
                    }
                }
                __result = stringBuilder.ToString();
            }
        }
Esempio n. 2
0
        public static bool ShotCalculationTipStringPrefix(ref string __result, Thing target)
        {
            StringBuilder stringBuilder = new StringBuilder();

            if (Find.Selector.SingleSelectedThing != null)
            {
                Thing singleSelectedThing = Find.Selector.SingleSelectedThing;
                Verb  verb = null;
                Pawn  pawn = singleSelectedThing as Pawn;
                if (pawn != null && pawn != target && pawn.equipment != null && pawn.equipment.Primary != null)
                {
                    Comp_VerbSaveable compsav = pawn.equipment.Primary.GetComp <Comp_VerbSaveable>();
                    if (compsav != null && compsav.tempVerb != null && compsav.tempVerb is Verb_LaunchProjectile)
                    {
                        verb = compsav.tempVerb;
                    }
                    else
                    {
                        verb = pawn.equipment.PrimaryEq.PrimaryVerb;
                    }
                }
                Building_TurretGun building_TurretGun = singleSelectedThing as Building_TurretGun;
                if (building_TurretGun != null && building_TurretGun != target)
                {
                    verb = building_TurretGun.AttackVerb;
                }
                if (verb != null)
                {
                    stringBuilder.Append("ShotBy".Translate(Find.Selector.SingleSelectedThing.LabelShort, Find.Selector.SingleSelectedThing) + ": ");
                    if (verb.CanHitTarget(target))
                    {
                        stringBuilder.Append(ShotReport.HitReportFor(verb.caster, verb, target).GetTextReadout());
                    }
                    else
                    {
                        stringBuilder.AppendLine("CannotHit".Translate());
                    }
                    Pawn pawn2 = target as Pawn;
                    if (pawn2 != null && pawn2.Faction == null && !pawn2.InAggroMentalState)
                    {
                        float manhunterOnDamageChance;
                        if (verb.IsMeleeAttack)
                        {
                            manhunterOnDamageChance = PawnUtility.GetManhunterOnDamageChance(pawn2, 0f, singleSelectedThing);
                        }
                        else
                        {
                            manhunterOnDamageChance = PawnUtility.GetManhunterOnDamageChance(pawn2, singleSelectedThing);
                        }
                        if (manhunterOnDamageChance > 0f)
                        {
                            stringBuilder.AppendLine();
                            stringBuilder.AppendLine(string.Format("{0}: {1}", "ManhunterPerHit".Translate(), manhunterOnDamageChance.ToStringPercent()));
                        }
                    }
                }
            }
            __result = stringBuilder.ToString();
            return(false);
        }
Esempio n. 3
0
        public static string ShotCalculationTipString(Thing target)
        {
            StringBuilder stringBuilder = new StringBuilder();

            if (Find.Selector.SingleSelectedThing != null)
            {
                Thing singleSelectedThing = Find.Selector.SingleSelectedThing;
                Verb  verb = null;
                Pawn  pawn = singleSelectedThing as Pawn;
                if (pawn != null && pawn != target && pawn.equipment != null && pawn.equipment.Primary != null && pawn.equipment.PrimaryEq.PrimaryVerb is Verb_LaunchProjectile)
                {
                    verb = pawn.equipment.PrimaryEq.PrimaryVerb;
                }
                Building_TurretGun building_TurretGun = singleSelectedThing as Building_TurretGun;
                if (building_TurretGun != null && building_TurretGun != target)
                {
                    verb = building_TurretGun.AttackVerb;
                }
                if (verb != null)
                {
                    stringBuilder.Append("ShotBy".Translate(Find.Selector.SingleSelectedThing.LabelShort, Find.Selector.SingleSelectedThing) + ": ");
                    if (verb.CanHitTarget(target))
                    {
                        stringBuilder.Append(ShotReport.HitReportFor(verb.caster, verb, target).GetTextReadout());
                    }
                    else
                    {
                        stringBuilder.AppendLine("CannotHit".Translate());
                    }
                    Pawn pawn2 = target as Pawn;
                    if (pawn2 != null && pawn2.Faction == null && !pawn2.InAggroMentalState)
                    {
                        float num = (!verb.IsMeleeAttack) ? PawnUtility.GetManhunterOnDamageChance(pawn2, singleSelectedThing) : PawnUtility.GetManhunterOnDamageChance(pawn2, 0f, singleSelectedThing);
                        if (num > 0f)
                        {
                            stringBuilder.AppendLine();
                            stringBuilder.AppendLine(string.Format("{0}: {1}", "ManhunterPerHit".Translate(), num.ToStringPercent()));
                        }
                    }
                }
            }
            return(stringBuilder.ToString());
        }
 public void Notify_DamageTaken(DamageInfo dinfo)
 {
     this.mentalStateHandler.Notify_DamageTaken(dinfo);
     if (dinfo.Def.ExternalViolenceFor(this.pawn))
     {
         this.lastHarmTick = Find.TickManager.TicksGame;
         if (this.pawn.Spawned)
         {
             Pawn pawn = dinfo.Instigator as Pawn;
             if (!this.mentalStateHandler.InMentalState && dinfo.Instigator != null && (pawn != null || dinfo.Instigator is Building_Turret) && dinfo.Instigator.Faction != null && (dinfo.Instigator.Faction.def.humanlikeFaction || (pawn != null && pawn.def.race.intelligence >= Intelligence.ToolUser)) && this.pawn.Faction == null && (this.pawn.RaceProps.Animal || this.pawn.IsWildMan()) && (this.pawn.CurJob == null || this.pawn.CurJob.def != JobDefOf.PredatorHunt || dinfo.Instigator != ((JobDriver_PredatorHunt)this.pawn.jobs.curDriver).Prey) && Rand.Chance(PawnUtility.GetManhunterOnDamageChance(this.pawn, dinfo.Instigator)))
             {
                 this.StartManhunterBecauseOfPawnAction("AnimalManhunterFromDamage");
             }
             else if (dinfo.Instigator != null && dinfo.Def.makesAnimalsFlee && Pawn_MindState.CanStartFleeingBecauseOfPawnAction(this.pawn))
             {
                 this.StartFleeingBecauseOfPawnAction(dinfo.Instigator);
             }
         }
         if (this.pawn.GetPosture() != PawnPosture.Standing)
         {
             this.lastDisturbanceTick = Find.TickManager.TicksGame;
         }
     }
 }
Esempio n. 5
0
        public IEnumerable <StatDrawEntry> SpecialDisplayStats(ThingDef parentDef)
        {
            yield return(new StatDrawEntry(StatCategoryDefOf.Basics, "Race".Translate(), parentDef.LabelCap, 2000, ""));

            yield return(new StatDrawEntry(StatCategoryDefOf.Basics, "Diet".Translate(), this.foodType.ToHumanString().CapitalizeFirst(), 0, ""));

            if (parentDef.race.leatherDef != null)
            {
                yield return(new StatDrawEntry(StatCategoryDefOf.Basics, "LeatherType".Translate(), parentDef.race.leatherDef.LabelCap, 0, ""));
            }
            if (parentDef.race.Animal || this.wildness > 0f)
            {
                yield return(new StatDrawEntry(StatCategoryDefOf.Basics, "Wildness".Translate(), this.wildness.ToStringPercent(), 0, "")
                {
                    overrideReportText = TrainableUtility.GetWildnessExplanation(parentDef)
                });
            }
            yield return(new StatDrawEntry(StatCategoryDefOf.Basics, "HarmedRevengeChance".Translate(), PawnUtility.GetManhunterOnDamageChance(parentDef.race).ToStringPercent(), 0, "")
            {
                overrideReportText = "HarmedRevengeChanceExplanation".Translate()
            });

            yield return(new StatDrawEntry(StatCategoryDefOf.Basics, "TameFailedRevengeChance".Translate(), parentDef.race.manhunterOnTameFailChance.ToStringPercent(), 0, ""));

            if (this.intelligence < Intelligence.Humanlike && this.trainability != null)
            {
                yield return(new StatDrawEntry(StatCategoryDefOf.Basics, "Trainability".Translate(), this.trainability.LabelCap, 0, ""));
            }
            yield return(new StatDrawEntry(StatCategoryDefOf.Basics, "StatsReport_LifeExpectancy".Translate(), this.lifeExpectancy.ToStringByStyle(ToStringStyle.Integer, ToStringNumberSense.Absolute), 0, ""));

            if (this.intelligence < Intelligence.Humanlike)
            {
                yield return(new StatDrawEntry(StatCategoryDefOf.Basics, "AnimalFilthRate".Translate(), (PawnUtility.AnimalFilthChancePerCell(parentDef, parentDef.race.baseBodySize) * 1000f).ToString("F2"), 0, "")
                {
                    overrideReportText = "AnimalFilthRateExplanation".Translate(new object[]
                    {
                        1000.ToString()
                    })
                });
            }
            if (this.packAnimal)
            {
                yield return(new StatDrawEntry(StatCategoryDefOf.Basics, "PackAnimal".Translate(), "Yes".Translate(), 0, "")
                {
                    overrideReportText = "PackAnimalExplanation".Translate()
                });
            }
            if (parentDef.race.nuzzleMtbHours > 0f)
            {
                yield return(new StatDrawEntry(StatCategoryDefOf.PawnSocial, "NuzzleInterval".Translate(), Mathf.RoundToInt(parentDef.race.nuzzleMtbHours * 2500f).ToStringTicksToPeriod(), 0, "")
                {
                    overrideReportText = "NuzzleIntervalExplanation".Translate()
                });
            }
            yield break;
        }
Esempio n. 6
0
        public IEnumerable <StatDrawEntry> SpecialDisplayStats(ThingDef parentDef, StatRequest req)
        {
            yield return(new StatDrawEntry(StatCategoryDefOf.BasicsPawn, "Race".Translate(), parentDef.LabelCap, parentDef.description, 2100));

            if (!parentDef.race.IsMechanoid)
            {
                string text = foodType.ToHumanString().CapitalizeFirst();
                yield return(new StatDrawEntry(StatCategoryDefOf.BasicsPawn, "Diet".Translate(), text, "Stat_Race_Diet_Desc".Translate(text), 1500));
            }
            if (req.HasThing && req.Thing is Pawn && (req.Thing as Pawn).needs != null && (req.Thing as Pawn).needs.food != null)
            {
                yield return(new StatDrawEntry(StatCategoryDefOf.BasicsPawn, "HungerRate".Translate(), ((req.Thing as Pawn).needs.food.FoodFallPerTickAssumingCategory(HungerCategory.Fed) * 60000f).ToString("0.##"), NutritionEatenPerDayExplanation_NewTemp(req.Thing as Pawn), 1600));
            }
            if (parentDef.race.leatherDef != null)
            {
                yield return(new StatDrawEntry(StatCategoryDefOf.BasicsPawn, "LeatherType".Translate(), parentDef.race.leatherDef.LabelCap, "Stat_Race_LeatherType_Desc".Translate(), 3550, null, new Dialog_InfoCard.Hyperlink[1]
                {
                    new Dialog_InfoCard.Hyperlink(parentDef.race.leatherDef)
                }));
            }
            if (parentDef.race.Animal || wildness > 0f)
            {
                yield return(new StatDrawEntry(StatCategoryDefOf.BasicsPawn, "Wildness".Translate(), wildness.ToStringPercent(), TrainableUtility.GetWildnessExplanation(parentDef), 2050));

                yield return(new StatDrawEntry(StatCategoryDefOf.BasicsPawn, "HarmedRevengeChance".Translate(), PawnUtility.GetManhunterOnDamageChance(parentDef.race).ToStringPercent(), "HarmedRevengeChanceExplanation".Translate(), 510));

                yield return(new StatDrawEntry(StatCategoryDefOf.BasicsPawn, "TameFailedRevengeChance".Translate(), parentDef.race.manhunterOnTameFailChance.ToStringPercent(), "Stat_Race_Animal_TameFailedRevengeChance_Desc".Translate(), 511));
            }
            if ((int)intelligence < 2 && trainability != null)
            {
                yield return(new StatDrawEntry(StatCategoryDefOf.BasicsPawn, "Trainability".Translate(), trainability.LabelCap, "Stat_Race_Trainability_Desc".Translate(), 2500));
            }
            yield return(new StatDrawEntry(StatCategoryDefOf.BasicsPawn, "StatsReport_LifeExpectancy".Translate(), lifeExpectancy.ToStringByStyle(ToStringStyle.Integer), "Stat_Race_LifeExpectancy_Desc".Translate(), 2000));

            if ((int)intelligence < 2 && !parentDef.race.IsMechanoid)
            {
                yield return(new StatDrawEntry(StatCategoryDefOf.BasicsPawn, "AnimalFilthRate".Translate(), (PawnUtility.AnimalFilthChancePerCell(parentDef, parentDef.race.baseBodySize) * 1000f).ToString("F2"), "AnimalFilthRateExplanation".Translate(1000.ToString()), 2203));
            }
            if (parentDef.race.Animal)
            {
                yield return(new StatDrawEntry(StatCategoryDefOf.BasicsPawn, "PackAnimal".Translate(), packAnimal ? "Yes".Translate() : "No".Translate(), "PackAnimalExplanation".Translate(), 2202));

                if (parentDef.race.nuzzleMtbHours > 0f)
                {
                    yield return(new StatDrawEntry(StatCategoryDefOf.PawnSocial, "NuzzleInterval".Translate(), Mathf.RoundToInt(parentDef.race.nuzzleMtbHours * 2500f).ToStringTicksToPeriod(), "NuzzleIntervalExplanation".Translate(), 500));
                }
            }
        }