public void CompPostTock()
 {
     lastTockTick = Find.TickManager.TicksGame;
     if (MarkedhediffDef == null)
     {
         MarkedhediffDef = this.Def;
         corpse          = null;
         pawn            = null;
         pawnKindDef     = YautjaBloodedUtility.RandomMarked(MarkedhediffDef);
         //    Log.Message(string.Format("{0}: {1}", MarkedhediffDef, pawnKindDef));
         MarkHedifftype  = null;
         MarkHedifflabel = pawnKindDef.LabelCap;
         predator        = pawnKindDef.RaceProps.predator;
         combatPower     = pawnKindDef.combatPower;
         BodySize        = pawnKindDef.race.race.baseBodySize;
         Comp_Yautja _Yautja = this.Pawn.TryGetComp <Comp_Yautja>();
         if (_Yautja != null)
         {
             _Yautja.MarkHedifflabel = MarkHedifflabel;
             _Yautja.pawn            = pawn;
             _Yautja.corpse          = corpse;
             _Yautja.MarkedhediffDef = MarkedhediffDef;
             _Yautja.MarkHedifflabel = MarkHedifflabel;
             _Yautja.predator        = predator;
             _Yautja.BodySize        = BodySize;
             _Yautja.combatPower     = combatPower;
         }
     }
 }
Ejemplo n.º 2
0
        // Token: 0x06002ADC RID: 10972 RVA: 0x001433C0 File Offset: 0x001417C0
        public override void DoEffect(Pawn user)
        {
            bool selected = Find.Selector.SelectedObjects.Contains(user);
            //    base.DoEffect(user);
            Hediff         hediff;
            Comp_Yautja    _Yautja = user.TryGetComp <Comp_Yautja>();
            Hediff         blooded = user.health.hediffSet.GetFirstHediffOfDef(YautjaDefOf.RRY_Hediff_BloodedUM);
            BodyPartRecord part    = user.health.hediffSet.GetFirstHediffOfDef(YautjaDefOf.RRY_Hediff_BloodedUM).Part;
            HediffDef      marked  = _Yautja.MarkedhediffDef;

            if (YautjaBloodedUtility.Marked(user, out hediff))
            {
                user.health.RemoveHediff(hediff);
            }
            user.health.RemoveHediff(blooded);
            user.health.AddHediff(marked, part);
            ThingDef thingDef = null;

            foreach (var item in corpse.InnerPawn.health.hediffSet.GetNotMissingParts())
            {
                if (Rand.Chance(corpse.InnerPawn.health.hediffSet.GetPartHealth(item) / 3) && item.def == XenomorphDefOf.RRY_Xeno_TailSpike && !corpse.InnerPawn.health.hediffSet.PartIsMissing(item))
                {
                    partRecord = item;
                    thingDef   = XenomorphDefOf.RRY_Xenomorph_TailSpike;
                    corpse.InnerPawn.health.AddHediff(HediffMaker.MakeHediff(HediffDefOf.MissingBodyPart, corpse.InnerPawn, this.partRecord));
                    GenSpawn.Spawn(ThingMaker.MakeThing(thingDef), user.Position, user.Map);
                }
                if (Rand.Chance(corpse.InnerPawn.health.hediffSet.GetPartHealth(item) / 3) && item.def == XenomorphDefOf.RRY_Xeno_Shell && !corpse.InnerPawn.health.hediffSet.PartIsMissing(item))
                {
                    partRecord = item;
                    thingDef   = XenomorphDefOf.RRY_Xenomorph_HeadShell;
                    corpse.InnerPawn.health.AddHediff(HediffMaker.MakeHediff(HediffDefOf.MissingBodyPart, corpse.InnerPawn, this.partRecord));
                    GenSpawn.Spawn(ThingMaker.MakeThing(thingDef), user.Position, user.Map);
                }
            }
            if (user.story.adulthood.identifier == null || user.story.adulthood.identifier == "Yautja_YoungBlood")
            {
                AlienRace.BackstoryDef backstoryDef = DefDatabase <AlienRace.BackstoryDef> .GetNamed("Yautja_Blooded");

#if DEBUG
                if (selected)
                {
                    Log.Message(string.Format("changing {0}", user.story.adulthood.identifier));
                }
#endif

                user.story.adulthood = backstoryDef.backstory;
#if DEBUG
                if (selected)
                {
                    Log.Message(string.Format("to {0}", user.story.adulthood.identifier));
                }
#endif
            }
        }
        public override void DoEffect(Pawn user)
        {
            bool selected = Find.Selector.SelectedObjects.Contains(user);
            //    base.DoEffect(user);
            Comp_Yautja    _Yautja   = user.TryGetComp <Comp_Yautja>();
            Hediff         blooded   = user.health.hediffSet.GetFirstHediffOfDef(YautjaDefOf.RRY_Hediff_BloodedUM);
            BodyPartRecord part      = user.health.hediffSet.GetFirstHediffOfDef(YautjaDefOf.RRY_Hediff_BloodedUM).Part;
            HediffDef      markedDef = _Yautja.MarkedhediffDef;

            if (YautjaBloodedUtility.Marked(user, out Hediff hediff))
            {
                user.health.RemoveHediff(hediff);
            }
            user.health.RemoveHediff(blooded);
            Hediff marked = HediffMaker.MakeHediff(markedDef, user, part);// user.health.hediffSet.GetFirstHediffOfDef(markedDef);
            HediffComp_MarkedYautja marked_Yautja = marked.TryGetComp <HediffComp_MarkedYautja>();

            corpse = (Corpse)this.parent;
            marked_Yautja.BodySize        = corpse.InnerPawn.BodySize;
            marked_Yautja.combatPower     = corpse.InnerPawn.kindDef.combatPower;
            marked_Yautja.corpse          = corpse;
            marked_Yautja.MarkHedifflabel = corpse.InnerPawn.KindLabel;
            marked_Yautja.pawn            = corpse.InnerPawn;
            marked_Yautja.pawnKindDef     = corpse.InnerPawn.kindDef;
            marked_Yautja.predator        = corpse.InnerPawn.kindDef.RaceProps.predator;
            marked_Yautja.props           = new HediffCompProperties_MarkedYautja
            {
                pawn            = corpse.InnerPawn,
                corpse          = corpse,
                MarkedhediffDef = markedDef,
                MarkHedifflabel = corpse.InnerPawn.KindLabel,
                predator        = corpse.InnerPawn.kindDef.RaceProps.predator,
                BodySize        = corpse.InnerPawn.BodySize,
                combatPower     = corpse.InnerPawn.kindDef.combatPower
            };
            Log.Message(string.Format(" 11 "));
            user.health.AddHediff(markedDef, part);
            Log.Message(string.Format(" 12 "));
            ThingDef thingDef = null;

            Log.Message(string.Format(" 13 "));
            foreach (var item in corpse.InnerPawn.health.hediffSet.GetNotMissingParts())
            {
                if (Rand.Chance(corpse.InnerPawn.health.hediffSet.GetPartHealth(item) / 3) && item.def == XenomorphDefOf.RRY_Xeno_TailSpike && !corpse.InnerPawn.health.hediffSet.PartIsMissing(item))
                {
                    partRecord = item;
                    thingDef   = XenomorphDefOf.RRY_Xenomorph_TailSpike;
                    corpse.InnerPawn.health.AddHediff(HediffMaker.MakeHediff(HediffDefOf.MissingBodyPart, corpse.InnerPawn, this.partRecord));
                    GenSpawn.Spawn(ThingMaker.MakeThing(thingDef), user.Position, user.Map);
                }
                if (Rand.Chance(corpse.InnerPawn.health.hediffSet.GetPartHealth(item) / 3) && item.def == XenomorphDefOf.RRY_Xeno_Shell && !corpse.InnerPawn.health.hediffSet.PartIsMissing(item))
                {
                    partRecord = item;
                    thingDef   = XenomorphDefOf.RRY_Xenomorph_HeadShell;
                    corpse.InnerPawn.health.AddHediff(HediffMaker.MakeHediff(HediffDefOf.MissingBodyPart, corpse.InnerPawn, this.partRecord));
                    GenSpawn.Spawn(ThingMaker.MakeThing(thingDef), user.Position, user.Map);
                }
            }
            if (user.story.adulthood.identifier == null || user.story.adulthood.identifier == "RRY_Yautja_YoungBlood")
            {
                if (marked.def == YautjaDefOf.RRY_Hediff_BloodedMXenomorph)
                {
                    AlienRace.BackstoryDef backstoryDef = DefDatabase <AlienRace.BackstoryDef> .GetNamed("RRY_Yautja_Blooded");

#if DEBUG
                    //    if (selected) Log.Message(string.Format("changing {0}", user.story.adulthood.identifier));
#endif

                    user.story.adulthood = backstoryDef.backstory;
#if DEBUG
                    //    if (selected) Log.Message(string.Format("to {0}", user.story.adulthood.identifier));
#endif
                }
            }
        }
        public static bool BloodStatus(Pawn pawn, out Hediff BloodHD)
        {
            HediffSet      hediffSet = pawn.health.hediffSet;
            BodyPartRecord part      = pawn.RaceProps.body.AllParts.Find(x => x.def == BodyPartDefOf.Head);
            HediffDef      hediffDef;
            bool           result = false;

            BloodHD = null;
            bool hasbloodedM = hediffSet.hediffs.Any <Hediff>(x => x.def.defName.StartsWith(markedDef.defName));

            if (hasbloodedM)
            {
                BloodHD = hediffSet.hediffs.Find(x => x.def.defName.Contains(markedDef.defName));
                //    Log.Message(string.Format("hasbloodedM: {0}", BloodHD));
                result = true;
            }
            bool hasunblooded = hediffSet.HasHediff(unbloodedDef);

            if (hasunblooded)
            {
                BloodHD = hediffSet.GetFirstHediffOfDef(unbloodedDef);
                if (!PlayerKnowledgeDatabase.IsComplete(YautjaConceptDefOf.RRY_Concept_Unblooded) && pawn.IsColonist && pawn.Spawned && (pawn.Map != null || pawn.MapHeld != null))
                {
                    LessonAutoActivator.TeachOpportunity(YautjaConceptDefOf.RRY_Concept_Unblooded, OpportunityType.Important);
                }
                //    Log.Message(string.Format("hasunblooded: {0}", BloodHD));
                result = false;
            }
            bool hasbloodedUM = hediffSet.HasHediff(unmarkedDef);

            if (hasbloodedUM)
            {
                BloodHD = hediffSet.GetFirstHediffOfDef(unmarkedDef);
                if (!PlayerKnowledgeDatabase.IsComplete(YautjaConceptDefOf.RRY_Concept_Blooding) && pawn.IsColonist && pawn.Spawned && (pawn.Map != null || pawn.MapHeld != null))
                {
                    LessonAutoActivator.TeachOpportunity(YautjaConceptDefOf.RRY_Concept_Blooding, OpportunityType.Important);
                }
                //    Log.Message(string.Format("hasbloodedUM: {0}", BloodHD));
                result = true;
            }
            if (BloodHD == null)
            {
                //    Log.Message(string.Format("1"));
                Backstory pawnStoryC = pawn.story.childhood;
                Backstory pawnStoryA = pawn.story.adulthood ?? null;

                if (pawn.kindDef.race == YautjaDefOf.RRY_Alien_Yautja && pawnStoryA != null)
                {
                    //    Log.Message(string.Format("2"));
                    if (pawnStoryA != bsDefUnblooded.backstory)
                    {
                        //    Log.Message(string.Format("3"));
                        Comp_Yautja _Yautja = pawn.TryGetComp <Comp_Yautja>();
                        hediffDef = _Yautja.Props.bloodedDefs.RandomElement();

                        if (hediffDef != null)
                        {
                            //    Log.Message(string.Format("4"));
                            PawnKindDef pawnKindDef = YautjaBloodedUtility.RandomMarked(hediffDef);
                            if (_Yautja != null)
                            {
                                //    Log.Message(string.Format("5"));
                                _Yautja.MarkHedifflabel = pawnKindDef.LabelCap;
                                _Yautja.MarkedhediffDef = hediffDef;
                                _Yautja.predator        = pawnKindDef.RaceProps.predator;
                                _Yautja.BodySize        = pawnKindDef.RaceProps.baseBodySize;
                                _Yautja.combatPower     = pawnKindDef.combatPower;
                            }
                        }
                    }
                    else
                    {
                        //    Log.Message(string.Format("6"));
                        hediffDef = unbloodedDef;
                    }
                }
                else
                {
                    //    Log.Message(string.Format("7"));
                    hediffDef = unbloodedDef;
                }
                //    Log.Message(string.Format("8"));
                pawn.health.AddHediff(hediffDef, part);
                //    Log.Message(string.Format("9"));
                BloodHD = hediffSet.GetFirstHediffOfDef(hediffDef);
                //    Log.Message(string.Format("10"));
                result = true;
                //    Log.Message(string.Format("11"));
            }
            else
            {
                //    Log.Message(string.Format("12"));
                Comp_Yautja _Yautja = pawn.TryGetComp <Comp_Yautja>();
                //    Log.Message(string.Format("12 a {0}", BloodHD.def));
                if (hasbloodedM)
                {
                    PawnKindDef pawnKindDef = YautjaBloodedUtility.RandomMarked(BloodHD.def);
                    //    Log.Message(string.Format("12 B {0}", pawnKindDef));
                    if (_Yautja != null && _Yautja.MarkHedifflabel.NullOrEmpty())
                    {
                        //    Log.Message(string.Format("13 "));
                        _Yautja.MarkHedifflabel = pawnKindDef.LabelCap;
                        //    Log.Message(string.Format("13 a"));
                        _Yautja.MarkedhediffDef = BloodHD.def;
                        //    Log.Message(string.Format("13 b"));
                        _Yautja.predator = pawnKindDef.RaceProps.predator;
                        //    Log.Message(string.Format("13 c"));
                        _Yautja.BodySize = pawnKindDef.RaceProps.baseBodySize;
                        //    Log.Message(string.Format("13 d"));
                        _Yautja.combatPower = pawnKindDef.combatPower;
                        //    Log.Message(string.Format("13 f"));
                    }
                }
            }
            //    Log.Message(string.Format("14"));
            return(result);
        }
        public static void Post_GeneratePawn_Yautja(PawnGenerationRequest request, ref Pawn __result)
        {
            Comp_Yautja _Yautja = __result.TryGetComp <Comp_Yautja>();

            if (_Yautja != null)
            {
                Backstory pawnStoryC = __result.story.childhood;
                Backstory pawnStoryA = __result.story.adulthood ?? null;

                AlienRace.BackstoryDef bsDefUnblooded = DefDatabase <AlienRace.BackstoryDef> .GetNamed("RRY_Yautja_YoungBlood");

                AlienRace.BackstoryDef bsDefBlooded = DefDatabase <AlienRace.BackstoryDef> .GetNamed("RRY_Yautja_Blooded");

                AlienRace.BackstoryDef bsDefBadbloodA = DefDatabase <AlienRace.BackstoryDef> .GetNamed("RRY_Yautja_BadBloodA");

                AlienRace.BackstoryDef bsDefBadblooBd = DefDatabase <AlienRace.BackstoryDef> .GetNamed("RRY_Yautja_BadBloodB");

                HediffDef unbloodedDef = YautjaDefOf.RRY_Hediff_Unblooded;
                HediffDef unmarkedDef  = YautjaDefOf.RRY_Hediff_BloodedUM;
                HediffDef markedDef    = YautjaDefOf.RRY_Hediff_BloodedM;

                bool hasunblooded = __result.health.hediffSet.HasHediff(unbloodedDef);
                bool hasbloodedUM = __result.health.hediffSet.HasHediff(unmarkedDef);
                bool hasbloodedM  = __result.health.hediffSet.hediffs.Any <Hediff>(x => x.def.defName.StartsWith(markedDef.defName));

                if (!hasunblooded && !hasbloodedUM && !hasbloodedM)
                {
                    HediffDef hediffDef;
                    if (pawnStoryA != null)
                    {
                        if (pawnStoryA != bsDefUnblooded.backstory && __result.kindDef.race == YautjaDefOf.RRY_Alien_Yautja)
                        {
                            hediffDef = _Yautja.Props.bloodedDefs.RandomElement();

                            if (hediffDef != null)
                            {
                                PawnKindDef pawnKindDef = YautjaBloodedUtility.RandomMarked(hediffDef);
                                if (_Yautja != null)
                                {
                                    _Yautja.MarkHedifflabel = pawnKindDef.LabelCap;
                                    _Yautja.MarkedhediffDef = hediffDef;
                                    _Yautja.predator        = pawnKindDef.RaceProps.predator;
                                    _Yautja.BodySize        = pawnKindDef.RaceProps.baseBodySize;
                                    _Yautja.combatPower     = pawnKindDef.combatPower;
                                    //    Log.Message(string.Format("{0}: {1}", hediffDef.stages[0].label, pawnKindDef.LabelCap));
                                }
                            }
                        }
                        else
                        {
                            hediffDef = unbloodedDef;
                        }
                    }
                    else
                    {
                        hediffDef = unbloodedDef;
                    }
                    foreach (var item in __result.RaceProps.body.AllParts)
                    {
                        if (item.def == BodyPartDefOf.Head)
                        {
                            __result.health.AddHediff(hediffDef, item);
                        }
                    }
                }
                else
                {
                    //    Log.Message(string.Format("new pawn has hasunblooded:{0}, hasbloodedUM:{1}, hasbloodedM:{2}", hasunblooded, hasbloodedUM, hasbloodedM));
                }
            }
            if (__result.kindDef.race == YautjaDefOf.RRY_Alien_Yautja)
            {
                if (request.Faction.leader == null && request.Faction != Faction.OfPlayerSilentFail && request.KindDef.race == YautjaDefOf.RRY_Alien_Yautja)
                {
                    bool upgradeWeapon = Rand.Chance(0.5f);
                    if (__result.equipment.Primary != null && upgradeWeapon)
                    {
                        __result.equipment.Primary.TryGetQuality(out QualityCategory weaponQuality);
                        if (weaponQuality != QualityCategory.Legendary)
                        {
                            Thing       Weapon         = __result.equipment.Primary;
                            CompQuality Weapon_Quality = Weapon.TryGetComp <CompQuality>();
                            if (Weapon_Quality != null)
                            {
                                Weapon_Quality.SetQuality(QualityCategory.Legendary, ArtGenerationContext.Outsider);
                            }
                        }
                    }
                    else if (__result.apparel.WornApparelCount > 0 && !upgradeWeapon)
                    {
                        foreach (var item in __result.apparel.WornApparel)
                        {
                            item.TryGetQuality(out QualityCategory gearQuality);
                            float upgradeChance = 0.5f;
                            bool  upgradeGear   = Rand.Chance(0.5f);
                            if (gearQuality != QualityCategory.Legendary)
                            {
                                CompQuality Gear_Quality = item.TryGetComp <CompQuality>();
                                if (Gear_Quality != null)
                                {
                                    if (upgradeGear)
                                    {
                                        Gear_Quality.SetQuality(QualityCategory.Legendary, ArtGenerationContext.Outsider);
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
            }

            /*
             * if (__result.Faction.def.defName.Contains("RRY_USCM"))
             * {
             *  __result.relations.ClearAllRelations();
             *
             *  if (__result.gender != Gender.Male)
             *  {
             *      PawnKindDef pawnKindDef = request.KindDef;
             *      if (pawnKindDef == request.KindDef) pawnKindDef = Rand.Chance(0.15f) ? AstartesOGDefOf.OG_Astartes_Neophyte : AstartesOGDefOf.OG_Astartes_Brother;
             *      if (pawnKindDef == request.KindDef) pawnKindDef = Rand.Chance(0.15f) ? AstartesOGDefOf.OG_Astartes_Sargent : AstartesOGDefOf.OG_Astartes_Brother;
             *      if (pawnKindDef == request.KindDef) pawnKindDef = Rand.Chance(0.15f) ? AstartesOGDefOf.OG_Astartes_Captain : AstartesOGDefOf.OG_Astartes_Brother;
             *      request = new PawnGenerationRequest(request.KindDef, request.Faction, request.Context, -1, true, false, false, false, false, true, 0f, fixedGender: Gender.Male, allowGay: false);
             *      __result = PawnGenerator.GeneratePawn(request);
             *  }
             *
             *  __result.story.bodyType = BodyTypeDefOf.Hulk;
             *  __result.gender = Gender.Male;
             *  //Log.Message(string.Format(__result.Drawer.renderer.graphics.headGraphic.data.texPath));
             *  //   __result.Drawer.renderer.graphics.headGraphic.data.texPath.ToString();
             *  HairDef hairdef = Rand.Chance(0.5f) ? AstartesOGDefOf.Shaved : AstartesOGDefOf.Topdog;
             *  __result.story.hairDef = hairdef;
             * }
             */
            if (__result.kindDef.RaceProps.FleshType == XenomorphRacesDefOf.RRY_Xenomorph)
            {
                if (request.KindDef == XenomorphDefOf.RRY_Xenomorph_Queen)
                {
                    __result.gender = Gender.Female;

                    /*
                     * bool QueenPresent = false;
                     *
                     * foreach (var p in Find.AnyPlayerHomeMap.mapPawns.AllPawns)
                     * {
                     *  if (p.kindDef == XenomorphDefOf.RRY_Xenomorph_Queen)
                     *  {
                     *  //    Log.Message(string.Format("Queen Found"));
                     *      QueenPresent = true;
                     *      break;
                     *  }
                     * }
                     * if (QueenPresent)
                     * {
                     *  request = new PawnGenerationRequest(XenomorphDefOf.RRY_Xenomorph_Warrior, request.Faction, request.Context, -1, true, false, false, false, false, true, 0f, fixedGender: Gender.None, allowGay: false);
                     *  __result = PawnGenerator.GeneratePawn(request);
                     *  __result.gender = Gender.None;
                     *  return;
                     * }
                     * else
                     * {
                     *  __result.gender = Gender.Female;
                     * }
                     */
                }
                else
                {
                    __result.gender = Gender.None;
                }
            }
            if (__result.kindDef.race != YautjaDefOf.RRY_Alien_Yautja && __result.RaceProps.Humanlike && (__result.story.hairDef == YautjaDefOf.RRY_Yaujta_Dreds || __result.story.hairDef == YautjaDefOf.RRY_Yaujta_Ponytail || __result.story.hairDef == YautjaDefOf.RRY_Yaujta_Bald))
            {
                Log.Message(string.Format("Non Yautja with Yautja Hair"));
                __result.story.hairDef = DefDatabase <HairDef> .AllDefsListForReading.FindAll(x => !x.hairTags.Contains("Yautja")).RandomElement();
            }
            if (Rand.Chance(0.005f) && XenomorphUtil.isInfectablePawn(__result) && SettingsHelper.latest.AllowHiddenInfections)
            {
                HediffDef def = Rand.Chance(0.75f) ? XenomorphDefOf.RRY_HiddenXenomorphImpregnation : XenomorphDefOf.RRY_HiddenNeomorphImpregnation;
                __result.health.AddHediff(def, __result.RaceProps.body.corePart, null);
            }
            var hediffGiverSet = __result?.def?.race?.hediffGiverSets;

            if (hediffGiverSet == null)
            {
                return;
            }
            foreach (var item in hediffGiverSet)
            {
                var hediffGivers = item.hediffGivers;
                if (hediffGivers == null)
                {
                    return;
                }
                if (hediffGivers.Any(y => y is HediffGiver_StartWithHediff))
                {
                    foreach (var hdg in hediffGivers.Where(x => x is HediffGiver_StartWithHediff))
                    {
                        HediffGiver_StartWithHediff hediffGiver_StartWith = (HediffGiver_StartWithHediff)hdg;
                        hediffGiver_StartWith.GiveHediff(__result);
                    }
                }
            }
        }
Ejemplo n.º 6
0
        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);
                }
            }
        }
Ejemplo n.º 7
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);
                }
            }
        }