View Full Version : Comm Lot Sim-Specific Summons
6th Jul 2011, 6:02 PM
I'm interested in creating an object that will summon specific sims based on their careers to the community lot the object has been placed in for the period of time the sim would be 'at work'. Basically, I want to make a police station and all the sims in the Law Enforcement career would be there during their shifts.
Inge has some OFB customer choosers and school pupil summoners, but they don't quite do what I need. Where do I start?
8th Jul 2011, 9:01 AM
Hi Phaenoh. :)
So, conceptually I think you would create an object which loops through the Sims of the hood. The loop:
finds those who are in Law Enforcement career,
gets their job level,
summons them if it is the right time to do so according to this job level (perhaps via setting them next to a pedestrian portal and fading them into existence...in which case, Smonaff's Jogging mod (http://www.modthesims.info/download.php?t=199203) may be good to look at for some information....another/better example may exist and I'm just unable to think of it at the moment...),
and then pushes an interaction onto them before proceeding with the loop (i.e. going onto to the next Sim).
The pushed interaction may actually be another loop. This time it is a series of sub-interactions (e.g. "Type on computer", "Walk to file cabinet", etc.) which are chosen however you wish (e.g. randomly) for the duration of the Sim's time on the lot. This loop would terminate when it is time for the Sim to leave; in which case, they are then "instructed" to simulate going home and are deleted/de-spawned. The nature of the sub-interactions can vary depending upon job level/rank.
For whatever use it may be for you, I've made a quick little "toy" using a version of Echo's "Making your first BHAV" tutorial test object/painting as a base, which I had been using a various testing purposes and which uses her original GUID. (I hope you don't mind, Echo. :) ). Its purpose is to show how you might go about determining the job and job level.
I imported two BHAVs from the JobData semi-globals:
1. "Test - NID Has a Job? - GUID in T[0,1]" checks to see if the Sim (using his/her Neighbor ID) has a job and returns its GUID split amongst Temp 0 and Temp 1.
2. "Function - Get Level in Temp 0" returns the Sim's job level (using his/her Object ID), but it assumes the Sim is employed (i.e. the Sim's job level is between 1 and 10).
I assumed you would only be checking for the Adult career, but the Teen/Elder check would be the similar principle.
Interaction - Come do stuff
Node 0: Simple routing for testing purposes.
Node 1: Set the Stack Object to the Sim invoking the interaction.
Node 2: Set Local 0 to the Stack Object (Sim's) Neighbor ID (This is for reporting purposes.)
Node 3: Get the Sim's job's GUID in Temp 0 and Temp 1 (If this is false, the Sim doesn't have a job.)
Node 4: Checks if Temp 0 is equal to second half of the Adult Law Enforcement GUID (If this is false, there's no need to continue...the Sim must have some other job.)
Node 5: Checks if Temp 1 is equal to first half of the Adult Law Enforcement GUID (If this is false, there's no need to continue...the Sim must have some other job.)
Node 6: Get the Sim's job level in Temp 0 (Hopefully, this won't fail since we're assuming the Sim does have a job level since we just checked for employment.)
Node 7: Set Local 1 equal to Temp 0 (Like Local 0, this is really not necessary; it's just for the purpose of string replacement/substitution in the text dialogue I have for reporting the result. But, if you want different behaviors for job levels you can performs checks on Temp 0 here to route the program flow to give different instructions for each level.)
Nodes 8-10: Dialog reporting using Local 0 and Local 1.
Try it out on some Sims. It should either report them as unemployed, as being in the Law Enforcement career (with their level/rank), or simply as "not in the Law Enforcement career."
Obviously, this isn't really in the form in which you'd be needing it, but hopefully this will give you a nudge in the right direction. :)
9th Jul 2011, 6:30 AM
I really need to figure out how you guys all learn this stuff. I still feel so lost. How do I run a neighborhood-wide check for sims? Can I use the same array tree set up I used in my phonebook? That one made an array tree, is it the same format? I started trying to make it just show me my phonebook list of sims in Law Enforcement, but I got lost in the BHAVs. :(
So I do a search on all the sims, test them for the right career track, then summon them at a time based on their shift time? Then I can have them go off and do work related things. I can handle the work stuff I think. I looked into how the Open/Close Business Sign calls the employees and it just seems that it uses the animation 'Call Over' to summon them.
I found a BHAV Schedule - Visitor - Reccuring, could this be useful for what I'm trying to do maybe? Kinda thinking out loud here, but if anyone else has any ideas to offer, I'd be grateful.
9th Jul 2011, 7:43 AM
For a neighborhood-wide scanning of Sims, you would use "Set to Next" (Primitive 0x001F) (http://www.modthesims.info/wiki.php?title=0x001F) using the neighbor id (more info (http://www.modthesims.info/wiki.php?title=Neighbor_id)). You may not necessarily need an array; you could perhaps perform the check and pushing on the spot.
This is kinda pseudo-code...
0: Any pre-loop code... (This simplified loop spans nodes 1-6.)
1: Set to Next Neighbor ID (If True, then a Sim has been found; if False, then the loop should terminate by going to Node 7)
2: Is the Sim in Law Enforcement? (If True, proceed; if False, go back to the Set to Next)
3: What is the Sim's rank? (Value is stored in a Temp for future use)
4: Check to see if the time is the right time for the Sim to show up. If this starting time can't easily be determined and returned into a value for use in a comparison (like the levels/ranks are returned into Temp 0), the arrival times may need to be hardcoded as a separate check for each level. That is, the value of the Temp would determine to what you should then compare the current time to (e.g. if Temp == 5 then check to see if the current hour is 3PM since that is when Level 5 goes to work; if Temp == 6 then check to see if it's 8AM since that is when Level 6 checks in---probably not the real hours for those levels ;) ). (If True, proceed; if False, go back to the Set to Next since the Sim doesn't need to show up.)
5: Spawn the Sim
6: Push the interaction onto the Sim based upon rank (e.g. If Temp == 1, push this interaction...if Temp == 2, push that interaction, and so forth...)
7: Any post-loop code...
The Pushing node(s) would point back to the Set to Next to get the next Sim. Without trying it, I don't know if you would need to define a starting point (see Set to Next never returning False (http://www.modthesims.info/wiki.php?title=Set_to_Next_never_returning_False)). I don't know if this is something that should be done continuously or only on the hour.
Also, since I don't know if Sims would be duplicated if told to spawn multiple times, it may be necessary to check to see if the Sim is already on the lot before spawning. I don't have time right now, but I can look to see if EA made a nice BHAV which determines if a Sim is already on the lot; else, there may be a way to make use of the fact that Sims not present on the lot do not have an Object ID (which is why the Neighbor ID must be used for the Set to Next). However, I seem to recall this is not a problem for InSim's Summoner. I think I remember accidentally telling it to Summon a Sim who was already on the lot and nothing happened (not even an error)....but I haven't looked at its code to see how it's spawning Sims.
I will look at the "Schedule - Visitor - Reccuring" BHAV and the Open/Close sign when I get the chance (I'm off to bed).
I guess I'm thinking aloud here too. :)
ETA: The spawning could place the Sim at an entry portal and handle its phasing into existence. The pushed interactions could possibly handle animating arrival (routing to some place away from the portal) and would keep the Sim busy (constantly performing time checks) until it should leave.
Hmmm...if the Sim doesn't have an Object ID before it's actually on the lot, the "Function - Get Level in Temp 0" BHAV may not work since it uses the Object ID. I will need to sleep on it and do some more thinking.... :)
12th Jul 2011, 9:45 AM
Derp. Okay, I've thought about it some more. After you've determined the Sim is in the Law Enforcement career, you might can spawn the Sim with something like "[prim 0x002A] Create New Object Instance (Neighbor in stack object, place: out of world (put new object id in Stack Object), Create object normally, fail if tile is non-empty: False, pass Temp 0 to main: False, move in a new Sim: False, copying design mode materials from object in Temp 5: False)" (Wizard code: 00000000060400000000000000000000) to spawn the Sim off-world.
You could then tell the game to place the Sim somewhere via something like "[prim 0x0010] Find Location For (Stack Object, start at Local 0x0000, normal, prefer empty: True, user editable: False, on level ground: False, with empty border: False, begin in front of refobj: False, with line of sight to center: False)" (Wizard code: 00000100000000000000000000000000; Local 0 is any object you wish to use as a reference point for its location such as if you wanted it near the Active Sim, the mailbox, or a portal).
Then you fade the Sim to be visible with something like "[global 0x02CB] Fade Object - IN (3 args: Object=Stack Object's 0x000B (object id), Target Alpha=Literal 0x00FF, Over Ticks=Literal 0x0014)" (Wizard code: 040B0007FF000714000A000001000000).
I would think the Sim would have an Object ID once it's created with the "Create New Object" so that its job rank could be determined before it is placed and made visible. If the Sim shouldn't be spawned yet, it can be deleted via "[prim 0x0012] Remove Object Instance."
I want to say that phone calls work on a similar principle in that they spawn the Sim you're calling, but the Sim actually only exists off-world....but I'm not certain.
I've looked into the Open/Close sign, I think the Employee spawning occurs via the "[global 0x0502] Schedule - Employee - Immediately (1 arg: nID=Stack Object ID 0x0000)" node which then references a BHAV called "CT - Visitor - Once" from a controller. I've looked at the controller, but don't understand everything I see. :|
24th Aug 2011, 10:11 PM
I'm working on a different project at the moment and just realized I prolly need this in that one as well. Should I use this code in a Guardian BHAV if I want to make sure only sims in particular careers can use my object, or is there an easier way that someone knows about.
vBulletin v3.0.14, Copyright ©2000-2013, Jelsoft Enterprises Ltd.