Beispiel #1
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);
                }
            }
        }