private static void PartSystem(HediffWithComps __instance, DamageInfo?dinfo)
            {
                HediffComp_PartModule partModule = __instance.TryGetComp <HediffComp_PartModule>();

                if (partModule != null)
                {
                    partModule.SpecialPostAdd(dinfo);
                }
            }
 public static void Postfix(HediffWithComps __instance, ref float __result)
 {
     if (__result > 0)
     {
         // Check for stabilized comp
         HediffComp_Stabilize comp = __instance.TryGetComp <HediffComp_Stabilize>();
         if (comp != null)
         {
             __result = __result * (comp.BleedModifier);
         }
     }
 }
        public override void Effect(Pawn target)
        {
            CasterPawn.Drawer.Notify_DebugAffected();
            MoteMaker.ThrowText(this.CasterPawn.DrawPos, this.CasterPawn.Map, AbilityUser.StringsToTranslate.AU_CastSuccess, -1f);
            HediffWithComps hediff = (HediffWithComps)HediffMaker.MakeHediff(VampDefOf.ROMV_MindReadingHediff, this.CasterPawn, null);

            if (hediff.TryGetComp <HediffComp_ReadMind>() is HediffComp_ReadMind rm)
            {
                rm.MindBeingRead = target;
            }
            hediff.Severity = 1.0f;
            this.CasterPawn.health.AddHediff(hediff, null, null);
        }
Esempio n. 4
0
        public static bool CanBeStabilized(this Hediff diff)
        {
            HediffWithComps hediff = diff as HediffWithComps;

            if (hediff == null)
            {
                return(false);
            }
            if (hediff.BleedRate == 0f || hediff.IsTended() || hediff.IsPermanent())
            {
                return(false);
            }
            HediffComp_Stabilize comp = hediff.TryGetComp <HediffComp_Stabilize>();

            return(comp != null && !comp.Stabilized);
        }
        public static bool FullyImmune(this Hediff hd)
        {
            HediffWithComps hediffWithComps = hd as HediffWithComps;

            if (hediffWithComps == null)
            {
                return(false);
            }
            HediffComp_Immunizable hediffComp_Immunizable = hediffWithComps.TryGetComp <HediffComp_Immunizable>();

            if (hediffComp_Immunizable == null)
            {
                return(false);
            }
            return(hediffComp_Immunizable.FullyImmune);
        }
        public static bool IsOld(this Hediff hd)
        {
            HediffWithComps hediffWithComps = hd as HediffWithComps;

            if (hediffWithComps == null)
            {
                return(false);
            }
            HediffComp_GetsOld hediffComp_GetsOld = hediffWithComps.TryGetComp <HediffComp_GetsOld>();

            if (hediffComp_GetsOld == null)
            {
                return(false);
            }
            return(hediffComp_GetsOld.IsOld);
        }
        public static bool IsTended(this Hediff hd)
        {
            HediffWithComps hediffWithComps = hd as HediffWithComps;

            if (hediffWithComps == null)
            {
                return(false);
            }
            HediffComp_TendDuration hediffComp_TendDuration = hediffWithComps.TryGetComp <HediffComp_TendDuration>();

            if (hediffComp_TendDuration == null)
            {
                return(false);
            }
            return(hediffComp_TendDuration.IsTended);
        }
Esempio n. 8
0
 public bool HasAnyDisease(Pawn p)
 {
     foreach (Hediff h in p.health.hediffSet.hediffs)
     {
         HediffWithComps        hwc = h as HediffWithComps;
         HediffComp_Immunizable hci = null;
         if (hwc != null)
         {
             hci = hwc.TryGetComp <HediffComp_Immunizable>();
         }
         if (hci != null)
         {
             return(true);
         }
     }
     return(false);
 }
Esempio n. 9
0
		public override void Apply(LocalTargetInfo target, LocalTargetInfo dest)
		{
			Props.sound = SoundDefOf.PsycastPsychicEffect;//SoundDefOf.PsycastPsychicPulse;
			base.Apply(target, dest);

			if (target.Pawn == null) { return; }
			for (int i = 0; i < 10*MorePsycasts_Mod.settings.flash_heal_heal_amount; i++)
            {
				Hediff_Injury hediff_Injury = FindInjury(target.Pawn);
				if (hediff_Injury != null)
                {
					hediff_Injury.Heal(0.1f);
					HediffWithComps hediffWithComps = hediff_Injury as HediffWithComps;
					if (hediffWithComps != null)
					{
						hediffWithComps.TryGetComp<HediffComp_GetsPermanent>().Props.becomePermanentChanceFactor *= (float)MorePsycasts_Mod.settings.flash_heal_scar_chance;
					}
				}
			}
			//SoundDefOf.PsycastPsychicEffect.PlayOneShot(new TargetInfo(target.Cell, parent.pawn.Map));
		}
Esempio n. 10
0
        // Token: 0x0600004D RID: 77 RVA: 0x00003A84 File Offset: 0x00001C84
        public void TrySealWounds()
        {
            IEnumerable <Hediff> enumerable = from hd in this.pawn.health.hediffSet.hediffs
                                              where hd.TendableNow(false)
                                              select hd;

            if (enumerable != null)
            {
                foreach (Hediff hediff in enumerable)
                {
                    HediffWithComps hediffWithComps = hediff as HediffWithComps;
                    if (hediffWithComps != null)
                    {
                        HediffComp_TendDuration hediffComp_TendDuration = hediffWithComps.TryGetComp <HediffComp_TendDuration>();
                        hediffComp_TendDuration.tendQuality   = 2f;
                        hediffComp_TendDuration.tendTicksLeft = Find.TickManager.TicksGame;
                        this.pawn.health.Notify_HediffChanged(hediff);
                    }
                }
            }
        }
Esempio n. 11
0
        public override void DoCell(Rect rect, Pawn pawn, PawnTable table)
        {
            if (pawn.Dead || pawn.health?.hediffSet == null || !pawn.health.hediffSet.HasImmunizableNotImmuneHediff())
            {
                return;
            }

            HediffWithComps mostSevere = FindMostSevereHediff(pawn);

            if (mostSevere == null)
            {
                return;
            }

            float deltaSeverity = GetTextFor(mostSevere);

            GUI.color = GetPrettyColorFor(deltaSeverity);

            Rect rect2 = new Rect(rect.x, rect.y, rect.width, Mathf.Min(rect.height, 30f));

            Text.Font     = GameFont.Small;
            Text.Anchor   = TextAnchor.MiddleCenter;
            Text.WordWrap = false;
            Widgets.Label(rect2, GetTextFor(mostSevere).ToStringPercent());
            Text.WordWrap = true;
            Text.Anchor   = TextAnchor.UpperLeft;
            string tip = GetTip(pawn, mostSevere);

            if (!tip.NullOrEmpty())
            {
                TooltipHandler.TipRegion(rect2, tip);
            }

            float severityChangePerDayFromImmu = (float)AccessTools.Method(typeof(HediffComp_Immunizable), "SeverityChangePerDay")
                                                 .Invoke(mostSevere.TryGetComp <HediffComp_Immunizable>(), null);

            float severityChangePerDayFromTendD = 0f;

            if (mostSevere.TryGetComp <HediffComp_TendDuration>()?.IsTended ?? false)
            {
                severityChangePerDayFromTendD =
                    mostSevere.TryGetComp <HediffComp_TendDuration>().TProps.severityPerDayTended *
                    mostSevere.TryGetComp <HediffComp_TendDuration>().tendQuality;
            }

            float immunityPerDay = 0f;

            ImmunityRecord immunityRecord = pawn.health.immunity.GetImmunityRecord(mostSevere.def);

            if (immunityRecord != null)
            {
                immunityPerDay = immunityRecord.ImmunityChangePerTick(pawn, true, mostSevere) * GenDate.TicksPerDay;
            }

            GUI.color = Color.white;

            bool redFlag = !(severityChangePerDayFromTendD + severityChangePerDayFromImmu > immunityPerDay);

            Texture2D texture2D = redFlag ? StaticConstructorOnGameStart.SortingIcon : StaticConstructorOnGameStart.SortingDescendingIcon;

            GUI.color = redFlag ? HealthUtility.GoodConditionColor : HealthUtility.RedColor;
            Rect position2 = new Rect(rect.xMax - texture2D.width - 1f, rect.yMax - texture2D.height - 1f, texture2D.width, texture2D.height);

            GUI.DrawTexture(position2, texture2D);
            GUI.color = Color.white;
        }
Esempio n. 12
0
 private float GetTextFor(HediffWithComps hediff)
 => hediff?.TryGetComp <HediffComp_Immunizable>().Immunity - hediff?.Severity ?? -1f;    //nullcheck for Comparer.
        public override void CompTick()
        {
            base.CompTick();
            if (base.parent.IsHashIntervalTick(30) && base.parent != null && base.parent is Pawn pawn)
            {
                bool selected = Find.Selector.SelectedObjects.Contains(Pawn);
                blooded = YautjaBloodedUtility.BloodStatus(Pawn, out BloodStatus);
                if (!blooded)
                {
                    pawn.health.AddHediff(unbloodedDef, partRecord);
                }
#if DEBUG
                if (base.parent.IsHashIntervalTick(300) && selected)
                {
                    Log.Message(string.Format("BloodStatus: {0}", BloodStatus));
                }
#endif
                if (BloodStatus.def == unmarkedDef)
                {
#if DEBUG
                    if (base.parent.IsHashIntervalTick(300) && selected)
                    {
                        Log.Message(string.Format("unmarkedDef: {0}", unmarkedDef));
                    }
#endif
                    unmarked = BloodStatus;
#if DEBUG
                    if (base.parent.IsHashIntervalTick(300) && selected)
                    {
                        Log.Message(string.Format("unmarked: {0}", unmarked));
                    }
#endif
                    if (this.MarkHedifflabel != null)
                    {
#if DEBUG
                        if (base.parent.IsHashIntervalTick(300) && selected)
                        {
                            Log.Message(string.Format("{0}", this.MarkHedifflabel));
                        }
#endif
                    }
                }
                if (Pawn.records.GetAsInt(RecordDefOf.Kills) > TotalkillsRecord)
                {
                    pawnKills = Pawn.records.GetAsInt(RecordDefOf.Kills);
#if DEBUG
                    if (selected)
                    {
                        Log.Message("Records mismatch");
                    }
                    if (Pawn.LastAttackedTarget.Thing is Pawn p)
                    {
                        Log.Message(string.Format("pawn: {0}, {1} ", p.Label, Pawn.LastAttackedTarget.Thing.Label));
                    }
                    if (Pawn.LastAttackedTarget.Thing is Corpse c)
                    {
                        Log.Message(string.Format("corpse: {0}", c.Label));
                    }
#endif
                    if (Pawn.LastAttackedTarget != null && (Pawn.LastAttackedTarget.Thing is Pawn other && !Pawn.Dead))
                    {
#if DEBUG
                        if (selected)
                        {
                            Log.Message("found pawn");
                        }
#endif
                        Corpse otherCorpse = other.Corpse;
#if DEBUG
                        if (selected)
                        {
                            Log.Message("found corpse");
                        }
#endif
                        int omelee = other.RaceProps.Humanlike ? other.skills.GetSkill(SkillDefOf.Melee).Level : 0;
#if DEBUG
                        if (selected)
                        {
                            Log.Message(string.Format("omelee: {0}", omelee));
                        }
#endif
                        int oshoot = other.RaceProps.Humanlike ? other.skills.GetSkill(SkillDefOf.Shooting).Level : 0;
#if DEBUG
                        if (selected)
                        {
                            Log.Message(string.Format("oshoot: {0}", oshoot));
                        }
#endif
                        float mdps = other.GetStatValue(StatDefOf.MeleeDPS);
#if DEBUG
                        if (selected)
                        {
                            Log.Message(string.Format("mdps: {0}", mdps));
                        }
#endif
                        float mhc = other.GetStatValue(StatDefOf.MeleeHitChance);
#if DEBUG
                        if (selected)
                        {
                            Log.Message(string.Format("mhc: {0}", mhc));
                        }
#endif
                        float mdc = other.GetStatValue(StatDefOf.MeleeDodgeChance);
#if DEBUG
                        if (selected)
                        {
                            Log.Message(string.Format("mdc: {0}", mdc));
                        }
#endif
                        if (other.kindDef.race == XenomorphRacesDefOf.RRY_Xenomorph_Queen && other.Dead)
                        {
                            markedDef = YautjaDefOf.RRY_Hediff_BloodedMXenomorphQueen;
                        }
                        else if (other.kindDef.race == XenomorphRacesDefOf.RRY_Xenomorph_Drone || other.kindDef.race == XenomorphRacesDefOf.RRY_Xenomorph_Runner || other.kindDef.race == XenomorphRacesDefOf.RRY_Xenomorph_Warrior || other.kindDef.race == XenomorphRacesDefOf.RRY_Xenomorph_Neomorph && other.Dead)
                        {
                            markedDef = YautjaDefOf.RRY_Hediff_BloodedMXenomorph;
                        }
                        else if (other.kindDef.race == XenomorphRacesDefOf.RRY_Xenomorph_Predalien && other.Dead)
                        {
                            markedDef = YautjaDefOf.RRY_Hediff_BloodedMPredalien;
                        }
                        else if (other.kindDef.race == YautjaDefOf.RRY_Alien_Yautja && other.story.adulthood.identifier.StartsWith("Yautja_BadBlood") && other.Dead)
                        {
                            markedDef = YautjaDefOf.RRY_Hediff_BloodedMBadBlood;
                        }
                        else if (other.kindDef.race == ThingDefOf.Human && !other.kindDef.factionLeader && other.Dead)
                        {
                            markedDef = YautjaDefOf.RRY_Hediff_BloodedMHuman;
                        }
                        else if (other.kindDef.race == ThingDefOf.Human && (other.kindDef.factionLeader || (other.kindDef.isFighter && other.kindDef.combatPower > (100 - (omelee + oshoot)))) && other.Dead)
                        {
                            markedDef = YautjaDefOf.RRY_Hediff_BloodedMWorthyHuman;
                        }
                        else if (other.kindDef.race != ThingDefOf.Human && !other.kindDef.factionLeader && other.RaceProps.Humanlike && other.Dead)
                        {
                            markedDef = YautjaDefOf.RRY_Hediff_BloodedMHumanlike;
                        }
                        else if (other.kindDef.race != ThingDefOf.Human && (other.kindDef.factionLeader || (other.kindDef.isFighter && other.kindDef.combatPower > (100 - (omelee + oshoot)))) && other.RaceProps.Humanlike && other.Dead)
                        {
                            markedDef = YautjaDefOf.RRY_Hediff_BloodedMWorthyHumanlike;
                        }
                        else if (other.kindDef.race == YautjaDefOf.RRY_Alien_Yautja && !other.story.adulthood.identifier.StartsWith("Yautja_BadBlood") && other.Dead && (other.Faction.PlayerGoodwill > 0 || other.Faction.IsPlayer))
                        {
                            markedDef = YautjaDefOf.RRY_Hediff_BloodedMBadBlood;
                        }
                        else if (!other.kindDef.race.defName.StartsWith("RRY_Xenomorph_") && !other.RaceProps.Humanlike && other.Dead && (other.kindDef.combatPower > 100 || (other.kindDef.RaceProps.predator == true && other.kindDef.combatPower > 50)))
                        {
                            markedDef = YautjaDefOf.RRY_Hediff_BloodedM;
                        }
                        else
                        {
#if DEBUG
                            if (selected)
                            {
                                Log.Message(string.Format("Unworthy kill, ignoring"));
                            }
#endif
                            TotalkillsRecord = Pawn.records.GetAsInt(RecordDefOf.Kills);
                            return;
                        }
                        if (markedDef == null)
                        {
#if DEBUG
                            if (selected)
                            {
                                Log.Message(string.Format("markedDef is null, break failed"));
                            }
#endif
                        }
#if DEBUG
                        if (selected)
                        {
                            Log.Message(string.Format("markedDef: {0}", markedDef));
                        }
#endif
                        if (Pawn.health.hediffSet.HasHediff(unbloodedDef))
                        {
                            Hediff unblooded = Pawn.health.hediffSet.GetFirstHediffOfDef(this.unbloodedDef);
#if DEBUG
                            if (selected)
                            {
                                Log.Message("found unblooded");
                            }
#endif
#if DEBUG
                            if (selected)
                            {
                                Log.Message("removing old unblooded hediff");
                            }
#endif
                            Pawn.health.hediffSet.hediffs.Remove(unblooded);
#if DEBUG
                            if (selected)
                            {
                                Log.Message("store info");
                            }
                            if (selected)
                            {
                                Log.Message(string.Format(
                                                "{6} is storing other:{0}, corpse:{1}, MarkedhediffDef:{2}, predator:{3}, BodySize:{4}, combatPower:{5}",
                                                other.Label,
                                                otherCorpse.Label,
                                                markedDef,
                                                other.kindDef.RaceProps.predator,
                                                other.BodySize,
                                                other.kindDef.combatPower,
                                                Pawn.Name.ToStringShort
                                                ));
                            }
#endif
                            this.pawn            = other;
                            this.corpse          = otherCorpse;
                            this.MarkedhediffDef = markedDef;
                            this.MarkHedifflabel = other.KindLabel;
                            this.predator        = other.kindDef.RaceProps.predator;
                            this.BodySize        = other.BodySize;
                            this.combatPower     = other.kindDef.combatPower;
#if DEBUG
                            if (selected)
                            {
                                Log.Message("adding hediff");
                            }
#endif
                            Pawn.health.AddHediff(HediffMaker.MakeHediff(YautjaDefOf.RRY_Hediff_BloodedUM, Pawn, partRecord), partRecord, null);
                            HediffWithComps blooded = (HediffWithComps)Pawn.health.hediffSet.GetFirstHediffOfDef(YautjaDefOf.RRY_Hediff_BloodedUM);
#if DEBUG
                            if (selected)
                            {
                                Log.Message("adding comp to hediff");
                            }
#endif
                            blooded.source         = Pawn.LastAttackedTarget.Thing.def;
                            blooded.comps[0].props = new HediffCompProperties_BloodedYautja
                            {
                                pawn            = other,
                                corpse          = otherCorpse,
                                MarkedhediffDef = markedDef,
                                predator        = other.kindDef.RaceProps.predator,
                                BodySize        = other.BodySize,
                                combatPower     = other.kindDef.combatPower
                            };
                            HediffComp_BloodedYautja bloodedYautja = blooded.TryGetComp <HediffComp_BloodedYautja>();
#if DEBUG
                            if (selected)
                            {
                                Log.Message("info Stored");
                            }
                            if (selected)
                            {
                                Log.Message(string.Format(
                                                "{6} stored other:{0}, corpse:{1}, MarkedhediffDef:{2}, predator:{3}, BodySize:{4}, combatPower:{5}",
                                                bloodedYautja.HediffProps.pawn,
                                                bloodedYautja.HediffProps.corpse,
                                                bloodedYautja.HediffProps.MarkedhediffDef,
                                                bloodedYautja.HediffProps.predator,
                                                bloodedYautja.HediffProps.BodySize,
                                                bloodedYautja.HediffProps.combatPower,
                                                Pawn.Name.ToStringShort
                                                ));
                            }
#endif
                        }

                        //else if (!pawn.health.hediffSet.HasHediff(unblooded.def) && pawn.health.hediffSet.HasHediff(blooded.def))
                        else if (Pawn.health.hediffSet.HasHediff(unmarkedDef))
                        {
#if DEBUG
                            if (selected)
                            {
                                Log.Message("old unmarked hediff found, checking combatPower");
                            }
#endif
                            if (this.combatPower < other.kindDef.combatPower)
                            {
#if DEBUG
                                if (selected)
                                {
                                    Log.Message("new combatPower is higher, removing old unmarked hediff");
                                }
#endif
                                Hediff oldunmarked = Pawn.health.hediffSet.GetFirstHediffOfDef(YautjaDefOf.RRY_Hediff_BloodedUM);
                                Pawn.health.hediffSet.hediffs.Remove(oldunmarked);

#if DEBUG
                                if (selected)
                                {
                                    Log.Message("store new info");
                                }
                                if (selected)
                                {
                                    Log.Message(string.Format(
                                                    "{6} is storing other:{0}, corpse:{1}, MarkedhediffDef:{2}, predator:{3}, BodySize:{4}, combatPower:{5}",
                                                    other.Label,
                                                    otherCorpse.Label,
                                                    markedDef,
                                                    other.kindDef.RaceProps.predator,
                                                    other.BodySize,
                                                    other.kindDef.combatPower,
                                                    Pawn.Name.ToStringShort
                                                    ));
                                }
#endif
                                this.pawn            = other;
                                this.corpse          = otherCorpse;
                                this.MarkedhediffDef = markedDef;
                                this.MarkHedifflabel = other.KindLabel;
                                this.predator        = other.kindDef.RaceProps.predator;
                                this.BodySize        = other.BodySize;
                                this.combatPower     = other.kindDef.combatPower;
                                Pawn.health.AddHediff(HediffMaker.MakeHediff(YautjaDefOf.RRY_Hediff_BloodedUM, Pawn, partRecord), partRecord, null);
                                HediffWithComps blooded = (HediffWithComps)Pawn.health.hediffSet.GetFirstHediffOfDef(YautjaDefOf.RRY_Hediff_BloodedUM);
#if DEBUG
                                if (selected)
                                {
                                    Log.Message("adding comp to hediff");
                                }
#endif
                                blooded.source         = Pawn.LastAttackedTarget.Thing.def;
                                blooded.comps[0].props = new HediffCompProperties_BloodedYautja
                                {
                                    pawn            = other,
                                    corpse          = otherCorpse,
                                    MarkedhediffDef = markedDef,
                                    predator        = other.kindDef.RaceProps.predator,
                                    BodySize        = other.BodySize,
                                    combatPower     = other.kindDef.combatPower
                                };
                                HediffComp_BloodedYautja bloodedYautja = blooded.TryGetComp <HediffComp_BloodedYautja>();
#if DEBUG
                                if (selected)
                                {
                                    Log.Message("info Stored");
                                }
                                if (selected)
                                {
                                    Log.Message(string.Format(
                                                    "{6} stored other:{0}, corpse:{1}, MarkedhediffDef:{2}, predator:{3}, BodySize:{4}, combatPower:{5}",
                                                    bloodedYautja.HediffProps.pawn,
                                                    bloodedYautja.HediffProps.corpse,
                                                    bloodedYautja.HediffProps.MarkedhediffDef,
                                                    bloodedYautja.HediffProps.predator,
                                                    bloodedYautja.HediffProps.BodySize,
                                                    bloodedYautja.HediffProps.combatPower,
                                                    Pawn.Name.ToStringShort
                                                    ));
                                }
#endif
                            }
                        }
                        else
                        {
                            bool hasbloodedM = Pawn.health.hediffSet.hediffs.Any <Hediff>(x => x.def.defName.StartsWith(GenericmarkedDef.defName));
                            if (hasbloodedM)
                            {
                                foreach (var item in Pawn.health.hediffSet.hediffs)
                                {
                                    if (item.def.defName.StartsWith(GenericmarkedDef.defName))
                                    {
#if DEBUG
                                        if (selected)
                                        {
                                            Log.Message("old marked hediff found, checking combatPower");
                                        }
#endif
                                        if (this.combatPower < other.kindDef.combatPower)
                                        {
#if DEBUG
                                            if (selected)
                                            {
                                                Log.Message("new combatPower is higher, removing old marked hediff");
                                            }
#endif
                                            Hediff oldmarked = item;
                                            // Pawn.health.hediffSet.hediffs.Remove(oldmarked);

#if DEBUG
                                            if (selected)
                                            {
                                                Log.Message("store new info");
                                            }
                                            if (selected)
                                            {
                                                Log.Message(string.Format(
                                                                "{6} is storing other:{0}, corpse:{1}, MarkedhediffDef:{2}, predator:{3}, BodySize:{4}, combatPower:{5}",
                                                                other.Label,
                                                                otherCorpse.Label,
                                                                markedDef,
                                                                other.kindDef.RaceProps.predator,
                                                                other.BodySize,
                                                                other.kindDef.combatPower,
                                                                Pawn.Name.ToStringShort
                                                                ));
                                            }
#endif
                                            this.pawn            = other;
                                            this.corpse          = otherCorpse;
                                            this.MarkedhediffDef = markedDef;
                                            this.MarkHedifflabel = other.KindLabel;
                                            this.predator        = other.kindDef.RaceProps.predator;
                                            this.BodySize        = other.BodySize;
                                            this.combatPower     = other.kindDef.combatPower;
                                            Pawn.health.AddHediff(HediffMaker.MakeHediff(YautjaDefOf.RRY_Hediff_BloodedUM, Pawn, partRecord), partRecord, null);
                                            HediffWithComps blooded = (HediffWithComps)Pawn.health.hediffSet.GetFirstHediffOfDef(YautjaDefOf.RRY_Hediff_BloodedUM);
#if DEBUG
                                            if (selected)
                                            {
                                                Log.Message("adding comp to hediff");
                                            }
#endif
                                            blooded.source         = Pawn.LastAttackedTarget.Thing.def;
                                            blooded.comps[0].props = new HediffCompProperties_BloodedYautja
                                            {
                                                pawn            = other,
                                                corpse          = otherCorpse,
                                                MarkedhediffDef = markedDef,
                                                predator        = other.kindDef.RaceProps.predator,
                                                BodySize        = other.BodySize,
                                                combatPower     = other.kindDef.combatPower
                                            };
                                            HediffComp_BloodedYautja bloodedYautja = blooded.TryGetComp <HediffComp_BloodedYautja>();
#if DEBUG
                                            if (selected)
                                            {
                                                Log.Message("info Stored");
                                            }
                                            if (selected)
                                            {
                                                Log.Message(string.Format(
                                                                "{6} stored other:{0}, corpse:{1}, MarkedhediffDef:{2}, predator:{3}, BodySize:{4}, combatPower:{5}",
                                                                bloodedYautja.HediffProps.pawn,
                                                                bloodedYautja.HediffProps.corpse,
                                                                bloodedYautja.HediffProps.MarkedhediffDef,
                                                                bloodedYautja.HediffProps.predator,
                                                                bloodedYautja.HediffProps.BodySize,
                                                                bloodedYautja.HediffProps.combatPower,
                                                                Pawn.Name.ToStringShort
                                                                ));
                                            }
#endif
                                        }
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    TotalkillsRecord = Pawn.records.GetAsInt(RecordDefOf.Kills);
                }
            }
        }
Esempio n. 14
0
        public void CalcTick()
        {
            if (!Pawn.IsColonist)
            {
                return;
            }
            if (Pawn.Map != Find.CurrentMap)
            {
                return;
            }
            if (Pawn.Map == null)
            {
                return;
            }
            if (!Find.CurrentMap.mapPawns.FreeColonistsAndPrisoners.Any(x => x.def == YautjaDefOf.RRY_Alien_Yautja))
            {
                return;
            }

            if (inducted != true)
            {
                inducted = false;
            }
            if (inductable != true)
            {
                inductable = false;
            }
            if (base.parent != null && base.parent is Pawn pawn && pawn.Map != null)
            {
                bool selected = Find.Selector.SelectedObjects.Contains(Pawn);
                blooded = YautjaBloodedUtility.BloodStatus(Pawn, out BloodStatus);

                if (BloodStatus.def == unmarkedDef)
                {
                    unmarked = BloodStatus;
                    if (this.MarkHedifflabel != null)
                    {
                    }
                }
                if (Pawn.records.GetAsInt(RecordDefOf.Kills) > TotalkillsRecord || (!inducted && inductable) || (inducted && inductable))
                {
                    //    Log.Message(string.Format("kill incread: {0}\n!inducted: {1} && inductable: {2}", Pawn.records.GetAsInt(RecordDefOf.Kills) > TotalkillsRecord, !inducted, inductable));
                    pawnKills = Pawn.records.GetAsInt(RecordDefOf.Kills);
                    if (Pawn.LastAttackedTarget != null && (Pawn.LastAttackedTarget.Thing is Pawn other && !Pawn.Dead))
                    {
                        corpse = other.Corpse;
                        Corpse otherCorpse = other.Corpse;
                        int    omelee      = other.RaceProps.Humanlike ? other.skills.GetSkill(SkillDefOf.Melee).Level : 0;
                        int    oshoot      = other.RaceProps.Humanlike ? other.skills.GetSkill(SkillDefOf.Shooting).Level : 0;
                        float  mdps        = other.GetStatValue(StatDefOf.MeleeDPS);
                        float  mhc         = other.GetStatValue(StatDefOf.MeleeHitChance);
                        float  mdc         = other.GetStatValue(StatDefOf.MeleeDodgeChance);

                        markedDef = YautjaBloodedUtility.GetMark(other.kindDef);
                        if (markedDef == null)
                        {
                            if (other.kindDef.race == XenomorphRacesDefOf.RRY_Xenomorph_Queen && other.Dead)
                            {
                                markedDef = YautjaDefOf.RRY_Hediff_BloodedMXenomorphQueen;
                            }
                            else if (other.kindDef.race == XenomorphRacesDefOf.RRY_Xenomorph_Drone || other.kindDef.race == XenomorphRacesDefOf.RRY_Xenomorph_Runner || other.kindDef.race == XenomorphRacesDefOf.RRY_Xenomorph_Warrior || other.kindDef.race == XenomorphRacesDefOf.RRY_Xenomorph_Neomorph && other.Dead)
                            {
                                markedDef = YautjaDefOf.RRY_Hediff_BloodedMXenomorph;
                            }
                            else if (other.kindDef.race == ThingDefOf.Thrumbo && other.Dead)
                            {
                                markedDef = YautjaDefOf.RRY_Hediff_BloodedMXenomorph;
                            }
                            else if (other.kindDef.race == XenomorphRacesDefOf.RRY_Xenomorph_Predalien && other.Dead)
                            {
                                markedDef = YautjaDefOf.RRY_Hediff_BloodedMPredalien;
                            }
                            else if (other.kindDef.race == YautjaDefOf.RRY_Alien_Yautja && other.story.adulthood.identifier.StartsWith("Yautja_BadBlood") && other.Dead)
                            {
                                markedDef = YautjaDefOf.RRY_Hediff_BloodedMBadBlood;
                            }
                            else if (other.kindDef.race == ThingDefOf.Human && !other.kindDef.factionLeader && other.Dead)
                            {
                                markedDef = YautjaDefOf.RRY_Hediff_BloodedMHuman;
                            }
                            else if (other.kindDef.race == ThingDefOf.Human && (other.kindDef.factionLeader || (other.kindDef.isFighter && other.kindDef.combatPower > (100 - (omelee + oshoot)))) && other.Dead)
                            {
                                markedDef = YautjaDefOf.RRY_Hediff_BloodedMWorthyHuman;
                            }
                            else if (other.kindDef.race != ThingDefOf.Human && !other.kindDef.factionLeader && other.RaceProps.Humanlike && other.Dead)
                            {
                                markedDef = YautjaDefOf.RRY_Hediff_BloodedMHumanlike;
                            }
                            else if (other.kindDef.race != ThingDefOf.Human && (other.kindDef.factionLeader || (other.kindDef.isFighter && other.kindDef.combatPower > (100 - (omelee + oshoot)))) && other.RaceProps.Humanlike && other.Dead)
                            {
                                markedDef = YautjaDefOf.RRY_Hediff_BloodedMWorthyHumanlike;
                            }
                            else if (other.kindDef.race == YautjaDefOf.RRY_Alien_Yautja && !other.story.adulthood.identifier.StartsWith("Yautja_BadBlood") && other.Dead && (other.Faction.PlayerGoodwill > 0 || other.Faction.IsPlayer))
                            {
                                markedDef = YautjaDefOf.RRY_Hediff_BloodedMBadBlood;
                            }
                            else if (!other.kindDef.race.defName.StartsWith("RRY_Xenomorph_") && !other.RaceProps.Humanlike && other.Dead && (other.kindDef.combatPower > 100 || (other.kindDef.RaceProps.predator == true && other.kindDef.combatPower > 50)))
                            {
                                markedDef = YautjaDefOf.RRY_Hediff_BloodedM;
                            }
                            else
                            {
                                TotalkillsRecord = Pawn.records.GetAsInt(RecordDefOf.Kills);
                                return;
                            }
                        }
                        if (markedDef == null)
                        {
                        }
                        if (Pawn.health.hediffSet.HasHediff(unbloodedDef))
                        {
                            Hediff unblooded = Pawn.health.hediffSet.GetFirstHediffOfDef(this.unbloodedDef);
                            this.pawn            = other;
                            this.corpse          = otherCorpse;
                            this.MarkedhediffDef = markedDef;
                            this.MarkHedifflabel = other.KindLabel;
                            this.predator        = other.kindDef.RaceProps.predator;
                            this.BodySize        = other.BodySize;
                            this.combatPower     = other.kindDef.combatPower;
                            if (!inducted && !inductable)
                            {
                                this.inductable = true;
                            }
                            if (inducted || Pawn.kindDef.race == YautjaDefOf.RRY_Alien_Yautja)
                            {
                                inductable = false;
                                Pawn.health.hediffSet.hediffs.Remove(unblooded);
                                Pawn.health.AddHediff(HediffMaker.MakeHediff(YautjaDefOf.RRY_Hediff_BloodedUM, Pawn, partRecord), partRecord, null);
                                HediffWithComps blooded = (HediffWithComps)Pawn.health.hediffSet.GetFirstHediffOfDef(YautjaDefOf.RRY_Hediff_BloodedUM);
                                blooded.source         = Pawn.LastAttackedTarget.Thing.def;
                                blooded.comps[0].props = new HediffCompProperties_BloodedYautja
                                {
                                    pawn            = other,
                                    corpse          = otherCorpse,
                                    MarkedhediffDef = markedDef,
                                    predator        = other.kindDef.RaceProps.predator,
                                    BodySize        = other.BodySize,
                                    combatPower     = other.kindDef.combatPower
                                };
                                HediffComp_BloodedYautja bloodedYautja = blooded.TryGetComp <HediffComp_BloodedYautja>();
                            }
                        }
                        else if (Pawn.health.hediffSet.HasHediff(unmarkedDef))
                        {
                            if (this.combatPower < other.kindDef.combatPower)
                            {
                                Hediff oldunmarked = Pawn.health.hediffSet.GetFirstHediffOfDef(YautjaDefOf.RRY_Hediff_BloodedUM);
                                Pawn.health.hediffSet.hediffs.Remove(oldunmarked);
                                this.pawn            = other;
                                this.corpse          = otherCorpse;
                                this.MarkedhediffDef = markedDef;
                                this.MarkHedifflabel = other.KindLabel;
                                this.predator        = other.kindDef.RaceProps.predator;
                                this.BodySize        = other.BodySize;
                                this.combatPower     = other.kindDef.combatPower;
                                Pawn.health.AddHediff(HediffMaker.MakeHediff(YautjaDefOf.RRY_Hediff_BloodedUM, Pawn, partRecord), partRecord, null);
                                HediffWithComps blooded = (HediffWithComps)Pawn.health.hediffSet.GetFirstHediffOfDef(YautjaDefOf.RRY_Hediff_BloodedUM);
                                blooded.source         = Pawn.LastAttackedTarget.Thing.def;
                                blooded.comps[0].props = new HediffCompProperties_BloodedYautja
                                {
                                    pawn            = other,
                                    corpse          = otherCorpse,
                                    MarkedhediffDef = markedDef,
                                    predator        = other.kindDef.RaceProps.predator,
                                    BodySize        = other.BodySize,
                                    combatPower     = other.kindDef.combatPower
                                };
                                HediffComp_BloodedYautja bloodedYautja = blooded.TryGetComp <HediffComp_BloodedYautja>();
                            }
                        }
                        else
                        {
                            bool hasbloodedM = Pawn.health.hediffSet.hediffs.Any <Hediff>(x => x.def.defName.StartsWith(GenericmarkedDef.defName));
                            if (hasbloodedM)
                            {
                                foreach (var item in Pawn.health.hediffSet.hediffs)
                                {
                                    if (item.def.defName.StartsWith(GenericmarkedDef.defName))
                                    {
                                        if (this.combatPower <= other.kindDef.combatPower)
                                        {
                                            Hediff oldmarked = item;
                                            this.pawn            = other;
                                            this.corpse          = otherCorpse;
                                            this.MarkedhediffDef = markedDef;
                                            this.MarkHedifflabel = other.KindLabel;
                                            this.predator        = other.kindDef.RaceProps.predator;
                                            this.BodySize        = other.BodySize;
                                            this.combatPower     = other.kindDef.combatPower;
                                            Pawn.health.AddHediff(HediffMaker.MakeHediff(YautjaDefOf.RRY_Hediff_BloodedUM, Pawn, partRecord), partRecord, null);
                                            HediffWithComps blooded = (HediffWithComps)Pawn.health.hediffSet.GetFirstHediffOfDef(YautjaDefOf.RRY_Hediff_BloodedUM);
                                            blooded.source         = Pawn.LastAttackedTarget.Thing.def;
                                            blooded.comps[0].props = new HediffCompProperties_BloodedYautja
                                            {
                                                pawn            = other,
                                                corpse          = otherCorpse,
                                                MarkedhediffDef = markedDef,
                                                predator        = other.kindDef.RaceProps.predator,
                                                BodySize        = other.BodySize,
                                                combatPower     = other.kindDef.combatPower
                                            };
                                            HediffComp_BloodedYautja bloodedYautja = blooded.TryGetComp <HediffComp_BloodedYautja>();
                                        }
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    TotalkillsRecord = Pawn.records.GetAsInt(RecordDefOf.Kills);
                }
            }
        }