// Token: 0x06000031 RID: 49 RVA: 0x00002E20 File Offset: 0x00001020
        protected override void DoIngestionOutcomeSpecial(Pawn pawn, Thing ingested)
        {
            bool flag = AddictionUtility.AddictedToAnything(pawn);

            if (flag)
            {
                foreach (ChemicalDef chemical in DefDatabase <ChemicalDef> .AllDefs)
                {
                    bool flag2 = AddictionUtility.IsAddicted(pawn, chemical);
                    if (flag2)
                    {
                        Hediff hediff  = AddictionUtility.FindAddictionHediff(pawn, chemical);
                        Hediff hediff2 = AddictionUtility.FindToleranceHediff(pawn, chemical);
                        pawn.health.RemoveHediff(hediff);
                        bool flag3 = hediff2 != null;
                        if (flag3)
                        {
                            pawn.health.RemoveHediff(hediff2);
                        }
                    }
                }
                foreach (HediffDef def in this.BeneficialAddictiveDrugHediffs)
                {
                    Hediff firstHediffOfDef = pawn.health.hediffSet.GetFirstHediffOfDef(def, false);
                    bool   flag4            = firstHediffOfDef != null;
                    if (flag4)
                    {
                        pawn.health.RemoveHediff(firstHediffOfDef);
                    }
                }
            }
        }
 protected virtual void DoIngestionOutcomeSpecial(Pawn pawn, Thing ingested)
 {
     if (!AddictionUtility.AddictedToAnything(pawn))
     {
         return;
     }
     using (IEnumerator <ChemicalDef> enumerator = DefDatabase <ChemicalDef> .get_AllDefs().GetEnumerator())
     {
         while (((IEnumerator)enumerator).MoveNext())
         {
             ChemicalDef current = enumerator.Current;
             if (AddictionUtility.IsAddicted(pawn, current))
             {
                 Hediff addictionHediff = (Hediff)AddictionUtility.FindAddictionHediff(pawn, current);
                 Hediff toleranceHediff = AddictionUtility.FindToleranceHediff(pawn, current);
                 ((Pawn_HealthTracker)pawn.health).RemoveHediff(addictionHediff);
                 if (toleranceHediff != null)
                 {
                     ((Pawn_HealthTracker)pawn.health).RemoveHediff(toleranceHediff);
                 }
             }
         }
     }
     using (IEnumerator <HediffDef> enumerator = this.BeneficialAddictiveDrugHediffs.GetEnumerator())
     {
         while (((IEnumerator)enumerator).MoveNext())
         {
             HediffDef current          = enumerator.Current;
             Hediff    firstHediffOfDef = ((HediffSet)((Pawn_HealthTracker)pawn.health).hediffSet).GetFirstHediffOfDef(current, false);
             if (firstHediffOfDef != null)
             {
                 ((Pawn_HealthTracker)pawn.health).RemoveHediff(firstHediffOfDef);
             }
         }
     }
 }
Example #3
0
        public static void GiveVitaeEffects(Pawn receiver, Pawn donor)
        {
            var pawn = receiver;

            //Give Vitae High Effect
            Hediff vitaeHighHediff = HediffMaker.MakeHediff(VampDefOf.ROMV_VitaeHigh, pawn, null);
            float  numHigh         = 0.75f;

            AddictionUtility.ModifyChemicalEffectForToleranceAndBodySize(pawn, VampDefOf.ROMV_VitaeChemical, ref numHigh);
            vitaeHighHediff.Severity = numHigh;
            pawn.health.AddHediff(vitaeHighHediff, null, null);

            //Give Vitae Tolerance Effect
            Hediff vitaeToleranceHediff = HediffMaker.MakeHediff(VampDefOf.ROMV_VitaeTolerance, pawn, null);
            float  numTol = 0.035f;

            numTol /= receiver.BodySize;
            AddictionUtility.ModifyChemicalEffectForToleranceAndBodySize(pawn, VampDefOf.ROMV_VitaeChemical, ref numTol);
            vitaeToleranceHediff.Severity = numTol;
            pawn.health.AddHediff(vitaeToleranceHediff, null, null);

            const float addictiveness                   = 1.0f;
            const float minToleranceToAddict            = 0.01f;
            const float existingAddictionSeverityOffset = 0.2f;

            var needLevelOffset        = 1f;
            var overdoseSeverityOffset = new FloatRange(0.18f, 0.35f);
            var chemical = VampDefOf.ROMV_VitaeChemical;

            var addictionHediffDef = VampDefOf.ROMV_VitaeAddiction;
            var lookTarget         = receiver;
            var hediff             = AddictionUtility.FindToleranceHediff(lookTarget, VampDefOf.ROMV_VitaeChemical);
            var num             = hediff?.Severity ?? 0f;
            var hediffAddiction = AddictionUtility.FindAddictionHediff(lookTarget, VampDefOf.ROMV_VitaeChemical);

            if (hediffAddiction != null)
            {
                hediffAddiction.Severity += existingAddictionSeverityOffset;
            }
            else if (Rand.Value < addictiveness && num >= minToleranceToAddict)
            {
                lookTarget.health.AddHediff(addictionHediffDef, null, null);
                if (PawnUtility.ShouldSendNotificationAbout(lookTarget))
                {
                    Find.LetterStack.ReceiveLetter("LetterLabelNewlyAddicted".Translate(chemical.label).CapitalizeFirst(),
                                                   "LetterNewlyAddicted".Translate(lookTarget.LabelShort, chemical.label, lookTarget.Named("PAWN"))
                                                   .AdjustedFor(lookTarget, "PAWN").CapitalizeFirst(), LetterDefOf.NegativeEvent, lookTarget, null, null);
                }
                AddictionUtility.CheckDrugAddictionTeachOpportunity(lookTarget);
            }

            if (addictionHediffDef.causesNeed != null)
            {
                var need = lookTarget.needs.AllNeeds.Find((Need x) => x.def == addictionHediffDef.causesNeed);
                if (need != null)
                {
                    AddictionUtility.ModifyChemicalEffectForToleranceAndBodySize(lookTarget, chemical,
                                                                                 ref needLevelOffset);
                    need.CurLevel += needLevelOffset;
                }
            }
//            var firstHediffOfDef = lookTarget.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.DrugOverdose, false);
//            var num2 = firstHediffOfDef?.Severity ?? 0f;
//            if (num2 < 0.9f && Rand.Value < largeOverdoseChance)
//            {
//                var num3 = Rand.Range(0.85f, 0.99f);
//                HealthUtility.AdjustSeverity(lookTarget, HediffDefOf.DrugOverdose, num3 - num2);
//                if (lookTarget.Faction == Faction.OfPlayer)
//                {
//                    Messages.Message("MessageAccidentalOverdose".Translate(new object[]
//                    {
//                        lookTarget.LabelIndefinite(),
//                        chemical.LabelCap
//                    }).CapitalizeFirst(), MessageTypeDefOf.NegativeHealthEvent);
//                }
//            }
//            else
//            {
//                var num4 = overdoseSeverityOffset.RandomInRange / lookTarget.BodySize;
//                if (num4 > 0f)
//                {
//                    HealthUtility.AdjustSeverity(lookTarget, HediffDefOf.DrugOverdose, num4);
//                }
//            }
        }
Example #4
0
        // Token: 0x06000016 RID: 22 RVA: 0x0000259C File Offset: 0x0000079C
        public static void DoSSVape(Pawn p, Thing t)
        {
            var HediffName = "";
            var defName    = t.def.defName;

            switch (defName)
            {
            case "SSVaperRegular":
                HediffName = "SSVape_Regular_High";
                break;

            case "SSVaperFruity":
                HediffName = "SSVape_Fruity_High";
                break;

            case "SSVaperMenthol":
                HediffName = "SSVape_Menthol_High";
                break;
            }

            if (!HediffName.StartsWith("SSVape"))
            {
                return;
            }

            var hediffdef = DefDatabase <HediffDef> .GetNamed(HediffName, false);

            var SLChemDef = DefDatabase <ChemicalDef> .GetNamed("Smokeleaf");

            if (hediffdef == null)
            {
                return;
            }

            var SeverityToApply = 0.5f;

            if (SSHediffEffecter.HediffEffect(hediffdef, SeverityToApply, p, null, out _))
            {
                var SLTol = DefDatabase <HediffDef> .GetNamed("SmokeleafTolerance");

                if (SLTol != null)
                {
                    var Sev = 0.02f / p.BodySize;
                    SSHediffEffecter.HediffEffect(SLTol, Sev, p, null, out _);
                }

                if (p.RaceProps.IsFlesh)
                {
                    var addictionHediffDef = DefDatabase <HediffDef> .GetNamed("SmokeleafAddiction");

                    var hediff_Addiction = AddictionUtility.FindAddictionHediff(p, SLChemDef);
                    var hediff           = AddictionUtility.FindToleranceHediff(p, SLChemDef);
                    var num = hediff?.Severity ?? 0f;
                    if (hediff_Addiction != null)
                    {
                        hediff_Addiction.Severity += 0.06f;
                    }
                    else if (Rand.Value < 0.01f && num >= 0.15f)
                    {
                        p.health.AddHediff(addictionHediffDef);
                        if (PawnUtility.ShouldSendNotificationAbout(p))
                        {
                            Find.LetterStack.ReceiveLetter(
                                "LetterLabelNewlyAddicted".Translate(SLChemDef.label).CapitalizeFirst(),
                                "LetterNewlyAddicted".Translate(p.LabelShort, SLChemDef.label, p.Named("PAWN"))
                                .AdjustedFor(p).CapitalizeFirst(), LetterDefOf.NegativeEvent, p);
                        }
                    }

                    if (addictionHediffDef.causesNeed != null)
                    {
                        var need = p.needs.AllNeeds.Find(x => x.def == addictionHediffDef.causesNeed);
                        if (need != null)
                        {
                            var effect = 1f;
                            AddictionUtility.ModifyChemicalEffectForToleranceAndBodySize(p, SLChemDef,
                                                                                         ref effect);
                            need.CurLevel += effect;
                        }
                    }
                }
            }

            if (p?.needs != null)
            {
                var need2 = p.needs.TryGetNeed(NeedDefOf.Rest);
                if (need2 != null)
                {
                    var effect2 = -0.1f;
                    AddictionUtility.ModifyChemicalEffectForToleranceAndBodySize(p, SLChemDef, ref effect2);
                    need2.CurLevel += effect2;
                }
            }

            bool joyNeed;

            if (p == null)
            {
                joyNeed = false;
            }
            else
            {
                var needs = p.needs;
                joyNeed = needs?.joy != null;
            }

            if (joyNeed)
            {
                var Chem = DefDatabase <JoyKindDef> .GetNamed("Chemical", false);

                var needs2 = p.needs;
                if (needs2 != null)
                {
                    needs2.joy.GainJoy(0.85f, Chem);
                }
            }

            if (p?.Map != null)
            {
                var BreathOffset = new Vector3(0f, 0f, -0.04f);
                var loc          = p.Drawer.DrawPos + p.Drawer.renderer.BaseHeadOffsetAt(p.Rotation) +
                                   (p.Rotation.FacingCell.ToVector3() * 0.21f) + BreathOffset;
                for (var i = 0; i < 4; i++)
                {
                    ThrowVapeBreathPuff(loc, p.Map, p.Rotation.AsAngle, p.Position.ToVector3());
                    FleckMaker.ThrowSmoke(p.Position.ToVector3(), p.Map, 0.5f);
                }
            }

            var usesLeft = ((SSVapeData)t).SSVapeUses;

            usesLeft--;
            ((SSVapeData)t).SSVapeUses = usesLeft;
            if (usesLeft > 0)
            {
                return;
            }

            t.Destroy();
            if (p == null)
            {
                return;
            }

            GenDrop.TryDropSpawn(
                ThingMaker.MakeThing(DefDatabase <ThingDef> .GetNamed("SSVaperEmpty", false)), p.Position,
                p.Map, ThingPlaceMode.Near, out var newVapeThing);
            ((SSVapeData)newVapeThing).SSVapeType = "empty";
            ((SSVapeData)newVapeThing).SSVapeUses = 0;
        }