Replies: 6 (Who?), Viewed: 460 times.
Lab Assistant
Original Poster
#1 Old 20th Jan 2021 at 4:04 PM
Default About Reaction Broadcasters
I've looked around for some documentation on Reaction Broadcasters, mostly finding information on the TS4 ones. Do they work in a similar fashion in TS3? If not, where could I find some info on them?
Advertisement
Virtual gardener
staff: administrator
#2 Old 22nd Jan 2021 at 1:58 PM
Quote:
Originally Posted by CyrusBanefort
I've looked around for some documentation on Reaction Broadcasters, mostly finding information on the TS4 ones. Do they work in a similar fashion in TS3? If not, where could I find some info on them?
Heya!

It's funny that you asked, I too was looking into this yesterday :p but it's actually not that difficult.

A simple version of it would be:

Code:
      
      // Our reaction interaction class. Keep in mind that the previous interaction will get canceled and this one will be added to the queue. Sort of like 'react to fire'
        public class SeeingSomeoneJournalReaction : Interaction<Sim, LyraleiJournal>
        {
            public class Definition : InteractionDefinition<Sim, LyraleiJournal, SeeingSomeoneReadJournalReaction>
            {
                public override string GetInteractionName(Sim a, LyraleiJournal target, InteractionObjectPair interaction)
                {
                    return "Journal Reaction seeing";
                }
            // This part is super important! Here you check whether the ReactionBroadcast should be triggered for a particular sim. For sims giving birth, you wouldn't want them to react on themselves but sims that are not pregnant, then you'd want to have a special check like ' if(!a.SimDescription.IsPregnant), return true' or something like that
                public override bool Test(Sim a, LyraleiJournal target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
                {
                    if (a.SimDescription.SimDescriptionId != target.mOwnerDescId.SimDescriptionId)
                    {
                        return true;
                    }
                    return false;
                    //if (a.SimDescription.SimDescriptionId == target.mOwnerDescId.SimDescriptionId)
                    //{
                    //    return true;
                    //}
                }
            }
            public static InteractionDefinition Singleton = new Definition();
            public override bool Run()
            {
                print("Hey!! I'm writing in my journal!!");
                string socialName = base.Actor.SimDescription.Teen ? "Teen Insult" : "Shoo";
                Sim.ForceSocial(base.Actor, base.Target.CopyingSim, socialName, InteractionPriorityLevel.High, true);
                InteractionInstance entry = PickUpJournal.Singleton.CreateInstance(base.Target, base.Actor, new InteractionPriority(InteractionPriorityLevel.High), false, true);
                base.Actor.InteractionQueue.Add(entry);
                return true;
            }
        }

public class WriteInJournal : Interaction<Sim, LyraleiJournal>
{
   // Pretend everything a regular interaction needs is here....

   public override bool Run()
   {
      base.StandardEntry();
        base.BeginCommodityUpdates();
        base.Target.SeeingBroadcasterCreate(base.Target);

      // When we get to the end of the interaction:
      base.Target.SeeingBroadcasterDestroy();
        base.StandardExit(true);
        return true;
   }
}
      



        [Tunable]
      // Depending on what you need, there are a few differnet ways to set the params, but most of the time this is enough.
        public static ReactionBroadcasterParams kCopyingBroadcasterParams = new ReactionBroadcasterParams();
        [Tunable]
        public ReactionBroadcaster mCopyingBroadcaster;

       public void CopyingBroadcasterCreate(LyraleiJournal copiedHomework)
        {
            mCopyingBroadcaster = new ReactionBroadcaster(this, kCopyingBroadcasterParams, CopyingReactionCallback);
        }
   

      public void CopyingBroadcasterDestroy()
        {
            mCopyingBroadcaster.Dispose();
            mCopyingBroadcaster = null;
        }
        public static void CopyingReactionCallback(Sim s, ReactionBroadcaster rb)
        {
            LyraleiJournal homework = rb.BroadcastingObject as LyraleiJournal;
            if (s.SimDescription.SimDescriptionId == homework.mOwnerDescId.SimDescriptionId && homework.CopyingSim != null)
            {
                InteractionInstance entry = SeeingSomeoneReadJournalReaction.Singleton.CreateInstance(homework, s, new InteractionPriority(InteractionPriorityLevel.High), false, true);
                s.InteractionQueue.AddNext(entry);
            }
        }

And voila! You got yourself a simple reactionbroadcast
Lab Assistant
Original Poster
#3 Old 24th Jan 2021 at 4:43 PM
@Lyralei , thanks. Could you tell me where could I find the ghost and vampire reaction broadcasters, to get a sense of how I should do what I want to with the Reactions?
Virtual gardener
staff: administrator
#4 Old 25th Jan 2021 at 7:04 PM
Quote:
Originally Posted by CyrusBanefort
@Lyralei , thanks. Could you tell me where could I find the ghost and vampire reaction broadcasters, to get a sense of how I should do what I want to with the Reactions?
urnstone > ReactToGhostBroadcaster  ILspy should give you the correct variable if you do CTRL+F

For vampires thats: VampireOccult > kVampireReactionParams
Lab Assistant
Original Poster
#5 Old 3rd Feb 2021 at 12:55 AM
For loading reaction broadcasters, what could be done?
Virtual gardener
staff: administrator
#6 Old 3rd Feb 2021 at 11:10 AM
Quote:
Originally Posted by CyrusBanefort
For loading reaction broadcasters, what could be done?
Well from a C# perspective, (And therefore initially the game too) all we need to do is instantiate it wherever. So in my case, I got all the code shown before + I'm calling the following function inside of the Run() function of when my sim is reading someone else journal (And the owner comes in and therefore needs to freak out):

CopyingBroadcasterCreate(this);

Because we always need to create a broadcast. (Aka, instantiating it)

Now, if I'm assuming what you'd want a broadcast to be used for, I do get how interaction instantiating it won't do the trick. Instead, I'd then look at the TragicClown buff, which is a buff your sim has and if other sims are around them they'll start crying. In fact, I think you could even hide the moodlets and pull it off that way too.

Otherwise, you'll have to do some super intense programm-y things to get this to work globally, so this should do it!
Lab Assistant
Original Poster
#7 Old 3rd Feb 2021 at 2:03 PM
Good idea. I'll look into the buff.
Back to top