public static void IgnoreCloak(Pawn __instance, ref bool __result, IAttackTargetSearcher disabledFor)
        {
            bool            selected__instance = Find.Selector.SelectedObjects.Contains(__instance);
            Comp_Facehugger _Xenomorph         = null;

            if (disabledFor != null)
            {
                if (disabledFor.Thing != null)
                {
                    _Xenomorph = disabledFor.Thing.TryGetComp <Comp_Facehugger>();
                    if (_Xenomorph != null)
                    {
                        __result = __result || !XenomorphUtil.isInfectablePawn(__instance);
                        //    Log.Message(string.Format("__instance: {0}, __result: {1}, _Xenomorph: {2}, Infectable?: {3}", __instance, __result, _Xenomorph, XenomorphUtil.isInfectablePawn(__instance)));
                    }
                }
            }
            if (__instance != null)
            {
                if (__instance != null)
                {
                }
            } // XenomorphDefOf.RRY_Hediff_Xenomorph_Hidden
            __result = __result || ((__instance.health.hediffSet.HasHediff(YautjaDefOf.RRY_Hediff_Cloaked) || __instance.health.hediffSet.HasHediff(XenomorphDefOf.RRY_Hediff_Xenomorph_Hidden)) && _Xenomorph == null);
        }
コード例 #2
0
        // Token: 0x0600295E RID: 10590 RVA: 0x00139BAC File Offset: 0x00137FAC

        public override void CompTickRare()
        {
            float ambientTemperature = this.parent.AmbientTemperature;
            bool  selected           = Find.Selector.SelectedObjects.Contains(this.parent) && Prefs.DevMode;
            Thing thing = null;

            if (MyMap != null && MyPos.InBounds(MyMap))
            {
                thing = GenClosest.ClosestThingReachable(MyPos, MyMap, ThingRequest.ForGroup(ThingRequestGroup.Pawn), PathEndMode.OnCell, TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Deadly, false), Props.triggerRadius, x => XenomorphUtil.isInfectablePawn(((Pawn)x)), null, 0, -1, false, RegionType.Set_Passable, false);
            }
            int huggercount = thing != null?XenomorphUtil.TotalSpawnedFacehuggerPawnCount(MyMap, 10, (Pawn)thing) : 0;

            int hostcount = thing != null?XenomorphUtil.TotalSpawnedInfectablePawnCount(MyMap, 10, this.MyPos) : 0;

            bool shouldHatch = huggercount < hostcount;

            if (thing != null && ambientTemperature > -20f)
            {
                Pawn pawn = (Pawn)thing;
                bool flag = XenomorphUtil.isInfectablePawn(pawn);
                if (selected)
                {
                    //    Log.Message(string.Format("{0} isInfectable?: {1}", pawn.Label, flag));
                }
                if (flag)
                {
                    this.canHatch = true;
                }
                if (canHatch && shouldHatch && DistanceBetween(MyPos, pawn.Position) < 10f)
                {
                    float thingdist      = DistanceBetween(MyPos, pawn.Position);
                    float thingsize      = pawn.BodySize;
                    float thingstealth   = thing.GetStatValue(StatDefOf.HuntingStealth);
                    float thingmovespeed = thing.GetStatValue(StatDefOf.MoveSpeed);
                    if (selected)
                    {
                        //    Log.Message(string.Format("distance between {1} @{3} and {2} @ {4}: {0}", DistanceBetween(MyPos, pawn.Position), this.parent.LabelShort, pawn.Label, MyPos, pawn.Position));
                        //    Log.Message(string.Format("{0} thingsize: {1}, thingstealth: {2}, thingmovespeed: {3}", pawn.Label, thingsize, thingstealth, thingmovespeed));
                    }

                    float hatchon = ((10 * thingdist) - (thingsize * 5));
                    float roll    = thingstealth > 0 ? (Rand.RangeInclusive(0, 100) * thingstealth): (Rand.RangeInclusive(0, 100));
                    if (roll > hatchon)
                    {
                        this.willHatch = true;
                    }
                    if (selected)
                    {
                        Log.Message(string.Format("{0} hatchon: {1}, roll: {2}, willHatch: {3}", pawn.Label, hatchon, roll, willHatch));
                    }
                }
            }
            if (thing == null)
            {
                //    if (selected) Log.Message(string.Format("{0} @ {1}, Cant hatch No suitable Host Found", this.parent.Label, MyPos, canHatch));
            }
        }
        public static void Postfix(Thing bedThing, Pawn sleeper, Pawn traveler, ref bool __result)
        {
            bool flag  = bedThing is Building_XenomorphCocoon;
            bool flag2 = traveler != null?traveler.kindDef.race.defName.Contains("RRY_Xenomorph") : false;

            bool flag3 = XenomorphUtil.isInfectablePawn(sleeper);

            __result = __result && !flag || (__result && flag && flag2);
            //    Log.Message(string.Format("RestUtility_Bed_IsValidBedFor sleeper: {0} traveler: {1} result: {2} = !flag: {3} && flag2: {4}", sleeper, traveler, __result, !flag , flag2));
            return;
        }
 public static void HarmsHealthPostfix(Pawn_MeleeVerbs __instance, Thing target, ref Verb ___curMeleeVerb)
 {
     if (__instance.Pawn.isXenomorph() && __instance.Pawn.def != XenomorphRacesDefOf.RRY_Xenomorph_FaceHugger && target is Pawn pawn)
     {
         if (XenomorphUtil.isInfectablePawn(pawn))
         {
             bool             flag = Rand.Chance(0.04f);
             List <VerbEntry> updatedAvailableVerbsList = __instance.GetUpdatedAvailableVerbsList(flag);
             //    Log.Message(string.Format("All AvailableVerbs for {0}: {1}", __instance.Pawn.LabelShortCap, updatedAvailableVerbsList.Count));
             updatedAvailableVerbsList = updatedAvailableVerbsList.FindAll(x => x.verb.maneuver == DefDatabase <ManeuverDef> .GetNamedSilentFail("Smash"));
             //    Log.Message(string.Format("AvailableVerbs Smash for {0}: {1}", __instance.Pawn.LabelShortCap, updatedAvailableVerbsList.Count));
             bool      flag2 = false;
             VerbEntry verbEntry;
             if (updatedAvailableVerbsList.TryRandomElementByWeight((VerbEntry ve) => ve.GetSelectionWeight(target), out verbEntry))
             {
                 flag2 = true;
                 //    Log.Message(string.Format("{0}'s using {1} against {2}", __instance.Pawn.LabelShortCap, verbEntry.verb.maneuver, pawn.LabelShortCap));
             }
             else if (flag)
             {
                 updatedAvailableVerbsList = __instance.GetUpdatedAvailableVerbsList(false);
                 updatedAvailableVerbsList = updatedAvailableVerbsList.FindAll(x => x.verb.maneuver == DefDatabase <ManeuverDef> .GetNamedSilentFail("Smash"));
                 flag2 = updatedAvailableVerbsList.TryRandomElementByWeight((VerbEntry ve) => ve.GetSelectionWeight(target), out verbEntry);
                 //    Log.Message(string.Format("{0}'s using {1} against {2}", __instance.Pawn.LabelShortCap, verbEntry.verb.maneuver, pawn.LabelShortCap));
             }
             if (flag2)
             {
                 //    verbEntry.verb.tool.capacities.Contains();
                 ___curMeleeVerb = verbEntry.verb;
             }
             else
             {
                 Log.ErrorOnce(string.Concat(new object[]
                 {
                     __instance.Pawn.ToStringSafe <Pawn>(),
                     " has no available melee attack, spawned=",
                     __instance.Pawn.Spawned,
                     " dead=",
                     __instance.Pawn.Dead,
                     " downed=",
                     __instance.Pawn.Downed,
                     " curJob=",
                     __instance.Pawn.CurJob.ToStringSafe <Job>(),
                     " verbList=",
                     updatedAvailableVerbsList.ToStringSafeEnumerable(),
                     " bodyVerbs=",
                     __instance.Pawn.verbTracker.AllVerbs.ToStringSafeEnumerable()
                 }), __instance.Pawn.thingIDNumber ^ 195867354, false);
                 ___curMeleeVerb = null;
             }
         }
     }
 }
コード例 #5
0
        // Token: 0x060004D2 RID: 1234 RVA: 0x00031074 File Offset: 0x0002F474
        public static bool TryFindGoodImpregnateVictim(Pawn kidnapper, float maxDist, out Pawn victim, List <Thing> disallowed = null)
        {
            if (!kidnapper.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation) || !kidnapper.Map.reachability.CanReachMapEdge(kidnapper.Position, TraverseParms.For(kidnapper, Danger.Some, TraverseMode.ByPawn, false)))
            {
                //    Log.Message(string.Format("TryFindGoodImpregnateVictim \n{0} incapable of job", kidnapper.LabelShortCap));
                victim = null;
                return(false);
            }
            Predicate <Thing> validator = delegate(Thing t)
            {
                Pawn pawn       = t as Pawn;
                bool cocoonFlag = !pawn.health.hediffSet.HasHediff(XenomorphDefOf.RRY_Hediff_Cocooned);
                bool pawnFlag   = ((XenomorphUtil.isInfectablePawn(pawn))) && !XenomorphUtil.IsXenomorph(pawn) && pawn.gender == Gender.Female && pawn.Downed && (pawn.Faction == null || pawn.Faction.HostileTo(kidnapper.Faction) || kidnapper.Faction == null);
                //    Log.Message(string.Format(" cocoonFlag; {0} \n pawnFlag: {1}", cocoonFlag, pawnFlag));
                return((cocoonFlag && pawnFlag) && (kidnapper.CanReserve(pawn, 1, -1, null, false) && (disallowed == null || !disallowed.Contains(pawn))) && pawn != kidnapper && pawn.gender == Gender.Female);
            };

            //    Log.Message(string.Format("TryFindGoodImpregnateVictim \nvalidator {0}", validator));
            victim = (Pawn)GenClosest.ClosestThingReachable(kidnapper.Position, kidnapper.Map, ThingRequest.ForGroup(ThingRequestGroup.Pawn), PathEndMode.OnCell, TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Some, false), maxDist, validator, null, 0, -1, false, RegionType.Set_Passable, false);
            //    Log.Message(string.Format("TryFindGoodImpregnateVictim \nvictim {0}", victim));
            return(victim != null);
        }
コード例 #6
0
        // Token: 0x060004D2 RID: 1234 RVA: 0x00031074 File Offset: 0x0002F474
        public static bool TryFindGoodKidnapVictim(Pawn kidnapper, float maxDist, out Pawn victim, List <Thing> disallowed = null)
        {
            if (!kidnapper.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation) || !kidnapper.Map.reachability.CanReachMapEdge(kidnapper.Position, TraverseParms.For(kidnapper, Danger.Some, TraverseMode.ByPawn, false)))
            {
                victim = null;
                return(false);
            }
            Predicate <Thing> validator = delegate(Thing t)
            {
                Pawn pawn                       = t as Pawn;
                bool cocoonFlag                 = !pawn.health.hediffSet.HasHediff(XenomorphDefOf.RRY_Hediff_Cocooned);
                bool xenoimpregnationFlag       = !pawn.health.hediffSet.HasHediff(XenomorphDefOf.RRY_XenomorphImpregnation) || (pawn.health.hediffSet.HasHediff(XenomorphDefOf.RRY_XenomorphImpregnation) && pawn.health.hediffSet.GetFirstHediffOfDef(XenomorphDefOf.RRY_XenomorphImpregnation).CurStageIndex != pawn.health.hediffSet.GetFirstHediffOfDef(XenomorphDefOf.RRY_XenomorphImpregnation).def.stages.Count - 2);
                bool xenohiddenimpregnationFlag = !pawn.health.hediffSet.HasHediff(XenomorphDefOf.RRY_HiddenXenomorphImpregnation) || (pawn.health.hediffSet.HasHediff(XenomorphDefOf.RRY_HiddenXenomorphImpregnation) && pawn.health.hediffSet.GetFirstHediffOfDef(XenomorphDefOf.RRY_HiddenXenomorphImpregnation).CurStageIndex != pawn.health.hediffSet.GetFirstHediffOfDef(XenomorphDefOf.RRY_HiddenXenomorphImpregnation).def.stages.Count - 2);
                bool neoimpregnationFlag        = !pawn.health.hediffSet.HasHediff(XenomorphDefOf.RRY_NeomorphImpregnation);
                bool neohiddenimpregnationFlag  = !pawn.health.hediffSet.HasHediff(XenomorphDefOf.RRY_HiddenNeomorphImpregnation);
                bool impregnationFlag           = xenoimpregnationFlag && xenohiddenimpregnationFlag && neoimpregnationFlag && neohiddenimpregnationFlag;
                bool pawnFlag                   = ((XenomorphUtil.isInfectablePawn(pawn, true))) && pawn.Downed && (pawn.Faction == null || pawn.Faction.HostileTo(kidnapper.Faction));
                return(cocoonFlag && pawnFlag && kidnapper.CanReserve(pawn, 1, -1, null, false) && (disallowed == null || !disallowed.Contains(pawn)));
            };

            victim = (Pawn)GenClosest.ClosestThingReachable(kidnapper.Position, kidnapper.Map, ThingRequest.ForGroup(ThingRequestGroup.Pawn), PathEndMode.OnCell, TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Some, false), maxDist, validator, null, 0, -1, false, RegionType.Set_Passable, false);
            return(victim != null);
        }
コード例 #7
0
        public void GiveHediff(Pawn pawn)
        {
            if (!XenomorphUtil.isInfectablePawn(pawn))
            {
                return;
            }
            //If the random number is not within the chance range, exit.
            if (!(chance >= Rand.Range(0.0f, 100.0f)))
            {
                return;
            }
            //If the gender is male, check the male commonality chance, and if it fails, exit.
            if (pawn.gender == Gender.Male && !(maleCommonality >= Rand.Range(0.0f, 100.0f)))
            {
                return;
            }
            //If the gender is female, check the female commonality chance, and if it fails, exit.
            if (pawn.gender == Gender.Female && !(femaleCommonality >= Rand.Range(0.0f, 100.0f)))
            {
                return;
            }

            HediffGiverUtility.TryApply(pawn, hediff, partsToAffect);
        }
コード例 #8
0
        public override void TickLong()
        {
            base.TickLong();
            bool selected = Find.Selector.SingleSelectedThing == this;

            if (!this.IsBurning() && !this.Destroyed && this.Map != null)
            {
                Thing thing = GenClosest.ClosestThingReachable(this.Position, this.Map, ThingRequest.ForGroup(ThingRequestGroup.Pawn), PathEndMode.OnCell, TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Deadly, false), radius, x => XenomorphUtil.isInfectablePawn(((Pawn)x)), null, 0, -1, false, RegionType.Set_Passable, false);
                if (thing != null && this.Growth > 0.95f && !thing.Destroyed && !((Pawn)thing).Dead)
                {
                    List <Thing> thingList = GridsUtility.GetThingList(thing.Position, this.Map);
                    Thing        thing2;


                    if (!PlayerKnowledgeDatabase.IsComplete(XenomorphConceptDefOf.RRY_Concept_Fungus))
                    {
                        thing2 = ThingMaker.MakeThing(XenomorphDefOf.RRY_Neomorph_Spores_Hidden);
                    }
                    else
                    {
                        thing2 = ThingMaker.MakeThing(XenomorphDefOf.RRY_Neomorph_Spores);
                    }

                    float Chance = ((0.5f * Growth) * ((Pawn)thing).BodySize) / DistanceBetween(this.Position, thing.Position);
                    //    if (selected) Log.Message(string.Format("Chance: {0}", Chance));
                    if (Rand.Chance(Chance) && !thingList.Exists(x => x.def == XenomorphDefOf.RRY_Neomorph_Spores))
                    {
                        if (thing.Faction == Faction.OfPlayer)
                        {
                            string text = TranslatorFormattedStringExtensions.Translate("Xeno_Neospores_Trigger", thing.LabelShortCap, this.Label);
                            //    Log.Message(text);
                            MoteMaker.ThrowText(this.Position.ToVector3(), this.Map, text, 5f);
                        }
                        GenSpawn.Spawn(thing2, thing.Position, this.Map);
                    }
                }
                else
                {
                    HarmRandomPlantInRadius(radius / 2);
                }
            }
        }
コード例 #9
0
        public static List <Thing> SpawnedEggsNeedHosts(Map map)
        {
            List <Thing> list = new List <Thing>();

            foreach (var item in SpawnedEggs(map))
            {
                Pawn host = (Pawn)GenClosest.ClosestThingReachable(item.Position, item.Map, ThingRequest.ForGroup(ThingRequestGroup.Pawn), PathEndMode.OnCell, TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Deadly, false), 1, x => XenomorphUtil.isInfectablePawn(((Pawn)x)), null, 0, -1, false, RegionType.Set_Passable, false);
                if (host == null)
                {
                    list.Add(item);
                }
            }
            return(list);
        }
コード例 #10
0
 public static List <Pawn> SpawnedInfectablePawns(Map map, int radius, IntVec3 position, IntVec3 otherposition)
 {
     return(map.mapPawns.AllPawnsSpawned.FindAll(x => XenomorphUtil.isInfectablePawn(x) && XenomorphUtil.DistanceBetween(otherposition, position) < radius));
 }
コード例 #11
0
 public static List <Pawn> SpawnedInfectablePawns(Map map)
 {
     return(map.mapPawns.AllPawnsSpawned.FindAll(x => XenomorphUtil.isInfectablePawn(x)));
 }
コード例 #12
0
        // Token: 0x060039DE RID: 14814 RVA: 0x001B8078 File Offset: 0x001B6478
        private IEnumerable <DamageInfo> DamageInfosToApply(LocalTargetInfo target)
        {
            Pawn  hitPawn     = (Pawn)target;
            bool  flag        = XenomorphUtil.isInfectablePawn(hitPawn);
            float tgtmelee    = 0f;
            float tgtdodge    = 0f;
            float armourBlunt = 0f;
            float armourSharp = 0f;
            float armourHeat  = 0f;
            float armour      = 0f;

            if (hitPawn.RaceProps.Humanlike)
            {
                tgtmelee = hitPawn.skills.GetSkill(SkillDefOf.Melee).Level;
            }
            if (hitPawn.RaceProps.Humanlike)
            {
                tgtdodge = hitPawn.GetStatValue(StatDefOf.MeleeDodgeChance);
            }
            if (hitPawn.RaceProps.Humanlike)
            {
                if (hitPawn.apparel.WornApparel.Count > 0 && hitPawn.apparel.WornApparel is List <Apparel> wornApparel)
                {
                    for (int i = 0; i < wornApparel.Count; i++)
                    {
                        bool flag2 = wornApparel[i].def.apparel.CoversBodyPart(Head);
                        if (flag2)
                        {
                            armourBlunt = wornApparel[i].def.statBases.GetStatOffsetFromList(StatDefOf.ArmorRating_Blunt); // hitPawn.GetStatValue(StatDefOf.ArmorRating_Blunt, false);
                            armourSharp = wornApparel[i].def.statBases.GetStatOffsetFromList(StatDefOf.ArmorRating_Sharp); //hitPawn.GetStatValue(StatDefOf.ArmorRating_Sharp, false);
                            armourHeat  = wornApparel[i].def.statBases.GetStatOffsetFromList(StatDefOf.ArmorRating_Heat);  //hitPawn.GetStatValue(StatDefOf.ArmorRating_Heat, false);
                            armour      = (armourBlunt + armourSharp + armourHeat);
                            //     Log.Message(string.Format("Pawn: {4}\narmourBlunt: {0}, armourSharp: {1}, armourHeat: {2}, Total Armour {3}", armourBlunt, armourSharp, armourHeat, armour, wornApparel[i].LabelShortCap));
                        }
                    }
                }
            }
            float InfecterRoll     = (Rand.Value * 100) * (1 - tgtdodge);
            float InfectionDefence = 50 + tgtmelee + (armour * 10);

            if ((InfecterRoll > InfectionDefence || hitPawn.Downed) && flag && hitPawn is Pawn && !hitPawn.health.hediffSet.HasHediff(XenomorphDefOf.RRY_Hediff_Anesthetic))
            {
                infect = true;
            }
            else
            {
                infect = false;
            }
            float            damAmount        = this.verbProps.AdjustedMeleeDamageAmount(this, base.CasterPawn);
            float            armorPenetration = this.verbProps.AdjustedArmorPenetration(this, base.CasterPawn);
            DamageDef        damDef           = this.verbProps.meleeDamageDef;
            BodyPartGroupDef bodyPartGroupDef = null;

            HediffDef hediffDef = null;

            damAmount = Rand.Range(damAmount * 0.8f, damAmount * 1.2f);
            if (base.CasterIsPawn)
            {
                bodyPartGroupDef = this.verbProps.AdjustedLinkedBodyPartsGroup(this.tool);
                if (damAmount >= 1f)
                {
                    if (base.HediffCompSource != null)
                    {
                        hediffDef = base.HediffCompSource.Def;
                    }
                }
                else
                {
                    damAmount = 1f;
                    damDef    = DamageDefOf.Blunt;
                }
            }
            ThingDef source;

            if (base.EquipmentSource != null)
            {
                source = base.EquipmentSource.def;
            }
            else
            {
                source = base.CasterPawn.def;
            }
            Vector3    direction = (target.Thing.Position - base.CasterPawn.Position).ToVector3();
            DamageDef  def       = damDef;
            float      num       = damAmount;
            float      num2      = armorPenetration;
            Thing      caster    = this.caster;
            DamageInfo mainDinfo = new DamageInfo(def, num, num2, -1f, caster, null, source, DamageInfo.SourceCategory.ThingOrUnknown, null);

            mainDinfo.SetBodyRegion(BodyPartHeight.Undefined, BodyPartDepth.Outside);
            mainDinfo.SetWeaponBodyPartGroup(bodyPartGroupDef);
            mainDinfo.SetWeaponHediff(hediffDef);
            mainDinfo.SetAngle(direction);
            yield return(mainDinfo);

            if (this.surpriseAttack && ((this.verbProps.surpriseAttack != null && !this.verbProps.surpriseAttack.extraMeleeDamages.NullOrEmpty <ExtraMeleeDamage>()) || (this.tool != null && this.tool.surpriseAttack != null && !this.tool.surpriseAttack.extraMeleeDamages.NullOrEmpty <ExtraMeleeDamage>())))
            {
                IEnumerable <ExtraMeleeDamage> extraDamages = Enumerable.Empty <ExtraMeleeDamage>();
                if (this.verbProps.surpriseAttack != null && this.verbProps.surpriseAttack.extraMeleeDamages != null)
                {
                    extraDamages = extraDamages.Concat(this.verbProps.surpriseAttack.extraMeleeDamages);
                }
                if (this.tool != null && this.tool.surpriseAttack != null && !this.tool.surpriseAttack.extraMeleeDamages.NullOrEmpty <ExtraMeleeDamage>())
                {
                    extraDamages = extraDamages.Concat(this.tool.surpriseAttack.extraMeleeDamages);
                }
                foreach (ExtraMeleeDamage extraDamage in extraDamages)
                {
                    int   extraDamageAmount           = GenMath.RoundRandom(extraDamage.AdjustedDamageAmount(this, base.CasterPawn));
                    float extraDamageArmorPenetration = extraDamage.AdjustedArmorPenetration(this, base.CasterPawn);
                    def    = extraDamage.def;
                    num2   = (float)extraDamageAmount;
                    num    = extraDamageArmorPenetration;
                    caster = this.caster;
                    DamageInfo extraDinfo = new DamageInfo(def, num2, num, -1f, caster, null, source, DamageInfo.SourceCategory.ThingOrUnknown, null);
                    extraDinfo.SetBodyRegion(BodyPartHeight.Undefined, BodyPartDepth.Outside);
                    extraDinfo.SetWeaponBodyPartGroup(bodyPartGroupDef);
                    extraDinfo.SetWeaponHediff(hediffDef);
                    extraDinfo.SetAngle(direction);
                    yield return(extraDinfo);
                }
            }
            yield break;
        }
コード例 #13
0
        public override void TickLong()
        {
            base.TickLong();
            bool selected = Find.Selector.SingleSelectedThing == this;

            if (!this.IsBurning() && !this.Destroyed && this.Map != null)
            {
                Thing thing = GenClosest.ClosestThingReachable(this.Position, this.Map, ThingRequest.ForGroup(ThingRequestGroup.Pawn), PathEndMode.OnCell, TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Deadly, false), 6f, x => XenomorphUtil.isInfectablePawn(((Pawn)x)), null, 0, -1, false, RegionType.Set_Passable, false);
                if (thing != null && this.Growth > 0.95f && !thing.Destroyed && !((Pawn)thing).Dead)
                {
                    List <Thing> thingList = GridsUtility.GetThingList(thing.Position, this.Map);
                    Thing        thing2;
                    if (this.def == XenomorphDefOf.RRY_Plant_Neomorph_Fungus)
                    {
                        thing2 = ThingMaker.MakeThing(XenomorphDefOf.RRY_Neomorph_Spores);
                    }
                    else
                    {
                        thing2 = ThingMaker.MakeThing(XenomorphDefOf.RRY_Neomorph_Spores_Hidden);
                    }
                    float Chance = ((0.5f * Growth) * ((Pawn)thing).BodySize) / DistanceBetween(this.Position, thing.Position);
                    if (selected)
                    {
                        Log.Message(string.Format("Chance: {0}", Chance));
                    }
                    if (Rand.Chance(Chance) && !thingList.Exists(x => x.def == XenomorphDefOf.RRY_Neomorph_Spores))
                    {
                        if (thing.Faction == Faction.OfPlayer)
                        {
                            string text = TranslatorFormattedStringExtensions.Translate("Xeno_Neospores_Trigger", thing.LabelShortCap, this.Label);
                            Log.Message(text);
                            MoteMaker.ThrowText(this.Position.ToVector3(), this.Map, text, 5f);
                        }
                        GenSpawn.Spawn(thing2, thing.Position, this.Map);
                    }
                }
                else
                {
                    Plant plant = (Plant)GenClosest.ClosestThingReachable(this.Position, this.Map, ThingRequest.ForGroup(ThingRequestGroup.Plant), PathEndMode.OnCell, TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Deadly, false), 3f, x => ((Plant)x).Growth > 0.65f && x.def != XenomorphDefOf.RRY_Plant_Neomorph_Fungus && x.def != XenomorphDefOf.RRY_Plant_Neomorph_Fungus_Hidden && (x.def.defName.Contains("Grass") || x.def.defName.Contains("Moss")), null, 0, -1, false, RegionType.Set_Passable, false);
                    if (plant != null && !plant.Destroyed && !plant.IsBurning() && this.Growth > 0.95f)
                    {
                        if (selected)
                        {
                            Log.Message(string.Format("plant: {0}", plant));
                        }
                        float Chance2 = ((0.5f * Growth) * plant.Growth / DistanceBetween(this.Position, plant.Position));
                        if (selected)
                        {
                            Log.Message(string.Format("Chance2: {0}", Chance2));
                        }
                        if (Rand.Chance(Chance2))
                        {
                            Thing thing2;
                            if (this.def == XenomorphDefOf.RRY_Plant_Neomorph_Fungus)
                            {
                                thing2 = ThingMaker.MakeThing(XenomorphDefOf.RRY_Neomorph_Spores);
                            }
                            else
                            {
                                thing2 = ThingMaker.MakeThing(XenomorphDefOf.RRY_Neomorph_Spores_Hidden);
                            }
                            if (selected)
                            {
                                Log.Message(string.Format("was: {0}", plant));
                            }
                            IntVec3 vec3 = plant.Position;
                            GenSpawn.Spawn(thing2, vec3, this.Map);
                            plant.Destroy();
                            GenSpawn.Spawn(ThingMaker.MakeThing(this.def), vec3, this.Map);
                        }
                    }
                }
            }
        }
コード例 #14
0
        // Token: 0x0600295E RID: 10590 RVA: 0x00139BAC File Offset: 0x00137FAC
        public override void CompTickRare()
        {
            bool  selected = Find.Selector.SingleSelectedThing == this.parent;
            Thing thing    = GenClosest.ClosestThingReachable(this.parent.Position, this.parent.Map, ThingRequest.ForGroup(ThingRequestGroup.Pawn), PathEndMode.OnCell, TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Deadly, false), Props.triggerRadius, x => XenomorphUtil.isInfectablePawn(((Pawn)x)), null, 0, -1, false, RegionType.Set_Passable, false);

            if (thing != null)
            {
                Pawn pawn = (Pawn)thing;
                bool flag = XenomorphUtil.isInfectablePawn(pawn);
#if DEBUG
                if (selected)
                {
                    Log.Message(string.Format("{0} isInfectable?: {1}", pawn.Label, flag));
                }
#endif
                if (flag)
                {
                    this.canHatch = true;
                }
                if (canHatch)
                {
                    float  thingdist      = DistanceBetween(this.parent.Position, pawn.Position);
                    float  thingsize      = pawn.BodySize;
                    float  thingstealth   = thing.GetStatValue(StatDefOf.HuntingStealth);
                    float  thingmovespeed = thing.GetStatValue(StatDefOf.MoveSpeed);
                    Stance thingstance    = pawn.stances.curStance;
#if DEBUG
                    if (selected)
                    {
                        Log.Message(string.Format("distance between {1} @{3} and {2} @ {4}: {0}", DistanceBetween(this.parent.Position, pawn.Position), this.parent.LabelShort, pawn.Label, this.parent.Position, pawn.Position));
                        Log.Message(string.Format("{0} thingsize: {1}, thingstealth: {2}, thingmovespeed: {3}, thingstance: {4}", pawn.Label, thingsize, thingstealth, thingmovespeed, thingstance));
                    }
#endif
                    float hatchon = ((100 / thingdist) * thingsize);
                    if (thingstance.GetType() == typeof(Stance_Mobile))
                    {
                        hatchon = (((100 / thingdist) * thingmovespeed) * thingsize);
                    }
                    float roll = (Rand.RangeInclusive(0, 100) / thingstealth);
#if DEBUG
                    if (selected)
                    {
                        Log.Message(string.Format("{0} hatchon: {1}, roll: {2}, moving?: {3}", pawn.Label, hatchon, roll, thingstance.GetType() == typeof(Stance_Mobile)));
                    }
#endif
                    if (roll < hatchon)
                    {
                        this.willHatch = true;
                    }
                }
            }
#if DEBUG
            if (thing == null)
            {
                if (selected)
                {
                    Log.Message(string.Format("{0} @ {1}, Cant hatch No suitable Host Found", this.parent.Label, this.parent.Position, canHatch));
                }
            }
#endif
        }
コード例 #15
0
        // Token: 0x060039DE RID: 14814 RVA: 0x001B8078 File Offset: 0x001B6478
        private IEnumerable <DamageInfo> DamageInfosToApply(LocalTargetInfo target)
        {
            Pawn  hitPawn  = (Pawn)target;
            bool  flag     = XenomorphUtil.isInfectablePawn(hitPawn);
            float tgtmelee = 0f;
            float tgtdodge = 0f;

            if (hitPawn.RaceProps.Humanlike)
            {
                tgtmelee = hitPawn.skills.GetSkill(SkillDefOf.Melee).Level;
            }
            if (hitPawn.RaceProps.Humanlike)
            {
                tgtdodge = hitPawn.GetStatValue(StatDefOf.MeleeDodgeChance);
            }
            if (((Rand.Value * 100) * (1 - tgtdodge) > 50 + tgtmelee || hitPawn.Downed) && flag && hitPawn is Pawn)
            {
                infect = true;
            }
            float            damAmount        = this.verbProps.AdjustedMeleeDamageAmount(this, base.CasterPawn);
            float            armorPenetration = this.verbProps.AdjustedArmorPenetration(this, base.CasterPawn);
            DamageDef        damDef           = this.verbProps.meleeDamageDef;
            BodyPartGroupDef bodyPartGroupDef = null;
            HediffDef        hediffDef        = null;

            damAmount = Rand.Range(damAmount * 0.8f, damAmount * 1.2f);
            if (base.CasterIsPawn)
            {
                bodyPartGroupDef = this.verbProps.AdjustedLinkedBodyPartsGroup(this.tool);
                if (damAmount >= 1f)
                {
                    if (base.HediffCompSource != null)
                    {
                        hediffDef = base.HediffCompSource.Def;
                    }
                }
                else
                {
                    damAmount = 1f;
                    damDef    = DamageDefOf.Blunt;
                }
            }
            ThingDef source;

            if (base.EquipmentSource != null)
            {
                source = base.EquipmentSource.def;
            }
            else
            {
                source = base.CasterPawn.def;
            }
            Vector3    direction = (target.Thing.Position - base.CasterPawn.Position).ToVector3();
            DamageDef  def       = damDef;
            float      num       = damAmount;
            float      num2      = armorPenetration;
            Thing      caster    = this.caster;
            DamageInfo mainDinfo = new DamageInfo(def, num, num2, -1f, caster, null, source, DamageInfo.SourceCategory.ThingOrUnknown, null);

            mainDinfo.SetBodyRegion(BodyPartHeight.Undefined, BodyPartDepth.Outside);
            mainDinfo.SetWeaponBodyPartGroup(bodyPartGroupDef);
            mainDinfo.SetWeaponHediff(hediffDef);
            mainDinfo.SetAngle(direction);
            yield return(mainDinfo);

            if (this.surpriseAttack && ((this.verbProps.surpriseAttack != null && !this.verbProps.surpriseAttack.extraMeleeDamages.NullOrEmpty <ExtraMeleeDamage>()) || (this.tool != null && this.tool.surpriseAttack != null && !this.tool.surpriseAttack.extraMeleeDamages.NullOrEmpty <ExtraMeleeDamage>())))
            {
                IEnumerable <ExtraMeleeDamage> extraDamages = Enumerable.Empty <ExtraMeleeDamage>();
                if (this.verbProps.surpriseAttack != null && this.verbProps.surpriseAttack.extraMeleeDamages != null)
                {
                    extraDamages = extraDamages.Concat(this.verbProps.surpriseAttack.extraMeleeDamages);
                }
                if (this.tool != null && this.tool.surpriseAttack != null && !this.tool.surpriseAttack.extraMeleeDamages.NullOrEmpty <ExtraMeleeDamage>())
                {
                    extraDamages = extraDamages.Concat(this.tool.surpriseAttack.extraMeleeDamages);
                }
                foreach (ExtraMeleeDamage extraDamage in extraDamages)
                {
                    int   extraDamageAmount           = GenMath.RoundRandom(extraDamage.AdjustedDamageAmount(this, base.CasterPawn));
                    float extraDamageArmorPenetration = extraDamage.AdjustedArmorPenetration(this, base.CasterPawn);
                    def    = extraDamage.def;
                    num2   = (float)extraDamageAmount;
                    num    = extraDamageArmorPenetration;
                    caster = this.caster;
                    DamageInfo extraDinfo = new DamageInfo(def, num2, num, -1f, caster, null, source, DamageInfo.SourceCategory.ThingOrUnknown, null);
                    extraDinfo.SetBodyRegion(BodyPartHeight.Undefined, BodyPartDepth.Outside);
                    extraDinfo.SetWeaponBodyPartGroup(bodyPartGroupDef);
                    extraDinfo.SetWeaponHediff(hediffDef);
                    extraDinfo.SetAngle(direction);
                    yield return(extraDinfo);
                }
            }
            yield break;
        }
コード例 #16
0
        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);
                    }
                }
            }
        }