Esempio n. 1
0
        public override void Perform(Sim sim, DiseaseVector vector)
        {
            if (sim.OccultManager == null)
            {
                return;
            }

            if (mRemove)
            {
                OccultTypeHelper.Remove(sim.SimDescription, mOccult, true);
            }
            else
            {
                if (sim.OccultManager.HasOccultType(mOccult))
                {
                    return;
                }

                if (mDropOthers)
                {
                    foreach (OccultTypes type in Enum.GetValues(typeof(OccultTypes)))
                    {
                        if (type == OccultTypes.None)
                        {
                            continue;
                        }

                        OccultTypeHelper.Remove(sim.SimDescription, type, true);
                    }
                }

                OccultTypeHelper.Add(sim.SimDescription, mOccult, false, true);
            }
        }
Esempio n. 2
0
        public override void Perform(Sim sim, DiseaseVector vector)
        {
            if (sim.Autonomy == null) return;

            if (sim.Autonomy.Motives == null) return;            

            if (sim.Autonomy.Motives.HasMotive(mMotive))
            {
                int delta = (int)(mDeltaValue * (Vector.Settings.GetMotiveAdjustmentRatio(vector.Guid) / 100f));

                if (delta < 0)
                {
                    float current = sim.Autonomy.Motives.GetValue(mMotive);

                    if (current < mLowerBound)
                    {
                        delta = 0;
                    }
                    if ((current + delta) < mLowerBound)
                    {
                        delta = (int)(mLowerBound - current);
                    }
                }

                sim.Autonomy.Motives.ChangeValue(mMotive, delta);
            }
        }
Esempio n. 3
0
        public override void Perform(Sim sim, DiseaseVector vector)
        {
            if (SimTypes.IsDead(sim.SimDescription)) return;

            if (!mAllowActive)
            {
                if (SimTypes.IsSelectable(sim)) return;
            }

            if (sim.InteractionQueue == null) return;

            SimDescription.DeathType type = mType;
            if (type == SimDescription.DeathType.None)
            {
                List<SimDescription.DeathType> choices = new List<SimDescription.DeathType>();
                foreach (SimDescription.DeathType choice in Enum.GetValues(typeof(SimDescription.DeathType)))
                {
                    if (!OccultTypeHelper.IsInstalled(choice)) continue;

                    choices.Add(choice);
                }

                if (choices.Count == 0) return;

                type = RandomUtil.GetRandomObjectFromList(choices);
            }

            InteractionInstance entry = Urnstone.KillSim.Singleton.CreateInstance(sim, sim, new InteractionPriority(InteractionPriorityLevel.MaxDeath, 0f), false, false);
            (entry as Urnstone.KillSim).simDeathType = type;
            sim.InteractionQueue.Add(entry);
        }
Esempio n. 4
0
        public override void Perform(Sim sim, DiseaseVector vector)
        {
            int count = 0;

            List <GameObject> objs = sim.LotCurrent.GetObjectsInRoom <GameObject>(sim.RoomId);

            while ((count < mMaximum) && (objs.Count > 0))
            {
                GameObject obj = RandomUtil.GetRandomObjectFromList(objs);
                count++;

                RepairableComponent repairable = obj.Repairable;
                if (repairable == null)
                {
                    continue;
                }

                if (!repairable.CanBreak())
                {
                    continue;
                }

                repairable.BreakObject(sim, true);
            }
        }
Esempio n. 5
0
        public override void Perform(Sim sim, DiseaseVector vector)
        {
            if (sim.OccultManager== null) return;

            if (mRemove)
            {
                OccultTypeHelper.Remove(sim.SimDescription, mOccult, true);
            }
            else
            {
                if (sim.OccultManager.HasOccultType(mOccult)) return;

                if (mDropOthers)
                {
                    foreach (OccultTypes type in Enum.GetValues(typeof(OccultTypes)))
                    {
                        if (type == OccultTypes.None) continue;

                        OccultTypeHelper.Remove(sim.SimDescription, type, true);
                    }
                }

                OccultTypeHelper.Add(sim.SimDescription, mOccult, false, true);
            }
        }
Esempio n. 6
0
        public override void Perform(Sim sim, DiseaseVector vector)
        {
            if (sim.SimDescription.IsPregnant)
            {
                return;
            }

            if (mClone)
            {
                Pregnancies.Start(sim, sim.SimDescription, mHandlePlantSim);
            }
            else if (vector.Infector != 0)
            {
                SimDescription other = SimDescription.Find(vector.Infector);
                if (other != null)
                {
                    if (!mAllowCloseRelations)
                    {
                        if (Relationships.IsCloselyRelated(sim.SimDescription, other, false))
                        {
                            return;
                        }
                    }

                    Pregnancies.Start(sim, other, mHandlePlantSim);
                }
            }
        }
Esempio n. 7
0
        public override void Perform(Sim sim, DiseaseVector vector)
        {
            if (sim.Autonomy == null)
            {
                return;
            }

            if (sim.Autonomy.Motives == null)
            {
                return;
            }

            if (sim.Autonomy.Motives.HasMotive(mMotive))
            {
                int delta = (int)(mDeltaValue * (Vector.Settings.GetMotiveAdjustmentRatio(vector.Guid) / 100f));

                if (delta < 0)
                {
                    float current = sim.Autonomy.Motives.GetValue(mMotive);

                    if (current < mLowerBound)
                    {
                        delta = 0;
                    }
                    if ((current + delta) < mLowerBound)
                    {
                        delta = (int)(mLowerBound - current);
                    }
                }

                sim.Autonomy.Motives.ChangeValue(mMotive, delta);
            }
        }
Esempio n. 8
0
 public static void ShowNotice(SimDescription sim, DiseaseVector vector, string prefix)
 {
     if (Vector.Settings.mOutbreakShowNotices)
     {
         Common.Notify(sim.CreatedSim, prefix + Common.Localize("Outbreak:Success", sim.IsFemale, new object[] { sim, vector.GetLocalizedName(sim.IsFemale) }));
     }
 }
Esempio n. 9
0
        public override void Perform(Sim sim, DiseaseVector vector)
        {
            int count = 0;

            List <GameObject> objs = sim.LotCurrent.GetObjectsInRoom <GameObject>(sim.RoomId);

            while ((count < mMaximum) && (objs.Count > 0))
            {
                GameObject obj = RandomUtil.GetRandomObjectFromList(objs);

                count++;

                if (obj.GetFireType() == FireType.DoesNotBurn)
                {
                    continue;
                }

                LotLocation loc         = LotLocation.Invalid;
                ulong       lotLocation = World.GetLotLocation(obj.PositionOnFloor, ref loc);

                if (!World.HasSolidFloor(obj.LotCurrent.mLotId, loc))
                {
                    continue;
                }

                if (lotLocation == 0x0L)
                {
                    continue;
                }

                Sims3.Gameplay.Objects.Fire.CreateFire(lotLocation, loc);
            }
        }
Esempio n. 10
0
 public virtual void Resist(Event e, DiseaseVector vector)
 {
     foreach (ResistanceBooter.Data resistance in mResistances)
     {
         resistance.Perform(e, vector);
     }
 }
Esempio n. 11
0
            protected override void OnPerform(Event e)
            {
                if (!mVector.CanOutbreak)
                {
                    return;
                }

                Sim actor = e.Actor as Sim;

                if (actor == null)
                {
                    return;
                }

                if (!mInstigator.Perform(e))
                {
                    return;
                }

                DiseaseVector vector = new DiseaseVector(mVector, Vector.Settings.GetNewStrain(mVector));

                if (vector.Infect(actor.SimDescription, true))
                {
                    mInstigator.ShowStory(actor.SimDescription);

                    ScoringLog.sLog.IncStat(vector.UnlocalizedName + " Success " + mInstigator.Guid);
                }
            }
Esempio n. 12
0
        public static bool Inoculate(SimDescription sim, DiseaseVector vector, bool paid, bool testExisting)
        {
            if (vector.InoculationCost <= 0)
            {
                return(false);
            }

            DiseaseVector newVector = Vector.Settings.GetVector(sim, vector.Guid);

            if (newVector == null)
            {
                newVector = new DiseaseVector(vector, sim);
                newVector.Inoculate(vector.InoculationStrain, paid);

                Vector.Settings.AddVector(sim, newVector);
                return(true);
            }
            else
            {
                if (testExisting)
                {
                    if (newVector.IsInoculationUpToDate)
                    {
                        return(false);
                    }
                }

                if (!newVector.CanInoculate)
                {
                    return(false);
                }

                return(newVector.Inoculate(vector.InoculationStrain, paid));
            }
        }
Esempio n. 13
0
        protected override bool IsSuccess(SimDescription sim, DiseaseVector vector)
        {
            if (vector.Increment(Counter) < mMaximum) return true;

            vector.Erase(Counter);
            return false;
        }
Esempio n. 14
0
        public override void Perform(Sim sim, DiseaseVector vector)
        {
            float delta = RandomUtil.GetFloat(mMinimum, mMaximum);

            if (delta == 0)
            {
                return;
            }

            float fitness = sim.SimDescription.mCurrentShape.Fit + delta;

            if (fitness < 0)
            {
                fitness = 0;
            }
            else if (fitness > 1)
            {
                fitness = 1;
            }

            sim.SimDescription.ForceSetBodyShape(sim.SimDescription.mCurrentShape.Weight, fitness);

            sim.RequireImmediateBodyShapeUpdate = true;
            sim.SimDescription.UpdateBodyShape(0f, sim.ObjectId);
        }
Esempio n. 15
0
        public static bool Inoculate(SimDescription sim, VectorBooter.Data vector, bool paid, bool testExisting)
        {
            DiseaseVector inoculate = new DiseaseVector(vector, Vector.Settings.GetCurrentStrain(vector));

            inoculate.Inoculate(vector.InoculationStrain, paid);

            return(Inoculate(sim, inoculate, paid, testExisting));
        }
Esempio n. 16
0
        protected override bool IsSuccess(SimDescription sim, DiseaseVector vector)
        {
            bool result = vector.NewStrain;

            vector.NewStrain = false;

            return(result);
        }
Esempio n. 17
0
        protected override bool IsSuccess(SimDescription sim, DiseaseVector vector)
        {
            bool result = vector.NewStrain;

            vector.NewStrain = false;

            return result;
        }
Esempio n. 18
0
        public static bool Perform(SimDescription sim, bool promptStrength, bool random)
        {
            List <VectorBooter.Item> choices = VectorBooter.GetVectorItems(sim);

            int maxSelection = 0;

            if (!promptStrength)
            {
                maxSelection = 1;
            }

            List <VectorBooter.Item> selection = new List <VectorBooter.Item>();

            if (random)
            {
                if (choices.Count == 0)
                {
                    return(false);
                }

                selection.Add(RandomUtil.GetRandomObjectFromList(choices));
            }
            else
            {
                CommonSelection <VectorBooter.Item> .Results items = new CommonSelection <VectorBooter.Item>(Common.Localize("Infect:MenuName"), choices).SelectMultiple(maxSelection);
                if ((items == null) || (items.Count == 0))
                {
                    return(false);
                }

                selection.AddRange(items);
            }

            foreach (VectorBooter.Item item in selection)
            {
                DiseaseVector.Variant strain = Vector.Settings.GetCurrentStrain(item.Value);

                int strength = strain.Strength;

                if (promptStrength)
                {
                    string text = StringInputDialog.Show(Common.Localize("Infect:MenuName"), Common.Localize("Infect:Prompt", false, new object[] { item.Value.GetLocalizedName(false) }), strain.Strength.ToString());

                    if (!int.TryParse(text, out strength))
                    {
                        Common.Notify(Common.Localize("Numeric:Error"));
                    }
                }

                strain.Strength = strength;

                DiseaseVector disease = new DiseaseVector(item.Value, strain);

                disease.Infect(sim, true);
            }

            return(true);
        }
Esempio n. 19
0
        public override void Perform(Sim sim, DiseaseVector vector)
        {
            if (sim.BuffManager == null)
            {
                return;
            }

            sim.BuffManager.AddElement(mBuff, mMoodValue, mDuration, mOrigin);
        }
Esempio n. 20
0
        public override void Perform(Sim sim, DiseaseVector vector)
        {
            if (sim.IdleManager == null)
            {
                return;
            }

            sim.IdleManager.ScheduleIdle(mPriority, mMood);
        }
Esempio n. 21
0
            public void Symptomize(Sim sim, DiseaseVector vector)
            {
                if (sim == null)
                {
                    return;
                }

                mStages[vector.Stage].Symptomize(sim, vector);
            }
Esempio n. 22
0
        protected override bool IsSuccess(SimDescription sim, DiseaseVector vector)
        {
            if (vector.Increment(Counter) < mMaximum)
            {
                return(true);
            }

            vector.Erase(Counter);
            return(false);
        }
Esempio n. 23
0
            public virtual void Perform(Event e, DiseaseVector vector)
            {
                if (!mTest.IsSuccess(e))
                {
                    return;
                }

                vector.AlterResistance(Delta);

                ScoringLog.sLog.AddStat(Guid + " Resistance", Delta);
            }
Esempio n. 24
0
 public override int GetNextStage(SimDescription sim, DiseaseVector vector)
 {
     if (IsSuccess(sim, vector))
     {
         return(mSuccessStage.Second);
     }
     else
     {
         return(mFailureStage.Second);
     }
 }
Esempio n. 25
0
 public override int GetNextStage(SimDescription sim, DiseaseVector vector)
 {
     if (IsSuccess(sim, vector))
     {
         return mSuccessStage.Second;
     }
     else
     {
         return mFailureStage.Second;
     }
 }
Esempio n. 26
0
 public virtual void Symptomize(Sim sim, DiseaseVector vector)
 {
     if ((string.IsNullOrEmpty(mSymptomScoring)) ||
         (ScoringLookup.GetScore(mSymptomScoring, sim.SimDescription) >= mSymptomScoringMinimum))
     {
         foreach (SymptomChance chance in mSymptoms)
         {
             chance.Perform(sim, vector);
         }
     }
 }
Esempio n. 27
0
            protected VectorControl.StageType RunStage(DiseaseVector vector, int stage, out int nextCheck)
            {
                Stage data = mStages[stage];

                nextCheck = data.GetDuration(vector);
                if (nextCheck < 0)
                {
                    nextCheck = 0;
                }

                return(data.Type);
            }
Esempio n. 28
0
        protected override bool IsSuccess(SimDescription sim, DiseaseVector vector)
        {
            int minimum = mMinimum;
            if (minimum == int.MinValue)
            {
                minimum = vector.NetStrength;
            }

            minimum += vector.GetCounter(mMinMutation);

            return (ScoringLookup.GetScore(mScoring, sim) > minimum);
        }
Esempio n. 29
0
        public override void Perform(Sim sim, DiseaseVector vector)
        {
            if (SimTypes.IsDead(sim.SimDescription))
            {
                return;
            }

            List <Sim> sims = new List <Sim>();

            foreach (Sim other in sim.LotCurrent.GetSims())
            {
                if (other == sim)
                {
                    continue;
                }

                if (mRoomOnly)
                {
                    if (other.RoomId != sim.RoomId)
                    {
                        continue;
                    }
                }

                sims.Add(other);
            }

            if (sims.Count == 0)
            {
                return;
            }

            Sim choice = RandomUtil.GetRandomObjectFromList(sims);

            try
            {
                if (sim.SimDescription.IsZombie)
                {
                    InteractionInstance entry = new Sim.ZombifiedSocials.Definition(Sim.ZombifiedSocials.Definition.eInteractionType.Braaaiiins).CreateInstance(choice, sim, new InteractionPriority(InteractionPriorityLevel.High), true, true);
                    sim.InteractionQueue.AddNext(entry);
                }
                else if (mSocial != "Braaaiiins")
                {
                    InteractionInstance entry = new SocialInteractionA.Definition(mSocial, null, null, false).CreateInstance(choice, sim, new InteractionPriority(InteractionPriorityLevel.High), true, true);

                    sim.InteractionQueue.AddNext(entry);
                }
            }
            catch (Exception e)
            {
                Common.DebugException(sim, choice, e);
            }
        }
Esempio n. 30
0
        public override void Perform(Sim sim, DiseaseVector vector)
        {
            if (sim.InteractionQueue == null)
            {
                return;
            }

            if (sim.CurrentInteraction is ICountsAsWorking)
            {
                return;
            }

            if (SimTypes.IsServiceOrRole(sim.SimDescription, false))
            {
                if (!SimTypes.IsSelectable(sim))
                {
                    return;
                }
            }

            if (!mAffectSleep)
            {
                if (sim.CurrentInteraction is ISleeping)
                {
                    return;
                }
            }

            if (sim.CurrentInteraction != null)
            {
                if (sim.CurrentInteraction.Target is RabbitHole)
                {
                    return;
                }
            }

            try
            {
                if (mAll)
                {
                    sim.InteractionQueue.CancelAllInteractions();
                }
                else if (sim.CurrentInteraction != null)
                {
                    sim.InteractionQueue.CancelInteraction(sim.CurrentInteraction, false);
                }
            }
            catch (Exception e)
            {
                Common.DebugException(sim, e);
            }
        }
Esempio n. 31
0
        public override int GetNextStage(SimDescription sim, DiseaseVector vector)
        {
            int result = RandomUtil.GetInt(mTotalWeight);

            int i = 0, current = 0;
            for (i = 0; i < mNextWeights.Length; i++)
            {
                current += mNextWeights[i];
                if (current > result) break;
            }

            return mNextStages[i].Second;
        }
Esempio n. 32
0
        protected override bool IsSuccess(SimDescription sim, DiseaseVector vector)
        {
            int minimum = mMinimum;

            if (minimum == int.MinValue)
            {
                minimum = vector.NetStrength;
            }

            minimum += vector.GetCounter(mMinMutation);

            return(ScoringLookup.GetScore(mScoring, sim) > minimum);
        }
Esempio n. 33
0
            public void Perform(Sim sim, DiseaseVector vector)
            {
                if (!RandomUtil.RandomChance01(mChance))
                {
                    return;
                }

                foreach (SymptomBooter.Data symptom in mSymptoms)
                {
                    symptom.Perform(sim, vector);

                    ScoringLog.sLog.IncStat(symptom.Guid + " Symptom");
                }
            }
Esempio n. 34
0
        public override int GetDuration(DiseaseVector vector)
        {
            int min = mMinDuration + vector.GetCounter(mMinMutation);
            int max = mMaxDuration + vector.GetCounter(mMaxMutation);

            if (max < min)
            {
                max = min;
            }

            if (max <= 0) return 0;

            return RandomUtil.GetInt(min, max);
        }
Esempio n. 35
0
        protected override bool IsSuccess(SimDescription sim, DiseaseVector vector)
        {
            int value = vector.GetCounter(Counter);

            if (value > (mMaximum + vector.GetCounter(mMaxMutation)))
            {
                return(false);
            }

            if (value < (mMinimum + vector.GetCounter(mMinMutation)))
            {
                return(false);
            }

            return(true);
        }
Esempio n. 36
0
        public override void Perform(Sim sim, DiseaseVector vector)
        {
            if (SimTypes.IsDead(sim.SimDescription))
            {
                return;
            }

            if (!mAllowActive)
            {
                if (SimTypes.IsSelectable(sim))
                {
                    return;
                }
            }

            if (sim.InteractionQueue == null)
            {
                return;
            }

            SimDescription.DeathType type = mType;
            if (type == SimDescription.DeathType.None)
            {
                List <SimDescription.DeathType> choices = new List <SimDescription.DeathType>();
                foreach (SimDescription.DeathType choice in Enum.GetValues(typeof(SimDescription.DeathType)))
                {
                    if (!OccultTypeHelper.IsInstalled(choice))
                    {
                        continue;
                    }

                    choices.Add(choice);
                }

                if (choices.Count == 0)
                {
                    return;
                }

                type = RandomUtil.GetRandomObjectFromList(choices);
            }

            InteractionInstance entry = Urnstone.KillSim.Singleton.CreateInstance(sim, sim, new InteractionPriority(InteractionPriorityLevel.MaxDeath, 0f), false, false);

            (entry as Urnstone.KillSim).simDeathType = type;
            sim.InteractionQueue.Add(entry);
        }
Esempio n. 37
0
        public override int GetNextStage(SimDescription sim, DiseaseVector vector)
        {
            int result = RandomUtil.GetInt(mTotalWeight);

            int i = 0, current = 0;

            for (i = 0; i < mNextWeights.Length; i++)
            {
                current += mNextWeights[i];
                if (current > result)
                {
                    break;
                }
            }

            return(mNextStages[i].Second);
        }
Esempio n. 38
0
        public override int GetDuration(DiseaseVector vector)
        {
            int min = mMinDuration + vector.GetCounter(mMinMutation);
            int max = mMaxDuration + vector.GetCounter(mMaxMutation);

            if (max < min)
            {
                max = min;
            }

            if (max <= 0)
            {
                return(0);
            }

            return(RandomUtil.GetInt(min, max));
        }
Esempio n. 39
0
            protected override void OnPerform(Event e)
            {
                if (!mVector.CanOutbreak) return;

                Sim actor = e.Actor as Sim;
                if (actor == null) return;

                if (!mInstigator.Perform(e)) return;

                DiseaseVector vector = new DiseaseVector(mVector, Vector.Settings.GetNewStrain(mVector));

                if (vector.Infect(actor.SimDescription, true))
                {
                    mInstigator.ShowStory(actor.SimDescription);

                    ScoringLog.sLog.IncStat(vector.UnlocalizedName + " Success " + mInstigator.Guid);
                }
            }
Esempio n. 40
0
        public static void StartOutbreak(VectorBooter.Data vector, bool verbose)
        {
            DiseaseVector disease = new DiseaseVector(vector, Vector.Settings.GetNewStrain(vector));

            ScoringLog.sLog.IncStat(disease.UnlocalizedName + " Attempt Outbreak");

            List <Sim> sims = new List <Sim>(LotManager.Actors);

            if (sims.Count > 0)
            {
                int count = 0;
                while ((count < Vector.Settings.mNumPatientZero) && (sims.Count > 0))
                {
                    Sim choice = RandomUtil.GetRandomObjectFromList(sims);
                    sims.Remove(choice);

                    if (choice.SimDescription.ToddlerOrBelow)
                    {
                        continue;
                    }

                    if (!Vector.Settings.mOutbreakAllowActive)
                    {
                        if (choice.Household == Household.ActiveHousehold)
                        {
                            continue;
                        }
                    }

                    if (disease.Infect(choice.SimDescription, true))
                    {
                        count++;

                        if (verbose)
                        {
                            ShowNotice(choice.SimDescription, disease, Common.kDebugging ? "Outbreak" : "");
                        }

                        ScoringLog.sLog.IncStat(disease.UnlocalizedName + " Outbreak");
                    }
                }
            }
        }
Esempio n. 41
0
        public override void Perform(Sim sim, DiseaseVector vector)
        {
            int count = 0;

            List<GameObject> objs = sim.LotCurrent.GetObjectsInRoom<GameObject>(sim.RoomId);

            while ((count < mMaximum) && (objs.Count > 0))
            {
                GameObject obj = RandomUtil.GetRandomObjectFromList(objs);
                count++;

                RepairableComponent repairable = obj.Repairable;
                if (repairable == null) continue;

                if (!repairable.CanBreak()) continue;

                repairable.BreakObject(sim, true);
            }
        }
Esempio n. 42
0
        public override void Perform(Sim sim, DiseaseVector vector)
        {
            float delta = GetDelta(sim);

            float weight = sim.SimDescription.Weight + delta;
            if (weight < -1)
            {
                weight = -1;
            }
            else if (weight > 1)
            {
                weight = 1;
            }

            sim.SimDescription.ForceSetBodyShape(weight, sim.SimDescription.mCurrentShape.Fit);

            sim.RequireImmediateBodyShapeUpdate = true;
            sim.SimDescription.UpdateBodyShape(0f, sim.ObjectId);
        }
Esempio n. 43
0
        public override void Perform(Sim sim, DiseaseVector vector)
        {
            float delta = RandomUtil.GetFloat(mMinimum, mMaximum);
            if (delta == 0) return;

            float fitness = sim.SimDescription.mCurrentShape.Fit + delta;
            if (fitness < 0)
            {
                fitness = 0;
            }
            else if (fitness > 1)
            {
                fitness = 1;
            }

            sim.SimDescription.ForceSetBodyShape(sim.SimDescription.mCurrentShape.Weight, fitness);

            sim.RequireImmediateBodyShapeUpdate = true;
            sim.SimDescription.UpdateBodyShape(0f, sim.ObjectId);
        }
Esempio n. 44
0
        public override void Perform(Sim sim, DiseaseVector vector)
        {
            if (sim.SimDescription.IsPregnant) return;

            if (mClone)
            {
                Pregnancies.Start(sim, sim.SimDescription, mHandlePlantSim);
            }
            else if (vector.Infector != 0)
            {
                SimDescription other = SimDescription.Find(vector.Infector);
                if (other != null)
                {
                    if (!mAllowCloseRelations)
                    {
                        if (Relationships.IsCloselyRelated(sim.SimDescription, other, false)) return;
                    }

                    Pregnancies.Start(sim, other, mHandlePlantSim);
                }
            }
        }
Esempio n. 45
0
        public override void Perform(Sim sim, DiseaseVector vector)
        {
            if (sim.InteractionQueue == null) return;

            if (sim.CurrentInteraction is ICountsAsWorking) return;

            if (SimTypes.IsServiceOrRole(sim.SimDescription, false))
            {
                if (!SimTypes.IsSelectable(sim)) return;
            }

            if (!mAffectSleep)
            {
                if (sim.CurrentInteraction is ISleeping) return;
            }

            if (sim.CurrentInteraction != null)
            {
                if (sim.CurrentInteraction.Target is RabbitHole) return;
            }

            try
            {
                if (mAll)
                {
                    sim.InteractionQueue.CancelAllInteractions();
                }
                else if (sim.CurrentInteraction != null)
                {
                    sim.InteractionQueue.CancelInteraction(sim.CurrentInteraction, false);
                }
            }
            catch (Exception e)
            {
                Common.DebugException(sim, e);
            }
        }
Esempio n. 46
0
        public override void Perform(Sim sim, DiseaseVector vector)
        {
            int count = 0;

            List<GameObject> objs = sim.LotCurrent.GetObjectsInRoom<GameObject>(sim.RoomId);

            while ((count < mMaximum) && (objs.Count > 0))
            {
                GameObject obj = RandomUtil.GetRandomObjectFromList(objs);

                count++;

                if (obj.GetFireType() == FireType.DoesNotBurn) continue;

                LotLocation loc = LotLocation.Invalid;
                ulong lotLocation = World.GetLotLocation(obj.PositionOnFloor, ref loc);

                if (!World.HasSolidFloor(obj.LotCurrent.mLotId, loc)) continue;

                if (lotLocation == 0x0L) continue;

                Sims3.Gameplay.Objects.Fire.CreateFire(lotLocation, loc);
            }
        }
Esempio n. 47
0
        public override void Perform(Sim sim, DiseaseVector vector)
        {
            if (sim.BuffManager == null) return;

            sim.BuffManager.AddElement(mBuff, mMoodValue, mDuration, mOrigin);
        }
Esempio n. 48
0
        public override void Perform(Sim sim, DiseaseVector vector)
        {
            if (SimTypes.IsDead(sim.SimDescription)) return;

            if (!mAllowActive)
            {
                if (SimTypes.IsSelectable(sim.SimDescription)) return;
            }

            bool found = false;

            foreach (Sim other in sim.LotCurrent.GetSims())
            {
                if (other == sim) continue;

                if (ScoringLookup.GetScore(mScoring, other.SimDescription) >= mMinimum)
                {
                    found = true;
                    break;
                }
            }

            if (found) return;

            List<Lot> lots = new List<Lot>(LotManager.sLots.Values);

            while (lots.Count > 0)
            {
                Lot lot = RandomUtil.GetRandomObjectFromList(lots);
                lots.Remove(lot);

                if (lot.IsWorldLot) continue;

                if (lot == sim.LotCurrent) continue;

                foreach (Sim other in lot.GetSims())
                {
                    if (ScoringLookup.GetScore(mScoring, other.SimDescription) >= mMinimum)
                    {
                        InteractionDefinition definition = null;

                        if (lot.IsCommunityLot)
                        {
                            definition = VisitCommunityLot.Singleton;
                        }
                        else
                        {
                            if (sim.IsGreetedOnLot(lot))
                            {
                                definition = GoToLot.Singleton;
                            }
                            else
                            {
                                definition = VisitLot.Singleton;
                            }
                        }

                        InteractionInstance instance = definition.CreateInstance(lot, sim, new InteractionPriority(InteractionPriorityLevel.Autonomous), true, true);
                        sim.InteractionQueue.Add(instance);

                        return;
                    }
                }              
            }
        }
Esempio n. 49
0
            protected override void OnPerform()
            {
                if (mHouse == Household.ActiveHousehold) return;

                List<SimDescription> babies = new List<SimDescription>();
                List<SimDescription> teens = new List<SimDescription>();
                List<SimDescription> adults = new List<SimDescription>();
                List<SimDescription> teensAndAdults = new List<SimDescription>();

                foreach(SimDescription sim in Households.All(mHouse))
                {
                    if ((sim.IsPet) || (sim.ToddlerOrBelow))
                    {
                        babies.Add(sim);
                    }
                    else if (sim.YoungAdultOrAbove)
                    {
                        adults.Add(sim);
                        teensAndAdults.Add(sim);
                    }
                    else if (sim.Teen)
                    {
                        teens.Add(sim);
                        teensAndAdults.Add(sim);
                    }
                }

                if (adults.Count == 0)
                {
                    adults = teens;
                }

                bool purchaseInoculation = false;

                foreach(SimDescription sim in adults)
                {                
                    if (ScoringLookup.GetScore("NRaasVectorPurchaseInoculation", sim) > 0)
                    {
                        purchaseInoculation = true;
                        break;
                    }
                }

                if (purchaseInoculation)
                {
                    List<DiseaseVector> potentials = new List<DiseaseVector>();

                    foreach(SimDescription sim in babies)
                    {
                        GetInoculates(sim, potentials, false);
                    }

                    while (potentials.Count > 0)
                    {
                        DiseaseVector potential = RandomUtil.GetRandomObjectFromList(potentials);
                        potentials.Remove(potential);

                        DiseaseVector inoculate = null;

                        List<SimDescription> potentialDonors = new List<SimDescription>();

                        foreach(SimDescription sim in teensAndAdults)
                        {
                            DiseaseVector vector = Vector.Settings.GetVector(sim, potential.Guid);
                            if (vector == null) continue;

                            if (!vector.IsInoculationUpToDate)
                            {
                                potentialDonors.Add(sim);
                            }

                            if (!vector.IsInoculated) continue;

                            inoculate = vector;
                            break;
                        }

                        if (inoculate == null)
                        {
                            if (mHouse.FamilyFunds < potential.InoculationCost) continue;

                            inoculate = new DiseaseVector(potential.Data, Vector.Settings.GetCurrentStrain(potential.Data));
                            inoculate.Inoculate(potential.Data.InoculationStrain, true);

                            if (potentialDonors.Count > 0)
                            {
                                SimDescription donor = RandomUtil.GetRandomObjectFromList(potentialDonors);
                                VectorControl.Inoculate(donor, inoculate, true, false);
                            }

                            mHouse.ModifyFamilyFunds(-potential.InoculationCost);

                            Common.DebugNotify("Donor Inoculate: " + mHouse.Name + Common.NewLine + "Cost: " + potential.InoculationCost + Common.NewLine + potential.GetUnlocalizedDescription());
                        }
                        else
                        {
                            Common.DebugNotify("Existing Inoculate: " + mHouse.Name + Common.NewLine + "Cost: " + potential.InoculationCost + Common.NewLine + potential.GetUnlocalizedDescription());
                        }

                        if (inoculate != null)
                        {
                            foreach (SimDescription child in babies)
                            {
                                VectorControl.Inoculate(child, inoculate, false, false);
                            }

                            return;
                        }
                    }

                    potentials.Clear();

                    foreach (SimDescription sim in Households.All(mHouse))
                    {
                        // Babies were handled earlier
                        if (sim.ToddlerOrBelow) continue;

                        GetInoculates(sim, potentials, true);
                    }

                    while (potentials.Count > 0)
                    {
                        DiseaseVector potential = RandomUtil.GetRandomObjectFromList(potentials);
                        potentials.Remove(potential);

                        if (mHouse.FamilyFunds < potential.InoculationCost) continue;

                        potential.Inoculate(potential.Data.InoculationStrain, true);

                        mHouse.ModifyFamilyFunds(-potential.InoculationCost);

                        if (Common.kDebugging)
                        {
                            Common.DebugNotify("Inoculate: " + mHouse.Name + Common.NewLine + "Cost: " + potential.InoculationCost + Common.NewLine + potential.GetUnlocalizedDescription());
                        }

                        return;
                    }
                }

                List<SimDescription> choices = new List<SimDescription>(adults);

                while (choices.Count > 0)
                {
                    SimDescription choice = RandomUtil.GetRandomObjectFromList(choices);
                    choices.Remove(choice);

                    if (ScoringLookup.GetScore("NRaasVectorPurchaseResistance", choice) > 0)
                    {
                        List<DiseaseVector> potentials = new List<DiseaseVector>();

                        GetResisters(choice, potentials);

                        if (potentials.Count > 0)
                        {
                            DiseaseVector potential = RandomUtil.GetRandomObjectFromList(potentials);

                            mHouse.ModifyFamilyFunds(-potential.ResistanceCost);

                            potential.AlterResistance(Vector.Settings.mResistanceBoost);

                            potential.SetToIdentified();

                            if (Common.kDebugging)
                            {
                                Common.DebugNotify("Boost: " + mHouse.Name + Common.NewLine + "Cost: " + potential.ResistanceCost + Common.NewLine + potential.GetUnlocalizedDescription());
                            }
                        }
                    }

                    /*
                    if (ScoringLookup.GetScore("NRaasVectorPurchaseProtection", choice) > 0)
                    {
                        purchaseProtection = true;
                    }
                    */
                }
            }
Esempio n. 50
0
 public override void Perform(Sim sim, DiseaseVector vector)
 {
     sim.PlayReaction(mType, mSpeed);
 }
Esempio n. 51
0
 protected abstract bool IsSuccess(SimDescription sim, DiseaseVector vector);
Esempio n. 52
0
        public static bool Inoculate(SimDescription sim, VectorBooter.Data vector, bool paid, bool testExisting)
        {
            DiseaseVector inoculate = new DiseaseVector(vector, Vector.Settings.GetCurrentStrain(vector));
            inoculate.Inoculate(vector.InoculationStrain, paid);

            return Inoculate(sim, inoculate, paid, testExisting);
        }
Esempio n. 53
0
 public DiseaseVector.Variant GetNewStrain(VectorBooter.Data vector, DiseaseVector.Variant strain)
 {
     return GetNewStrain(vector, strain, false);
 }
Esempio n. 54
0
        public static bool Inoculate(SimDescription sim, DiseaseVector vector, bool paid, bool testExisting)
        {
            if (vector.InoculationCost <= 0) return false;

            DiseaseVector newVector = Vector.Settings.GetVector(sim, vector.Guid);
            if (newVector == null)
            {
                newVector = new DiseaseVector(vector, sim);
                newVector.Inoculate(vector.InoculationStrain, paid);

                Vector.Settings.AddVector(sim, newVector);
                return true;
            }
            else
            {
                if (testExisting)
                {
                    if (newVector.IsInoculationUpToDate) return false;
                }

                if (!newVector.CanInoculate) return false;

                return newVector.Inoculate(vector.InoculationStrain, paid);
            }
        }
Esempio n. 55
0
        protected DiseaseVector.Variant GetNewStrain(VectorBooter.Data vector, DiseaseVector.Variant strain, bool force)
        {
            DiseaseVector.Variant newStrain = new DiseaseVector.Variant(vector, strain);

            if ((force) || (strain.Mutated))
            {
                // Doing this stops the previous strain from reentering this process
                strain.Mutated = false;

                long id = 1;

                DiseaseVector.Variant oldStrain;
                if (mVariants.TryGetValue(vector.Guid, out oldStrain))
                {
                    if (oldStrain.Strain < strain.Strain)
                    {
                        oldStrain.Strain = strain.Strain;
                    }

                    id = oldStrain.Strain;
                }
                else
                {
                    oldStrain = null;
                }

                if ((oldStrain == null) || (oldStrain.Variation(vector) < newStrain.Variation(vector)))
                {
                    newStrain.Strain++;

                    oldStrain = new DiseaseVector.Variant(newStrain, id + 1);

                    mVariants.Remove(vector.Guid);
                    mVariants.Add(vector.Guid, oldStrain);

                    if (Common.kDebugging)
                    {
                        Common.DebugNotify("BETTER " + vector.Guid + " Strain:" + Common.NewLine + oldStrain);
                    }
                }
                else if (RandomUtil.RandomChance01(vector.StrainMutationRate * (force ? 2 : 1)))
                {
                    newStrain.Strain = id + 1;

                    if (force)
                    {
                        oldStrain.Strain = newStrain.Strain;

                        if (Common.kDebugging)
                        {
                            Common.DebugNotify("OUTBREAK " + vector.Guid + " Strain:" + Common.NewLine + newStrain);
                        }
                    }
                    else
                    {
                        if (Common.kDebugging)
                        {
                            Common.DebugNotify("RANDOM " + vector.Guid + " Strain:" + Common.NewLine + newStrain);
                        }
                    }
                }
            }

            return newStrain;
        }
Esempio n. 56
0
        public override void Perform(Sim sim, DiseaseVector vector)
        {
            if (sim.IdleManager == null) return;

            sim.IdleManager.ScheduleIdle(mPriority, mMood);
        }
Esempio n. 57
0
        public static void StartOutbreak(VectorBooter.Data vector, bool verbose)
        {
            DiseaseVector disease = new DiseaseVector(vector, Vector.Settings.GetNewStrain(vector));

            ScoringLog.sLog.IncStat(disease.UnlocalizedName + " Attempt Outbreak");

            List<Sim> sims = new List<Sim>(LotManager.Actors);

            if (sims.Count > 0)
            {
                int count = 0;
                while ((count < Vector.Settings.mNumPatientZero) && (sims.Count > 0))
                {
                    Sim choice = RandomUtil.GetRandomObjectFromList(sims);
                    sims.Remove(choice);

                    if (choice.SimDescription.ToddlerOrBelow) continue;

                    if (!Vector.Settings.mOutbreakAllowActive)
                    {
                        if (choice.Household == Household.ActiveHousehold) continue;
                    }

                    if (disease.Infect(choice.SimDescription, true))
                    {
                        count++;

                        if (verbose)
                        {
                            ShowNotice(choice.SimDescription, disease, Common.kDebugging ? "Outbreak" : "");
                        }

                        ScoringLog.sLog.IncStat(disease.UnlocalizedName + " Outbreak");
                    }
                }
            }
        }
Esempio n. 58
0
        public void AddVector(SimDescription sim, DiseaseVector vector)
        {
            PrivateGetVectors(sim).Add(vector);

            if (!vector.IsInoculated)
            {
                if (Common.kDebugging)
                {
                    OutbreakControl.ShowNotice(sim, vector, "Infected: ");
                }
            }
        }
Esempio n. 59
0
 public override int GetNextStage(SimDescription sim, DiseaseVector vector)
 {
     return mNextStage.Second;
 }
Esempio n. 60
0
 public static void ShowNotice(SimDescription sim, DiseaseVector vector, string prefix)
 {
     if (Vector.Settings.mOutbreakShowNotices)
     {
         Common.Notify(sim.CreatedSim, prefix + Common.Localize("Outbreak:Success", sim.IsFemale, new object[] { sim, vector.GetLocalizedName(sim.IsFemale) }));
     }
 }