Beispiel #1
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            base.PrivateUpdate(frame);

            List <AthleticGameObject> objs = new List <AthleticGameObject>();

            InteractionInstance interaction = Target.CreatedSim.InteractionQueue.GetCurrentInteraction();

            if ((interaction != null) && (interaction.Target is AthleticGameObject))
            {
                IncStat("Trainee Ready");

                objs.Add(interaction.Target as AthleticGameObject);
            }
            else
            {
                foreach (Lot lot in ManagerLot.GetOwnedLots(Sim))
                {
                    objs.AddRange(lot.GetObjects <AthleticGameObject>(TestObject));
                }

                if (objs.Count == 0)
                {
                    foreach (Lot lot in ManagerLot.GetOwnedLots(Target))
                    {
                        objs.AddRange(lot.GetObjects <AthleticGameObject>(TestObject));
                    }
                    if (objs.Count == 0)
                    {
                        foreach (AthleticGameObject obj in Sims3.Gameplay.Queries.GetObjects <AthleticGameObject>())
                        {
                            if (!TestObject(obj))
                            {
                                continue;
                            }

                            if (!obj.LotCurrent.IsCommunityLot)
                            {
                                continue;
                            }

                            objs.Add(obj);
                        }

                        if (objs.Count == 0)
                        {
                            IncStat("No Training Object");
                            return(false);
                        }
                    }
                }
            }

            return(Situations.PushMeetUp(this, Sim, Target, RandomUtil.GetRandomObjectFromList(objs).LotCurrent, FirstAction));
        }
Beispiel #2
0
        public static bool PushForRepairman(IScoringGenerator stats, StoryProgressionObject manager, Household house)
        {
            List <SimDescription> choices = manager.Situations.GetFree(stats, new SimScoringList(stats, "Handiness", manager.Sims.TeensAndAdults, false).GetBestByMinScore(1), true);

            Dictionary <Household, List <GameObject> > repairs = new Dictionary <Household, List <GameObject> >();

            foreach (Lot lot in ManagerLot.GetOwnedLots(house))
            {
                GetRepairs(manager, lot.GetObjects <GameObject>(), repairs);
            }

            stats.AddStat("Residents", choices.Count);

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

                if (choice.CreatedSim == null)
                {
                    continue;
                }

                List <GameObject> repairWork = null;
                if (repairs.TryGetValue(house, out repairWork))
                {
                    if (PushInteractions(manager, choice, repairWork))
                    {
                        stats.IncStat("Resident Repairman");
                        return(true);
                    }
                    else
                    {
                        stats.IncStat("Push Fail");
                    }
                }
                else
                {
                    stats.IncStat("No Repairs Fonud");
                }
            }

            stats.IncStat("Service Repairman");

            Repairman instance = Repairman.Instance;

            if (instance != null)
            {
                instance.MakeServiceRequest(house.LotHome, true, ObjectGuid.InvalidObjectGuid);
            }
            return(true);
        }
Beispiel #3
0
        protected static int ComputeNetWorthOfObjectsInHousehold(Household house, bool includeObjectsRemovedOnEvict)
        {
            int num = 0;

            foreach (Lot lot in ManagerLot.GetOwnedLots(house))
            {
                foreach (GameObject obj in lot.GetObjects <GameObject>())
                {
                    if ((!(obj is Sim) && !(obj is PlumbBob)) && (includeObjectsRemovedOnEvict || obj.StaysAfterEvict()))
                    {
                        num += obj.Value;
                    }
                }
            }
            return(num);
        }
Beispiel #4
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            base.PrivateUpdate(frame);

            List <ChessTable> tables = new List <ChessTable>();

            foreach (Lot lot in ManagerLot.GetOwnedLots(Sim))
            {
                tables.AddRange(lot.GetObjects <ChessTable>(TestTable));
            }

            if (tables.Count == 0)
            {
                foreach (Lot lot in ManagerLot.GetOwnedLots(Target))
                {
                    tables.AddRange(lot.GetObjects <ChessTable>(TestTable));
                }

                if (tables.Count == 0)
                {
                    foreach (ChessTable table in Sims3.Gameplay.Queries.GetObjects <ChessTable>())
                    {
                        if (!TestTable(table))
                        {
                            continue;
                        }

                        if (!table.LotCurrent.IsCommunityLot)
                        {
                            continue;
                        }

                        tables.Add(table);
                    }

                    if (tables.Count == 0)
                    {
                        IncStat("No Table");
                        return(false);
                    }
                }
            }

            return(Situations.PushMeetUp(this, Sim, Target, RandomUtil.GetRandomObjectFromList(tables).LotCurrent, FirstAction));
        }
Beispiel #5
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            base.PrivateUpdate(frame);

            InventingSkill skill = Sim.SkillManager.GetElement(SkillNames.Inventing) as InventingSkill;

            List <InventionWorkbench> benches = new List <InventionWorkbench>();
            List <InventionWorkbench> empties = new List <InventionWorkbench>();

            foreach (Lot lot in ManagerLot.GetOwnedLots(Sim))
            {
                foreach (InventionWorkbench bench in lot.GetObjects <InventionWorkbench>())
                {
                    if (bench.InUse)
                    {
                        continue;
                    }

                    if (bench.mIsMakingFrankensim)
                    {
                        continue;
                    }

                    if (bench.mInventionProgress > 0)
                    {
                        if (skill == null)
                        {
                            continue;
                        }

                        if (!skill.KnownInventions.Contains(bench.mInventionKey))
                        {
                            continue;
                        }

                        benches.Add(bench);
                    }
                    else
                    {
                        empties.Add(bench);
                    }
                }
            }

            if (benches.Count == 0)
            {
                benches.AddRange(empties);

                if (benches.Count == 0)
                {
                    IncStat("No Bench");
                    return(false);
                }
            }

            int minimumScrap   = InventionWorkbench.kNumScrapsPerDiceRoll * 10;
            int inventoryScrap = Inventories.InventoryFindAll <Scrap>(Sim).Count;

            if (inventoryScrap < minimumScrap)
            {
                List <JunkPile> piles = new List <JunkPile>();
                foreach (JunkPile pile in Sims3.Gameplay.Queries.GetObjects <JunkPile>())
                {
                    if (pile.IsEmpty)
                    {
                        continue;
                    }

                    if (pile.LotCurrent == Sim.LotHome)
                    {
                        piles.Add(pile);
                    }
                    else if (pile.LotCurrent == null)
                    {
                        continue;
                    }
                    else if (pile.LotCurrent.IsCommunityLot)
                    {
                        piles.Add(pile);
                    }
                }

                bool success = false;

                while (piles.Count > 0)
                {
                    JunkPile junkChoice = RandomUtil.GetRandomObjectFromList(piles);
                    piles.Remove(junkChoice);

                    if (!Situations.PushInteraction(this, Sim, junkChoice, DigThroughEx.Singleton))
                    {
                        break;
                    }

                    IncStat("Push Dig Through");

                    success = true;
                }

                if (!success)
                {
                    Money.AdjustFunds(Sim, "BuyItem", -InventionWorkbench.Restock.GetScrapCost(minimumScrap - inventoryScrap));

                    AddStat("Buy Scrap", minimumScrap - inventoryScrap);

                    CreateScrap(Sim.CreatedSim, minimumScrap - inventoryScrap);
                }
                else
                {
                    return(true);
                }
            }

            InventionWorkbench choice = RandomUtil.GetRandomObjectFromList(benches);

            if (choice.mInventionProgress > 0)
            {
                IncStat("Try Continue");

                if (Situations.PushInteraction(this, Sim, choice, MakeInventionEx.Singleton))
                {
                    return(true);
                }

                IncStat("Continue Fail");
                return(false);
            }
            else
            {
                if ((skill != null) && (skill.GetUndiscoveredInventions().Count == 0x0) && (skill.ReachedMaxLevel()))
                {
                    IncStat("Try Start New");

                    if (Situations.PushInteraction(this, Sim, choice, MakeInventionEx.Singleton))
                    {
                        return(true);
                    }

                    IncStat("Start New Fail");
                    return(false);
                }
                else
                {
                    if ((skill == null) || (skill.KnownInventions.Count == 0) || (RandomUtil.RandomChance(25)))
                    {
                        IncStat("Try Invent");

                        if (Situations.PushInteraction(this, Sim, choice, new InventionWorkbench.Invent.Definition()))
                        {
                            return(true);
                        }

                        IncStat("Invent Fail");
                        return(false);
                    }
                    else
                    {
                        IncStat("Try Start New");

                        if (Situations.PushInteraction(this, Sim, choice, MakeInventionEx.Singleton))
                        {
                            return(true);
                        }

                        IncStat("Start New Fail");
                        return(false);
                    }
                }
            }
        }
Beispiel #6
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            base.PrivateUpdate(frame);

            List <SculptingStation> stations = new List <SculptingStation>();
            List <SculptingStation> empties  = new List <SculptingStation>();

            foreach (Lot lot in ManagerLot.GetOwnedLots(Sim))
            {
                foreach (SculptingStation station in lot.GetObjects <SculptingStation>())
                {
                    if (station.HasFinishedSculpture())
                    {
                        GameObject sculpture = station.GetCurrentSculpture();

                        station.OnHandToolChildUnslottedBase(sculpture, Slot.ContainmentSlot_0);

                        sculpture.UnParent();

                        if (!Sim.Household.SharedFamilyInventory.Inventory.TryToMove(sculpture))
                        {
                            int value = Money.Sell(Sim, sculpture);

                            AddStat("Sculpture Sold", value);
                        }
                        else
                        {
                            IncStat("Sculpture Stored");
                        }
                    }

                    if (station.HasUnfinishedSculpture())
                    {
                        GameObject currentSculpture = station.GetCurrentSculpture();
                        if ((currentSculpture != null) && (currentSculpture.SculptureComponent != null))
                        {
                            if (currentSculpture.SculptureComponent.Artist == Sim)
                            {
                                stations.Add(station);
                            }
                        }
                    }
                    else
                    {
                        empties.Add(station);
                    }
                }
            }

            if (stations.Count == 0)
            {
                stations.AddRange(empties);
            }

            if (stations.Count == 0)
            {
                IncStat("No Station");
                return(false);
            }

            SculptingStation choice = RandomUtil.GetRandomObjectFromList(stations);

            if (choice.HasUnfinishedSculpture())
            {
                IncStat("Sculpture Continued");

                return(Situations.PushInteraction(this, Sim, choice, ContinueSculptureEx.Singleton));
            }
            else
            {
                List <SculptureComponent.SculptureMaterial> materials = new List <SculptureComponent.SculptureMaterial>();

                int skillLevel = Sim.SkillManager.GetSkillLevel(SkillNames.Sculpting);

                skillLevel = Math.Max(0, skillLevel);

                foreach (SculptureComponent.SculptureMaterial material in Enum.GetValues(typeof(SculptureComponent.SculptureMaterial)))
                {
                    if (material == SculptureComponent.SculptureMaterial.None)
                    {
                        continue;
                    }

                    if (material == SculptureComponent.SculptureMaterial.Metal)
                    {
                        continue;
                    }

                    if (!SculptingSkill.HasLevelForMaterial(skillLevel, material))
                    {
                        continue;
                    }

                    if (!SculptingSkill.CanAfford(Sim.CreatedSim, material))
                    {
                        continue;
                    }

                    materials.Add(material);
                }

                if (materials.Count == 0)
                {
                    IncStat("No Material");
                    return(false);
                }

                SculptureComponent.SculptureMaterial materialChoice = RandomUtil.GetRandomObjectFromList(materials);

                List <SculptingSkill.SkillSculptureData> sculptures = SculptingSkill.ValidRandomSculpturesForLevelAndMaterial(skillLevel, materialChoice, Sim.CreatedSim);
                if (sculptures.Count == 0)
                {
                    IncStat("No Sculptures");
                    return(false);
                }

                SculptingSkill.SkillSculptureData sculptureChoice = RandomUtil.GetWeightedRandomObjectFromList(sculptures.ToArray()) as SculptingSkill.SkillSculptureData;

                IncStat("Sculpture Started");

                return(Situations.PushInteraction(this, Sim, choice, new CreateSculptureEx.Definition(null, sculptureChoice, materialChoice, new string[0])));
            }
        }
Beispiel #7
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            List <GameObject> burnables = new List <GameObject>();

            foreach (Lot lot in ManagerLot.GetOwnedLots(Target))
            {
                foreach (GameObject obj in lot.GetObjects <GameObject>())
                {
                    if (obj == null)
                    {
                        continue;
                    }

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

                    if (string.IsNullOrEmpty(obj.CatalogName))
                    {
                        continue;
                    }

                    if (obj is Sim)
                    {
                        continue;
                    }

                    if (obj is ICrib)
                    {
                        continue;
                    }

                    if (obj.InUse)
                    {
                        continue;
                    }

                    if (!obj.InWorld)
                    {
                        continue;
                    }

                    if (obj.LotCurrent == null)
                    {
                        continue;
                    }

                    LotLocation loc         = LotLocation.Invalid;
                    ulong       lotLocation = World.GetLotLocation(obj.PositionOnFloor, ref loc);
                    if (!World.HasSolidFloor(obj.LotCurrent.mLotId, loc))
                    {
                        continue;
                    }

                    burnables.Add(obj);
                }
            }

            if (burnables.Count == 0)
            {
                IncStat("No Burnables");
                return(false);
            }

            GameObject victim = RandomUtil.GetRandomObjectFromList(burnables);

            if (!Situations.PushVisit(this, Sim, Target.LotHome))
            {
                IncStat("Push Fail");
                return(false);
            }

            mFail = IsFail(Sim, Target);

            if (mFail)
            {
                int cost = (int)(victim.Value * 1.5);

                Money.AdjustFunds(Sim, "Damages", -cost);

                Money.AdjustFunds(Target, "Insurance", cost);
            }

            Manager.AddAlarm(new BurnScenario(Sim, Target, victim, this, mFail));
            return(true);
        }
Beispiel #8
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            base.PrivateUpdate(frame);

            List <NectarMaker> choices = new List <NectarMaker>();
            NectarMaker        best = null, broken = null;

            foreach (Lot lot in ManagerLot.GetOwnedLots(Sim))
            {
                foreach (NectarMaker maker in lot.GetObjects <NectarMaker>())
                {
                    if (!maker.Repairable.Broken)
                    {
                        choices.Add(maker);
                        if (maker.Inventory.IsFull())
                        {
                            best = maker;
                        }
                    }
                    else
                    {
                        broken = maker;
                    }

                    foreach (NectarBottle bottle in maker.mBottles)
                    {
                        Inventories.TryToMove(bottle, Sim.CreatedSim);
                    }

                    AddStat("Collected Bottles", maker.mBottles.Count);

                    maker.mBottles.Clear();
                }
            }

            List <NectarRack> racks = new List <NectarRack>();

            foreach (Lot lot in ManagerLot.GetOwnedLots(Sim))
            {
                foreach (NectarRack rack in lot.GetObjects <NectarRack>())
                {
                    if (rack.HasTreasure())
                    {
                        continue;
                    }

                    if (rack.Buyable)
                    {
                        continue;
                    }

                    if (rack.Tasteable)
                    {
                        continue;
                    }

                    if (rack.Inventory.IsFull())
                    {
                        continue;
                    }

                    racks.Add(rack);
                }
            }

            if (racks.Count > 0)
            {
                List <NectarBottle> bottles = new List <NectarBottle>(Inventories.InventoryFindAll <NectarBottle>(Sim));
                foreach (NectarBottle bottle in bottles)
                {
                    if (!bottle.CanBeSold())
                    {
                        continue;
                    }

                    NectarRack rack = RandomUtil.GetRandomObjectFromList(racks);

                    IncStat("Rack Stored");
                    rack.Inventory.TryToMove(bottle);

                    if (rack.Inventory.IsFull())
                    {
                        racks.Remove(rack);
                        if (racks.Count == 0)
                        {
                            break;
                        }
                    }
                }
            }

            if (best != null)
            {
                choices.Clear();
                choices.Add(best);
            }

            if (choices.Count == 0)
            {
                if (broken != null)
                {
                    IncStat("Attempt Repair");

                    Add(frame, new ScheduledRepairScenario(Sim, broken), ScenarioResult.Start);
                }
                else
                {
                    IncStat("No Choice");
                }
                return(false);
            }

            NectarMaker choice = RandomUtil.GetRandomObjectFromList(choices);

            if (!choice.Inventory.IsFull())
            {
                List <Ingredient> list = new List <Ingredient>(Inventories.InventoryFindAll <Ingredient>(Sim));

                while (list.Count > 0)
                {
                    Ingredient ingredient = RandomUtil.GetRandomObjectFromList(list);
                    list.Remove(ingredient);

                    if (!choice.CanAddToInventory(ingredient))
                    {
                        continue;
                    }

                    if (choice.Inventory.TryToMove(ingredient))
                    {
                        IncStat("Added: " + ingredient.CatalogName);
                    }

                    if (choice.Inventory.IsFull())
                    {
                        break;
                    }
                }
            }

            if (choice.Inventory.IsFull())
            {
                if ((ManagerCareer.HasSkillCareer(Sim, SkillNames.Nectar)) ||
                    (!ManagerCareer.HasSkillCareer(Sim.Household, SkillNames.Nectar)))
                {
                    int skillLevel = Sim.SkillManager.GetSkillLevel(SkillNames.Nectar);

                    List <NectarMaker.MakeNectarStyle> styles = new List <NectarMaker.MakeNectarStyle>();

                    styles.Add(NectarMaker.MakeNectarStyle.Basic);

                    if (skillLevel >= NectarMaker.kConcentratedUnlockLevel)
                    {
                        styles.Add(NectarMaker.MakeNectarStyle.Concentrated);
                    }
                    if (skillLevel >= NectarMaker.kMassProduceUnlockLevel)
                    {
                        styles.Add(NectarMaker.MakeNectarStyle.MassProduce);
                    }
                    if (skillLevel >= NectarMaker.kExtendedNectarationUnlockLevel)
                    {
                        styles.Add(NectarMaker.MakeNectarStyle.ExtendedNectaration);
                    }

                    return(Situations.PushInteraction(this, Sim, choice, new MakeNectarEx.Definition(RandomUtil.GetRandomObjectFromList(styles))));
                }
                else
                {
                    IncStat("Not Job");
                    return(false);
                }
            }
            else
            {
                IncStat("Not Full");
                return(false);
            }
        }
Beispiel #9
0
        protected override List <GameObject> GetInventory(SimDescription sim)
        {
            List <NectarMaker> makers = new List <NectarMaker>();

            foreach (Lot lot in ManagerLot.GetOwnedLots(Sim))
            {
                makers.AddRange(lot.GetObjects <NectarMaker>());
            }

            List <GameObject> list = new List <GameObject>(), nectarItems = new List <GameObject>();

            foreach (Ingredient ingredient in Inventories.InventoryFindAll <Ingredient>(sim))
            {
                if (sim.IsVampire)
                {
                    if (ingredient is VampireFruit)
                    {
                        continue;
                    }
                }

                if (!ingredient.CanBeSold())
                {
                    continue;
                }

                bool found = false;
                foreach (NectarMaker maker in makers)
                {
                    if (maker.CanAddToInventory(ingredient))
                    {
                        found = true;
                        break;
                    }
                }

                if (found)
                {
                    nectarItems.Add(ingredient);
                }
                else
                {
                    list.Add(ingredient);
                }
            }

            while (nectarItems.Count > 50)
            {
                GameObject choice = RandomUtil.GetRandomObjectFromList(nectarItems);

                nectarItems.Remove(choice);

                list.Add(choice);
            }

            foreach (HarvestMoneyBag bag in Inventories.InventoryFindAll <HarvestMoneyBag>(sim))
            {
                list.Add(bag);
            }

            return(list);
        }
Beispiel #10
0
            protected override bool PrivateUpdate(ScenarioFrame frame)
            {
                if (Sim.CreatedSim == null) return false;

                if (Sim.CreatedSim.Posture == null) return false;

                Sim horseSim = Sim.CreatedSim.Posture.Container as Sim;
                if ((horseSim == null) || (!horseSim.IsHorse))
                {
                    bool horseFound = false;

                    List<SimDescription> lotHorses = new List<SimDescription>();
                    List<SimDescription> horses = new List<SimDescription>();
                    foreach (SimDescription sim in HouseholdsEx.Pets(Sim.Household))
                    {
                        if (!sim.IsHorse) continue;

                        if (sim.SkillManager == null) continue;

                        horseFound = true;

                        if (sim.CreatedSim == null) continue;

                        if (sim.ChildOrBelow) continue;

                        if (sim.IsPregnant) continue;

                        if (ManagerSim.GetLTR(sim, Sim) < 0) continue;

                        if (sim.CreatedSim.LotCurrent == Sim.CreatedSim.LotCurrent)
                        {
                            lotHorses.Add(sim);
                        }

                        horses.Add(sim);
                    }

                    if (horses.Count == 0)
                    {
                        IncStat("No Horse");

                        if (!horseFound)
                        {
                            bool found = false;
                            foreach (Lot lot in ManagerLot.GetOwnedLots(Sim))
                            {
                                if (lot.GetObjects<IBoxStall>().Length > 0)
                                {
                                    found = true;
                                    break;
                                }
                            }

                            if (!found)
                            {
                                IncStat("No Stalls");
                                return false;
                            }

                            Add(frame, new PetAdoptionScenario(CASAgeGenderFlags.Horse, Sim), ScenarioResult.Start);
                        }

                        return false;
                    }

                    if (lotHorses.Count > 0)
                    {
                        horses = lotHorses;
                    }

                    AddStat("Horses", horses.Count);

                    while (horses.Count > 0)
                    {
                        SimDescription horseChoice = RandomUtil.GetRandomObjectFromList(horses);
                        horses.Remove(horseChoice);

                        float num = horseChoice.HasTrait(TraitNames.UntrainedHorse) ? TraitTuning.UntrainedHorseSaddleLtrThreshold : RidingSkill.kMinLtrForMountAccept;

                        if (ManagerSim.GetLTR(horseChoice, Sim) < num)
                        {
                            Add(frame, new ExistingFriendScenario(horseChoice, Sim, false), ScenarioResult.Start);

                            IncStat("Friend Building");
                            return false;
                        }

                        horseSim = horseChoice.CreatedSim;

                        if (RemountScenario.Perform(Manager, this, Sim, horseSim, new RemountScenario(Sim, horseSim)))
                        {
                            break;
                        }

                        horseSim = null;
                    }

                    if (horseSim == null)
                    {
                        IncStat("Mount Fail");
                        return false;
                    }

                    Skills.AddListener(new HorseMountedScenario(Sim, horseSim, mPushes));

                    IncStat("AddListener");
                }
                else
                {
                    Add(frame, new HorseMountedScenario(Sim, horseSim, mPushes), ScenarioResult.Start);
                }

                return true;
            }
Beispiel #11
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            bool success = false;

            List <IFishContainer> bowls = new List <IFishContainer>();

            foreach (Lot lot in ManagerLot.GetOwnedLots(Sim))
            {
                bowls.AddRange(lot.GetObjects <IFishContainer>());
            }

            List <GameObject> inventory = GetInventory(Sim);

            Dictionary <FishType, Fish> perfect = new Dictionary <FishType, Fish>();

            foreach (Fish fish in inventory)
            {
                if (fish == null)
                {
                    continue;
                }

                if (fish.GetQuality() == Sims3.Gameplay.Objects.Quality.Perfect)
                {
                    if (perfect.ContainsKey(fish.Type))
                    {
                        continue;
                    }

                    perfect.Add(fish.Type, fish);
                }
            }

            foreach (Fish fish in inventory)
            {
                if (fish == null)
                {
                    continue;
                }

                if (fish.GetQuality() == Sims3.Gameplay.Objects.Quality.Perfect)
                {
                    bool moved = false;

                    foreach (IFishContainer obj in bowls)
                    {
                        FishBowlBase bowl = obj as FishBowlBase;
                        if (bowl != null)
                        {
                            if (bowl.HasFish())
                            {
                                continue;
                            }

                            Inventories.ParentInventory(fish).TryToRemove(fish);

                            bowl.SetFishInBowl(fish);

                            bowl.StartFishFx();
                            bowl.FishFed();

                            EventTracker.SendEvent(EventTypeId.kPutFishInFishbowl, Sim.CreatedSim, bowl);

                            IncStat("Stored in Bowl");
                            moved = true;
                            break;
                        }
                        else
                        {
                            FishTank tank = obj as FishTank;
                            if (tank != null)
                            {
                                if (tank.Inventory == null)
                                {
                                    continue;
                                }

                                if (tank.Inventory.IsFull())
                                {
                                    continue;
                                }

                                tank.Inventory.TryToMove(fish);

                                IncStat("Stored in Tank");
                                moved = true;
                                break;
                            }
                        }
                    }

                    if (perfect[fish.Type] == fish)
                    {
                        moved = true;

                        IncStat("Perfect Retained");
                    }

                    if (moved)
                    {
                        continue;
                    }
                }

                int value = Money.Sell(Sim, fish);
                mFunds += value;

                AddStat("Sold", value);
                success = true;
            }

            return(success);
        }
Beispiel #12
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            base.PrivateUpdate(frame);

            List <GameObject> easels  = new List <GameObject>();
            List <GameObject> empties = new List <GameObject>();

            /*
             * foreach (Lot lot in ManagerLot.GetOwnedLots(Sim))
             * {
             *  foreach (DraftingTable table in lot.GetObjects<DraftingTable>())
             *  {
             *      if (table.Stool == null) continue;
             *
             *      if (table.InUse) continue;
             *
             *      DraftingTable.Canvas draft = table.Draft;
             *      if (draft != null)
             *      {
             *          if (!table.IsDraftValid(Sim.CreatedSim, SkillNames.Painting, OccupationNames.Undefined))
             *          {
             *              continue;
             *          }
             *
             *          if (draft.IsComplete)
             *          {
             *              if (!Situations.PushInteraction(Sim, table, DraftingTable.TakeDraft.Singleton))
             *              {
             *                  continue;
             *              }
             *          }
             *          else
             *          {
             *              easels.Add(table);
             *          }
             *      }
             *      else
             *      {
             *          empties.Add(table);
             *      }
             *  }
             * }
             * if (easels.Count == 0)
             * {
             *  easels.AddRange(empties);
             * }
             */

            if (easels.Count == 0)
            {
                foreach (Lot lot in ManagerLot.GetOwnedLots(Sim))
                {
                    foreach (Easel easel in lot.GetObjects <Easel>())
                    {
                        if (easel.CanSell(Sim.CreatedSim))
                        {
                            TakePainting(easel, Sim.CreatedSim);
                        }

                        if (!easel.CanPaint(Sim.CreatedSim))
                        {
                            continue;
                        }

                        if (easel.CurrentCanvas != null)
                        {
                            easels.Add(easel);
                        }
                        else
                        {
                            empties.Add(easel);
                        }
                    }
                }

                if (easels.Count == 0)
                {
                    easels.AddRange(empties);
                }
            }

            if (easels.Count == 0)
            {
                IncStat("No Easel");
                return(false);
            }

            GameObject choice = RandomUtil.GetRandomObjectFromList(easels);

            if (choice is Easel)
            {
                return(Situations.PushInteraction(this, Sim, choice, PaintEx.Singleton));
            }
            else
            {
                return(Situations.PushInteraction(this, Sim, choice, DraftingTable.Research.SingletonPainting));
            }
        }
Beispiel #13
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            List <GameObject> breakables = new List <GameObject>();

            foreach (Lot lot in ManagerLot.GetOwnedLots(Target))
            {
                foreach (GameObject obj in lot.GetObjects <GameObject>())
                {
                    if (obj == null)
                    {
                        continue;
                    }

                    if (obj.InUse)
                    {
                        continue;
                    }

                    if (!obj.InWorld)
                    {
                        continue;
                    }

                    if (!obj.IsRepairable)
                    {
                        continue;
                    }

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

                    if (component.Broken)
                    {
                        continue;
                    }

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

                    breakables.Add(obj);
                }
            }

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

            if (!base.PrivateUpdate(frame))
            {
                return(false);
            }

            mVictim = RandomUtil.GetRandomObjectFromList(breakables);

            RepairableComponent repair = mVictim.Repairable;

            repair.BreakObject(Sim.CreatedSim, true);

            mFail = IsFail(Sim, Target);

            if (mFail)
            {
                int cost = (int)(mVictim.Value * 1.5);

                Money.AdjustFunds(Sim, "Damages", -cost);

                Money.AdjustFunds(Target, "Insurance", cost);
            }

            Add(frame, new ExistingEnemyManualScenario(Sim, Target, Delta, 0, GetTitlePrefix(PrefixType.Story)), ScenarioResult.Start);

            if (OnInvestigateScenario != null)
            {
                OnInvestigateScenario(this, frame);
            }

            return(true);
        }
Beispiel #14
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            base.PrivateUpdate(frame);

            ManagedBuyProduct <ComputerLaptop> .Purchase(Sim, 0, this, UnlocalizedName, null, BuildBuyProduct.eBuyCategory.kBuyCategoryElectronics, BuildBuyProduct.eBuySubCategory.kBuySubCategoryComputers);

            List <Computer> computers = new List <Computer>();

            List <Computer> inventory = new List <Computer>();

            foreach (Computer computer in Inventories.InventoryFindAll <Computer>(Sim))
            {
                inventory.Add(computer);

                if (!computer.IsComputerUsable(Sim.CreatedSim, true, false, true))
                {
                    continue;
                }

                computers.Add(computer);
            }

            if (computers.Count == 0)
            {
                Computer broken = null;

                foreach (Lot lot in ManagerLot.GetOwnedLots(Sim))
                {
                    foreach (Computer computer in lot.GetObjects <Computer>())
                    {
                        if (!computer.IsComputerUsable(Sim.CreatedSim, true, false, true))
                        {
                            broken = computer;
                            continue;
                        }

                        computers.Add(computer);
                    }
                }

                if (computers.Count == 0)
                {
                    if (inventory.Count > 0)
                    {
                        foreach (Computer computer in inventory)
                        {
                            Money.Sell(Sim, computer);
                        }

                        IncStat("Sell Broken");
                    }

                    if (broken != null)
                    {
                        IncStat("Push Repair");

                        Add(frame, new ScheduledRepairScenario(Sim, broken), ScenarioResult.Start);
                        return(false);
                    }
                    else
                    {
                        IncStat("No Computer");
                        return(false);
                    }
                }
            }
            else if ((Sim.CreatedSim.LotCurrent == null) || (!Sim.CreatedSim.LotCurrent.CanSimTreatAsHome(Sim.CreatedSim)))
            {
                Situations.PushGoHome(this, Sim);
            }

            if (GetValue <RefineWritingOption, bool>())
            {
                return(Situations.PushInteraction(this, Sim, RandomUtil.GetRandomObjectFromList(computers), Computer.PracticeWriting.Singleton));
            }
            else
            {
                return(Situations.PushInteraction(this, Sim, RandomUtil.GetRandomObjectFromList(computers), NRaas.StoryProgressionSpace.Interactions.WriteNovelEx.Singleton));
            }
        }
Beispiel #15
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            base.PrivateUpdate(frame);

            if (CanCompete(Sim))
            {
                if (!Situations.PushMeetUp(this, Sim, Target, ManagerSituation.MeetUpType.Either, CompeteFirstAction))
                {
                    IncStat("Compete Push Fail");
                }
                else
                {
                    mReport = false;
                    return(true);
                }
            }

            List <TrainingDummy> dummies = new List <TrainingDummy>();

            foreach (Lot lot in ManagerLot.GetOwnedLots(Sim))
            {
                dummies.AddRange(lot.GetObjects <TrainingDummy>(TestDummy));
            }

            if (dummies.Count == 0)
            {
                foreach (Lot lot in ManagerLot.GetOwnedLots(Target))
                {
                    dummies.AddRange(lot.GetObjects <TrainingDummy>(TestDummy));
                }

                if (dummies.Count == 0)
                {
                    foreach (TrainingDummy dummy in Sims3.Gameplay.Queries.GetObjects <TrainingDummy>())
                    {
                        if (!TestDummy(dummy))
                        {
                            continue;
                        }

                        if (dummy.LotCurrent == null)
                        {
                            continue;
                        }

                        if (!dummy.LotCurrent.IsCommunityLot)
                        {
                            continue;
                        }

                        dummies.Add(dummy);
                    }

                    if (dummies.Count == 0)
                    {
                        IncStat("No Dummies");
                        return(false);
                    }
                }
            }

            return(Situations.PushMeetUp(this, Sim, Target, RandomUtil.GetRandomObjectFromList(dummies).LotCurrent, TrainFirstAction));
        }
Beispiel #16
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            List <GameObject> tables  = new List <GameObject>();
            List <GameObject> empties = new List <GameObject>();

            OccupationNames occupation = OccupationNames.Undefined;
            SkillNames      skill      = SkillNames.Painting;

            if (Sim.CreatedSim.Occupation is Stylist)
            {
                skill      = SkillNames.Styling;
                occupation = OccupationNames.Stylist;
            }
            else if (Sim.CreatedSim.Occupation is InteriorDesigner)
            {
                occupation = OccupationNames.InteriorDesigner;
            }

            foreach (Lot lot in ManagerLot.GetOwnedLots(Sim.Household))
            {
                foreach (DraftingTable table in lot.GetObjects <DraftingTable>())
                {
                    if (table.Stool == null)
                    {
                        continue;
                    }

                    if (table.InUse)
                    {
                        continue;
                    }

                    DraftingTable.Canvas draft = table.Draft;
                    if (draft != null)
                    {
                        if (!table.IsDraftValid(Sim.CreatedSim, skill, occupation))
                        {
                            IncStat("Draft Mismatch");
                            continue;
                        }
                        else if ((draft.IsComplete) && (!TakeDraft(table)))
                        {
                            IncStat("Take Fail");
                            continue;
                        }
                        else
                        {
                            tables.Add(table);
                        }
                    }
                    else
                    {
                        empties.Add(table);
                    }
                }
            }

            if (tables.Count == 0)
            {
                tables.AddRange(empties);
            }

            if (tables.Count == 0)
            {
                IncStat("No Tables");
                return(false);
            }

            GameObject choice = RandomUtil.GetRandomObjectFromList(tables);

            if (Sim.CreatedSim.Occupation is Stylist)
            {
                return(Situations.PushInteraction(this, Sim, choice, DraftingTable.Research.SingletonStylist));
            }
            else if (Sim.CreatedSim.Occupation is InteriorDesigner)
            {
                return(Situations.PushInteraction(this, Sim, choice, DraftingTable.Research.SingletonInteriorDesigner));
            }
            else
            {
                return(Situations.PushInteraction(this, Sim, choice, DraftingTable.Research.SingletonPainting));
            }
        }
Beispiel #17
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            List <GameObject> objects = new List <GameObject>();

            int min = Minimum;
            int max = Maximum;

            AddStat("Minimum", min);
            AddStat("Maximum", max);

            foreach (Lot lot in ManagerLot.GetOwnedLots(Target))
            {
                foreach (GameObject obj in lot.GetObjects <GameObject>())
                {
                    if (!obj.IsStealable())
                    {
                        continue;
                    }

                    if (string.IsNullOrEmpty(obj.CatalogName))
                    {
                        continue;
                    }

                    if (obj.Value <= 0)
                    {
                        continue;
                    }

                    if (obj.Value < min)
                    {
                        continue;
                    }

                    if (obj.Value > max)
                    {
                        continue;
                    }

                    objects.Add(obj);
                }
            }

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

            mFail = IsFail(Sim, Target);

            GameObject choice = RandomUtil.GetRandomObjectFromList(objects);

            mObjectName  = choice.CatalogName;
            mObjectValue = choice.Value;

            if (!mFail)
            {
                EventTracker.SendEvent(EventTypeId.kStoleObject, Sim.CreatedSim, choice);

                AddStat("Object Value", mObjectValue);

                if ((KeepObject) && (Sim.CreatedSim != null))
                {
                    if (!Inventories.TryToMove(choice, Sim.CreatedSim))
                    {
                        return(false);
                    }

                    choice.SetStealActors(Sim.CreatedSim, Target.CreatedSim);
                }
                else
                {
                    Money.AdjustFunds(Target, "Burgled", -mObjectValue);

                    Money.AdjustFunds(Sim, "Burgled", mObjectValue);
                }

                TraitFunctions.ItemStolenCallback(Target.Household, Origin.FromBurglar);

                foreach (Sim sim in HouseholdsEx.AllSims(Target.Household))
                {
                    EventTracker.SendEvent(EventTypeId.kWasRobbed, sim);
                }
            }

            if (OnInvestigateScenario != null)
            {
                OnInvestigateScenario(this, frame);
            }

            return(true);
        }
Beispiel #18
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            List <Book> choices = new List <Book>();

            if ((choices.Count == 0) && (AllowSkill))
            {
                mBooks.Clear();

                foreach (BookSkill book in Inventories.InventoryDuoFindAll <BookSkill, Book>(Sim))
                {
                    GreyedOutTooltipCallback greyedOutTooltipCallback = null;
                    if (!book.TestReadBook(Sim.CreatedSim, false, ref greyedOutTooltipCallback))
                    {
                        continue;
                    }

                    BookSkillData data = book.Data as BookSkillData;
                    if (data == null)
                    {
                        continue;
                    }

                    if (mBooks.ContainsKey(data.SkillGuid))
                    {
                        continue;
                    }

                    mBooks.Add(data.SkillGuid, book);
                }

                foreach (Lot lot in ManagerLot.GetOwnedLots(Sim))
                {
                    foreach (BookSkill book in lot.GetObjects <BookSkill>())
                    {
                        GreyedOutTooltipCallback greyedOutTooltipCallback = null;
                        if (!book.TestReadBook(Sim.CreatedSim, false, ref greyedOutTooltipCallback))
                        {
                            continue;
                        }

                        BookSkillData data = book.Data as BookSkillData;
                        if (data == null)
                        {
                            continue;
                        }

                        if (mBooks.ContainsKey(data.SkillGuid))
                        {
                            continue;
                        }

                        mBooks.Add(data.SkillGuid, book);
                    }
                }

                if ((!Sim.CreatedSim.LotCurrent.IsResidentialLot) && (!Sim.CreatedSim.LotCurrent.IsWorldLot))
                {
                    foreach (BookSkill book in Sim.CreatedSim.LotCurrent.GetObjects <BookSkill>())
                    {
                        GreyedOutTooltipCallback greyedOutTooltipCallback = null;
                        if (!book.TestReadBook(Sim.CreatedSim, false, ref greyedOutTooltipCallback))
                        {
                            continue;
                        }

                        BookSkillData data = book.Data as BookSkillData;
                        if (data == null)
                        {
                            continue;
                        }

                        if (mBooks.ContainsKey(data.SkillGuid))
                        {
                            continue;
                        }

                        mBooks.Add(data.SkillGuid, book);
                    }
                }

                if (mBooks.Count > 0)
                {
                    if (base.PrivateUpdate(frame))
                    {
                        return(true);
                    }
                    else
                    {
                        if (choices.Count == 0)
                        {
                            choices.AddRange(mBooks.Values);
                        }
                    }
                }
            }

            if ((choices.Count == 0) && (AllowNormal))
            {
                Dictionary <BookData, Book> books = new Dictionary <BookData, Book>();

                foreach (BookGeneral book in Inventories.InventoryDuoFindAll <BookGeneral, Book>(Sim))
                {
                    GreyedOutTooltipCallback greyedOutTooltipCallback = null;
                    if (!book.TestReadBook(Sim.CreatedSim, false, ref greyedOutTooltipCallback))
                    {
                        continue;
                    }

                    if (Sim.ReadBookDataList.ContainsKey(book.Data.ID))
                    {
                        continue;
                    }

                    if (books.ContainsKey(book.Data))
                    {
                        continue;
                    }

                    books.Add(book.Data, book);
                }

                foreach (Lot lot in ManagerLot.GetOwnedLots(Sim))
                {
                    foreach (BookGeneral book in lot.GetObjects <BookGeneral>())
                    {
                        GreyedOutTooltipCallback greyedOutTooltipCallback = null;
                        if (!book.TestReadBook(Sim.CreatedSim, false, ref greyedOutTooltipCallback))
                        {
                            continue;
                        }

                        if (Sim.ReadBookDataList.ContainsKey(book.Data.ID))
                        {
                            continue;
                        }

                        if (books.ContainsKey(book.Data))
                        {
                            continue;
                        }

                        books.Add(book.Data, book);
                    }
                }

                if ((!Sim.CreatedSim.LotCurrent.IsResidentialLot) && (!Sim.CreatedSim.LotCurrent.IsWorldLot))
                {
                    foreach (BookGeneral book in Sim.CreatedSim.LotCurrent.GetObjects <BookGeneral>())
                    {
                        GreyedOutTooltipCallback greyedOutTooltipCallback = null;
                        if (!book.TestReadBook(Sim.CreatedSim, false, ref greyedOutTooltipCallback))
                        {
                            continue;
                        }

                        if (Sim.ReadBookDataList.ContainsKey(book.Data.ID))
                        {
                            continue;
                        }

                        if (books.ContainsKey(book.Data))
                        {
                            continue;
                        }

                        books.Add(book.Data, book);
                    }
                }

                if (books.Count > 0)
                {
                    choices.AddRange(books.Values);
                }
            }

            if (choices.Count > 0)
            {
                return(Perform(RandomUtil.GetRandomObjectFromList(choices)));
            }

            return(false);
        }