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!
Doing all the things, and *mostly* not failing.
retired moderator
Original Poster
#1 Old 4th Jun 2017 at 6:11 AM
Default Maxis School Friend Code Broken?
I was asking people about what they'd change about the maxis private school, and a number of people mentioned wanting the school friends their kids to bring home to actually be from the same school. This code works for adults bringing home work friends, so did they break or not finish it for the schools?

I think I have isolated the correct BHAV, but as bhav'ing isn't my specialty, I can't tell if it isn't working or why. I'm also not entirely sure this bhav ever gets called. Could someone take a look at it and see what's going on? I haven't changed or done anything to the code yet, just attaching it for convenience sake.
Screenshots
Attached files:
File Type: rar  SchoolFriendCode.rar (621 Bytes, 23 downloads) - View custom content
Advertisement
Field Researcher
#2 Old 4th Jun 2017 at 10:41 AM Last edited by clsve : 4th Jun 2017 at 10:59 AM.
The School things are handled by JobDataSchool Globals (Group 0x7FBE051B) in a Pie Menu Fuction Action BHAV: 201A Interaction - At School which call BHAV 201D Sub - Return to World which call BHAV 202A Sub - Return to World - Try Bring Friend which call BHAV 2029 Sub - Get in T[0] - School Friend

As far as I can see there is likely a Bug in node (line) 0x08 of BHAV 2029 Sub - Get in T[0] - School Friend

0x08 [prim 0x0002] Expression (Local 0x0003 := Stack Object's Job Object GUID2)
which has to be changed to
[prim 0x0002] Expression (Local 0x0004 := Stack Object's Job Object GUID2)
Doing all the things, and *mostly* not failing.
retired moderator
Original Poster
#3 Old 4th Jun 2017 at 3:16 PM
So it does in fact get called, that's good. I'll try your suggestion and see if that takes care of the issue. Thanks for having a look!
Scholar
#4 Old 4th Jun 2017 at 4:18 PM
Line 9 of the same op-code has a bug of exactly the same nature "BHAV 2029 Sub - Get in T[0] - School Friend"
It should be 'Neighbour's person data 0x005A (Job Object GUID2) == Local 0x0004'
Doing all the things, and *mostly* not failing.
retired moderator
Original Poster
#5 Old 4th Jun 2017 at 10:11 PM
So I think I made the two changes you both suggested, then I tested it out. My public school kid eventually brought home 2 private school playable kids - rather than bring home public school townie kids (I checked, I have 4 public school townie kids in my test hood).

I've attached the package I was testing and screen shots of the whole thing so you don't have to download if you don't want. Is there something in the code that puts playable kids with the wrong school before townies with the right, or was that just luck? Maybe I messed up something somewhere?
Screenshots
Attached files:
File Type: rar  SchoolFriendFix.rar (626 Bytes, 10 downloads) - View custom content
Scholar
#6 Old 5th Jun 2017 at 11:46 AM
After a more careful look at it there's a lot more wrong than that.
In lines 6,7,8 and 9 it should be testing for 'person data 0x006B (School Object GUID 1)' and 'person data 0x006C (School Object GUID 2)' instead of 'person data 0x0059 (Job Object GUID1)' and 'person data 0x005A (Job Object GUID2)'.

As the default code is if the sim does not have a job then the locals would default to zero, only then will other sims test true if they don't have a job. If either have a job then it will never test true which may not be a bad thing. After fixing the faults it may be a good idea to add a line or two at the beginning to prevent bringing a friend home if the sim does have to go to work after school.
Doing all the things, and *mostly* not failing.
retired moderator
Original Poster
#7 Old 5th Jun 2017 at 4:00 PM
After some more digging, I've found that twoJeff's school bus dialog code is WAY better written, so I'm starting from there instead now, but upon testing, it still lets kids from the wrong schools come home. I've tweaked it a tad, but that wasn't sufficient. I have no idea what is going on.
Attached files:
File Type: rar  School bus - bring friend dialog-edit.rar (20.4 KB, 17 downloads) - View custom content
Scholar
#8 Old 6th Jun 2017 at 5:55 PM
This is from A&N, I haven't tested it in M&G but I'm quite sure I've made it compatible to M&G.
https://app.box.com/s/rk5xk2p6fzk6awcuvj8ni3x7h6zoa3hb (BringFriendFix.zip)
The first line ensures teens wont bring a friend home if they go to work after school that day. The second line just prevents friends from bringing more friends, in A&N if children/teens invite a friend for a sleepover on a school night then that friend will go to school with them the next morning.
Doing all the things, and *mostly* not failing.
retired moderator
Original Poster
#9 Old 7th Jun 2017 at 6:23 AM
Oooh! That does work! After initially wondering why on earth this one sim wasn't getting suggested to come home from school, I realized he had a job. After telling him to quit, yours works as expected. (I have M&G so I can also confirm compatibility.) This is really exciting now!

I've taken your BHAVs and spliced them into TwoJeff's dialog version, so now not only do just the right kids come home, but I also have the option to say no, and all the good fixes are included, like walking away from the bus before looking at your report card so your sister can get off the bus already.

The only two things left I have found that I'd like to change are having the school friend come home dressed in whatever school uniform they are supposed to be wearing - like the adult work friends do. I tried using the adult job code but that wasn't working at all, then I tried writing it in myself and that didn't work at all either. I don't want to hardcode it to the school uniform's GUID, because I have a few different private schools that use different uniforms, I just need it to pull whatever the school's official uniform is.

My second problem cropped up from your code, Chris, and I don't know how to put it back, but all the school friends think they are being invited over as house guests, and they get mad when I don't let them sleep. It is handy that friends can't invite extra friends over, but is that where that problem came from, or is it slightly different?
Attached files:
File Type: rar  BringCorrectSchoolFriendsDialog.rar (20.7 KB, 16 downloads) - View custom content
Scholar
#10 Old 7th Jun 2017 at 1:57 PM
The problem of friends being invited to stay must be something separate, after the friend has been chosen they are pushed to perform 'Interaction - Friend - Come Home' (instance 0x00002028). Line 0xB(11) (Line 3 in the file below) of that op-code clears any invited to stay flags so it must be something that's occurring later.

The following should dress private school students friends in the private school uniform, it uses the default GUID so any default replacement would be used but I don't understand that you have more than 1 private school. The default school doesn't have the outfit GUIDs in constants the way jobs do so you won't be able to have multiple outfits and retain compatibility with the default code. If you are adding the outfit GUIDs into the constants then replace the literal values in line 1 with those constants but your mod will have to include those constants for the default school.
https://app.box.com/s/3mdiszp0nyuh1oyptzbl54h7k1bzdiye (FreindDressCorrect.zip)
Doing all the things, and *mostly* not failing.
retired moderator
Original Poster
#11 Old 7th Jun 2017 at 4:55 PM
This is so frustrating that I'm not better at BHAVs. I've spent the entire morning trying to swap it over to using constants and I can't get it to work. What am I doing wrong?!?

Attached are pics of before and after using custom uniforms. The way that works is hard coding the GUID into it, but that won't work with the friend code we've been working on. I looked up how jobs handle it and tried to copy from there but it's not working. (uniform guids are in BCON 102E, lines 2 and 3 - just like adult job uniforms)

When I try it in game I get a jump bug, then testing cheats tells me Stack Number Out of Range.
Screenshots
Instructor
#12 Old 7th Jun 2017 at 6:14 PM
Quote: Originally posted by Phaenoh
When I try it in game I get a jump bug, then testing cheats tells me Stack Number Out of Range.


You are using two locals (0 and 1) but the Local Var Count box (over on the right) is set to zero, it needs to be 2

Just call me William, definitely not Who-Ward
Doing all the things, and *mostly* not failing.
retired moderator
Original Poster
#13 Old 7th Jun 2017 at 8:44 PM Last edited by Phaenoh : 7th Jun 2017 at 9:01 PM.
William, Thank You! That was the missing piece. I fixed that, then diligently copied over the adult dress for work code, tested it out and it worked! My kids all spun into their red school uniforms! Then when they came home, their friends were wearing the same red uniforms! YAY.

Now my last bit of weirdness is that house guest sleepover issue...
Attached files:
File Type: rar  Phaenoh_CorrectSchoolBringFriendsDialog.rar (21.0 KB, 22 downloads) - View custom content
Doing all the things, and *mostly* not failing.
retired moderator
Original Poster
#14 Old 8th Jun 2017 at 10:49 PM
After further testing, I figured out what the problem was. Nothing was wrong with the code, but instead, how I was testing. Originally I was using sethour to advance to whenever the bus was coming next, usually resulting in an overnight skip, and that's when the friends got mad. If I instead just fast forwarded to the next day, the kids left in the evenings like normal.

Now I just need to get all my ducks in order and it's ready for upload! Thank you again, bunches, Chris and William. You two are invaluable. <3
Doing all the things, and *mostly* not failing.
retired moderator
Original Poster
#15 Old 14th Jun 2017 at 4:32 PM
So I got bold after getting the outfits to use BCON values instead of being hard coded into the BHAVs, and I thought I'd give that a try with the school bus. The idea being that a military school could send the humvee instead of the bus or some such.

Buuuut, I've broken it in a really interesting way. Now for every student, an individual vehicle shows up (it does happen to be whatever GUID I put in the BCON, so that part works), and only the first student gets Go to School pushed on them, but then it falls out of their queue as they can't get on the bus/in the car. TestingCheats revealed no errors. This leads me to believe that I'm missing a BHAV somewhere that is still using the school bus GUID, but I've combed through the full list of JobSchoolGlobals three times now, and I think I've gotten all the ones that listed the school bus by GUID. My other idea is that I've screwed up a Set to Next somewhere. Any thoughts?
Attached files:
File Type: rar  Phaenoh_SchoolBusTweaks.rar (21.3 KB, 9 downloads) - View custom content
Scholar
#16 Old 15th Jun 2017 at 5:11 PM
Without looking at it (I will look at it) I can tell you that the school bus is recognised by only it's GUID so many times I considered it not viable to have alternatives. However to have different colour buses for different schools is very, very simple. The following has six different colours, it will use the default colour for the public school and any schools that have not been set to use an alternative colour. It uses a white bus for the default private school. The bus colour is set in the constant 0x102C:0x00 which is an otherwise unused gardening skill constant so it will exist in every school to avoid invalid constant errors and is in the range of 1 to 7.
https://app.box.com/s/4ryop53iqmuc0uugjr06rn846hkalqet (MoreSchoolBuses.zip 5kb)
Note the file is tiny because the yellow colour on the school bus is a straight colour so we don't need to use a texture, just define a colour in the material definition.
Doing all the things, and *mostly* not failing.
retired moderator
Original Poster
#17 Old 3rd Jul 2017 at 5:21 AM
My crazy life has settled back down for a bit. (I was moving on the 17th, then house sitting, then helping my sister while she was in the hospital, but now I'm back to having sim time. Yay!) Did you ever get a chance to look at the school bus stuff?

The color file does look promising, but what I'm really after is the ability to have different cars, like the HMV for a military school, a town car for a fancy school, a minivan for a special ed school, and the helicopter for a really exclusive school. I'll take another pass at my file in the morning. Maybe after being away from it for two weeks I'll see what I've missed.
Scholar
#18 Old 3rd Jul 2017 at 4:45 PM
No I haven't really looked at it but line 4 of 'Function - Create Car' is to prevent creating another bus if one already exists. If you change that from 'Set to Next (Stack Object ID 0x0000, object of type: GUID 0xAC034E2F)' to 'Set to Next (Stack Object ID 0x0000, Object of type GUID in temp 0/1)' it should prevent creating a second car. However you may also need to add a section to handle the default bus for schools that don't have a vehicle assigned.
Doing all the things, and *mostly* not failing.
retired moderator
Original Poster
#19 Old 4th Jul 2017 at 4:24 AM
So I combed through the semi globals again and found 2 more BHAVs that list the school bus by GUID, so I added them in. So far I've found the school bus being referenced by three different GUIDs, I don't know why, but in each instance I've tried to replace it with the BCON. I've looked at that line 4, but can't figure out what I've done wrong. It still spawns one vehicle per student, and while I can tell each student to go to school in their personal school bus, the interaction drops out of their queue once it's next. I think it might have something to do with the Arg and Local Values, but I'm still fuzzy on how those work.
Attached files:
File Type: rar  Phaenoh_SchoolBusProblems.rar (65.4 KB, 4 downloads) - View custom content
Scholar
#20 Old 4th Jul 2017 at 2:48 PM
I took a proper look at this today and it is very complicated. You're going to have to use two GUIDs for the vehicle, one to create it with and another to detect it's existence. That is because the main car Object Data has no tile associated so once the vehicle is created it that item ceases to exist so we need to check for it's existence by it's lead tile object. After the vehicle has been created we then locate/use it by the car category (different to the ownable car category) and since the school bus has no category but a totally different menu using the car category allows use to use the correct menu item.

Also all default career vehicles don't allow children to use their menus so you will have to override the menu on any vehicle you use. Most don't have child animations and the doors don't animate as children get in or out. Career and Service vehicles don't have the same bones as ownable vehicles as they don't need to turn into or out of driveways so animations from ownable vehicles may not work.

I updated the MoreSchoolBuses.zip (link above) to use the HMV for the default public school (it includes the HMV menu override), and still a white bus for the default private school so you can see/work out what changes are needed. Note that the constant 0x102C:0x00 (bus colour) must be zero if an alternate car is used, you can use either an alternate car or alternate colour bus. That zip also includes CareerCars.package which is not for the Download folder but contains the primary and lead tile Object Data and pie menus (updated for children) from the career vehicles to make the GUIDs and menus easy for you to locate. For vehicles that don't have multi tile (Captain Hero Flyaway) just use the only GUID for both.

I also moved the school uniform GUIDs to the constant table instance 0x102C because those constants exist in every school both default and custom so that'll prevent errors and avoid the need to explain how to update existing schools to be compatible later.
Doing all the things, and *mostly* not failing.
retired moderator
Original Poster
#21 Old 4th Jul 2017 at 8:06 PM
Thank you for digging through this and explaining what I've gotten myself into. I was really hoping after doing all the coding tweaks, it could be as easy as just swapping out a GUID for the end user if they wanted to use a different car, or a custom car (like the uniforms turned out to be). That doesn't sound like its going to be the case at all.

I tested out the files and the doors don't open for the kids with the HMV (as you mentioned), but they did slide in and out. As animations are another area that I'm clueless with, I think it would be wisest for me to stop digging while I can still get out of this hole. I'm going to work the HMV into my military school, but I think I'm just going to leave the regular school bus in place for my other schools. Judging from the full picture now, the amount of effort won't be worth the gain.

As for the school uniforms, I didn't make up 0x012E, every cloned school has that and it's just not being used, so my stuff shouldn't break other older schools. It has no values in it though, so would that be a problem? Is no value the same as 0? It's also exactly how the jobs deal with adding uniforms, so I won't need to write any new tutorials on how to do it, just a small mention somewhere.
Scholar
#22 Old 5th Jul 2017 at 2:08 PM Last edited by Chris Hatch : 8th Jul 2017 at 4:04 PM.
Unfortunately the constant table having no values will be a problem, that will throw an invalid constant error.

Edit:
I just updated the MoreSchoolBuses.zip (link above, now 39kb) to include a 'military colour' for the school bus as well as a child animation fix for the HMV. The CareerCars.package also includes the child animation texts for most default career vehicles that you may like to include should you choose to use them. Noteworthy vehicles that work OK include the limo and executive helicopter.
Back to top