Ejemplo n.º 1
0
 public HouseholdStore(IEnumerable <SimDescription> newSims, bool catchDreams)
 {
     if (newSims != null)
     {
         mNewSims = new List <SimDescription>(newSims);
     }
     mOldHouse = PlumbBob.sCurrentNonNullHousehold;
     if ((mOldHouse != null) && (catchDreams))
     {
         foreach (Sim member in AllSims(mOldHouse))
         {
             DreamStore element = new DreamStore(member, false, true);
             mDreamStore.Add(member, element);
         }
     }
     if (mNewSims != null)
     {
         foreach (SimDescription member in mNewSims)
         {
             Alive.ResetClearSimTask.
             CleanupBrokenSkills(member);
             mSafeStore.Add(member, new SafeStore(member, SafeStore.Flag.Selectable | SafeStore.Flag.Unselectable | SafeStore.Flag.StoreOpportunities));
             if ((member.CreatedSim != null) &&
                 (member.CreatedSim.Autonomy != null))
             {
                 Motives motives = member.CreatedSim.Autonomy.Motives;
                 if ((motives == null) || (motives.GetMotive(CommodityKind.Hunger) == null))
                 {
                     member.CreatedSim.Autonomy.RecreateAllMotives();
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        float temp = (m_motives[(int)Motives.kRest] as RestMotive).EnergyDecayAmount;

        (m_motives[(int)Motives.kRest] as RestMotive).EnergyDecayAmount = (m_motives[(int)Motives.kRest] as RestMotive).EnergyDecayAmount * (1 + m_motives[(int)Motives.kLeave].ScoreMotive()); // take into account frustration

        if (m_currentMotive == Motives.kNone)                                                                                                                                                   // if no motive get a motive
        {
            ChooseMotive();
            DecayMotives();
        }
        else if (m_currentMotive == Motives.kLeave && AtLocation()) // if wanting to leave and at door leave
        {
            if (m_motives[(int)m_currentMotive].DoMotive() == false)
            {
                m_currentMotive = Motives.kNone;
            }
        }
        else
        {
            if (AtLocation()) // do the apropriate task when at location
            {
                if (m_motives[(int)m_currentMotive].DoMotive() == false)
                {
                    m_currentMotive = Motives.kNone;
                }
            }
            else
            {
                // standard over time decay
                DecayMotives();
            }
        }
        (m_motives[(int)Motives.kRest] as RestMotive).EnergyDecayAmount = temp;
    }
Ejemplo n.º 3
0
            public override bool Test(Sim a, EquestrianCenter target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
            {
                if (target.IsActorUsingMe(a))
                {
                    return(false);
                }

                Posture posture = a.Posture as RidingPosture;

                if (posture == null)
                {
                    posture = a.Posture as LeadingHorsePosture;
                    if (posture == null)
                    {
                        greyedOutTooltipCallback = InteractionInstance.CreateTooltipCallback(EquestrianCenter.OfferStallionAsStud.LocalizeString(a.IsFemale, "NeedHorse", new object[] { a }));
                        return(false);
                    }
                }

                Sim container = posture.Container as Sim;

                if (!container.IsSelectable)
                {
                    return(false);
                }

                if (container.SimDescription.IsFemale)
                {
                    greyedOutTooltipCallback = InteractionInstance.CreateTooltipCallback(EquestrianCenter.OfferStallionAsStud.LocalizeString(a.IsFemale, "NeedMaleHorse", new object[] { a }));
                    return(false);
                }
                else if (container.SimDescription.Child)
                {
                    greyedOutTooltipCallback = InteractionInstance.CreateTooltipCallback(EquestrianCenter.OfferStallionAsStud.LocalizeString(a.IsFemale, "NeedAdultHorse", new object[] { a }));
                    return(false);
                }
                else if (container.SimDescription.Elder)
                {
                    greyedOutTooltipCallback = InteractionInstance.CreateTooltipCallback(EquestrianCenter.OfferStallionAsStud.LocalizeString(container.IsFemale, "ElderPetsTooOldForBreed", new object[] { container }));
                    return(false);
                }

                /*
                 * if (container.SimDescription.IsUnicorn)
                 * {
                 *  greyedOutTooltipCallback = InteractionInstance.CreateTooltipCallback(EquestrianCenter.OfferStallionAsStud.LocalizeString(a.IsFemale, "UnicornCannotBeOffered", new object[] { a }));
                 *  return false;
                 * }
                 */

                Motives motives = container.Motives;

                if (motives.HasMotive(CommodityKind.StallionOffered) && (motives.GetValue(CommodityKind.StallionOffered) >= EquestrianCenter.kOfferStallionMotiveThreshold))
                {
                    greyedOutTooltipCallback = InteractionInstance.CreateTooltipCallback(EquestrianCenter.OfferStallionAsStud.LocalizeString(a.IsFemale, "Cooldown", new object[] { a, container }));
                    return(false);
                }
                return(true);
            }
Ejemplo n.º 4
0
 protected void ForceSetMax (Motives ths, CommodityKind commodity)
 {
     Motive motive = ths.GetMotive(commodity);
     if ((motive != null) && (motive.Value != motive.Tuning.Max))
     {
         motive.UpdateMotiveBuffs(ths.mSim, commodity, (int) motive.Tuning.Max);
         motive.mValue = motive.Tuning.Max;
     }
 }
Ejemplo n.º 5
0
        protected void ForceSetMax(Motives ths, CommodityKind commodity)
        {
            Motive motive = ths.GetMotive(commodity);

            if ((motive != null) && (motive.Value != motive.Tuning.Max))
            {
                motive.UpdateMotiveBuffs(ths.mSim, commodity, (int)motive.Tuning.Max);
                motive.mValue = motive.Tuning.Max;
            }
        }
Ejemplo n.º 6
0
    private void ChooseMotive()  // picks a motive randomly and does it if posible
    {
        if (ReadyToLeave())
        {
            m_currentMotive = Motives.kLeave;
            m_navAgent.SetDestination(m_motives[(int)m_currentMotive].StartMotive());

            HistoryFrame historyFrame = new HistoryFrame((m_motives[(int)Motives.kEat] as EatMotive).Hunger,
                                                         (m_motives[(int)Motives.kRest] as RestMotive).Energy, (m_motives[(int)Motives.kSocialize] as SocialMotive).Social,
                                                         (m_motives[(int)Motives.kShop] as ShopMotive).GetItemsToBuy(), 0, 0, 0, 0, 1, GetCurrentMotive());

            AddHistory(historyFrame);
        }
        else
        {
            m_hungerScore = m_motives[(int)Motives.kEat].ScoreMotive();
            m_energyScore = m_motives[(int)Motives.kRest].ScoreMotive();
            m_shopScore   = m_motives[(int)Motives.kShop].ScoreMotive();
            m_leaveScore  = m_motives[(int)Motives.kLeave].ScoreMotive();
            m_socialScore = m_motives[(int)Motives.kSocialize].ScoreMotive();

            List <MotiveValuePair> desireOrder = new List <MotiveValuePair>
            {
                new MotiveValuePair(Motives.kEat, m_hungerScore), new MotiveValuePair(Motives.kRest, m_energyScore),
                new MotiveValuePair(Motives.kShop, m_shopScore), new MotiveValuePair(Motives.kLeave, m_leaveScore),
                new MotiveValuePair(Motives.kSocialize, m_socialScore)
            };

            desireOrder.Sort();

            m_currentMotive = desireOrder[desireOrder.Count - 1].mot;
            float choice = desireOrder[desireOrder.Count - 1].val;

            if (m_currentMotive == m_previousChoice && (choice - desireOrder[desireOrder.Count - 2].val) <= .1) // if choice is the same as last choice and the desire difference between second best is less then .1
            {
                m_currentMotive = desireOrder[desireOrder.Count - 2].mot;                                       // choose the next best thing
            }
            m_previousChoice = m_currentMotive;


            HistoryFrame historyFrame = new HistoryFrame((m_motives[(int)Motives.kEat] as EatMotive).Hunger,
                                                         (m_motives[(int)Motives.kRest] as RestMotive).Energy, (m_motives[(int)Motives.kSocialize] as SocialMotive).Social,
                                                         (m_motives[(int)Motives.kShop] as ShopMotive).GetItemsToBuy(), m_hungerScore, m_energyScore, m_socialScore,
                                                         m_shopScore, m_leaveScore, GetCurrentMotive());

            AddHistory(historyFrame);

            m_navAgent.SetDestination(m_motives[(int)m_currentMotive].StartMotive());
        }
    }
        void selectMotive()
        {
            int i;
            if (families.Count > 0) {
                i = Random.Range(0, 4);
            }
            else i = Random.Range(0, 3);

            switch (i) {
                case 0:
                    motive = Motives.revenge;       //Killing over an event in the murderer's history
                    break;
                case 1:
                    motive = Motives.loverRevenge;  //Killing because the victim refused to love them back
                    break;
                case 2:
                    motive = Motives.jealousLove;   //Killing because the NPC they love was in love with the victim
                    break;
                case 3:
                    motive = Motives.inheritance;   //Killing a family member for the sake of gaining inheritance, either from the victim or from someone who would've otherwise given money to that victim
                    break;
            }

            //Check that there is a suitable sibling pair for the inheritance plot
            if (motive == Motives.inheritance) {
                Debug.Log("checking if there are siblings for an inheritance plot");
                if (findSiblings()[0] != null) {
                    Debug.Log("Found suitable siblings for inheritance plot");
                    motive = Motives.inheritance;
                }
                else {
                    Debug.Log("No suitable siblings found for the inheritance plot, choosing new motive");
                    selectMotive();
                }
            }
        }
Ejemplo n.º 8
0
        protected override void PrivatePerform(SimDescription sim, SimData data, ScenarioFrame frame)
        {
            if (SimTypes.IsService(sim.Household))
            {
                return;
            }

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

            if (sim.AssignedRole != null)
            {
                if (sim.AssignedRole.IsActive)
                {
                    return;
                }
            }

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

            if (sim.CreatedSim.HasBeenDestroyed)
            {
                return;
            }

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

            Motives motives = sim.CreatedSim.Autonomy.Motives;

            if (motives == null)
            {
                return;
            }

            bool frozen = data.GetValue <StaticHungerOption, bool>();

            AlterDecay(motives.GetMotive(CommodityKind.VampireThirst), frozen);
            AlterDecay(motives.GetMotive(CommodityKind.Hunger), frozen);
            AlterDecay(motives.GetMotive(CommodityKind.BatteryPower), frozen);

            if (!sim.IsMummy)
            {
                frozen = data.GetValue <StaticEnergyOption, bool>();

                AlterDecay(motives.GetMotive(CommodityKind.Energy), frozen);
                AlterDecay(motives.GetMotive(CommodityKind.AlienBrainPower), frozen);

                frozen = data.GetValue <StaticBladderOption, bool>();

                AlterDecay(motives.GetMotive(CommodityKind.Bladder), frozen);
            }

            frozen = data.GetValue <StaticHygieneOption, bool>();

            if (!sim.IsFrankenstein)
            {
                AlterDecay(motives.GetMotive(CommodityKind.Hygiene), frozen);
            }

            AlterDecay(motives.GetMotive(CommodityKind.Maintenence), frozen);

            frozen = data.GetValue <StaticFunOption, bool>();

            AlterDecay(motives.GetMotive(CommodityKind.Fun), frozen);

            frozen = data.GetValue <StaticSocialOption, bool>();

            AlterDecay(motives.GetMotive(CommodityKind.Social), frozen);

            if (GameUtils.IsInstalled(ProductVersion.EP8))
            {
                frozen = data.GetValue <StaticTemperatureOption, bool>();

                AlterDecay(motives.GetMotive(CommodityKind.Temperature), frozen);
            }

            if (GameUtils.IsInstalled(ProductVersion.EP5))
            {
                switch (sim.Species)
                {
                case CASAgeGenderFlags.Horse:
                    frozen = data.GetValue <StaticExerciseOption, bool>();

                    AlterDecay(motives.GetMotive(CommodityKind.HorseExercise), frozen);

                    frozen = data.GetValue <StaticThirstOption, bool>();

                    AlterDecay(motives.GetMotive(CommodityKind.HorseThirst), frozen);
                    break;

                case CASAgeGenderFlags.Cat:
                    frozen = data.GetValue <StaticDestructionOption, bool>();

                    AlterDecay(motives.GetMotive(CommodityKind.CatScratch), frozen);
                    break;

                case CASAgeGenderFlags.Dog:
                case CASAgeGenderFlags.LittleDog:
                    frozen = data.GetValue <StaticDestructionOption, bool>();

                    AlterDecay(motives.GetMotive(CommodityKind.DogDestruction), frozen);

                    break;
                }
            }
        }
Ejemplo n.º 9
0
        public void motive_motive_distress(Sim sim, CommodityKind commodity)
        {
            if (commodity == (CommodityKind)0x44440444)
            {
                return;
            }

            SimDescription simd        = sim.SimDescription;
            BuffManager    buffManager = sim.BuffManager;
            Motives        moves       = sim.Motives;

            switch (commodity)
            {
            case CommodityKind.Bladder:
            {
                bool flag = true;
                InteractionDefinition interactionDefinition;
                switch (simd.Species)
                {
                case CASAgeGenderFlags.Horse:
                    interactionDefinition = Sim.HorsePee.Singleton;
                    break;

                case CASAgeGenderFlags.Dog:
                case CASAgeGenderFlags.LittleDog:
                    interactionDefinition = (InteractionDefinition)Sim.DogPeeStart.Singleton;
                    break;

                case CASAgeGenderFlags.Cat:
                    interactionDefinition = (InteractionDefinition)Sim.CatPeeStart.Singleton;
                    break;

                default:
                    interactionDefinition = Sim.BladderFailure.Singleton;
                    break;
                }

                foreach (InteractionInstance interaction in sim.InteractionQueue.InteractionList)
                {
                    if (interaction is Sim.DogPee || interaction is Sim.CatPee || interaction.InteractionDefinition == interactionDefinition)
                    {
                        flag = false;
                        break;
                    }
                }

                if (flag)
                {
                    SwimmingInPool swimmingInPool = sim.Posture as SwimmingInPool;
                    if (swimmingInPool == null)
                    {
                        InteractionInstance interactionInstance = interactionDefinition.CreateInstance(sim, sim, new InteractionPriority(InteractionPriorityLevel.High), false, false);
                        Sim.DogPeeStart     dogPeeStart         = interactionInstance as Sim.DogPeeStart;
                        if (dogPeeStart != null)
                        {
                            dogPeeStart.DoNotRoute = true;
                        }
                        else
                        {
                            Sim.CatPeeStart catPeeStart = interactionInstance as Sim.CatPeeStart;
                            if (catPeeStart != null)
                            {
                                catPeeStart.DoNotRoute = true;
                            }
                        }
                        if (sim.InteractionQueue.AddNext(interactionInstance) && simd.IsRaccoon)
                        {
                            sim.AddExitReason(ExitReason.BuffFailureState);
                        }
                        else
                        {
                            BuffInstance buffOfSolveCommodity = buffManager.GetBuffOfSolveCommodity(commodity);
                            if (buffOfSolveCommodity != null && buffOfSolveCommodity.EffectValue <= 0)
                            {
                                ThoughtBalloonManager.BalloonData balloonData = new ThoughtBalloonManager.BalloonData(buffOfSolveCommodity.ThumbString);
                                if (balloonData.IsValid)
                                {
                                    balloonData.BalloonType = ThoughtBalloonTypes.kScreamBalloon;
                                    balloonData.mCoolDown   = ThoughtBalloonCooldown.None;
                                    sim.ThoughtBalloonManager.ShowBalloon(balloonData);
                                }
                            }

                            moves.SetMax(CommodityKind.Bladder);

                            if (!simd.IsPet)
                            {
                                PuddleManager.AddPuddle(sim.Position);
                                moves.SetValue(CommodityKind.Hygiene, -100f);
                                if (GlobalFunctions.AreOtherSimsNearby(sim, BuffEmbarrassed.DistanceForEmbarrassedBuff))
                                {
                                    buffManager.AddElement(BuffNames.Embarrassed, Origin.FromPeeingSelf);
                                }
                                ActiveTopic.AddToSim(sim, "Embarrassment");
                            }
                            else
                            {
                                MetaAutonomyVenueType metaAutonomyVenueType = sim.LotCurrent.GetMetaAutonomyVenueType();
                                if ((!simd.IsADogSpecies || metaAutonomyVenueType != MetaAutonomyVenueType.DogPark) && World.GetTerrainType(sim.Position) == TerrainType.LotFloor)
                                {
                                    PuddleManager.AddPuddle(sim.Position);
                                }
                            }
                            EventTracker.SendEvent(EventTypeId.kBladderFailure, sim);
                        }
                        Motive motive = moves.GetMotive(CommodityKind.Bladder);
                        if (motive != null)
                        {
                            motive.PotionBladderDecayOverride = false;
                        }
                    }
                    else
                    {
                        swimmingInPool.ContainerPool.PeeInPool(sim);
                    }
                }
                break;
            }

            case CommodityKind.Hunger:
            case CommodityKind.VampireThirst:

                if (simd.IsFrankenstein)
                {
                    OccultFrankenstein.PushFrankensteinShortOut(sim);
                }
                else if (!simd.IsGhost && !simd.IsDead && !IsCheckKillSimInteraction(sim))
                {
                    if (sim.Posture.Satisfies(CommodityKind.ScubaDiving, null) && !simd.IsMermaid)
                    {
                        sim.Kill(SimDescription.DeathType.ScubaDrown);
                    }
                    else if (sim.Posture.Satisfies(CommodityKind.SwimmingInPool, null) && !simd.IsMermaid)
                    {
                        sim.Kill(SimDescription.DeathType.Drown);
                    }
                    else if (SimTemperature.HasFrozenSolidInteraction(sim))
                    {
                        sim.Kill(SimDescription.DeathType.Freeze, null, false);
                    }
                    else if (OccultMermaid.IsDehydrated(sim))
                    {
                        sim.Kill(SimDescription.DeathType.MermaidDehydrated, null, false);
                    }
                    else
                    {
                        sim.Kill(sim.SimDescription.IsVampire ? SimDescription.DeathType.Thirst : SimDescription.DeathType.Starve);
                    }
                }
                break;

            case CommodityKind.Temperature:
            {
                float value = moves.GetValue(CommodityKind.Temperature);
                if (value > 0f)
                {
                    SimTemperature.PushSpontaneouslyCombustInteraction(sim);
                }
                else
                {
                    SimTemperature.PushFreezeInteraction(sim);
                }
                break;
            }

            case CommodityKind.MermaidDermalHydration:
                OccultMermaid.CollapseFromDehydration(sim);
                break;
            }
        }
Ejemplo n.º 10
0
 public MotiveValuePair(Motives newMot, float newVal)
 {
     mot = newMot;
     val = newVal;
 }