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!
Quick Reply
Search this Thread
Senior Moderator
staff: senior moderator
Original Poster
#1 Old 8th Jan 2021 at 10:03 PM
Default Active careers - increase performance with existing interactions
So I have been looking into making an active librarian career of sorts. 
From what I can see about the other active careers, there are a few ways that the career performance increases:
- Skill contributions defined in the ActiveCareers xml
- Job/tasks so like pop up opportunities, also defined in the xmls
- Specific object interactions, like using the drafting table, that have the performance increase happen in the interaction's Run method

For my idea of this career, I only want a low-key type career, with a sim just needing to perform some related interactions rather than having opportunities that a player (me at least :p) needs to pay a lot of attention to. Basically how I think Zerbu's career mod works, but actually built in to its own career, and no rabbithole necessary (and potentially custom interactions/chain of interactions).
I feel a bit lost on how to implement the librarian career anyway, with what kinds of interactions should be involved (like custom ones), but one thing that I think would great to do would be to have existing interactions that would increase performance and so I hope I can get some help on how this could work :p  Because I'm pretty sure there is no super simple way to do it? Unless there is - I would love to know!

For example, if I want reading to be something that would increase the performance, these are some things I thought of:
- creating a new ReadBook interaction class derived from the existing one that would replace Run, to make the performance increase. 
- using event listeners to see when sim is reading a book, and increase performance that way. Though I feel like that would be a bit performance heavy? And also, I don't know if it's possible to know when the sim would stop the interaction to stop increasing performance. I suppose that could be done with a custom version of the interaction in Cleanup()
- having some kind of custom object/interaction that will send a sim to do one of the defined relevant interactions after starting a performance increase. I feel like this would work the best especially as it could mean inactive sims could be pushed to do the interactions at work, though it would need to be possible to track when the sim stops doing the interactions so the performance increase would stop.

I haven't had a lot of time to look through the game code and how all the other careers do things, and I'm also a bit confused looking at it because there are just so many functions for each career, but I tihink that what I have gathered so far is mostly accurate.
So I'm really not sure about what to do about it, if this kind of gameplay could be reasonably implemented in this way, but I think it's the only way to have a lot based, non-open-hours career?
And so those are my initial thoughts on how it could work, but I would love some help in this area, if there are any smart ways to go about this :p
I think that basically, I would need a way to trigger a gradual performance increase while some process/interaction is going on, and then track when it stops to stop the increase, and so any insight on how this could be achieved would be great :p
Thanks 
Advertisement
Virtual gardener
staff: administrator
#2 Old 9th Jan 2021 at 3:22 PM
I've noticed in the case for increasing the performance, it would indeed mean that you'd have to override the original interaction. Now what *seems* to be the thing that triggers the performance for, in this case, active careers, is the function "UpdateXP()". Active careers have, which i'm sure you know , a different performace to skill up. So you could just copy-paste EA's function and add that at the bottom of the run function

Quote:
- using event listeners to see when sim is reading a book, and increase performance that way. Though I feel like that would be a bit performance heavy? And also, I don't know if it's possible to know when the sim would stop the interaction to stop increasing performance. I suppose that could be done with a custom version of the interaction in Cleanup()
This approach could also work! I think to regards to 'event listeners', it's always good to ask the question "how many sims will we have that would get this event listener in the first place?". I'm assuming 2 at the most? So I'd say that's not a bad approach  Especially if you do an if statement before calling the listener to check their careers first.

Hope this helps! 
Senior Moderator
staff: senior moderator
Original Poster
#3 Old 9th Jan 2021 at 8:39 PM
Thanks for your reply! 
The main thing I think is important is having a gradual increase rather than a one-off boost before of after they do an interaction, so I think somehow I'm going to have to incorporate a kind of alarm that will add a small amount of xp every few sim seconds or so.

Also, I have been thinking that overriding interactions isn't the best way to go, as it would making this (or any other) active career being incompatible with other replaced interactions. Originally I thought of having a work version of the interactions rather than replacing them but I don't know how practical that would be :P

With the event listeners, is it possible then to have one that's tied to an a single sim? I thought they were only like global ones, like the ones in the pure script modding tutorials. That's why I thought they'd slow the game down a lot especially if multiple careers are using them. But if they can just be for individual sims that might work out!

So I do have another idea, and that's basically by having a repeating alarm function that can be used to add xp gradually. And so it could be triggered at the start of a sim doing a "good" interaction, and then stopped when they stop the interaction. There is still the issue of how to call it, whether to do it in a custom version of the interaction (which wouldn't be as bad because I could just call it and do base.Run() rather than having to copy the whole code with an update in the looped animation or whatever), with event listeners (still the issue of when the sim stops, and maybe not all interactions have an event associated?) or another way.

I did have the genius idea of looking at Zerbu's careers mod code, and it is kind of a lot (and also because I haven't used it myself in game) so that I'm not sure how it works exactly in terms of increasing performance gradually/immediately, but it looks like it checks what the sim is doing and if they are doing work interaction then it records that. And then I think at the end of the day it will increase performance based on that?

Alternatively....
I could do something similar to Zerbu's where instead of having the increase happen during work, it would happen at the end of the day based on how many work related interactions the sim does. So if I did the third option (say a computer with an interaction to pick a work interaction, and would record that they're starting it before sending them to do it), it could just calculate it from that. But my issue with that is that it won't take into account if the interaction gets cancelled/how long they do it for, and there should really be some benefit from doing work for a long amount of time rather than just starting something.
So I'm not sure if that's really a solution or just the same problem in a different way...

Argh! I'm confusing myself! It's really a matter of performance I suppose, as I'm hesitant to start having alarms being used all over the place because I feel like that would cause issues, and if I'm keeping in mind the future of other custom active careers it's not something I really want to do. Also, I feel like I've heard of people having issues with Zerbu's mod, just because of how much is has to keep track of and so with lots of sims/workplaces that would make sense that it will be hard on the game. 

So I guess what I'm wondering is if there is a somewhat easy way to track what interactions sims are doing, or probably more likely, specifically send them to do a certain interaction while tracking when they start/stop. That's really the only way I can think of having performance increase from existing interactions, so what would the best way to do that be? :P

The other option is of course scrapping this entirely, and so existing interactions won't increase peformance. I'm not even necessarily against this idea, as for a low-key experience, it kinda works well of having a basic slow job performance, with the possibility of performance boosts/salary bonus if a more in-depth custom interaction is done like recommending a book to a sim or writing a book review or something (what do librarians do anyway :P).
But I suppose I'm also thinking in terms of generally making custom careers, and it seems a shame that the only way to increase performance easily from activities is skilling only :P

So these are more semi-incoherent thoughts from me. I think it's just going to take a bit more work than I thought it would, to work out what to do and how to do it! 
Virtual gardener
staff: administrator
#4 Old 11th Jan 2021 at 11:43 AM
I think you're thinking about this a sliiiightly too difficult (Which is fine, there are endless ways to accomplish what you want to do :p And I'm pretty sure we've all been there, so asking for feedback here is a good thing!)

But it almost sounds like you might even be in the need for injecting "librarian" interactions that are hidden for regular sims

As an example: So, say, for the bookcase, librarians are the only sims that can do the "re-arrange books on alphabetical order" interaction. You basically use this method:  http://www.simlogical.com/ContentUp..._script_mod.pdf

Basically, you inject the "Re-arrange books" interaction to all bookcases. When you write the function, all you got to do is on the 'test' function, check the sim's occupation and voila! And, of course the updateXP thing :p In fact, you can even check on run if they're doing this interaction inside a library or not. And if it's a library, then give them the XP... or you even define this inside test! Here's an example:

Code:
            if (base.Actor.LotCurrent.CommercialLotSubType != CommercialLotSubType.kLibrary)
            {
                return false;
            }

Now, in the case of, saying, the interaction 'reading' which all sims *can* do already, then you should probably override them... BUT differently though. Rather than all sims, you again check for their occupation and *then* replace the interaction how you'd usually do it  

I know it's not exactly a reply to what you wrote but maybe it simplifies stuff a bit!
Senior Moderator
staff: senior moderator
Original Poster
#5 Old 11th Jan 2021 at 1:13 PM
Quote: Originally posted by Lyralei
I think you're thinking about this a sliiiightly too difficult (Which is fine, there are endless ways to accomplish what you want to do :p And I'm pretty sure we've all been there, so asking for feedback here is a good thing!)
...
Now, in the case of, saying, the interaction 'reading' which all sims *can* do already, then you should probably override them... BUT differently though. Rather than all sims, you again check for their occupation and *then* replace the interaction how you'd usually do it  

I know it's not exactly a reply to what you wrote but maybe it simplifies stuff a bit!
Okay yes that's definitely true 
My concern about replacing the interactions is that I'm not sure how well it would transfer over to the possibility of other active careers also using the same existing interactions. And thinking about non-active sims in the world having these active careers.
Now if I did something like, replace the interaction entirely and do UpdateXP, but first do a check that they have a career that this interaction should increase performance for (I think this is like how skills do it), then that would probably work best for other active careers using the same interactions to increase performance.

But it would also mean that if an interaction is replaced with another mod, it would be incompatible :P
So that's why I was hoping there is some way to update performance externally from the interaction itself, though I'm kind of thinking that's not really possible without doing something like Zerbu's mod where the sim's interaction queue is checked frequently. And I don't know if I want to do that because of performance issues :P

So you're probably right in that overriding interactions is the way to go, and I suppose generally hobby activity interactions aren't replaced by other mods so it should mostly be okay?

And thanks for pointer about injecting custom interactions! I haven't thought too much about doing that yet, but it should be easier (I should never say something should be easy ) in this sense, because the updateXP will be part of the interaction when I'm coding it, like how the Ambitions career objects/interactions work
Virtual gardener
staff: administrator
#6 Old 11th Jan 2021 at 2:51 PM
Quote:
My concern about replacing the interactions is that I'm not sure how well it would transfer over to the possibility of other active careers also using the same existing interactions. And thinking about non-active sims in the world having these active careers.
I was actually just thinking, which does give you a good workaround, if you can create an event listener that catches whether a sim got the librarian occupation, you could always do this: (using that reading example here again):

Code:
if(base.actor.SimDescription.Occupation.GetOccupationType(Careers.OccupationNames.Librarian))
{   
    base.Actor.RemoveInteractionByType(ReadBook.NotFromInventorySingleton);
         base.Actor.RemoveInteractionByType(ReadBook.FromInventorySingleton);

   // If for any reason RemoveInteractionByType doesn't do the trick. I think this should do it too (not tested though)
   InteractionObjectPair iop = new InteractionObjectPair(ReadBook.NotFromInventorySingleton, base.Actor);
   base.Actor.RemoveInteraction(iop);   

   // If you need to add yours
   base.Actor.Addinteraction(YOURINTERACTION.Singleton);
}
Voila! That's all it should take, AND this also makes it active career friendly  
Senior Moderator
staff: senior moderator
Original Poster
#7 Old 11th Jan 2021 at 4:17 PM Last edited by zoe22 : 11th Jan 2021 at 5:22 PM.
Wait so does that work for object based interactions? So removing the ReadBook interaction only for individual sims, rather than from the book itself?
I never realised it could be done like that :P

edit: so unless I did something wrong, it doesn't seem to work :P
In fact it actually made the sim non-clickable, as in no pie menu showing up when I click on them. Not sure if that's from removing the ReadBook interaction or adding the custom one, but either way, the original ReadBook interaction hasn't been replaced...
I think really I'd have to replace the interaction properly and just have a check within it for if the actor is a librarian?
Virtual gardener
staff: administrator
#8 Old 11th Jan 2021 at 6:09 PM
Ohh no wait you're right! I actually used this code in a different project that was a social interaction. Read book obviously isn't.. That was my fault :p

But I'd just ask yourself the question, which interactions would you need to replace? and is it crucial for them to be added to the mod? That's why I usually post myself a list of things I'd like to include. 

otherwise, if it's an additional interaction just for librarians (So, something like rearranging books) then id' stick to my other reply: https://db.modthesims.info/showthre...565#post5703565
Senior Moderator
staff: senior moderator
Original Poster
#9 Old 11th Jan 2021 at 6:29 PM
Ahh that makes sense :P

Well yeah, this is making me question the practicality of doing this.
I mean generally I think that custom active careers would really benefit from being able to use existing interactions to increase performance, especially if people want to make one with minimal scripting, because otherwise it's just skills that can affect performance without writing a bunch of code for a custom object/interaction or one of those job/opportunity type events. 

As for my Librarian career specifically, I could probably get away with making a couple of custom interactions that would improve performance, instead of something like reading books (though that would be a great option if it was something that could be done in an "accommodating" way) but really this whole thought process was also keeping in mind custom active careers in general - and basically having the ability to simulate a kind of Zerbu UC situation, but without the limitations and potentially performance issues of it :P
Back to top