예제 #1
0
        public static void damage_virally(Map m)
        {
            var vir_dam = DefDatabase <DamageDef> .GetNamed("ViralDamage");

            var p       = m.mapPawns.FreeColonists.RandomElement();
            var lun     = p.RaceProps.body.AllParts.Find((BodyPartRecord bpr) => String.Equals(bpr.def.defName, "LeftLung"));
            var dam_def = HealthUtility.GetHediffDefFromDamage(vir_dam, p, lun);
            var inj     = (Hediff_Injury)HediffMaker.MakeHediff(dam_def, p, null);

            inj.Severity = 2.0f;
            inj.TryGetComp <HediffComp_GetsPermanent>().IsPermanent = true;
            p.health.AddHediff(inj, lun, null);
        }
예제 #2
0
 public virtual void PostPostTerminalOn()
 {
     if (def == ThingDefs.VoidNetTerminal_Scout)
     {
         if (VoidEnergyHediffTerminalMoveSpeed != null && oldWearer != null && !oldWearer.Destroyed)
         {
             oldWearer.health.RemoveHediff(VoidEnergyHediffTerminalMoveSpeed);
         }
         VoidEnergyHediffTerminalMoveSpeed = HediffMaker.MakeHediff(HediffDefs.VoidEnergyHediffTerminalMoveSpeed, Wearer, null);
         Wearer.health.AddHediff(VoidEnergyHediffTerminalMoveSpeed, null, null, null);
     }
     oldWearer = Wearer;
 }
예제 #3
0
        private static void HugFace(DamageInfo dinfo, Thing victim)
        {
            var hitPawn = victim as Pawn;

            var hediff = HediffMaker.MakeHediff(HediffDef.Named("THU_XenoLarva"), hitPawn);

            hitPawn?.health?.AddHediff(hediff);

            RemoveFacehugger(dinfo.Instigator);

            Messages.Message("THU_FaceHugged_SuccessMessage".Translate(hitPawn?.Label),
                             MessageTypeDefOf.NegativeEvent);
        }
예제 #4
0
        public override void Effect(Pawn target)
        {
            CasterPawn.Drawer.Notify_DebugAffected();
            MoteMaker.ThrowText(CasterPawn.DrawPos, CasterPawn.Map, AbilityUser.StringsToTranslate.AU_CastSuccess);
            HediffWithComps hediff = (HediffWithComps)HediffMaker.MakeHediff(VampDefOf.ROMV_MindReadingHediff, CasterPawn);

            if (hediff.TryGetComp <HediffComp_ReadMind>() is HediffComp_ReadMind rm)
            {
                rm.MindBeingRead = target;
            }
            hediff.Severity = 1.0f;
            CasterPawn.health.AddHediff(hediff, null, null);
        }
예제 #5
0
 public override void CompTickRare()
 {
     base.CompTickRare();
     if (GetPawn.Position.GetTerrain(GetPawn.Map) == TerrainDefOf.Sand || GetPawn.Position.GetTerrain(GetPawn.Map) == MHRWDefOf.SoftSand)
     {
         Hediff sandglide = HediffMaker.MakeHediff(MHRWDefOf.DelexSand, GetPawn, null);
         GetPawn.health.AddHediff(sandglide);
     }
     else
     {
         GetPawn.health.hediffSet.hediffs.RemoveAll(x => x.def == MHRWDefOf.DelexSand);
     }
 }
        protected override void DoIngestionOutcomeSpecial(Pawn pawn, Thing ingested)
        {
            Hediff hediff = HediffMaker.MakeHediff(hediffDef, pawn);
            float  effect = ((!(severity > 0f)) ? hediffDef.initialSeverity : severity) * ingested.stackCount;

            if (divideByBodySize)
            {
                effect /= pawn.BodySize;
            }
            AddictionUtility.ModifyChemicalEffectForToleranceAndBodySize(pawn, toleranceChemical, ref effect);
            hediff.Severity = effect;
            pawn.health.AddHediff(hediff);
        }
예제 #7
0
        public StatDef ResistHediffStat = null;  //The default chance of adding a hediff.

        public void ApplyEffect(Thing hitThing)
        {
            if (hitThing != null && hitThing is Pawn hitPawn)
            {
                if (HediffToAdd != null)
                {
                    Rand.PushState();
                    var rand = Rand.Value; // This is a random percentage between 0% and 100%
                    Rand.PopState();
                    if (CanResistHediff == true)
                    {
                        /*
                         * if (ResistHediffChance!=0)
                         * {
                         *  rand = rand + ResistHediffChance;
                         * }
                         * else */
                        if (ResistHediffStat != null)
                        {
                            ResistHediffChance = hitPawn.GetStatValue(ResistHediffStat, true);
                        }
                        AddHediffChance = AddHediffChance * ResistHediffChance;
                    }

                    if (rand <= AddHediffChance)
                    {
                        var effectOnPawn = hitPawn?.health?.hediffSet?.GetFirstHediffOfDef(HediffToAdd);
                        Rand.PushState();
                        var randomSeverity = Rand.Range(0.15f, 0.30f);
                        Rand.PopState();
                        if (effectOnPawn != null)
                        {
                            effectOnPawn.Severity += randomSeverity;
                        }
                        else
                        {
                            Hediff hediff = HediffMaker.MakeHediff(HediffToAdd, hitPawn, null);
                            hediff.Severity = randomSeverity;
                            hitPawn.health.AddHediff(hediff, null, null);
                        }
                    }

                    /*
                     * else
                     * {
                     *  MoteMaker.ThrowText(hitThing.PositionHeld.ToVector3(), hitThing.MapHeld, "FailureMote".Translate(Def.AddHediffChance), 12f);
                     * }
                     */
                }
            }
        }
예제 #8
0
        public override void Apply(Pawn customTarget = null)
        {
            Pawn targetPawn = null;

            if (customTarget != null)
            {
                targetPawn = customTarget;
            }
            else
            {
                targetPawn = customizationWindow.newAndroid;
            }

            if (customTarget == null && customizationWindow == null)
            {
                Log.Error("customizationWindow is null! Impossible to add Hediffs without it.");
                return;
            }

            if (def.hediffToApply != null)
            {
                if (def.partsToApplyTo != null)
                {
                    foreach (BodyPartGroupDef bodyPartDef in def.partsToApplyTo)
                    {
                        IEnumerable <BodyPartRecord> notMissingParts = targetPawn.health.hediffSet.GetNotMissingParts(depth: BodyPartDepth.Outside);
                        foreach (BodyPartRecord part in notMissingParts)
                        {
                            if (part.IsInGroup(bodyPartDef) && (def.partsDepth == BodyPartDepth.Undefined || part.depth == def.partsDepth))
                            {
                                Hediff hediff = HediffMaker.MakeHediff(def.hediffToApply, targetPawn, part);
                                hediff.Severity = def.hediffSeverity;

                                appliedHediffs.Add(hediff);
                                targetPawn.health.AddHediff(hediff);
                            }
                        }
                    }
                }
                else
                {
                    Hediff hediff = HediffMaker.MakeHediff(def.hediffToApply, targetPawn);
                    hediff.Severity = def.hediffSeverity;

                    appliedHediffs.Add(hediff);
                    targetPawn.health.AddHediff(hediff);

                    //Log.Message("Applied Hediff: " + hediff.ToString());
                }
            }
        }
        /// <summary>
        /// Replaces all Hediffs with another one at the same position starting from a bodypart.
        /// </summary>
        /// <param name="pawn">Pawn to look in.</param>
        /// <param name="startingPart">Initial bodypart to start from.</param>
        /// <param name="hediffDef">HediffDefs to look for.</param>
        /// <param name="replaceWithDef">HediffDef to replace with.</param>
        public static void ReplaceHediffFromBodypart(this Pawn pawn, BodyPartRecord startingPart, HediffDef hediffDef, HediffDef replaceWithDef)
        {
            //Hediff list from pawn.
            List <Hediff> hediffs = pawn.health.hediffSet.hediffs;

            //Working lists for recursive iteration.
            List <BodyPartRecord> currentSet = new List <BodyPartRecord>();
            List <BodyPartRecord> nextSet    = new List <BodyPartRecord>();

            //Seed part.
            nextSet.Add(startingPart);

            do
            {
                //Initialize current set.
                currentSet.AddRange(nextSet);
                nextSet.Clear();

                foreach (BodyPartRecord part in currentSet)
                {
                    //Iterate through all Hediffs.
                    for (int i = hediffs.Count - 1; i >= 0; i--)
                    {
                        //Current Hediff to inspect.
                        Hediff hediff = hediffs[i];

                        //Matching BodyPartRecord and Hediff
                        if (hediff.Part == part && hediff.def == hediffDef)
                        {
                            //Remove Hediff.
                            Hediff hediff2 = hediffs[i];
                            hediffs.RemoveAt(i);
                            hediff2.PostRemoved();

                            //Add replacing Hediff.
                            Hediff newHeDiff = HediffMaker.MakeHediff(replaceWithDef, pawn, part);
                            hediffs.Insert(i, newHeDiff);
                        }
                    }

                    //Add next set.
                    for (int j = 0; j < part.parts.Count; j++)
                    {
                        nextSet.Add(part.parts[j]);
                    }
                }

                //Clear current set.
                currentSet.Clear();
            } while (nextSet.Count > 0); //Do while we got next set of parts to go through.
        }
예제 #10
0
        protected void AddedEffect(Thing hitThing)
        {
            if (def != null && hitThing != null && hitThing is Pawn hitPawn)
            {
                var rand = Rand.Value; // This is a random percentage between 0% and 100%

                StatDef ResistHediffStat   = def.ResistHediffStat;
                float   AddHediffChance    = def.AddHediffChance;
                float   ResistHediffChance = def.ResistHediffChance;
                if (def.CanResistHediff == true)
                {
                    /*
                     * if (Def.ResistHediffChance!=0)
                     * {
                     *  rand = rand + Def.ResistHediffChance;
                     * }
                     * else */
                    if (def.ResistHediffStat != null)
                    {
                        ResistHediffChance = hitPawn.GetStatValue(ResistHediffStat, true);
                    }
                    AddHediffChance = AddHediffChance * ResistHediffChance;
                }

                if (rand <= AddHediffChance) // If the percentage falls under the chance, success!
                {
                    var effectOnPawn   = hitPawn?.health?.hediffSet?.GetFirstHediffOfDef(def.HediffToAdd);
                    var randomSeverity = Rand.Range(0.15f, 0.30f);
                    if (effectOnPawn != null)
                    {
                        //If they already have plague, add a random range to its severity.
                        //If severity reaches 1.0f, or 100%, plague kills the target.
                        effectOnPawn.Severity += randomSeverity;
                    }
                    else
                    {
                        //These three lines create a new health differential or Hediff,
                        //put them on the character, and increase its severity by a random amount.
                        Hediff hediff = HediffMaker.MakeHediff(def.HediffToAdd, hitPawn, null);
                        hediff.Severity = randomSeverity;
                        hitPawn.health.AddHediff(hediff, null, null);
                    }
                }
                else //failure!
                {
                    /*
                     * MoteMaker.ThrowText(hitThing.PositionHeld.ToVector3(), hitThing.MapHeld, "TST_PlagueBullet_FailureMote".Translate(Def.AddHediffChance), 12f);
                     */
                }
            }
        }
예제 #11
0
        public override void DoEffectOn(Pawn user, Thing target)
        {
            Pawn pawn = (Pawn)target;

            if (pawn.Dead)
            {
                return;
            }
            Hediff         hediff = HediffMaker.MakeHediff(HediffDefOf.PsychicShock, pawn, null);
            BodyPartRecord part   = null;

            pawn.RaceProps.body.GetPartsWithTag(BodyPartTagDefOf.ConsciousnessSource).TryRandomElement(out part);
            pawn.health.AddHediff(hediff, part, null, null);
        }
예제 #12
0
        public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients, Bill bill)
        {
            if (!pawn.RaceProps.IsFlesh)
            {
                return;
            }
            pawn.health.forceIncap = true;

            Hediff_Comatose ailment = HediffMaker.MakeHediff(HediffDefOfComatose.ArtificialComa, pawn) as Hediff_Comatose;

            pawn.health.AddHediff(ailment);

            pawn.health.forceIncap = false;
        }
예제 #13
0
        public override void Notify_PawnDied()
        {
            base.Notify_PawnDied();
            Corpse       corpse = Pawn?.Corpse;
            CompRottable rott   = corpse.TryGetComp <CompRottable>();

            //float corpseNutrition = corpse.GetStatValue(StatDefOf.Nutrition);

            corpse.Strip();

            List <BodyPartRecord> parts =
                Pawn.RaceProps.body.corePart.parts.Where((BodyPartRecord part) => part.coverageAbs > 0f && !Pawn.health.hediffSet.PartIsMissing(part)).ToList();

            //parts.Add(Pawn.RaceProps.body.corePart);
            //foreach (BodyPartRecord part in Pawn.RaceProps.body.AllParts.Where((BodyPartRecord part) => !part.IsCorePart && part.coverageAbs > 0f && !Pawn.health.hediffSet.PartIsMissing(part)))
            foreach (BodyPartRecord part in parts)
            {
                Hediff hediff = HediffMaker.MakeHediff(InjectionHediffDef, Pawn, part);

                hediff.Severity = part.def.hitPoints * 20;
                Pawn.health.AddHediff(hediff, part, new DamageInfo(
                                          InjectionDamageDef, part.def.hitPoints * 20,
                                          armorPenetration: 2f,
                                          instigator: Pawn,
                                          weapon: Pawn.def,
                                          hitPart: part
                                          ));

                /*Pawn.TakeDamage(
                 *  new DamageInfo(
                 *      InjectionDamageDef, part.def.hitPoints * 20,
                 *      armorPenetration: 2f,
                 *      instigator: Pawn,
                 *      weapon: Pawn.def,
                 *      hitPart: part
                 *      )
                 * );*/
            }
            if (rott != null &&
                rott.RotProgress < rott.PropsRot.TicksToDessicated)
            {
                rott.RotProgress = rott.PropsRot.TicksToDessicated;
            }
            Plant thingTree = (Plant)ThingMaker.MakeThing(FleshTreeDef);

            GenSpawn.Spawn(thingTree, corpse.Position, corpse.Map, WipeMode.FullRefund);

            corpse.DeSpawn();
            thingTree.TryGetComp <CompThingHolder>().innerContainer.TryAdd(corpse);
        }
    protected override void DoWeatherOutcomeSpecial(Pawn pawn, GameCondition gameCondition)
    {
        var hediff = HediffMaker.MakeHediff(hediffDef, pawn);
        var num    = severity > 0f ? severity : hediffDef.initialSeverity;

        if (divideByBodySize)
        {
            num /= pawn.BodySize;
        }

        AddictionUtility.ModifyChemicalEffectForToleranceAndBodySize(pawn, toleranceChemical, ref num);
        hediff.Severity = num;
        pawn.health.AddHediff(hediff);
    }
        ///This method should be the only one to create the hediff
        public static void Create(Pawn mother, Pawn father)
        {
            if (mother == null)
            {
                return;
            }

            var torso = mother.RaceProps.body.AllParts.Find(x => x.def.defName == "Torso");
            //Log.Message("[RJW]Humanlike pregnancy " + mother + " is bred by " + father);

            var hediff = (Hediff_HumanlikePregnancy)HediffMaker.MakeHediff(HediffDef.Named("RJW_pregnancy"), mother, torso);

            hediff.Initialize(mother, father);
        }
예제 #16
0
        /// <summary>
        /// Transfers the hediffs from pawn1 onto pawn2
        /// </summary>
        /// <param name="pawn1">The pawn1.</param>
        /// <param name="pawn2">The pawn2.</param>
        /// <param name="selector">The selector.</param>
        /// <param name="transferFunc">The transfer function.</param>
        public static void TransferHediffs([NotNull] Pawn pawn1, [NotNull] Pawn pawn2, [NotNull] Func <Hediff, bool> selector, [NotNull] Func <BodyPartRecord, BodyPartRecord> transferFunc)
        {
            if (pawn1 == null)
            {
                throw new ArgumentNullException(nameof(pawn1));
            }
            if (pawn2 == null)
            {
                throw new ArgumentNullException(nameof(pawn2));
            }
            if (selector == null)
            {
                throw new ArgumentNullException(nameof(selector));
            }
            if (transferFunc == null)
            {
                throw new ArgumentNullException(nameof(transferFunc));
            }

            var health1 = pawn1.health;
            var health2 = pawn2.health;

            var tHediffs = health1?.hediffSet?.hediffs?.Where(selector);

            foreach (Hediff hediff in tHediffs.MakeSafe())
            {
                BodyPartRecord otherRecord;
                if (hediff.Part == null)
                {
                    otherRecord = null;
                }
                else
                {
                    otherRecord = transferFunc(hediff.Part);
                }

                if (otherRecord == null && hediff.Part != null)
                {
                    continue;
                }

                if (health2.hediffSet.HasHediff(hediff.def, otherRecord))
                {
                    continue;
                }

                var newHediff = HediffMaker.MakeHediff(hediff.def, pawn2, otherRecord);
                health2.AddHediff(newHediff);
            }
        }
예제 #17
0
        public static Pawn GenerateT5(int tile)
        {
            PawnKindDef           AndroidT5Colonist = PawnKindDefOf.AndroidT5Colonist;
            Faction               ofplayer          = Faction.OfAncients;
            PawnGenerationRequest request           = new PawnGenerationRequest(AndroidT5Colonist, ofplayer, PawnGenerationContext.NonPlayer, tile, false, false, false, false, true, false, 20f, true, true, true, false, false, false, false, false, 0f, null, 0f, null, null, null, null);
            Pawn pawn = PawnGenerator.GeneratePawn(request);

            HealthUtility.DamageUntilDowned(pawn);
            Hediff hediff = HediffMaker.MakeHediff(AndroidTiers.HediffDefOf.RebootingSequenceAT, pawn, null);

            hediff.Severity = 1f;
            pawn.health.AddHediff(hediff, null, null);
            return(pawn);
        }
        public override void PostRemoved()
        {
            base.PostRemoved();
            Hediff hediff = this.pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("VBE_EnergyDrinkCrash"), false);

            if (hediff != null)
            {
                hediff.Severity = 1f;
                return;
            }
            hediff          = HediffMaker.MakeHediff(HediffDef.Named("VBE_EnergyDrinkCrash"), this.pawn, null);
            hediff.Severity = 1f;
            this.pawn.health.AddHediff(hediff, null, null, null);
        }
예제 #19
0
        public void SpecialPostAdd(DamageInfo?dinfo)
        {
            base.CompPostPostAdd(dinfo);

            this.parent.pawn.health.RestorePart(this.parent.Part, this.parent, false);
            for (int i = 0; i < this.parent.Part.parts.Count; i++)
            {
                HediffWithComps hediff_BodyPartModule = (HediffWithComps)HediffMaker.MakeHediff(MSE_HediffDefOf.MSE_BodyPartModule, this.parent.pawn, null);
                hediff_BodyPartModule.Part = this.parent.Part.parts[i];
                this.parent.pawn.health.hediffSet.AddDirect(hediff_BodyPartModule, null, null);
            }

            MSE_VanillaExtender.HediffApplyHediffs(this.parent, this.parent.pawn, this.parent.Part);
        }
예제 #20
0
 public static void Blind(this Pawn pawn)
 {
     foreach (BodyPartRecord part in pawn.RaceProps.body.GetPartsWithTag(BodyPartTagDefOf.SightSource))
     {
         if (!pawn.health.hediffSet.PartIsMissing(part))
         {
             Hediff_MissingPart hediff_MissingPart = (Hediff_MissingPart)HediffMaker.MakeHediff(HediffDefOf.MissingBodyPart, pawn, null);
             hediff_MissingPart.lastInjury = HediffDefOf.Cut;
             hediff_MissingPart.Part       = part;
             hediff_MissingPart.IsFresh    = false;
             pawn.health.AddHediff(hediff_MissingPart, part, null, null);
         }
     }
 }
예제 #21
0
        ///This method should be the only one to create the hediff
        //Hediffs are made HediffMaker.MakeHediff which returns hediff of class different than the one needed, so we do the cast and then do all the same operations as in parent class
        //I don't know whether it'd be possible to use standard constructor instead of this retardation
        public static void Create(Pawn mother, Pawn father)
        {
            if (mother == null)
            {
                return;
            }

            BodyPartRecord torso = mother.RaceProps.body.AllParts.Find(x => x.def.defName == "Torso");
            //Log.Message("RJW beastial "+ mother + " " + father);

            Hediff_MechanoidPregnancy hediff = (Hediff_MechanoidPregnancy)HediffMaker.MakeHediff(HediffDef.Named("RJW_pregnancy_mech"), mother, torso);

            hediff.Initialize(mother, father);
        }
예제 #22
0
        public static void WakePatient(Pawn patientPawn, bool wakeNormally = true)
        {
            patientPawn.health.hediffSet.hediffs.RemoveAll((Hediff x) => x.def.defName == "MedPod_InducedComa");

            string         corticalStimulationType = wakeNormally ? "MedPod_CorticalStimulation" : "MedPod_CorticalStimulationImproper";
            string         popupMessage            = wakeNormally ? "MedPod_Message_TreatmentComplete".Translate(patientPawn.LabelCap, patientPawn) : "MedPod_Message_TreatmentInterrupted".Translate(patientPawn.LabelCap, patientPawn);
            MessageTypeDef popupMessageType        = wakeNormally ? MessageTypeDefOf.PositiveEvent : MessageTypeDefOf.NegativeHealthEvent;

            Messages.Message(popupMessage, patientPawn, popupMessageType, true);

            Hediff corticalStimulation = HediffMaker.MakeHediff(HediffDef.Named(corticalStimulationType), patientPawn);

            patientPawn.health.AddHediff(corticalStimulation);
        }
        protected override void Impact(Thing hitThing)
        {
            base.Impact(hitThing);
            Pawn pawn;

            if (this.Def != null && hitThing != null && (pawn = (hitThing as Pawn)) != null)
            {
                if (!pawn.RaceProps.IsFlesh)
                {
                    return;
                }
                foreach (HediffDef def in this.Def.HediffsToAdd)
                {
                    if (Rand.Value <= this.Def.AddHediffChance)
                    {
                        Hediff hediff;
                        if (pawn == null)
                        {
                            hediff = null;
                        }
                        else
                        {
                            Pawn_HealthTracker health = pawn.health;
                            if (health == null)
                            {
                                hediff = null;
                            }
                            else
                            {
                                HediffSet hediffSet = health.hediffSet;
                                hediff = hediffSet?.GetFirstHediffOfDef(def, false);
                            }
                        }
                        Hediff hediff2 = hediff;
                        float  num     = Rand.Range(0.25f, 0.4285f) / (float)Math.Pow((double)pawn.RaceProps.baseBodySize, 1.5);
                        if (hediff2 != null)
                        {
                            hediff2.Severity += num;
                        }
                        else
                        {
                            Hediff hediff3 = HediffMaker.MakeHediff(def, pawn, null);
                            hediff3.Severity = num;
                            pawn.health.AddHediff(hediff3, null, null, null);
                        }
                    }
                }
            }
        }
예제 #24
0
        public static Toil FinishDrinkTerrain(TargetIndex terrainVecIndex)
        {
            Toil toil = new Toil();

            toil.initAction = delegate
            {
                Pawn       actor      = toil.actor;
                Need_Water need_water = actor.needs.water();

                float numWater = need_water.MaxLevel - need_water.CurLevel;

                TerrainDef       terrain          = actor.Map.terrainGrid.TerrainAt(actor.CurJob.GetTarget(terrainVecIndex).Cell);
                WaterTerrainType drankTerrainType = terrain.GetWaterTerrainType();

                if (actor.needs.mood != null)
                {
                    // 直接飲んだ
                    if (actor.CanManipulate())
                    {
                        actor.needs.mood.thoughts.memories.TryGainMemory(MizuDef.Thought_DrankScoopedWater);
                    }
                    else
                    {
                        actor.needs.mood.thoughts.memories.TryGainMemory(MizuDef.Thought_SippedWaterLikeBeast);
                    }

                    ThoughtDef thoughtDef = MizuUtility.GetThoughtDefFromTerrainType(drankTerrainType);
                    if (thoughtDef != null)
                    {
                        // 水の種類による心情
                        actor.needs.mood.thoughts.memories.TryGainMemory(thoughtDef);
                    }
                }

                if (drankTerrainType == WaterTerrainType.SeaWater)
                {
                    // 海水の場合の健康状態悪化
                    actor.health.AddHediff(HediffMaker.MakeHediff(MizuDef.Hediff_DrankSeaWater, actor));
                }

                if (!actor.Dead)
                {
                    actor.needs.water().CurLevel += numWater;
                }
                actor.records.AddTo(MizuDef.Record_WaterDrank, numWater);
            };
            toil.defaultCompleteMode = ToilCompleteMode.Instant;
            return(toil);
        }
        public override void Tick()
        {
            if (launcher is Pawn launcherPawn && launcherPawn != null)
            {
                if (launcherPawn.Downed || launcherPawn.Dead)
                {
                    launcherPawn.health.hediffSet.hediffs.RemoveAll(h => h.def == RWBYDefOf.RWBY_RubyDashForm);
                    this.Destroy();
                    return;
                }
                Find.Selector.Deselect(launcher);
                Hediff dashHediff = new Hediff();
                dashHediff = HediffMaker.MakeHediff(RWBYDefOf.RWBY_RubyDashForm, launcherPawn);
                launcherPawn.health.AddHediff(dashHediff);
                launcherPawn.Position = Position;
                launcherPawn.Notify_Teleported(true, false);

                if (carriedPawn == null)
                {
                    foreach (Pawn pawn in Map.mapPawns.AllPawns)
                    {
                        if (pawn != launcherPawn && pawn.AdjacentTo8WayOrInside(launcherPawn))
                        {
                            carriedPawn = pawn;
                        }
                    }
                }
                if (carriedPawn != null)
                {
                    carriedPawn.Position = Position;
                    carriedPawn.Notify_Teleported(true, false);
                }
            }
            MoteMaker.ThrowDustPuffThick(Position.ToVector3(), Map, 2, Def.color);
            if (Find.TickManager.TicksGame % 2 == 0)
            {
                if (!Position.ShouldSpawnMotesAt(Map))
                {
                    return;
                }
                MoteThrown moteThrown = (MoteThrown)ThingMaker.MakeThing(RWBYDefOf.RWBY_Rose_Petal, null);
                moteThrown.Scale         = 1.9f;
                moteThrown.rotationRate  = 0f;
                moteThrown.exactPosition = Position.ToVector3();
                moteThrown.SetVelocity((float)Rand.Range(0, 360), 0.2f);
                GenSpawn.Spawn(moteThrown, Position, Map, WipeMode.Vanish);
            }
            base.Tick();
        }
예제 #26
0
        // Token: 0x06000004 RID: 4 RVA: 0x00002458 File Offset: 0x00000658
        internal static void ProximityHediffEffect(Thing thing, Pawn pawn)
        {
            if (pawn.RaceProps.IsMechanoid)
            {
                return;
            }

            var text          = ProximityGet.GetProxHediff(thing.def) ?? "";
            var proxHediffSev = ProximityGet.GetProxHediffSev(thing.def);
            var proxRange     = ProximityGet.GetProxRange(thing.def);

            if (proxHediffSev == 0f || text == "" || !NearThingInRange(thing, pawn, proxRange))
            {
                return;
            }

            var named = DefDatabase <HediffDef> .GetNamed(text, false);

            if (named == null || ProxImmuneTo(pawn, named))
            {
                return;
            }

            var    health = pawn.health;
            Hediff hediff;

            if (health == null)
            {
                hediff = null;
            }
            else
            {
                var hediffSet = health.hediffSet;
                hediff = hediffSet?.GetFirstHediffOfDef(named);
            }

            var hediff2 = hediff;

            if (hediff2 != null)
            {
                hediff2.Severity += proxHediffSev;
                return;
            }

            var hediff3 = HediffMaker.MakeHediff(named, pawn);

            hediff3.Severity = proxHediffSev;
            pawn.health.AddHediff(hediff3);
        }
예제 #27
0
        // Token: 0x06000005 RID: 5 RVA: 0x00002544 File Offset: 0x00000744
        internal static void ProximityTerrainHediffEffect(TerrainDef terrain, IntVec3 terrainPosition, Pawn pawn)
        {
            if (pawn.RaceProps.IsMechanoid)
            {
                return;
            }

            var text           = ProximityGet.GetTProxHediff(terrain) ?? "";
            var tproxHediffSev = ProximityGet.GetTProxHediffSev(terrain);
            var tproxRange     = ProximityGet.GetTProxRange(terrain);

            if (tproxHediffSev == 0f || text == "" || !TerrainInRange(terrain, terrainPosition, pawn, tproxRange))
            {
                return;
            }

            var named = DefDatabase <HediffDef> .GetNamed(text, false);

            if (named == null || ProxImmuneTo(pawn, named))
            {
                return;
            }

            var    health = pawn.health;
            Hediff hediff;

            if (health == null)
            {
                hediff = null;
            }
            else
            {
                var hediffSet = health.hediffSet;
                hediff = hediffSet?.GetFirstHediffOfDef(named);
            }

            var hediff2 = hediff;

            if (hediff2 != null)
            {
                hediff2.Severity += tproxHediffSev;
                return;
            }

            var hediff3 = HediffMaker.MakeHediff(named, pawn);

            hediff3.Severity = tproxHediffSev;
            pawn.health.AddHediff(hediff3);
        }
        protected override void DoIngestionOutcomeSpecial(Pawn pawn, Thing ingested)
        {
            var comp = ingested.TryGetComp <CompIngredients>();

            if (comp?.ingredients == null)
            {
                Log.Warning($"could not get comp ingredient on {ingested.Label}!");

                return;
            }
            _scratchDict.Clear();
            foreach (ThingDef thingDef in comp.ingredients)
            {
                if (!thingDef.IsMeat)
                {
                    continue;
                }
                foreach (MorphDef morphDef in MorphMeatUtilities.GetMorphsOfMeat(thingDef))
                {
                    if (morphDef.fullTransformation == null || morphDef.partialTransformation == null)
                    {
                        continue;
                    }

                    _scratchDict[morphDef] = _scratchDict.TryGetValue(morphDef) + 1;
                }
            }

            float c             = _scratchDict.Count;
            float severityToAdd = ingested.stackCount * severityPerServing * Rand.Range(0.7f, 2.5f);

            severityToAdd = pawn.GetMutagenicBuildupMultiplier() * severityToAdd;
            var hediff = (TargetedMutagenicBuildup)pawn.health.hediffSet.GetFirstHediffOfDef(Defs.Hediffs.MutagenicFoodBuildup);

            if (hediff == null)
            {
                hediff          = (TargetedMutagenicBuildup)HediffMaker.MakeHediff(Defs.Hediffs.MutagenicFoodBuildup, pawn);
                hediff.Severity = 0.01f;
                pawn.health.hediffSet.AddDirect(hediff);
            }

            hediff.Severity += severityToAdd;

            foreach (KeyValuePair <MorphDef, int> keyValuePair in _scratchDict)
            {
                MorphDef morphDef = keyValuePair.Key;
                hediff.AddTarget(morphDef);
            }
        }
예제 #29
0
        private void Finished()
        {
            List <Pair <Pawn, int> > voteTally = new List <Pair <Pawn, int> >();

            foreach (Candidate candidate in this.candidates)
            {
                IEnumerable <string> votesForMe = (from v in this.votes
                                                   where v == candidate.pawn.LabelShort
                                                   select v);
                voteTally.Add(new Pair <Pawn, int>(candidate.pawn, votesForMe.Count()));
            }
            //If there ends up being a tie, we'll just assume the least competitive candidates drop out.
            //The chances of there being a tie after that are exceedingly slim, but the result will be essentially random.
            IEnumerable <Pair <Pawn, int> > orderedTally = (from v in voteTally
                                                            orderby PsycheHelper.Comp(v.First).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Competitive) descending
                                                            orderby v.Second descending
                                                            select v);

            if (Prefs.DevMode && Prefs.LogVerbose)
            {
                foreach (Pair <Pawn, int> t in orderedTally)
                {
                    Log.Message("Psychology :: Votes for " + t.First + ": " + t.Second);
                }
            }
            Pair <Pawn, int> winningCandidate = orderedTally.First();

            if (orderedTally.Count() > 1 && orderedTally.First().Second == orderedTally.ElementAt(1).Second)
            {
                Find.LetterStack.ReceiveLetter("LetterLabelTieSettled".Translate(winningCandidate.First), "LetterTieSettled".Translate(winningCandidate.First), LetterDefOf.NeutralEvent, winningCandidate.First);
            }
            StringBuilder issuesString = new StringBuilder();

            for (int i = 0; i < candidates.Find(c => c.pawn == winningCandidate.First).nodes.Count; i++)
            {
                issuesString.AppendFormat("{0}) {1}{2}", i + 1, PsycheHelper.Comp(winningCandidate.First).Psyche.GetPersonalityNodeOfDef(candidates.Find(c => c.pawn == winningCandidate.First).nodes[i]).PlatformIssue, (i != candidates.Find(c => c.pawn == winningCandidate.First).nodes.Count - 1 ? "\n" : ""));
            }
            if (this.map == null)
            {
                this.map = winningCandidate.First.Map;
            }
            Hediff mayor = HediffMaker.MakeHediff(HediffDefOfPsychology.Mayor, winningCandidate.First);

            (mayor as Hediff_Mayor).worldTileElectedOn = map.Tile;
            (mayor as Hediff_Mayor).yearElected        = GenLocalDate.Year(map);
            winningCandidate.First.health.AddHediff(mayor);
            winningCandidate.First.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOfPsychology.WonElection);
            Find.LetterStack.ReceiveLetter("LetterLabelElectionWon".Translate(winningCandidate.First), "LetterElectionWon".Translate(winningCandidate.First, this.baseName, winningCandidate.Second, issuesString.ToString()), LetterDefOf.NeutralEvent, winningCandidate.First);
        }
예제 #30
0
        private static void TryToInfectSpacer(Thing thing)
        {
            var spaceRefugee = (thing as ActiveDropPod)?.Contents?.innerContainer?.FirstOrDefault(passenger => passenger.Faction == Faction.OfSpacer) as Pawn;

            if (spaceRefugee == null || !IsRandomSuccess())
            {
                return;
            }

            var hediff = HediffMaker.MakeHediff(HediffDef.Named("THU_XenoLarva"), spaceRefugee);

            spaceRefugee.health?.AddHediff(hediff);

            Log.Message("infected a space refugee (" + replacementPercent + "% chance)");
        }