Hi there! You are currently browsing as a guest. Why not create an account? Then you get less ads, can thank creators, post feedback, keep a list of your favourites, and more!
Inventor
#76 Old 27th Apr 2015 at 5:03 PM Last edited by Arsil : 16th Jul 2015 at 10:57 AM.
Not sure about the elegance of the code, but this seems to get the job done.
I'm still testing it (if it's all right saving and reloading, if it's all right if you move
into another city, go and come back from vacation/UNI, etc).

You have to add "using Sims3.Gameplay.StoryProgression;" at the top.

Code:
        private static void OnPreLoad()            
        {
            Phone.CallToggleRoommateServices.Singleton = new CallToggleRoommateServicesModded.DefinitionModded();
            //Phone.CallChangeRoommateType.Singleton = new CallChangeRoommateTypeModded.DefinitionModded();
            //Phone.CallChangeRoommateCount.Singleton = new CallChangeRoommateCountModded.DefinitionModded();
            try
            {
                ActionTuning at = StoryProgressionService.sService.mDemographicTuning.ActionTuning["AddRoommate"];
                at.Multiplier = 0;
            }
            catch (Exception exc)
            {
                DebugMsg(exc.Message + "\n" + exc.StackTrace.Substring(0, 500));
            }
        }

or maybe
Code:
            StoryProgressionService sps = StoryProgressionService.sService;
            if (sps != null)
            {
                ActionTuning at = sps.mDemographicTuning.ActionTuning["AddRoommate"];
                if (at != null)
                {
                    at.Multiplier = 0;
                }
                else
                {
                    // display message about ActionTuning not found?
                }
            }
            else
            {
                // display message about StoryProgressionService not initialized?
            }


EDIT: there are other 2 StoryActions that may or may not require attention:
- RemoveRoommate
- KillRoommate
Both have their own xml tuning

EDIT / WARNING
Code:
+ exc.StackTrace.Substring(0, 500));

This instruction can throw an exception if the string returned by StackTrace is shorter than 500. Don't imitate this crappy code.
Advertisement
Field Researcher
#77 Old 27th Apr 2015 at 9:19 PM
Quote: Originally posted by Arsil
Lazy quoting mode enabled.

# Do you say those aren't relevant because they won't work in an apartment lot? Or because it defeats the purpose?

The first you said.

# Either way, though, since this action replaced the default phone interaction, it should be there so it will work properly on other lots.

If we leave them as they are, they will continue doing that.

# Besides, I could think of situations where you might want an apartment to run that way (assuming that it works).

Such as?



Like...if I wanted to have 2 playable apartments and then the rest NPC doors? Just assign the roommates to the "other" apartment in the building. But I guess it won't matter anyway, since it won't work...
Field Researcher
#78 Old 27th Apr 2015 at 10:14 PM Last edited by pjsutton : 27th Apr 2015 at 10:59 PM.
I just tried it out (did not use your code because I didn't feel like fighting with all the errors, I know it's because I just copied and pasted).

I enabled roommates and at 9 am 6 showed up ... And were not added to the household! So, it does work! I just need to add the parts about the type and number.

EDIT: don't know if it's related but I let the game run for 10 sim days and it never collected the rent from the 6 Sims that it said would be collected. My Sims paid rent in the form of bills, twice, and did it using the mailbox.
Field Researcher
#79 Old 28th Apr 2015 at 1:38 AM
I think this might need to be in there somewhere...

Code:
if (SimClock.CurrentDayOfWeek == RoommateManager.kRoommateRentDay)
				{
					if (RoommateManager.CanControlRoommateServices(Household.ActiveHousehold))
					{
						int num2 = RoommateManager.GetRentAmount(Household.ActiveHousehold) * this.mRoommates.Count;
						Household.ActiveHousehold.ModifyFamilyFunds(num2);
						StyledNotification.Format format = new StyledNotification.Format(Localization.LocalizeString("Gameplay/Interactions/Roommates:RentCollection", new object[]
						{
							num2
						}), ObjectGuid.InvalidObjectGuid, ObjectGuid.InvalidObjectGuid, StyledNotification.NotificationStyle.kGameMessagePositive);
						StyledNotification.Show(format);
					}
					else if (Household.ActiveHouseholdLot.IsApartmentLot)
					{
						uint amount = (uint)(Household.ActiveHouseholdLot.RentalCost + Household.ActiveHousehold.UnpaidBills);
						Bill bill = GlobalFunctions.CreateObjectOutOfWorld("Bill") as Bill;
						List<Sim> sims = Household.ActiveHousehold.Sims;
						if (bill != null && sims != null && sims.Count > 0)
						{
							bill.Amount = amount;
							Household.ActiveHousehold.UnpaidBills = 0;
							Mailbox mailboxOnLot = Mailbox.GetMailboxOnLot(Household.ActiveHousehold.LotHome);
							if (mailboxOnLot != null)
							{
								mailboxOnLot.AddMail(bill, false);
								bill.OriginatingHousehold = Household.ActiveHousehold;
							}
						}
					}
Field Researcher
#80 Old 28th Apr 2015 at 4:04 AM
I can't seem to get the game to give me rent from the roommates. When I enable them/change the number of them, it tells me the amount that it'll be collecting, but then it never gives me any money. "RoommateRentDay" in the game somewhere is set to Friday. I think you can find this in the RoommateManager.

I've tried during a variety of things and nothing seems to get this to work. The only thing I did NOT try since trying to implement this is to change the active household and come back. Maybe that has something to do with it.

Also, when I played with roommates enabled and clicked on one and went to "Roommates... / Dismiss Roommate" at 1 am the next day SP added a new Sim to my household. So maybe those two other StoryActions do need to be edited.

I did not try your SP scripts yet, still just playing with the edited XML. Wanted to try to get the rent working properly and then try to clean up the code since it's a horrendous mess (but, functional... I managed to get the roommate count and roommate type interactions to appear! Really proud of myself for that one!)

Aside from these issues, it seems to be working great. I was concerned that none of the interactions from RoommateManager would function properly, like Ask/Convince to..., but those did.
Field Researcher
#81 Old 28th Apr 2015 at 5:48 AM
You are still playing in an Apartment lot right? If you read the code you copy and pasted (I assume from the RoommateValidation method) 2 posts above, you should notice that rent is never collected from your roommates on apartment/dorm lots (remember "RoommateManager.CanControlRoommateServices(Household.ActiveHousehold)"? This is still the default game check, not your custom one).

You'll have to either set up your own alarm or replace the RoommateManager's mRoommateValidation alarm with a custom one that will collect the rent from your roommates on the lot you are playing. Since you're replacing the CallToggleRoommateServices interaction, you can modify the OnCalledFinished method so that after the StartAcceptingRoommates line is run (which, if you clicked on it to read you'll see the StartAlarm method is called at the end of it, which sets up the mRoommateValidation), try adding
Code:
Household.RoommateManager.StopAlarm(); <- To remove the alarm that was just setup

Household.RoommateManager.mRoommateValidationAlarm = AlarmManager.Global.AddAlarmDay(RoommateManager.kRoommateValidationTimeOfDay, DaysOfTheWeek.All, new AlarmTimerCallback(Name of your custom version of the RoommateValidation method here), "RoommateValidation", AlarmType.NeverPersisted, null);
Field Researcher
#82 Old 28th Apr 2015 at 11:20 AM
Quote: Originally posted by icarus_allsorts
You are still playing in an Apartment lot right? If you read the code you copy and pasted (I assume from the RoommateValidation method) 2 posts above, you should notice that rent is never collected from your roommates on apartment/dorm lots (remember "RoommateManager.CanControlRoommateServices(Household.ActiveHousehold)"? This is still the default game check, not your custom one).

You'll have to either set up your own alarm or replace the RoommateManager's mRoommateValidation alarm with a custom one that will collect the rent from your roommates on the lot you are playing. Since you're replacing the CallToggleRoommateServices interaction, you can modify the OnCalledFinished method so that after the StartAcceptingRoommates line is run (which, if you clicked on it to read you'll see the StartAlarm method is called at the end of it, which sets up the mRoommateValidation), try adding
Code:
Household.RoommateManager.StopAlarm(); <- To remove the alarm that was just setup

Household.RoommateManager.mRoommateValidationAlarm = AlarmManager.Global.AddAlarmDay(RoommateManager.kRoommateValidationTimeOfDay, DaysOfTheWeek.All, new AlarmTimerCallback(Name of your custom version of the RoommateValidation method here), "RoommateValidation", AlarmType.NeverPersisted, null);


Yes but I had replaced my RoommsteManager.CanControlRoommateServices with my custom version every time I saw it, so I thought that would fix it.

I wonder if I could add a toggle on the phone Roommates menu that would let you switch rent collecting on or off, depending on how you want to play. I'll try your addition tonight.
Field Researcher
#83 Old 29th Apr 2015 at 3:29 AM
I think maybe I will post this in its current form and let people test it out - I did at the SP pieces and took out the demographics XML and it still worked properly.

I do know that "dismiss roommate" kicked SP to spawn a new one, so we'll need to address that somehow.

And keep working on the rent thing...

Thanks!!
Field Researcher
#84 Old 18th May 2015 at 3:02 AM
Okay ... so what could cause this to happen?

The mod works fine until I choose a Sim and click "Dismiss Roommate" - then everything breaks and it seems to ignore both the SP overrides we made, and the roommate services that WERE enabled become disabled. Thus spawning new player-controlled roommates between 1-2 am.

I tried changing the "RemoveRoommate" value in SP to 0 but that didn't do anything.

What could cause it to "reset" like this?
Inventor
#85 Old 6th Jun 2015 at 4:33 PM
Hi pjsutton.

There's an unknown resource in the package you uploaded to MTS.
It contains a xml tuning (the instantiator). You can delete that resource safely
since you also have a legit _XML resource for that.

I think the code inside your "try" is never executed, you can check that putting
a debugging message inside the catch. The reason is that, at that point of the gameflow,
the StoryProgressionService hasn't been initialized yet. The only way I could make it work
was to add an AlarmHandle in OnWorldLoadFinished to be executed ASAP when the
game is running, something like this:



I apologize because I was the one who suggested you that code.
Actually the code I suggested had debugging messages, but for an unfortunate
coincidence I never noticed that it wasn't executed until now.
Field Researcher
#86 Old 17th Jun 2015 at 7:11 AM
Okay, I'm still having trouble getting the mod to collect the rent from the roommates...I think it has something to do with "RoommateValidation" and an alarm ... but I don't know much about alarms.

I will post this here, but I don't know how to make that "Spoiler" button come up so it will be long... (I re-arranged some stuff in the code and "fixed" a few things that weren't doing anything ... or so I thought ... to try and get the rent to collect, but it still doesn't.)

Code:
using Sims3.Gameplay;
using Sims3.Gameplay.Academics;
using Sims3.Gameplay.Actors;
using Sims3.Gameplay.ActorSystems;
using Sims3.Gameplay.Autonomy;
using Sims3.Gameplay.Careers;
using Sims3.Gameplay.CAS;
using Sims3.Gameplay.Core;
using Sims3.Gameplay.EventSystem;
using Sims3.Gameplay.Interactions;
using Sims3.Gameplay.Interfaces;
using Sims3.Gameplay.Moving;
using Sims3.Gameplay.Objects.Electronics;
using Sims3.Gameplay.Situations;
using Sims3.Gameplay.Socializing;
using Sims3.Gameplay.StoryProgression;
using Sims3.Gameplay.Utilities;
using Sims3.Gameplay.Visa;
using Sims3.SimIFace;
using Sims3.SimIFace.CAS;
using Sims3.UI;
using System;
using System.Collections.Generic;
namespace LeapsForCauchy
{

    public class RoommatesFix
    {
        [Tunable]
        protected static bool kInstantiator;
        public static DaysOfTheWeek kRoommateRentDay = DaysOfTheWeek.Tuesday;
        public static float kRoommateRentMultiplier = 09;
        public List<ulong> mRoommates = new List<ulong>();
        public static float kRoommateValidationTimeOfDay = 09;
        public static int GetRentAmount(Household household)
        {
            if (household != null)
            {
                return (int)((float)household.LotHome.Cost * RoommatesFix.kRoommateRentMultiplier);
            }
            return 0;
        }
        public static bool ControlRoommateServices(Household household)
        {
            return household != null && household.LotHome != null && !household.LotHome.IsDormitoryLot && !GameUtils.IsOnVacation();
        }
        static RoommatesFix()
        {

            RoommatesFix.kInstantiator = false;
            LoadSaveManager.ObjectGroupsPreLoad += new ObjectGroupsPreLoadHandler(RoommatesFix.OnPreLoad);
            World.OnWorldLoadFinishedEventHandler += new EventHandler(RoommatesFix.OnWorldLoadFinished);
        }
        public static void OnWorldLoadFinished(object sender, EventArgs e)
        {
            EventTracker.AddListener(EventTypeId.kHouseholdSelected, new ProcessEventDelegate(RoommatesFix.OnHouseholdChanged));
        }
        public static ListenerAction OnHouseholdChanged(Event e)
        {
            if (Household.ActiveHousehold != null && Household.ActiveHouseholdLot != null && Household.ActiveHouseholdLot.IsApartmentLot)
            {
                Household.RoommateManager.StopAcceptingRoommates(true);
            }
            return ListenerAction.Keep;
        }
        private static void OnPreLoad()
        {
            Phone.CallToggleRoommateServices.Singleton = new RoommatesFix.FixedCallToggleRoommateServices.Definition();
            Phone.CallChangeRoommateCount.Singleton = new RoommatesFix.FixedCallChangeRoommateCount.Definition();
            Phone.CallChangeRoommateType.Singleton = new RoommatesFix.FixedCallChangeRoommateType.Definition();
        }


        public class FixedCallToggleRoommateServices : Phone.Call
        {
            public class Definition : Phone.Call.CallDefinition<RoommatesFix.FixedCallToggleRoommateServices>
            {
                public override string GetInteractionName(ref InteractionInstanceParameters parameters)
                {
                    string result;
                    if (Household.RoommateManager.AcceptingRoommates)
                    {
                        result = Localization.LocalizeString("Gameplay/Interactions/Roommates:Disable", new object[0]);
                    }
                    else
                    {
                        result = Localization.LocalizeString("Gameplay/Interactions/Roommates:Enable", new object[0]);
                    }
                    return result;
                }
                public override string[] GetPath(bool isFemale)
                {
                    return new string[]
					{
						Localization.LocalizeString("Gameplay/Objects/Electronics/SmartPhone:RealEstateAndTravel", new object[0]) + Localization.Ellipsis,
						Localization.LocalizeString("Gameplay/Interactions/Roommates:RoommatesPathName", new object[0]) + Localization.Ellipsis
					};
                }
                public override bool Test(Sim a, Phone target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
                {
                    return !isAutonomous && RoommatesFix.ControlRoommateServices(a.Household);
                }
            }
            public static InteractionDefinition Singleton = new RoommatesFix.FixedCallToggleRoommateServices.Definition();
            public override Phone.Call.ConversationBehavior OnCallConnected()
            {
                return Phone.Call.ConversationBehavior.TalkBriefly;
            }
            public override void OnCallFinished()
            {
                if (Household.RoommateManager.AcceptingRoommates)
                {
                    Household.RoommateManager.StopAcceptingRoommates(true);
                }
                else
                {
                    Household.RoommateManager.StartAcceptingRoommates(this.Actor.Household);
                    this.Actor.ShowTNSIfSelectable(Localization.LocalizeString("Gameplay/Notifications/Roommates:StartAccepting", new object[]
					{
						new AbsoluteTime(RoommatesFix.kRoommateValidationTimeOfDay),
						RoommatesFix.GetRentAmount(this.Actor.Household) * Household.RoommateManager.MaxNumRoommates
					}), StyledNotification.NotificationStyle.kGameMessagePositive);
                 //   Household.RoommateManager.StopAlarm();
                 //   Household.RoommateManager.mRoommateValidationAlarm = AlarmManager.Global.AddAlarmDay(RoommateManager.kRoommateValidationTimeOfDay, DaysOfTheWeek.All, new AlarmTimerCallback(this.RoommateValidation), "RoommateValidation", AlarmType.NeverPersisted, null);
                }
            }
            
        }
        public class FixedCallChangeRoommateCount : ImmediateInteraction<Sim, Phone>
        {
            public class Definition : ImmediateInteractionDefinition<Sim, Phone, RoommatesFix.FixedCallChangeRoommateCount>
            {
                public int mNumRoommates;
                public Definition()
                {
                }
                public Definition(int num)
                {
                    this.mNumRoommates = num;
                }
                public override string GetInteractionName(ref InteractionInstanceParameters parameters)
                {
                    return EAText.GetNumberString((double)this.mNumRoommates);
                }
                public override string[] GetPath(bool isFemale)
                {
                    return new string[]
					{
						Localization.LocalizeString("Gameplay/Objects/Electronics/SmartPhone:RealEstateAndTravel", new object[0]) + Localization.Ellipsis,
						Localization.LocalizeString("Gameplay/Interactions/Roommates:RoommatesPathName", new object[0]) + Localization.Ellipsis,
						Localization.LocalizeString("Gameplay/Interactions/Roommates:MaxNumRoommates", new object[0]) + Localization.Ellipsis
					};
                }
                public override void AddInteractions(InteractionObjectPair iop, Sim actor, Phone target, List<InteractionObjectPair> results)
                {
                    int num = 8 - actor.Household.NumActorMembersCountingPregnancy + actor.Household.GetNumberOfRoommates();
                    for (int i = 1; i <= num; i++)
                    {
                        results.Add(new InteractionObjectPair(new RoommatesFix.FixedCallChangeRoommateCount.Definition(i), target));
                    }
                }
                public static string TooManyCurrentRoommates()
                {
                    return Localization.LocalizeString("Gameplay/Interactions/Roommates:TooManyRoommates", new object[0]);
                }
                public static string CurrentNumRoommates()
                {
                    return Localization.LocalizeString("Gameplay/Interactions/Roommates:CurrentNumRoommates", new object[0]);
                }
                public static string EnableRoommatesFirst()
                {
                    return Localization.LocalizeString("Gameplay/Interactions/Roommates:RoommatesMustBeEnabled", new object[0]);
                }
                public override bool Test(Sim a, Phone target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
                {
                    bool result;
                    if (!target.IsUsableBy(a))
                    {
                        result = false;
                    }
                    else if (isAutonomous)
                    {
                        result = false;
                    }
                    else if (!RoommatesFix.ControlRoommateServices(a.Household))
                    {
                        result = false;
                    }
                    else if (!Household.RoommateManager.AcceptingRoommates)
                    {
                        greyedOutTooltipCallback = new GreyedOutTooltipCallback(RoommatesFix.FixedCallChangeRoommateCount.Definition.EnableRoommatesFirst);
                        result = false;
                    }
                    else if (Household.RoommateManager.MaxNumRoommates == this.mNumRoommates)
                    {
                        greyedOutTooltipCallback = new GreyedOutTooltipCallback(RoommatesFix.FixedCallChangeRoommateCount.Definition.CurrentNumRoommates);
                        result = false;
                    }
                    else if (this.mNumRoommates < a.Household.GetNumberOfRoommates())
                    {
                        greyedOutTooltipCallback = new GreyedOutTooltipCallback(RoommatesFix.FixedCallChangeRoommateCount.Definition.TooManyCurrentRoommates);
                        result = false;
                    }
                    else
                    {
                        result = true;
                    }
                    return result;
                }
            }
            public static InteractionDefinition Singleton = new RoommatesFix.FixedCallChangeRoommateCount.Definition();
            public override string GetInteractionName()
            {
                return Localization.LocalizeString("Gameplay/Interactions/Roommates:MaxNumRoommates", new object[0]) + Localization.Ellipsis + base.GetInteractionName();
            }
            public override bool RunFromInventory()
            {
                return this.Run();
            }
            public override bool Run()
            {
                Household.RoommateManager.SetMaxRoommateNumber((base.InteractionDefinition as RoommatesFix.FixedCallChangeRoommateCount.Definition).mNumRoommates);
                this.Actor.ShowTNSIfSelectable(Localization.LocalizeString("Gameplay/Notifications/Roommates:StartAccepting", new object[]
				{
					new AbsoluteTime(RoommateManager.kRoommateValidationTimeOfDay),
					RoommateManager.GetRentAmount(this.Actor.Household) * Household.RoommateManager.MaxNumRoommates
				}), StyledNotification.NotificationStyle.kGameMessagePositive);
                return true;
            }
        }
        public class FixedCallChangeRoommateType : ImmediateInteraction<Sim, Phone>
        {
            public class Definition : ImmediateInteractionDefinition<Sim, Phone, RoommatesFix.FixedCallChangeRoommateType>
            {
                public RoommateManager.RoommateTypes mType;
                public Definition()
                {
                }
                public Definition(RoommateManager.RoommateTypes type)
                {
                    this.mType = type;
                }
                public override string GetInteractionName(ref InteractionInstanceParameters parameters)
                {
                    return Localization.LocalizeString("Gameplay/Interactions/Roommates:" + this.mType.ToString(), new object[0]);
                }
                public override string[] GetPath(bool isFemale)
                {
                    return new string[]
					{
						Localization.LocalizeString("Gameplay/Objects/Electronics/SmartPhone:RealEstateAndTravel", new object[0]) + Localization.Ellipsis,
						Localization.LocalizeString("Gameplay/Interactions/Roommates:RoommatesPathName", new object[0]) + Localization.Ellipsis,
						Localization.LocalizeString("Gameplay/Interactions/Roommates:SetRoommateType", new object[0]) + Localization.Ellipsis
					};
                }
                public override void AddInteractions(InteractionObjectPair iop, Sim actor, Phone target, List<InteractionObjectPair> results)
                {
                    results.Add(new InteractionObjectPair(new RoommatesFix.FixedCallChangeRoommateType.Definition(RoommateManager.RoommateTypes.Female), target));
                    results.Add(new InteractionObjectPair(new RoommatesFix.FixedCallChangeRoommateType.Definition(RoommateManager.RoommateTypes.Male), target));
                    results.Add(new InteractionObjectPair(new RoommatesFix.FixedCallChangeRoommateType.Definition(RoommateManager.RoommateTypes.Coed), target));
                }
                public static string AlreadyCurrentType()
                {
                    return Localization.LocalizeString("Gameplay/Interactions/Roommates:AlreadySameType", new object[0]);
                }
                public static string EnableRoommatesFirst()
                {
                    return Localization.LocalizeString("Gameplay/Interactions/Roommates:RoommatesMustBeEnabled", new object[0]);
                }
                public override bool Test(Sim a, Phone target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
                {
                    bool result;
                    if (!target.IsUsableBy(a))
                    {
                        result = false;
                    }
                    else if (isAutonomous)
                    {
                        result = false;
                    }
                    else if (!RoommatesFix.ControlRoommateServices(a.Household))
                    {
                        result = false;
                    }
                    else if (!Household.RoommateManager.AcceptingRoommates)
                    {
                        greyedOutTooltipCallback = new GreyedOutTooltipCallback(Phone.CallChangeRoommateType.Definition.EnableRoommatesFirst);
                        result = false;
                    }
                    else if (Household.RoommateManager.RoommateType == this.mType)
                    {
                        greyedOutTooltipCallback = new GreyedOutTooltipCallback(Phone.CallChangeRoommateType.Definition.AlreadyCurrentType);
                        result = false;
                    }
                    else
                    {
                        result = true;
                    }
                    return result;
                }
            }
            public static InteractionDefinition Singleton = new RoommatesFix.FixedCallChangeRoommateType.Definition();
            public override string GetInteractionName()
            {
                return Localization.LocalizeString("Gameplay/Interactions/Roommates:SetRoommateType", new object[0]) + Localization.Ellipsis + base.GetInteractionName();
            }
            public override bool RunFromInventory()
            {
                return this.Run();
            }
            public override bool Run()
            {
                Household.RoommateManager.SetRoommateType((base.InteractionDefinition as RoommatesFix.FixedCallChangeRoommateType.Definition).mType);
                return true;
            }
        }
        public class NewRoommateManager
        {
            [Persistable(false)]
            public AlarmHandle mRoommateValidationAlarm = AlarmHandle.kInvalidHandle;
            public List<ulong> mRoommates = new List<ulong>();
            public bool mHasThrownWelcomeParty;
            public RoommateManager.RoommateTypes mRoommateType;
            public int mMaxNumRoommates;
            public void RemoveCallbacks(Household household)
            {
                if (household != null)
                {
                    household.HouseholdSimsChanged -= new Household.HouseholdSimsChangedCallback(this.HouseholdSimChanged);
                }
            }
            public void RemoveRoommateInteractions(Sim roommate)
            {
                if (roommate != null)
                {
                    roommate.RemoveInteractionByType(RoommateManager.DismissRoommate.Singleton);
                    roommate.RemoveInteractionByType(RoommateManager.AskRoommateTo.Definition.Singleton);
                    roommate.RemoveInteractionByType(RoommateManager.MoochFromRoommateDefinition.Singleton);
                }
            }
            public bool RemoveRoommateInternal(SimDescription roommate)
            {
                bool result;
                if (roommate == null)
                {
                    result = false;
                }
                else if (!this.mRoommates.Remove(roommate.SimDescriptionId))
                {
                    result = false;
                }
                else
                {
                    roommate.IsNeverSelectable = false;
                    this.RemoveRoommateInteractions(roommate.CreatedSim);
                    if (this.mRoommates.Count == 0)
                    {
                        this.RemoveCallbacks(roommate.Household);
                    }
                    if (roommate.Household != null)
                    {
                        foreach (SimDescription current in roommate.Household.SimDescriptions)
                        {
                            if (current != roommate)
                            {
                                Relationship relationship = current.GetRelationship(roommate, true);
                                relationship.Roommates = false;
                            }
                        }
                    }
                    result = true;
                }
                return result;
            }
            public bool IsNPCRoommate(ulong simDescriptionID)
            {
                return this.mRoommates.Contains(simDescriptionID);
            }
            public bool IsNPCRoommate(Sim sim)
            {
                return sim != null && this.IsNPCRoommate(sim.SimDescription.SimDescriptionId);
            }
            public void HouseholdSimChanged(HouseholdEvent householdEvent, IActor member, Household oldHousehold)
            {
                if (householdEvent == HouseholdEvent.kSimRemoved)
                {
                    Sim sim = member as Sim;
                    if (sim != null && this.IsNPCRoommate(sim))
                    {
                        this.RemoveRoommateInternal(sim.SimDescription);
                    }
                }
            }
            public void SetupCallbacks(Household household)
            {
                if (household != null)
                {
                    household.HouseholdSimsChanged -= new Household.HouseholdSimsChangedCallback(this.HouseholdSimChanged);
                    household.HouseholdSimsChanged += new Household.HouseholdSimsChangedCallback(this.HouseholdSimChanged);
                }
            }
            public void AddRoommateInteractions(Sim roommate)
            {
                if (roommate != null)
                {
                    roommate.AddInteraction(RoommateManager.DismissRoommate.Singleton);
                    roommate.AddInteraction(RoommateManager.AskRoommateTo.Definition.Singleton);
                    roommate.AddInteraction(RoommateManager.MoochFromRoommateDefinition.Singleton);
                }
            }
            public bool AddRoommate(SimDescription roommate, Household household)
            {
                bool result;
                if (roommate == null)
                {
                    result = false;
                }
                else if (this.mRoommates.Count >= this.mMaxNumRoommates)
                {
                    result = false;
                }
                else
                {
                    roommate.IsNeverSelectable = true;
                    this.mRoommates.Add(roommate.SimDescriptionId);
                    if (roommate.Household != household)
                    {
                        if (roommate.Household != null)
                        {
                            roommate.Household.Remove(roommate);
                        }
                        if (household != null)
                        {
                            household.Add(roommate);
                        }
                    }
                    this.AddRoommateInteractions(roommate.CreatedSim);
                    if (roommate.Household != null)
                    {
                        foreach (SimDescription current in roommate.Household.SimDescriptions)
                        {
                            if (current != roommate)
                            {
                                Relationship relationship = current.GetRelationship(roommate, true);
                                relationship.Roommates = true;
                            }
                        }
                    }
                    this.SetupCallbacks(household);
                    if (household != null)
                    {
                        household.OnMemberChanged(roommate, roommate.CreatedSim);
                    }
                    result = true;
                }
                return result;
            }
            public bool CanBeRoommate(SimDescription simDesc)
            {
                bool result;
                if (simDesc != null)
                {
                    bool flag = true;
                    if (this.mRoommateType == RoommateManager.RoommateTypes.Male && simDesc.IsFemale)
                    {
                        flag = false;
                    }
                    if (this.mRoommateType == RoommateManager.RoommateTypes.Female && !simDesc.IsFemale)
                    {
                        flag = false;
                    }
                    bool flag2 = true;
                    if ((simDesc.IsEngaged || simDesc.IsMarried) && simDesc.Partner.Household != Household.ActiveHousehold)
                    {
                        flag2 = false;
                    }
                    bool youngAdultOrAbove = simDesc.YoungAdultOrAbove;
                    bool flag3 = !simDesc.HasActiveRole && !simDesc.IsServicePerson;
                    bool flag4 = !simDesc.IsPregnant;
                    result = (flag4 && flag && flag2 && youngAdultOrAbove && flag3 && simDesc.IsHuman);
                }
                else
                {
                    result = false;
                }
                return result;
            }
            public void NewRoommateValidation()
            {
                if (Household.ActiveHousehold != null)
                {
                    if (Household.ActiveHouseholdLot != null)
                    {
                        if (Household.ActiveHouseholdLot.IsSororityLot)
                        {
                            this.mRoommateType = RoommateManager.RoommateTypes.Female;
                        }
                        else if (Household.ActiveHouseholdLot.IsFraternityLot)
                        {
                            this.mRoommateType = RoommateManager.RoommateTypes.Male;
                        }
                    }
                    if (GameplayMovingModel.MovingCurrentlyInProgress)
                    {
                        return;
                    }
                    int num = this.mRoommates.Count;
                    while (num < this.mMaxNumRoommates && Household.ActiveHousehold.NumActorMembersCountingPregnancy - GameStates.NumHouseholdMembersNotInWorldCountingPregnant < 8)
                    {
                        CASAgeGenderFlags cASAgeGenderFlags;
                        switch (this.mRoommateType)
                        {
                            case RoommateManager.RoommateTypes.Coed:
                                cASAgeGenderFlags = CASAgeGenderFlags.GenderMask;
                                break;
                            case RoommateManager.RoommateTypes.Male:
                                cASAgeGenderFlags = CASAgeGenderFlags.Male;
                                break;
                            case RoommateManager.RoommateTypes.Female:
                                cASAgeGenderFlags = CASAgeGenderFlags.Female;
                                break;
                            default:
                                cASAgeGenderFlags = CASAgeGenderFlags.GenderMask;
                                break;
                        }
                        List<SimDescription> list = Household.AllTownieSimDescriptions(new Predicate<SimDescription>(this.CanBeRoommate));
                        SimDescription simDescription;
                        Sim sim;
                        if (list.Count != 0)
                        {
                            simDescription = RandomUtil.GetRandomObjectFromList<SimDescription>(list);
                            if (simDescription.CreatedSim == null)
                            {
                                sim = simDescription.Instantiate(Household.ActiveHouseholdLot);
                            }
                            else
                            {
                                sim = simDescription.CreatedSim;
                            }
                        }
                        else
                        {
                            CASAgeGenderFlags age = CASAgeGenderFlags.YoungAdult;
                            if (cASAgeGenderFlags == CASAgeGenderFlags.GenderMask)
                            {
                                cASAgeGenderFlags = (RandomUtil.CoinFlip() ? CASAgeGenderFlags.Male : CASAgeGenderFlags.Female);
                            }
                            simDescription = Genetics.MakeSim(age, cASAgeGenderFlags, GameUtils.GetCurrentWorld(), 4294967295u);
                            Genetics.AssignRandomTraits(simDescription);
                            WorldName currentWorld = GameUtils.GetCurrentWorld();
                            simDescription.FirstName = SimUtils.GetRandomGivenName(simDescription.IsMale, currentWorld);
                            simDescription.LastName = SimUtils.GetRandomFamilyName(currentWorld);
                            Household.NpcHousehold.Add(simDescription);
                            sim = simDescription.Instantiate(Household.ActiveHouseholdLot);
                        }
                        this.AddRoommate(simDescription, Household.ActiveHousehold);
                        if (GameUtils.IsUniversityWorld())
                        {
                            if (simDescription.OccupationAsAcademicCareer == null)
                            {
                                AcademicDegreeNames degreeName = AcademicDegreeManager.ChooseWeightRandomSuitableDegree(simDescription);
                                uint coursesPerDay = AcademicCareer.ChooseRandomCoursesPerDay();
                                AcademicCareer.EnrollSimInAcademicCareer(simDescription, degreeName, coursesPerDay);
                            }
                        }
                        else if (simDescription.Occupation == null)
                        {
                            List<Career> list2 = Career.ValidRabbitHoleCareers(true);
                            if (list2.Count > 0)
                            {
                                Career randomObjectFromList = RandomUtil.GetRandomObjectFromList<Career>(list2);
                                AcquireOccupationParameters occupationParameters = new AcquireOccupationParameters(randomObjectFromList.mCareerGuid, RandomUtil.GetRandomObjectFromList<CareerLocation>(randomObjectFromList.Locations), false, false);
                                occupationParameters.ForceAutomaticChange = true;
                                simDescription.CareerManager.AcquireOccupation(occupationParameters);
                            }
                        }
                        if (GameUtils.IsUniversityWorld())
                        {
                            IGameObject gameObject = null;
                            if (sim.LotHome != null)
                            {
                                gameObject = sim.LotHome.GetFrontDoor(eFrontDoorType.kFrontDoorTypeDefault);
                                if (gameObject == null)
                                {
                                    gameObject = sim.LotHome.FindMailbox();
                                }
                            }
                            if (gameObject != null)
                            {
                                InteractionInstance entry = TravelUtil.ArrivalRouteHomeInMovingVanInUniversityWorld.Singleton.CreateInstance(gameObject, sim, new InteractionPriority(InteractionPriorityLevel.UserDirected, -2f), false, false);
                                sim.InteractionQueue.Add(entry);
                            }
                        }
                        else
                        {
                            Sim.MakeSimGoHome(sim, false);
                        }
                        num++;
                    }
                    if (SimClock.CurrentDayOfWeek == RoommatesFix.kRoommateRentDay)
                    {
                        if (RoommatesFix.ControlRoommateServices(Household.ActiveHousehold))
                        {
                            int num2 = RoommatesFix.GetRentAmount(Household.ActiveHousehold) * this.mRoommates.Count;
                            Household.ActiveHousehold.ModifyFamilyFunds(num2);
                            StyledNotification.Format format = new StyledNotification.Format(Localization.LocalizeString("Gameplay/Interactions/Roommates:RentCollection", new object[]
							{
								num2
							}), ObjectGuid.InvalidObjectGuid, ObjectGuid.InvalidObjectGuid, StyledNotification.NotificationStyle.kGameMessagePositive);
                            StyledNotification.Show(format);
                        }
                        else if (Household.ActiveHouseholdLot.IsApartmentLot)
                        {
                            uint amount = (uint)(Household.ActiveHouseholdLot.RentalCost + Household.ActiveHousehold.UnpaidBills);
                            Bill bill = GlobalFunctions.CreateObjectOutOfWorld("Bill") as Bill;
                            List<Sim> sims = Household.ActiveHousehold.Sims;
                            if (bill != null && sims != null && sims.Count > 0)
                            {
                                bill.Amount = amount;
                                Household.ActiveHousehold.UnpaidBills = 0;
                                Mailbox mailboxOnLot = Mailbox.GetMailboxOnLot(Household.ActiveHousehold.LotHome);
                                if (mailboxOnLot != null)
                                {
                                    mailboxOnLot.AddMail(bill, false);
                                    bill.OriginatingHousehold = Household.ActiveHousehold;
                                }
                            }
                        }
                    }
                }
                if (!this.mHasThrownWelcomeParty && GameUtils.IsUniversityWorld())
                {
                    this.mHasThrownWelcomeParty = true;
                    NpcParty.ScheduleUniversityWelcomeParty();
                }
                try
                {
                    ActionTuning actionTuning = StoryProgressionService.sService.mDemographicTuning.ActionTuning["AddRoommate"];
                    actionTuning.Multiplier = 0f;
                }
                catch (Exception var_21_4C1)
                {
                }
                try
                {
                    ActionTuning actionTuning = StoryProgressionService.sService.mDemographicTuning.ActionTuning["RemoveRoommate"];
                    actionTuning.Multiplier = 0f;
                }
                catch (Exception var_21_4C1)
                {
                }
            }
        }
    }
    
    }
Inventor
#87 Old 17th Jun 2015 at 9:30 AM
How to use the SPOILER tag:
(SPOILER)hidden text(/SPOILER)
Using square brackets instead of round ones you get

Please edit your previous posts, wall of texts make the thread hard to read.

Write the "code" tag all lowercase, so it doesn't add a blank line after every line (doubling the length of the text).

Use debugging messages (kDebugging is a boolean tunable static field):

-----

You can't expect the game to use your custom version of RoommateManager instead of the default one,
it's not like an interaction that you can replace. But I see what you tried to do: RoommateValidation is
an instance method so you can't simply copy/paste it and just make the tweaks icarus_allsorts suggested.
Have you tried rewriting it as a static method? Being called by an alarm maybe you can't pass any parameter,
that could be a problem.

Why you put the code I suggested (to stop the "AddRoomate" story action) in that place?
Anyway, that might also be used to populate dormitories, so keep that in mind if they should start acting weird.

-----

We're definitely OFF TOPIC here, if this discussion continues can a moderator separate it and put it in
Modding Discussion? From post#46 http://modthesims.info/showthread.p...327#post4738327
Field Researcher
#88 Old 18th Jun 2015 at 4:26 AM
Quote: Originally posted by Arsil
How to use the SPOILER tag:
(SPOILER)hidden text(/SPOILER)
Using square brackets instead of round ones you get

Please edit your previous posts, wall of texts make the thread hard to read.

Write the "code" tag all lowercase, so it doesn't add a blank line after every line (doubling the length of the text).

Use debugging messages (kDebugging is a boolean tunable static field):

-----

You can't expect the game to use your custom version of RoommateManager instead of the default one,
it's not like an interaction that you can replace. But I see what you tried to do: RoommateValidation is
an instance method so you can't simply copy/paste it and just make the tweaks icarus_allsorts suggested.
Have you tried rewriting it as a static method? Being called by an alarm maybe you can't pass any parameter,
that could be a problem.

Why you put the code I suggested (to stop the "AddRoomate" story action) in that place?
Anyway, that might also be used to populate dormitories, so keep that in mind if they should start acting weird.

-----

We're definitely OFF TOPIC here, if this discussion continues can a moderator separate it and put it in
Modding Discussion? From post#46 http://modthesims.info/showthread.p...327#post4738327


Yes, it is off topic ... I did create a new thread once but I did not subscribe to it and now can't find it... if a mod could move this that would be great!

Your story action was placed there kind of accidentally because I added stuff before it. I've since gotten rid of the whole "NewRoommateManager" since I realize I didn't even call it, so now the story action is placed in a better spot. I did what you suggested, but it does not show me the debug message - but I probably did that part wrong. So, I am not sure whether that is working correctly or not.

I thought I had removed the edited Demographics XML - are you saying that is what the "UNKN" thing is in S3PE?

I got it to collect rent from the roommates when I want it to! Right now, I'm trying to make it "remember" the choice of roommate settings when changing the active household, since it seems to "forget" that - the game without the mod does this too, so it seems to be another EA "feature".
Inventor
#89 Old 18th Jun 2015 at 9:24 AM
Nah, that UNKN resource was a copy of the xml with the kInstantiator tag.

If you put the debug message inside the "catch" block, then not getting any warning in game
means it's working fine (of course, that completely depends where you have put it and in what form).

Gee, you never answer directly to questions, you make it hard to help you ;P
Were you able to make a custom version of RoommateValidation as a static method?
And why should roommates pay rent to your household if it doesn't own the lot?
Doesn't it make more sense to make your Sims pay less (somehow based on the number
of NPC roommates vs total number of inhabitants) in the first place?
Field Researcher
#90 Old 18th Jun 2015 at 1:57 PM
Quote: Originally posted by Arsil
Nah, that UNKN resource was a copy of the xml with the kInstantiator tag.

If you put the debug message inside the "catch" block, then not getting any warning in game
means it's working fine (of course, that completely depends where you have put it and in what form).

Gee, you never answer directly to questions, you make it hard to help you ;P
Were you able to make a custom version of RoommateValidation as a static method?
And why should roommates pay rent to your household if it doesn't own the lot?
Doesn't it make more sense to make your Sims pay less (somehow based on the number
of NPC roommates vs total number of inhabitants) in the first place?


Apparently mods don't care that this is so off-topic :-D

Haha! Yes, I did make a custom RoommateValidation, it seems to work well now. I have it checking for roommates and charging the appropriate amount of of rent:



Why should roommates be paying me? Because I want it that way! To me, that simulates one aspect of life - young people moving out on their own, renting a place, and splitting the cost. I realize it's a little different here, but it gets the idea across!

I did something and now it doesn't make the PC Sims pay rent, and I'm not sure why. I could have sworn when I first did this, the rent got paid in the form of bills in the mailbox, but now they don't appear to get any bills in the mail (not sure why). On a Uni lot, the rent is just automatically deducted from the household funds. I tried to do that with Mailbox.CreateRegularBillForHousehold, and I realized that it wasn't telling the mail carrier to come so it wasn't doing anything.

So, I think my next step is to somehow use ModifyFamilyFunds to do that, but not sure how. This is how it calculates the amount for the regular bills:



When it gets down to the part about "Bill bill createObjectOutOfWorld" is where I assume the whole thing falls apart, and I wanted to just replace that whole thing, up to the end, with something easy that deducts the amount just calculated "Bill amount" from the household funds. I have no idea what that "Tutorial" thing is all about, that was just copied and pasted, so I'll probably get rid of it.

Another problem I'm having is when you change the active household, the roommate services get set the same way. For example, Household A has roommates enabled with 2 roommates. If I switch to Household B, and look at the phone settings, the option for "Disable Roommate Services" appears on their phone - as if they have roommates enabled - but none live with them, nor do any appear. If I then decide to click "Disable" the menu goes back to the way it should, but if I switch back to Household A, the roommates that were currently living there are now gone, because I disabled roommates in Household B.

I'd like some way for the game to check whether there are currently any roommates in the house upon loading the game and/or switching households, set the phone settings appropriately, and also retain any existing roommates currently there. I tried some things with the line "Household.RoommateManager.AcceptingRoommates" thinking I could then use "mAcceptingRoommates = true" and then checking for that value in an if statement upon switching/loading, but it didn't work. Or else it did and not properly. Currently looks like this (it is disabled so it doesn't run)



Any suggestions on those things? I answered your questions and added like 5 more :-)
Inventor
#91 Old 18th Jun 2015 at 2:53 PM
# I answered your questions and added like 5 more :-)

You sure did. I'll try to help you when I get some time.
Unluckily, yesterday I got an idea for a new mod and now I'm obsessed by that.

The Tutorialette is that window displayed when you do certain things for the
first time and the game explains what is it all about. I think you should leave
it, unless the description says something that don't goes along with how your
mod modifies the roommates system.
Field Researcher
#92 Old 19th Jun 2015 at 7:19 AM
Quote: Originally posted by Arsil
# I answered your questions and added like 5 more :-)

You sure did. I'll try to help you when I get some time.
Unluckily, yesterday I got an idea for a new mod and now I'm obsessed by that.

The Tutorialette is that window displayed when you do certain things for the
first time and the game explains what is it all about. I think you should leave
it, unless the description says something that don't goes along with how your
mod modifies the roommates system.


Haha! I know how that goes!

Good news: I figured out how to change the family funds.

Bad news: The more I think about it, the more complicated I want it to become! Finally decided that I want the number of roommates you have to decrease the total cost of the rent proportionally:
Example: A house costs $1200 to rent. With 1 additional roommate, rent cost is only $600. 2 additional roommates, $400. 3 additional roommates, $300. Etc. Which is how (most) people would split rent costs in real life when renting a house/apartment together.

So, I need to come up with the formula to multiply the rent by based on 1. the number of roommates and 2. the total occupants of the house. Should be easy to do. Seems like it might involve a for loop? 1 RM = Rent / 2. 2 RM = rent / 3. 3 RM = rent / 4. etc...

Then I have to do a special case of renting the house with no roommates. The rent will stay the same.

Rent does not seem to be collected by default by my mod, so I have to "fudge" it so that it will. It'll also (I think) involve a custom string/message to display when the amount is deducted.

I'm excited thinking about how this might work out!
Inventor
#93 Old 19th Jun 2015 at 8:02 AM Last edited by Arsil : 19th Jun 2015 at 8:23 AM.
I'm glad you changed your mind. I think that way it makes much more sense.

You have to consider cases like these: total rent 100
- 1 selectable roommate + 1 NPC roommate : your household rent is 50
- 2 selectable roommate + 1 NPC roommate : your household rent is 66
Not sure how to handle child-, pets and bots, but that's your problem, not mine :P

And if your household owns the lot (hopefully the game won't change the lot type to a common
residential lot in that case), then your household should pay regular bills while NPC roommates
should pay rent to your household (maybe you can re-use default existing code or slightly tweak it).

I could have told you how to change the family funds, I didn't notice you asked, I guess I was too
distracted, sorry about that.

Keep up the good work ^^

EDIT: oh, just wanted to let you know that what I wrote is just "my two cents".
It's not like I'm a control freak and I want to tell you how to make your mod...
Field Researcher
#94 Old 19th Jun 2015 at 9:10 PM
Quote: Originally posted by Arsil
I'm glad you changed your mind. I think that way it makes much more sense.

You have to consider cases like these: total rent 100
- 1 selectable roommate + 1 NPC roommate : your household rent is 50
- 2 selectable roommate + 1 NPC roommate : your household rent is 66
Not sure how to handle child-, pets and bots, but that's your problem, not mine :P

And if your household owns the lot (hopefully the game won't change the lot type to a common
residential lot in that case), then your household should pay regular bills while NPC roommates
should pay rent to your household (maybe you can re-use default existing code or slightly tweak it).

I could have told you how to change the family funds, I didn't notice you asked, I guess I was too
distracted, sorry about that.

Keep up the good work ^^

EDIT: oh, just wanted to let you know that what I wrote is just "my two cents".
It's not like I'm a control freak and I want to tell you how to make your mod...


I see what you're thinking, but to make it simpler I was just planning on treating all controllable Sims in the household as "1" person, a group I guess if you want to think of it like that.

If the household owns the lot it will indeed be a residential lot, since that's the only way to own a lot ... and then the original rent/roommate system would take over. The code only checks if the lot is an apartment lot and changes it based on that.
Field Researcher
#95 Old 20th Jun 2015 at 2:56 AM
Quote: Originally posted by Arsil
I'm glad you changed your mind. I think that way it makes much more sense.

You have to consider cases like these: total rent 100
- 1 selectable roommate + 1 NPC roommate : your household rent is 50
- 2 selectable roommate + 1 NPC roommate : your household rent is 66
Not sure how to handle child-, pets and bots, but that's your problem, not mine :P

And if your household owns the lot (hopefully the game won't change the lot type to a common
residential lot in that case), then your household should pay regular bills while NPC roommates
should pay rent to your household (maybe you can re-use default existing code or slightly tweak it).

I could have told you how to change the family funds, I didn't notice you asked, I guess I was too
distracted, sorry about that.

Keep up the good work ^^

EDIT: oh, just wanted to let you know that what I wrote is just "my two cents".
It's not like I'm a control freak and I want to tell you how to make your mod...


BTW I made a new thread to discuss my "next" issue: http://www.modthesims.info/showthread.php?t=557827
Page 4 of 4
Back to top