protected override bool PrivateUpdate(ScenarioFrame frame) { Money.AdjustFunds(House, "PayDebt", -House.FamilyFunds); SetValue <DebtOption, int>(House, 0); return(true); }
protected void HandleDowry(SimDescription a, SimDescription b) { int min = GetValue <ArrangedMarriageDowryMinOption, int>(a); int max = GetValue <ArrangedMarriageDowryMaxOption, int>(a); if (max < min) { max = min; } int dowry = RandomUtil.GetInt(min, max); if (GetValue <DowryOnlyToPoorerOption, bool>()) { if (dowry > 0) { if (GetValue <NetWorthOption, int>(a.Household) < GetValue <NetWorthOption, int>(b.Household)) { IncStat("Dowry Poorer"); return; } } else { if (GetValue <NetWorthOption, int>(a.Household) > GetValue <NetWorthOption, int>(b.Household)) { IncStat("Dowry Poorer"); return; } } } Money.AdjustFunds(a, "ArrangedDowry", -dowry); Money.AdjustFunds(b, "ArrangedDowry", dowry); }
protected override bool PrivateUpdate(ScenarioFrame frame) { int bail = 0; ManagerSim.AddBuff(this, Sim, BuffNames.Nauseous, Origin.FromJailFood); Pair <string, int> value; if (sRepository.TryGetValue(Sim.SimDescriptionId, out value)) { mStoryName = value.First; bail = value.Second; sRepository.Remove(Sim.SimDescriptionId); } if (Sim.Occupation != null) { if (AddScoring("JailDemotion", GetValue <DemoteChanceOption, int>(), ScoringLookup.OptionType.Chance, Sim) > 0) { Sim.Occupation.DemoteSim(); } } bail += GetValue <BailOption, int>(); if (bail > 0) { Money.AdjustFunds(Sim, "CourtFees", -bail); } return(true); }
protected virtual bool AdjustFunds() { Money.AdjustFunds(Target, AccountingKey, -mFunds); Money.AdjustFunds(Sim, AccountingKey, mFunds); return(true); }
protected override bool PrivateUpdate(ScenarioFrame frame) { Household house = Lot.Household; foreach (GameObject obj in Lot.GetObjects <GameObject>()) { if (!obj.Charred) { RepairableComponent repair = obj.Repairable; if (repair == null) { continue; } if (!repair.TestReplace()) { continue; } } else { if (obj is PlumbBob) { obj.Charred = false; continue; } } try { IncStat("Found: " + obj.CatalogName); } catch { } GameObject go = null; try { go = RepairableComponent.CreateReplaceObject(obj); } catch (Exception e) { Common.DebugException(obj.CatalogName, e); } if (go == null) { continue; } IncStat("Replaced"); if (house != null) { Money.AdjustFunds(house, "Replacement", -obj.Cost); } } return(true); }
protected override bool PrivateUpdate(ScenarioFrame frame) { Household house = GetData <StoredNetWorthSimData>(Sim).Household; int iTotalWorth = GetData <StoredNetWorthSimData>(Sim).NetWorth; iTotalWorth -= GetValue <DebtOption, int>(house); SetValue <DebtOption, int>(house, 0); if (iTotalWorth <= 0) { IncStat("Inherit Cash: Poor"); return(false); } Dictionary <SimDescription, float> inheritors = Deaths.GetInheritors(Sim, GetValue <InheritorsOption, ManagerDeath.Inheritors>(), true); float fTotal = 0f; foreach (KeyValuePair <SimDescription, float> fraction in inheritors) { fTotal += fraction.Value; } AddStat("Worth", iTotalWorth); AddStat("Inheritors", inheritors.Count); AddStat("Split", fTotal); bool simMatches = (Deaths.MatchesAlertLevel(Sim)) || (Money.MatchesAlertLevel(Sim)); foreach (KeyValuePair <SimDescription, float> inheritor in inheritors) { int iInheritance = (int)(iTotalWorth * (inheritor.Value / fTotal)); if (iInheritance <= 0) { continue; } SimDescription child = inheritor.Key; if (child.Household == null) { continue; } Money.AdjustFunds(child, "Inheritance", iInheritance); if ((simMatches) || (Deaths.MatchesAlertLevel(child)) || (Money.MatchesAlertLevel(child))) { mInheritance.Add(child, iInheritance); } } return(mInheritance.Count > 0); }
protected override bool PrivateUpdate(ScenarioFrame frame) { Money.AdjustFunds(House, "PayDebt", -House.FamilyFunds); mHead = SimTypes.HeadOfFamily(House); mMovers = new List <SimDescription>(HouseholdsEx.All(House)); Add(frame, new DebtSplitFamilyScenario(House), ScenarioResult.Start); Add(frame, new DebtForgivenScenario(House), ScenarioResult.Failure); return(false); }
protected override bool PrivateUpdate(ScenarioFrame frame) { if (!base.PrivateUpdate(frame)) { return(false); } Political job = Sim.Occupation as Political; if (job == null) { IncStat("No Job"); return(false); } if ((job.ChanceCaught > 0) && (AddScoring("Embezzlement", Sim) > 0)) { if (AddScoring("CaughtEmbezzling", job.ChanceCaught, ScoringLookup.OptionType.Chance, Sim) > 0) { Add(frame, new CaughtEmbezzlingScenario(Sim), ScenarioResult.Start); } else { mSteal = (int)(Funds * job.PercentCampaignFundsToSteal); if (mSteal > Political.kEmbezzleMax) { mSteal = Political.kEmbezzleMax; } else if (mSteal < Political.kEmbezzleMin) { mSteal = Political.kEmbezzleMin; } } } Money.AdjustFunds(Sim, AccountingKey, mSteal); job.CampaignMoneyRaised += (Funds - mSteal); if ((Sim.CreatedSim != null) && (Target.CreatedSim != null)) { // CampaignDonationScenario will handle the adjust funds for the Target EventTracker.SendEvent(new IncrementalEvent(EventTypeId.kRaisedTonsOfMoney, Sim.CreatedSim, Target.CreatedSim, (float)Funds)); EventTracker.SendEvent(EventTypeId.kAskedForDonation, Sim.CreatedSim, Target.CreatedSim); } else { Money.AdjustFunds(Target, AccountingKey, -Funds); } return(true); }
protected override bool PrivateUpdate(ScenarioFrame frame) { Sim target = Event.TargetObject as Sim; if (target == null) { return(false); } Money.AdjustFunds(target.SimDescription, "CampaignDonation", -(int)Event.mIncrement); return(true); }
protected override bool PrivateUpdate(ScenarioFrame frame) { mSchoolFee = GetValue <Option, int>() + GetOption <FeeBySchoolOption>().GetFee(Sim.CareerManager.School.Guid); if (GetValue <IsRichOption, bool>(Sim.Household)) { mSchoolFee *= 2; } Money.AdjustFunds(Sim, "SchoolFee", -mSchoolFee); AddStat("Paid", mSchoolFee); return(true); }
protected override bool PrivateUpdate(ScenarioFrame frame) { if ((mMoveInWith == null) || (!House.Contains(mMoveInWith))) { mMoveInWith = SimTypes.HeadOfFamily(House); } List <SimDescription> movers = GetMovers(House, true); AddStat("Movers", movers.Count); foreach (SimDescription sim in movers) { int funds = 0, debt = 0; if ((!SimTypes.IsSpecial(sim)) && (!Household.RoommateManager.IsNPCRoommate(sim))) { int count = HouseholdsEx.NumHumans(sim.Household); if (count > 0) { funds = sim.FamilyFunds / count; Money.AdjustFunds(sim, "MoveOut", -funds); } if (count == 1) { debt += GetValue <DebtOption, int>(sim.Household); SetValue <DebtOption, int>(sim.Household, 0); funds += Households.Assets(sim); } } AddStat("New Funds", funds); Money.AdjustFunds(House, "MoveIn", funds); AddValue <DebtOption, int>(House, debt); Households.MoveSim(sim, House); } mMovers = movers; return(true); }
protected bool SmeltMetal(Metal metal) { if (!metal.mCollected) { return(false); } if (Sim.FamilyFunds < Metal.GetSmelt.kCostToSmelt) { IncStat("Smelt Cost"); return(false); } Money.AdjustFunds(Sim, "Smelting", -Metal.GetSmelt.kCostToSmelt); float chanceOfExtraIngot = Metal.GetSmelt.kChanceOfExtraIngot; Collecting skill = Sim.SkillManager.AddElement(SkillNames.Collecting) as Collecting; if (skill.IsMetalCollector()) { chanceOfExtraIngot = Metal.GetSmelt.kMetalCollectorExtraIngotChance; } int num2 = 0x1; while ((num2 < Metal.GetSmelt.kMaxNumberOfIngots) && RandomUtil.RandomChance01(chanceOfExtraIngot)) { num2++; Metal metal2 = RockGemMetalBase.Make(metal.Guid, true) as Metal; MetalEx.SmeltMetal(metal2, Sim); IncreaseIngotsCreatedForMetal(skill, metal2.Guid); Inventories.TryToMove(metal2, Sim.CreatedSim); } MetalEx.SmeltMetal(metal, Sim); IncreaseIngotsCreatedForMetal(skill, metal.Guid); skill.MetalSmelt(); IncStat("Metal Smelt"); return(true); }
protected void AdjustFundsMoveInLot(SimDescription sim, Dictionary <Household, bool> oldHouses) { if (!SimTypes.IsSpecial(sim)) { if (!oldHouses.ContainsKey(sim.Household)) { oldHouses.Add(sim.Household, true); AddStat("Old Home Funds", sim.FamilyFunds); } if (HouseholdsEx.NumHumans(sim.Household) > 0) { int funds = sim.Household.FamilyFunds / HouseholdsEx.NumHumans(sim.Household); AddStat("Transfer", funds); Money.AdjustFunds(House, "MoveIn", funds); Money.AdjustFunds(sim, "MoveOut", -funds); AddStat("Transfer Remainder", sim.FamilyFunds); if (HouseholdsEx.NumHumans(sim.Household) == 1) { Lots.PackupVehicles(sim.CreatedSim, false); int debt = GetValue <DebtOption, int>(sim.Household); AddValue <DebtOption, int>(House, debt); SetValue <DebtOption, int>(sim.Household, 0); AddStat("Debt Conversion", debt); funds = Households.Assets(sim); Money.AdjustFunds(House, "SellLot", funds); AddStat("Total Conversion", funds); } } } }
protected override bool PrivateUpdate(ScenarioFrame frame) { if (SimTypes.IsSpecial(House)) { SetValue <DebtOption, int>(House, 0); return(false); } else if (House.LotHome == null) { SetValue <DebtOption, int>(House, 0); return(true); } int debt = GetValue <DebtOption, int>(House); if (debt > 0) { if (House.FamilyFunds < debt) { AddStat("Paid off", House.FamilyFunds); SetValue <DebtOption, int>(House, debt - House.FamilyFunds); Money.AdjustFunds(House, "PayDebt", -House.FamilyFunds); } else { AddStat("Paid off", debt); Money.AdjustFunds(House, "PayDebt", -debt); SetValue <DebtOption, int>(House, 0); return(true); } } else if (debt < 0) { SetValue <DebtOption, int>(House, 0); } return(false); }
protected override bool PrivateUpdate(ScenarioFrame frame) { Household transfer = Household.Find(GetValue <TransferHouseholdOption, ulong>(House)); if (transfer == null) { return(false); } int percent = GetValue <TransferPercentOption, int>(House); int amount = 0; if (percent > 0) { int worth = GetValue <NetWorthOption, int>(House); if (worth > 0) { amount = (int)(worth * (percent / 100f)); } } else { int worth = GetValue <NetWorthOption, int>(transfer); if (worth > 0) { amount = -(int)(worth * (percent / 100f)); } } amount += GetValue <TransferAmountOption, int>(House); if (amount != 0) { Money.AdjustFunds(House, "HouseTransfer", -amount); Money.AdjustFunds(transfer, "HouseTransfer", amount); } return(true); }
protected override bool PrivateUpdate(ScenarioFrame frame) { if (mHousehold != null) { SimDescription head = SimTypes.HeadOfFamily(mHousehold); if (head != null) { Add(frame, new GotPaidScenario(Sim, head, mRepaired), ScenarioResult.Start); return(false); } } int basePay = GotPaidScenario.GetBasePay(Sim.OccupationAsSkillBasedCareer); int funds = RandomUtil.GetInt(basePay / 2, basePay); Money.AdjustFunds(Sim, "Repaired", funds); GotPaidScenario.UpdateExperience(Sim, funds); return(true); }
protected override bool PrivateUpdate(ScenarioFrame frame) { int fees = 0; if ((House != Household.ActiveHousehold) || (GetValue <ActiveFeeOption, bool>())) { fees = HouseholdsEx.NumSims(House) * GetValue <DailyInactivePerSimFeeOption, int>(); } if (Common.IsOnTrueVacation()) { fees += GetValue <VacationFeeOption, int>(); } Money.AdjustFunds(House, "DailyExpenses", -fees); if ((GetValue <DebtOption, int>(House) - House.FamilyFunds) > GetValue <MinimumDebtOption, int>()) { int elders = 0, children = 0; foreach (SimDescription sim in HouseholdsEx.Humans(House)) { if (sim.Elder) { elders++; } else if (sim.ChildOrBelow) { children++; } } Money.AdjustFunds(House, "SocialSecurity", elders * GetValue <SocialSecurityOption, int>()); Money.AdjustFunds(House, "Welfare", children * GetValue <WelfareOption, int>()); } return(true); }
protected override bool PrivateUpdate(ScenarioFrame frame) { ManagerLot.FindLotFlags flags = Inspect; if (CheapestHome) { flags |= ManagerLot.FindLotFlags.CheapestHome; } Lot lot = Lots.FindLot(this, mMovers, MaximumLoan, flags, OnLotPriceCheck); if (lot == null) { IncStat("No Lot"); return(false); } else if (lot.Household != null) { IncStat("Occupied"); return(false); } int lotCost = Lots.GetLotCost(lot); AddStat("Lot Cost", lotCost); List <SimDescription> sims = new List <SimDescription>(mMovers); Dictionary <Household, bool> oldHouses = new Dictionary <Household, bool>(); House = null; foreach (SimDescription sim in sims) { if (House == null) { if (SimTypes.IsSpecial(sim)) { break; } else if (HouseholdsEx.NumSims(sim.Household) == sims.Count) { House = sim.Household; } } else if (House != sim.Household) { House = null; break; } } int newFunds = 0; Lot oldLot = null; mNewHouse = false; if (House == null) { House = Household.Create(); House.ModifyFamilyFunds(-House.FamilyFunds); House.SetName(sims[0].LastName); SetValue <AcountingOption, AccountingData>(House, new AccountingData()); mNewHouse = true; } else if (House.LotHome != null) { oldLot = House.LotHome; newFunds = Lots.GetLotCost(House.LotHome); Lots.ProcessAbandonLot(oldLot); House.MoveOut(); } if (OnPresetLotHome != null) { OnPresetLotHome(lot, House); } lot.MoveIn(House); ManagerSim.ForceRecount(); Money.AdjustFunds(House, "SellLot", newFunds); AddStat("New Home Funds", House.FamilyFunds); SetValue <InspectedOption, bool>(House, false); if (mNewHouse) { foreach (SimDescription sim in sims) { if (sim.Household != null) { AdjustFundsMoveInLot(sim, oldHouses); } Households.MoveSim(sim, House); if (sim.IsMale) { House.Name = sim.LastName; } } } if (OnLotPriceCheck(this, lot, newFunds, newFunds) != ManagerLot.CheckResult.IgnoreCost) { PayForMoveInLot(oldHouses, lotCost); } AddStat("Remaining Funds", House.FamilyFunds); foreach (SimDescription sim in sims) { Sims.Instantiate(sim, lot, true); } EventTracker.SendEvent(new HouseholdUpdateEvent(EventTypeId.kFamilyMovedInToNewHouse, House)); if ((oldLot != null) && (GetValue <NotifyOnMoveOption, bool>(House))) { if (AcceptCancelDialog.Show(Common.Localize("NotifyOnMove:Prompt", false, new object[] { oldLot.Name, oldLot.Address }))) { if (CameraController.IsMapViewModeEnabled()) { Sims3.Gameplay.Core.Camera.ToggleMapView(); } Camera.FocusOnLot(oldLot.LotId, 0f); } } SetValue <NotifyOnMoveOption, bool>(House, false); return(true); }
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); }
protected bool CutGem(Gem gem) { if (!gem.mCollected) { return(false); } Collecting skill = Sim.SkillManager.AddElement(SkillNames.Collecting) as Collecting; List <Gem.CutData> choices = new List <Gem.CutData>(); int num = 0x0; if (skill != null) { num = skill.GemsCut(); if (skill.IsGemCollector()) { choices.Add(Gem.sToughestCut); } } foreach (Gem.CutData data in Gem.sCutData) { if ((data.NumberOfCuts <= num) && gem.ValidCut(data, Sim.CreatedSim)) { choices.Add(data); } } List <Gem.CutData> valid = new List <Gem.CutData>(); foreach (Gem.CutData data in choices) { if (Sim.FamilyFunds >= data.CostToCut) { valid.Add(data); } } if (valid.Count == 0) { IncStat("No Gem Cut Choices"); return(false); } Gem.CutData choice = RandomUtil.GetRandomObjectFromList(valid); Money.AdjustFunds(Sim, "GemCut", -choice.CostToCut); GemEx.CutGem(gem, choice, Sim); IncStat("Gem Cut"); if (skill != null) { skill.GemCut(); } ; return(true); }
protected override bool PrivateUpdate(ScenarioFrame frame) { int minimum = Minimum; int maximum = Maximum; AddStat("Minimum", minimum); AddStat("Maximum", maximum); if (Subtraction) { if (!AllowDebt) { int availableFunds = Funds; if (minimum > availableFunds) { AddStat("High Min", availableFunds); return(false); } if (maximum > availableFunds) { maximum = availableFunds; } AddStat("Maximum Modified", maximum); } } if (maximum <= 0) { IncStat("No Max"); return(false); } else if (minimum > maximum) { IncStat("Min Bigger"); return(false); } mFunds = RandomUtil.GetInt(minimum, maximum); if (mFunds == 0) { IncStat("No Change"); return(false); } int funds = mFunds; if (Subtraction) { funds = -funds; IncStat("Subtraction"); } AddStat("Funds", funds); Money.AdjustFunds(Sim, AccountingKey, funds); return(true); }
protected override bool PrivateUpdate(ScenarioFrame frame) { List <SimDescription> parents = new List <SimDescription>(); foreach (SimDescription parent in Relationships.GetParents(Sim)) { if (SimTypes.IsDead(parent)) { continue; } if (!parent.Elder) { continue; } if (parent.Household == Sim.Household) { continue; } if (!ManagerFriendship.AreFriends(Sim, parent)) { continue; } if (GetValue <NetWorthOption, int>(parent.Household) >= GetValue <NetWorthOption, int>(Sim.Household)) { IncStat("Unnecessary"); continue; } parents.Add(parent); } if (parents.Count == 0) { return(false); } if (AddScoring("CaresAboutChildren", GetValue <AlimonyChanceOption, int>(Sim), ScoringLookup.OptionType.Chance, Sim) <= 0) { return(false); } int perParentPayment = GetValue <PaymentOption, int>(); if (GetValue <IsRichOption, bool>(Sim.Household)) { perParentPayment *= GetValue <AlimonyScenario.RichMultipleOption, int>(); } foreach (SimDescription parent in parents) { if (!Money.Allow(this, parent, Managers.Manager.AllowCheck.None)) { IncStat("Money Denied Parent"); continue; } int payment = perParentPayment; if (Sim.FamilyFunds < payment) { payment = Sim.FamilyFunds; } mTotalPayments += payment; if (payment == 0) { IncStat("Insufficient"); } else { Money.AdjustFunds(Sim, "ElderSupport", -payment); Money.AdjustFunds(parent, "ElderSupport", payment); AddStat("Paid", payment); } } return(mTotalPayments > 0); }
protected override bool PrivateUpdate(ScenarioFrame frame) { foreach (MinorPetTerrarium terrarium in Lot.GetObjects <MinorPetTerrarium>()) { if (terrarium.HasLivingPet) { continue; } if (terrarium.Pet != null) { terrarium.Pet.FadeOut(false, true); IncStat("Dead Pet Removed"); } if (terrarium.Cleanable != null) { terrarium.Cleanable.ForceClean(); IncStat("Cleaned"); } List <MinorPetSpecies> choices = new List <MinorPetSpecies>(); foreach (KeyValuePair <MinorPetSpecies, MinorPetData> pair in MinorPet.sData) { if (!pair.Value.Stockable) { continue; } if (Lot.Household.FamilyFunds < pair.Value.StockCost) { continue; } if (!terrarium.AllowsPetType(pair.Value.MinorPetType)) { continue; } choices.Add(pair.Key); } AddStat("Choice", choices.Count); if (choices.Count > 0) { MinorPet pet = MinorPet.Make(RandomUtil.GetRandomObjectFromList(choices), true, false) as MinorPet; if (pet == null) { IncStat("Creation Fail"); } else { pet.SetBehaviorSMCStateStopped(); if (pet.ParentToSlot(terrarium, terrarium.PetContainmentSlot)) { pet.SetOpacity(0f, 0f); pet.FadeIn(); pet.SetBehaviorSMCStateActive(); pet.StartBehaviorSMC(false); Money.AdjustFunds(Lot.Household, "MinorPets", -pet.Data.StockCost); IncStat("Pet Placed"); } else { pet.FadeOut(); IncStat("Placement Fail"); } } } } return(true); }
protected override bool PrivateUpdate(ScenarioFrame frame) { List <SimDescription> children = new List <SimDescription>(); int chance = GetValue <AlimonyChanceOption, int>(Sim); foreach (SimDescription child in Relationships.GetChildren(Sim)) { if (GetValue <ForTeensOption, bool>()) { if (child.YoungAdultOrAbove) { continue; } } else { if (child.TeenOrAbove) { continue; } } if (SimTypes.IsDead(child)) { continue; } if (child.IsMarried) { continue; } if (child.Household == Sim.Household) { continue; } if (GetValue <NetWorthOption, int>(child.Household) >= GetValue <NetWorthOption, int>(Sim.Household)) { IncStat("Unnecessary"); continue; } if (!GetValue <ForAdoptedOption, bool>()) { List <SimDescription> parents = Relationships.GetParents(child); bool found = false; foreach (SimDescription member in CommonSpace.Helpers.Households.All(child.Household)) { if (parents.Contains(member)) { found = true; } } if (!found) { IncStat("Child Adopted"); continue; } } children.Add(child); } if (children.Count == 0) { return(false); } int perChildPayment = GetValue <PaymentOption, int>(); if (GetValue <IsRichOption, bool>(Sim.Household)) { perChildPayment *= GetValue <RichMultipleOption, int>(); } if (AddScoring("CaresAboutChildren", chance, ScoringLookup.OptionType.Chance, Sim) <= 0) { foreach (SimDescription child in children) { if (RandomUtil.RandomChance(GetValue <PropagationChanceOption, int>())) { Add(frame, new PropagateAlimonyFailScenario(child, Sim), ScenarioResult.Start); } } AddValue <AlimonyLapsesOption, int>(Sim, 1); if ((GetValue <AlimonyJailOption, bool>()) && (RandomUtil.RandomChance(GetValue <AlimonyLapsesOption, int>(Sim) * 10))) { Add(frame, new GoToJailScenario(Sim, "AlimonyJail", perChildPayment), ScenarioResult.Start); SetValue <AlimonyLapsesOption, int>(Sim, 0); } Add(frame, new SuccessScenario(), ScenarioResult.Start); return(true); } else { SetValue <AlimonyLapsesOption, int>(Sim, 0); } foreach (SimDescription child in children) { if (!Money.Allow(this, child, Managers.Manager.AllowCheck.None)) { IncStat("Money Denied Child"); continue; } int payment = perChildPayment; if (Sim.FamilyFunds < payment) { payment = Sim.FamilyFunds; } mTotalPayments += payment; if (payment == 0) { IncStat("Insufficient"); } else { Money.AdjustFunds(Sim, "ChildSupport", -payment); Money.AdjustFunds(child, "ChildSupport", payment); AddStat("Paid", payment); } } return(mTotalPayments > 0); }
protected override bool PrivateUpdate(ScenarioFrame frame) { Household house = Household.ActiveHousehold; Lot lot = house.LotHome; foreach (IThrowAwayable awayable in Sims3.Gameplay.Queries.GetObjects <IThrowAwayable>(lot)) { if (awayable == null) { continue; } if (awayable.InUse) { continue; } if (!awayable.HandToolAllowUserPickupBase()) { continue; } if (!awayable.ShouldBeThrownAway()) { continue; } if ((awayable.Parent != null) && (awayable.Parent.InUse)) { continue; } if (awayable is Bar.Glass) { continue; } if (awayable is Bill) { continue; } bool flag = false; if (awayable is BarTray) { foreach (Slot slot in awayable.GetContainmentSlots()) { if (awayable.GetContainedObject(slot) is Bar.Glass) { flag = true; break; } } } if (!flag) { awayable.ThrowAwayImmediately(); } } foreach (IDestroyOnMagicalCleanup destroyable in Sims3.Gameplay.Queries.GetObjects <IDestroyOnMagicalCleanup>(lot)) { GameObject obj = destroyable as GameObject; if (obj == null) { continue; } obj.FadeOut(false, true); } List <Fridge> fridges = new List <Fridge>(lot.GetObjects <Fridge>()); if (fridges.Count > 0) { Fridge fridge = fridges[0]; if ((fridge != null) && (house.SharedFridgeInventory != null) && (house.SharedFamilyInventory.Inventory != null)) { foreach (ServingContainer container in Sims3.Gameplay.Queries.GetObjects <ServingContainer>(lot)) { if ((!container.InUse) && (fridge.HandToolAllowDragDrop(container)) && (container.HasFood && container.HasFoodLeft()) && (!container.IsSpoiled && (container.GetQuality() >= Quality.Neutral))) { house.SharedFridgeInventory.Inventory.TryToAdd(container, false); } } } } foreach (Sim sim in HouseholdsEx.AllSims(house)) { if (!Inventories.VerifyInventory(sim.SimDescription)) { continue; } foreach (IThrowAwayable awayable2 in Inventories.QuickDuoFind <IThrowAwayable, GameObject>(sim.Inventory)) { if (awayable2 == null) { continue; } if (awayable2.InUse) { continue; } if (!awayable2.HandToolAllowUserPickupBase()) { continue; } if (!awayable2.ShouldBeThrownAway()) { continue; } if (awayable2.InUse) { continue; } if ((awayable2 is Newspaper) && !(awayable2 as Newspaper).IsOld) { continue; } if (awayable2 is TrashPileOpportunity) { continue; } if ((awayable2 is PreparedFood) && !(awayable2 as PreparedFood).IsSpoiled) { continue; } awayable2.ThrowAwayImmediately(); } } LotLocation[] puddles = World.GetPuddles(lot.LotId, LotLocation.Invalid); if (puddles.Length > 0x0) { foreach (LotLocation location in puddles) { if ((lot.TombRoomManager == null) || !lot.TombRoomManager.IsObjectInATombRoom(location)) { PuddleManager.RemovePuddle(lot.LotId, location); } } } try { List <Bill> allBills = new List <Bill>(); List <Bill> allBillsInMailboxes = new List <Bill>(); uint num = Bill.GetTotalAmountForAllBillsInHousehold(HouseholdsEx.AllSims(lot.Household)[0], allBills, allBillsInMailboxes); if (house.FamilyFunds >= num) { foreach (Bill bill in allBills) { if (!bill.InUse) { Money.AdjustFunds(house, "Bills", -(int)bill.Amount); bill.DestroyBill(true); } } } } catch (Exception e) { Common.DebugException(lot, e); } return(false); }
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); }
protected override bool PrivateUpdate(ScenarioFrame frame) { base.PrivateUpdate(frame); mNet = 0; Camera camera = ManagedBuyProduct <Camera> .Purchase(Sim, 0, this, UnlocalizedName, null, BuildBuyProduct.eBuyCategory.kBuyCategoryElectronics, BuildBuyProduct.eBuySubCategory.kBuySubCategoryHobbiesAndSkills); if (camera == null) { return(false); } Photography skill = Sim.SkillManager.GetSkill <Photography>(SkillNames.Photography); if (skill == null) { skill = Sim.SkillManager.AddElement(SkillNames.Photography) as Photography; } List <PhotographSize> sizes = new List <PhotographSize>(); foreach (PhotographSize size in sSizes) { if (Photography.SizeUnlocked(skill, size)) { sizes.Add(size); } } if (sizes.Count == 0) { IncStat("No Sizes"); return(false); } List <PaintingStyle> styles = new List <PaintingStyle>(); foreach (PaintingStyle style in sStyles) { if (Photography.StyleUnlocked(skill, style)) { styles.Add(style); } } if (styles.Count == 0) { IncStat("No Styles"); return(false); } List <SubjectDefinition> subjects = new List <SubjectDefinition>(); foreach (CollectionDefinition collection in PhotographySubjects.sCollectionDefinitions.Values) { if (!collection.AvailableForSkill(skill)) { continue; } if (collection.Location != WorldName.UserCreated) { continue; } foreach (SubjectDefinition definition in collection.Subjects) { try { if (!definition.AvailableForSkill(skill)) { continue; } } catch { continue; } subjects.Add(definition); } } if (subjects.Count == 0) { IncStat("No Subjects"); return(false); } int additional = AddScoring("AdditionalPhoto", Sim); int total = Sims3.Gameplay.Core.RandomUtil.GetInt(GetValue <Option, int>() + additional); if (total <= 0) { total = 1; } int totalFunds = 0; for (int i = 0; i < total; i++) { PhotographSize size = Sims3.Gameplay.Core.RandomUtil.GetRandomObjectFromList(sizes); PaintingStyle style = Sims3.Gameplay.Core.RandomUtil.GetRandomObjectFromList(styles); int cost = Photography.GetCostToTakePhoto(skill, camera, size, style); if (Sim.FamilyFunds < cost) { continue; } float x = 0f; float num3 = 1f; float num5 = 0f; float num6 = 1f; SubjectDefinition subject = Sims3.Gameplay.Core.RandomUtil.GetRandomObjectFromList(subjects); skill.ApplyMultiplier(ref num6, camera.CameraTuning.ValueMultiplier, "Value", "CameraTuning"); bool newSubject, firstShotTodayOfSubject, collectionComplete; UpdateRecords(skill, camera, subject, style, size, out newSubject, out firstShotTodayOfSubject, out collectionComplete); if (newSubject) { skill.ApplyBonus(ref x, (float)subject.SkillPoints, "Skill Gain", "Subject Tuning (New Subject)"); skill.ApplyBonus(ref num5, (float)subject.Value, "Value", "Subject Tuning (New Subject)"); } else if (firstShotTodayOfSubject) { skill.ApplyBonus(ref x, subject.SkillPoints * Photography.kFirstShotOfTheDaySkillGainMultiplier, "Skill Gain", "Subject Tuning (First Time Today)"); skill.ApplyBonus(ref num5, subject.Value * Photography.kFirstShotOfTheDayValueMultiplier, "Value", "Subject Tuning (First Time Today)"); } if (Sims3.Gameplay.Core.RandomUtil.RandomChance((skill.MaxSkillLevel - (skill.SkillLevel - 1)) * 10)) { skill.ApplyMultiplier(ref num6, Photography.kBadPhotoValueMultiplier, "Value", "Bad Photo (kBadPhotoValueMultiplier)"); } skill.ApplyMultiplier(ref num6, Photography.sValueMultipliers[skill.SkillLevel], "Value", "Sim's Skill Level"); skill.ApplyMultiplier(ref num6, Photography.sSizeData[size].ValueMultiplier, "Value", "Photo Size"); skill.ApplyMultiplier(ref num6, Photography.sStyleData[style].ValueMultiplier, "Value", "Photo Style"); if (collectionComplete) { skill.ApplyMultiplier(ref num6, subject.Collection.ValueMultiplierWhenComplete, "Value", "Collection Tuning (Complete)"); } else { skill.ApplyMultiplier(ref num6, subject.Collection.ValueMultiplier, "Value", "Collection Tuning"); } if (Sim.TraitManager.HasElement(TraitNames.PhotographersEye)) { skill.ApplyMultiplier(ref num6, TraitTuning.PhotographersEyePhotographValueMultiplier, "Value", "Photographer's Eye (TraitTuning)"); } skill.ApplyMultiplier(ref num3, camera.CameraTuning.SkillGainMultiplier, "Skill Gain", "CameraTuning"); int funds = (int)((Photography.kBaseValuePerPhoto + num5) * num6); if ((funds < cost) && (additional > 0)) { IncStat("Try Again"); total++; additional--; } skill.EarnedMoneyFromPhotography((uint)funds); skill.UpdateXpForEarningMoney(funds); totalFunds += funds; AddStat("Subject: " + subject.Name, funds); AddStat("Funds", funds); Money.AdjustFunds(Sim, "Photography", -cost); AddStat("Cost", cost); skill.SpentMoneyOnPhotography((uint)cost); AddScoring("Net", funds - cost); mNet += (funds - cost); float points = (Photography.kBaseSkillGainPerPhoto + x) * num3; AddStat("Skill", points); skill.AddPoints(points); skill.CheckForCompletedOpportunities(); } Money.AdjustFunds(Sim, "Photography", totalFunds); return(mNet > 0); }
protected void PayForMoveInLot(Dictionary <Household, bool> oldHouses, int lotCost) { if (lotCost <= House.FamilyFunds) { AddStat("Self Purchase", lotCost); Money.AdjustFunds(House, "BuyLot", -lotCost); lotCost = 0; } else { lotCost -= House.FamilyFunds; AddStat("Remainder", lotCost); Money.AdjustFunds(House, "BuyLot", -House.FamilyFunds); } int maximumLoan = MaximumLoan; int oldHouseFunds = 0; foreach (Household oldHouse in oldHouses.Keys) { oldHouseFunds += oldHouse.FamilyFunds; } int totalFunds = maximumLoan + oldHouseFunds; if (lotCost > totalFunds) { Money.AdjustFunds(House, "BuyLot", totalFunds - lotCost); lotCost = totalFunds; IncStat("Miscalculated Lot Cost"); } else { int dowry = (int)((totalFunds - lotCost) * (NewHomeStarterPercent / 100f)); dowry -= House.FamilyFunds; if (dowry > 0) { AddStat("Dowry", dowry); Money.AdjustFunds(House, "Dowry", dowry); lotCost += dowry; } if (maximumLoan > lotCost) { maximumLoan = lotCost; } if (maximumLoan > 0) { if ((GetValue <NetWorthOption, int>(House) / 2) < maximumLoan) { maximumLoan /= 2; AddStat("Loan Reduced", GetValue <NetWorthOption, int>(House)); } Money.AdjustFunds(House, "BuyLot", -maximumLoan); lotCost -= maximumLoan; AddStat("Loan", maximumLoan); } } if (lotCost > 0) { AddStat("Final Cost", lotCost); if (oldHouseFunds > lotCost) { foreach (Household oldHouse in oldHouses.Keys) { int part = -lotCost * (oldHouse.FamilyFunds / oldHouseFunds); Money.AdjustFunds(oldHouse, "BuyLot", part); AddScoring("Old Home Final (A)", part); } } else { foreach (Household oldHouse in oldHouses.Keys) { int part = -lotCost / oldHouses.Count; Money.AdjustFunds(oldHouse, "BuyLot", part); AddScoring("Old Home Final (B)", part); } } } }
protected override bool PrivateUpdate(ScenarioFrame frame) { List <PropertyData> properties = new List <PropertyData>(); int max = Maximum; int min = Minimum; foreach (PropertyData property in Sim.Household.RealEstateManager.AllProperties) { int cost = GetCost(property); if (cost <= 0) { continue; } if (cost < min) { continue; } if (cost > max) { continue; } properties.Add(property); } if (properties.Count == 0) { return(false); } mFail = IsFail(Sim, Target); if (!mFail) { PropertyData choice = RandomUtil.GetRandomObjectFromList(properties); mObjectName = choice.LocalizedName; mObjectValue = GetCost(choice); if (ActualTransfer) { ManagerMoney.TransferProperty(Sim.Household, Target.Household, choice); } else { Money.AdjustFunds(Target, "PropertyTransfer", -mObjectValue); Money.AdjustFunds(Sim, "PropertyTransfer", mObjectValue); } if (Delta < 0) { TraitFunctions.ItemStolenCallback(Target.Household, Origin.FromTheft); foreach (Sim sim in HouseholdsEx.AllSims(Target.Household)) { EventTracker.SendEvent(EventTypeId.kWasRobbed, sim); } } } if (Delta < 0) { if (OnInvestigateScenario != null) { OnInvestigateScenario(this, frame); } } return(true); }
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); }