Quick Reply
Search this Thread
Test Subject
Original Poster
#1 Old 9th Sep 2024 at 11:08 AM
Default How to send an event in a custom interaction?
Hi! I have been wondering how exactly events work. Basically, something happens ingame (e.g. a Sim uses a magic potion), an event gets send (e.g. a magic potion has been used by the actor Sim), which triggers other stuff (e.g. the Sim is now one step closer to fulfil their lifetime wish of using 50 magic potions). Correct?

Now, if I want to make a custom interaction which triggers a specific event (for example, a custom vampire bite interactions which triggers the event of a Sim being bitten, or a custom spell which triggers the event of dark magic being used), how should I do this? I found this line of code:

EventTracker.SendEvent((EventTypeId)0x3B8E439A, Actor);

Is that... all I have to do? Just send the correct event, and the game handles the rest? Or do I need to add something else?

Thanks in advance
Advertisement
Instructor
#2 Old 10th Sep 2024 at 4:04 PM
Haven't been modding (or simming) for a very long time but I do remember having the exact same question.

This is as I recall:

Events are being hard-coded (see EventTypeId: https://www.nraas.net/community/EA-...ts-EventTypeId). EventListener "listens" to when an event is triggered, and does something. See, for example, my Subway mod. This was also why there are some unintended behaviours - e.g. if you have a Subway custom career / any other interaction that allows Sim to enter into the Subway rabbithole for other reasons than taking the Subway, the "EventListener" that listens to the event "when you enter a rabbithole" (and there is also a check to check if the rabbithole is a Subway) is still fulfilled.

I think why you see the "0x..." bit is because you use ILSpy/ any other decompiler to read the code so you cannot read the original.

Short answer, no, you should not send an event because, unless a core mod is made (and is not recommended generally unless necessary).

One simple, possible way of doing it otherwise however is e.g. adding a moodlet upon your original intended "Event". Subsequent interactions add checks for the presence of this Moodlet (e.g. an interaction only shows up when your Sim has the moodlet). You can use a custom moodlet which is far easier to make (sorry - forgot the details already).
Scholar
#3 Old 12th Sep 2024 at 3:40 PM
I think you're right --
EventTracker.SendEvent(EventTypeID.eventNameYouWant) in your code is all you need, assuming as SimsMatthew pointed out, you want any EA or mod code associated with those events to trigger. I use this all the time. I don't follow what SimsMatthew is saying about core mods. I think maybe the second half of the sentence was lost?

EventTypeId is an enum. I use VisualStudio, and with it I have been able to use the enum names directly.

If you want to make code happen on a specific event, you have to create an event listener for it. There are several tutorials that show this if you want to do it.

Echo Weaver's Simblr: http://echoweaver.tumblr.com/
A portrait in stubbornness - Playing the same legacy since 2009
Sample a Brave Legacy: http://sims3sample.illation.net
Test Subject
Original Poster
#4 Old 12th Sep 2024 at 11:13 PM
Thank you for your help!
Back to top