View Full Version : Moving an object around the lot with BHAVs
17th Jun 2010, 10:11 PM
Yes, it's me again. Despite everything else I have going on, an idea has crept into my head and it simply won't let me be. :rolleyes:
I'm trying to make an object that moves/glides a Sim around independently from what the Sim is doing while on it. I understand that there are already rideable objects, but they use NPCs. I want to avoid that route for various reasons, but if it's impossible to avoid then so be it.
I have looked into the roach object to see how it uses the Snap BHAV to move the roaches around. I have successfully achieved movement with the current/active Sim, though it is not a smooth glide. While my understanding of the roach BHAVs is not yet where I can direct the Sim to move in an explicit (not random) path*, I have at least transferred the option over and got it to somewhat work. I have not yet got it to work for the actual object, though. Hence this post.
I've used Echo's clown podium as a base because
it is most like what I'm looking for in a base object for this --- it already has a Sim snapped into a slot and having a good 'ol time doing its own thing :)
her other cart objects have trouble with residential lots and I want this to work on residential lots
as I said earlier, I'm trying to avoid using a NPC for the actual movement
I just shamelessly love that clown and how it works :giggler:
The object movement is intended to be continuous while in the appropriate context (i.e. it moves while "on" and doesn't move when "off") and is thus in a loop controlled by a boolean switch (toggled via the Pie Menu). The Sim movement is not continuous and only done by command via the Pie Menu.
There are no errors when in debug mode, so I'm not sure what exactly is wrong. I'm sure it's a BHAV issue that I'm simply not seeing. I'm afraid I've looked at this for so long that I'm making things worse or more complicated than they need to be. (I'm of the mindset to work with versions -- make a copy, make changes, and repeat -- but at the cost of drowning in a sea of various versions.)
Ideally, I want to make a gliding motion along a straight path, like you'd see with a person on a moving sidewalk in the airport. Is my approach all wrong for this?
I've attached my test podium (which has a new GUID). The other necessary and unmodified clown stuff (e.g. the actual clown NPC and accessories) is in Echo's upload (http://www.modthesims.info/download.php?t=213108) should anyone want to try running the object in-game.
*I understand that it is snapping the Sim into a slot by slot number, but I don't understand the Temp part and perhaps the logic of all that is going on in the BHAV. What is the correlation between the slot number of the lot grid? The metaphorical light bulb of understanding/epiphany won't light for some reason. For simplicity, I changed the nodes regarding effects to No-Ops. I suppose for an explicit path, I could try [global 0x01B2] "Snap - Left" or [global 0x01B3] "Snap - Right," correct?
Edited to Add: Even though I'm able to get the Sim to move, I don't think I want to snap the object the Sim's feet (I think there are only slots for individual feet) and simply move the Sim. If the Sim were to raise their foot, the object would rise with it (which would look weird depending on the animation). In short, the Sim should be on top of the object, but I guess I won't really know if this is the best approach until the object moves on its own.
18th Jun 2010, 03:41 AM
Heya MSD :)
I'm not on my home PC at the moment so I can't look at your changes (I will do once I get home!) but I'll mention a few things straight away in case they help. :)
When I first started work on moving carnival carts, I did exactly this, based on the roaches code. (Well, technically it was based on the code I made for pet chickens back for the "farmers set"... But the chicken was based on the roaches code originally. Gotta love abandoned projects! ;) ). It's been a couple of years since I worked on it, so my memory might be a bit shaky, but I recall that the roaches code worked by a nifty bit of trickery. The roaches object comes with several slots of its own. One in front, one behind, one on each side, and one on each of the diagonals. The roaches aren't snapping into world slots, they're snapping into their own slots. From memory, the TEMP value you mention is populated with a random value between 0 and 7 (inclusive), so that the roaches choose one of their 8 slots to snap into at random. To make the object always move forwards, you want it to always go to the same number. You need to change it from a random temp to a literal or constant value.
There are a few issues with this solution in general, which the NPC fixes.
The first is that if anything blocks the way of the object, even if that thing allows sim intersection, the snap won't work. It will just return false. Unlike NPCs, snapping cannot route around anything, because it's not actually routing at all. It's just taking one step at a time, right up until it hits a wall, then it keeps banging its head against said wall. ;)
The second is that, since the movement is based on snapping, it moves in a very jerky way rather than smoothly. The way to make the movement continuous is to play an animation on the object which glides from one tile to the other just before the snap happens. It's an illusion - you animate from one tile to the other, then very very quickly snap them into the other location and reset the animation to frame 0. The problem is that once you have snapped, you need to do additional processing to figure out where the object will be snapping next, and so there will be several lines of code before the next animation is called. That means that you can't use the standard animation blend-in and blend-out, and which causes a very slight jerkiness between the object arriving at a tile and then leaving it again.
The third is that the object will not turn to face the direction it is moving. When the object snaps right, it resets its orientation. Sometimes it's facing the same as the way it was before. Sometimes it's facing to the front of the lot. I can't remember what the specific rules were. For objects like roaches, this isn't a problem; they've got an animated texture so it looks like they're swarming all over the place. For an object like a cart, or something when you want the contained sim to face in the direction they're moving, this is a problem. You can counteract this a bit by using code which changes the orientation, but again this is not smooth. It will not turn around, it will just suddenly be pointing in a different direction. It's visually quite jarring when that happens. ;)
Ultimately, I couldn't solve any of the above to my level of satisfaction back when I was messing with them, which is why I went the NPC route. Not working on home lots was more a combination of laziness and apathy on my behalf (after 6 months of work on nothing but the carts, I was so over it!). The actual problem is that unique NPCs do not get saved with lots - they get destroyed on reload. Because the object is contained inside the NPC, when the NPC gets destroyed the object disappears with it.
The work around for it is to keep an object out-of-world which keeps track of the NPC and the contained object. On save, the OOW object will get kept, along with any data stored in it. When the lot next loads, it's that OOW object's responsibility to recreate the object and its associated NPC at its last known position.
I'll take a poke at your package this evening once I get home, but that might be some food for thought in the mean time. :)
18th Jun 2010, 10:32 AM
Hone now, and hey, I stand corrected. The code doesn't have them moving randomly (although my chickens code does ;) ). They're moving towards food. In the "Roaches - Move" BHAV, it's searching for objects by category (food), then calculating the distance from their current location to the location of that food. It's finding the one which is closest of all the foods on the lot, then using "Get in Temp 0 & 1 - Rel. and Abs. Direction - From (X) to (Y)" to get the direction the food is in relative to themselves. That's what ends up in Temp 0, and so that's what's selecting which slot they should snap into.
As to why the roaches and the sim moved correctly but the podium did not, the podium is almost certainly missing the appropriate slots to snap into. Given as it started life as a table, it's probably not surprising that it doesn't have slots designed to allow it to move itself. ;)
18th Jun 2010, 07:54 PM
Ah, okay. Thanks for the insights and help. :) Wow, those roaches really are sly little things, aren't they?
I've gotten the Sim to traverse in a straight path now. (For multi-tile movement, I'll need to slow it down a lot. I still have it one tile at a time, but I queued the interaction up several times ;) )
I'm thinking now that my approach is perhaps backwards. Rather than putting a Sim in an object that moves, perhaps I should snap the object onto the Sim which moves. The reason why I was avoiding that approach is that (for better or for worse) the object moves with the body slot.
Ideally, I could use "[prim 0x002A] Create New Object Instance (GUID 0x--------, place: underneath Me (walk-over-able objects only), Do not duplicate object, 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)" and some nifty BHAV magic/trickery to keep the object placed under the Sim, make it keep up with the Sim, and not leave a trail of the spawned objects. But, I'm guessing that body slots really are the only or best method for that.
There's a side of me that really hates going into detail (let alone posting screenshots of work-in-progress projects). Perhaps I'm a little afraid I'll jinx the project and it will become yet another abandoned project. But I feel this project is so doable and within reach that I should perhaps risk it (especially if it will assist in its creation).
I'm trying to make a Surfing interaction (I'm pretty sure if it already existed, I think I would have downloaded it by now ;) ). There are custom animations (which I didn't make unfortunately) that look like they'd work providing that I...
perhaps move the surfboard mesh up in 3D space to be closer to the foot
possibly switch body slots for some of the animations (or flip them) so that the Sim still appears to have at least one foot on the board while surfing and/or
perhaps can change the orientation of the object in the slot via BHAVs so that it's always facing the right way (some of the animations angle the Sim differently). Is that even possible? What about 45 degree rotations?
Yeah, the board is upside down. (That's another thing I should perhaps correct in a mesh editor.) This board is just a test board; I didn't make it. If I make my own or find a better one, some of the alignment/position issues might change slightly (hopefully for the better). I'll also need to turn off the ripple effect around the Sim's neck (though I don't know if there's a "wait, before you completely abort this interaction, run this bhav" to turn the effect back on should the user cancel the interaction). I'm trying to take baby steps and not get too excited or ahead of myself. :)
Using "moveobjects on" and the "M" key to toggle slots, there seem to be a slot under each Sim foot (not the ankle slots). I can only seem to place the board there with the manual slot toggle with the "M" key. Either I'm continuously using the wrong parameters from the container slots listing in the wiki entry (http://www.modthesims.info/wiki.php?title=Body_Slots), the slots in question simply aren't documented there, or there's something else that I'm doing wrong. (That third option is certainly always possible :giggler: ) I seem to have found the slot; it's beyond 0x13 where the Wiki's documentation ends.
With this approach though, when the interaction is done, the Sim is still considered swimming in the sea. (In one of my previous versions, the Sim would reset or something and become trapped underwater.) He/She can exit the ocean just as they would if they were swimming and they already gain all the benefits from swimming (body skill, fun, etc) since the game still views them as swimming. I don't know how yet I'm going to time it with the in-game waves or if I should try to make my own (maybe a "surfboard on a wave" object that is specially made to always fit for the animations?). I hope I'm not getting too far ahead of myself. This idea is driving me crazy because it just seems so doable! :lol:
Right now, the components are all separated. The Sim is first directed into the ocean as normal. The surfboard is one object (mainly decorative and just for the illusion of surfing) but it's put into place by my test object. My test object also moves the Sim one tile forward at a time on command; else the Sim swims around as normal if not posing. I'm using a posing object to animate the Sim (which conveniently takes precedence over the swimming animation). I'm trying to get all my proverbial ducks in a row before I combine them into an even greater headache-inducing mess a single package. :)
If you need to look at my updated test object, I can post it. (It's my first test object--your BHAV tutorial painting.) It's a bit messy, so I'll need some time to clean it up before I post it.
As always, thanks so much for you help. I welcome any more thoughts or insights you may have. :)
19th Jun 2010, 03:46 AM
Definitely sounds like an interesting idea. There's a list of all the sim body slots here:
which might be of use. Objects snap into Container Slots :)
I take it you're pretty firmly against making your own custom animations? I ask mostly because there are two common ways the game does this sort of stuff. In one case, you're better off snapping the object into the sim, the other way the inverse is true. :)
1) A custom locomotion. That's how swimming actually looks like swimming and not walking on water. If the object which starts the interaction snaps the object into the sim and pushes a new set of locomotion strings on to the locomotion stack, then the sim will use those animations instead of the swimming animations. When you want to stop the interaction, pop the surfing locomotion off the stack and the sim drops back to the standard swimming animation, which they will safely abort once they reach dry land. Custom locomotions are really just a matter of setting up a list of animations in a particular order, which you want to use in place of the standard movements. I think swimming has 8 animations which would need equivalents; swim-TurnInPlace, swimSlowTurnAndGoShort, swimSlowTurnAndGo, swimSlowTurnAndStopShort, swimSlowTurnAndStop, swimSlowShort, swimSlow,swimPose. There's a really good explanation of locomotions in the Sims2Differences document.
2) A giant object. This is technically much easier, but takes a fair chunk of animation time. You make the object really quite big, covering a dozen tiles or so. If you like, you can make those extra tiles into animated waves, so that sims actually have something to surf on. ;) The object is jointed, so that the waves are on one set of joints and the surfboard is on another joint. You snap the sim into the object, on a slot which is a child of the surfboard joint (essentially snapping the sim into the surfboard part of that object) then animate the board zooming along and around those waves (in time to the waves being appropriately placed. You then separately animate the sim using poses leaning various ways and adjusting their position on the surfboard. That technique is much closer to the way the rollerskating rinks work.
If you're going with the snap-into-slots technique, then it's not really going to be easier one way or another which object gets snapped into which other object - it's just going to take different types of changes. :) If you snap the sim into the object, then you'll need to create slots in the object to allow it to snap, and make sure that you have object animations to handle any tilting and angling the board needs to do. If you snap the object into the sim, you've got to make sure that nothing else tries to snap into that slot while they're surfing (bad things happen if two things try to share the same spot ;) ) and that the sim's movement doesn't cause the surfboard to move unexpectedly. :)
And you'll want to do a "hard-stop" on animations playing on the sim, so she doesn't have ripples emanating from her neck. ;)
26th Jun 2010, 04:57 AM
I'm trying not to become discouraged. It's funny how things always seem so simple and logical in your head and when you're not working on them...but then you load up SimPE and, well, yeeeah... *sigh* :lol:
The work around for it is to keep an object out-of-world which keeps track of the NPC and the contained object. On save, the OOW object will get kept, along with any data stored in it. When the lot next loads, it's that OOW object's responsibility to recreate the object and its associated NPC at its last known position.
Assuming this would be done with stored attributes within the OOW object, I suppose the data that would need to be stored would be: the location (no idea how to correlate a number to a specific tile on the grid...unless it's X rows and Y columns from a certain corner) the texture used (tough surfer guys don't often use those pink Hawaiian flowery surfboards :) ) the Sim using it miscellaneous data: wave size if there is variation (e.g. based on body skill?), direction if Sims don't always surf in straight lines (e.g. approaching the shore at a slight angle whenever there are swimmers in the way?), surfing mode (e.g. headed towards shore, heading to the far back of the lot to catch a wave, currently surfing), etc.
Beyond these assumptions, I'm not sure where I'd begin with this approach (i.e. what base I should use). Unless, it's like a token stored on the Sim (not that I'm a seasoned expert on tokens, but I've at least tried some things with tokens. :lol: ) Regarding the recreation, would it only be done once Live Mode is set in motion? In other words: if I pause the game before I save, reload the lot, and the game is still paused on reload...would the recreation have taken place or would it only take place once I unpaused the game? Would the surfing Sim be in some random place on the lot until snapped into to place or auto-magically in the right place on lot reload?
(I ask because I always pause before saving. That way, if it's months before I return to a lot, I can see what's going on and prepare myself before the whole house instantaneously burns down because it started Live Mode at triple speed. :lol: )
Unless it is like individual tokens, what about multiple instances (e.g. 5 Sims surfing at the same time = 5 instances of the OOW object?)
I'm starting to believe the NPC might be the best approach for a smooth gliding motion.
I take it you're pretty firmly against making your own custom animations?
For now, yes. I'm not at that point yet and probably won't be until I understand Blender beyond making a cube (which is easy since it is done automatically when the program loads ;) ).
1) A custom locomotion.
Can any Sim animation serve as a locomotion? Either this is not the case or I did something wrong when I attempted this. I've tried replacing a line of locomotions with non-locomotion animations (via treeag's "Sim Locomotor"). The Sim just defaulted to hopping like the Social Bunny. This somewhat more of "just curious" question because I'm starting to lean towards your second suggestion...
2) A giant object.
I haven't had a chance to look into the rollerskating rink as a base object yet. On one hand, it would be ideal for this interaction to not need placement within a lot (although it might be possible to make it spawn wherever there is room in the sea automatically); the surfing Sims would be ready to surf whenever.
On the other hand, it might be good to specify special areas that are suitable for surfing (e.g. not in the way of the BV ship). That might put an end to the potential issues of surfers surfing over swimmers, if swimmers know they can't swim through the surfing lane while surfing is in progress. It would simply be a row (or column depending on your perspective) of squares to make a single surfing lane. Then, I imagine I would tell the NPC to route from slot to slot in the object, pacing back and forth.
The slot-snap movement technique does fascinate me, though. Perhaps this wrong (please correct me if so), but the way I conceptualize it is that it would be as though I have the ability to stuff myself into the pants pocket of the pants I'm currently wearing....and this some how moves me down the sidewalk. If that's the case, I'm fine with that, as odd as it might be. :wtf: It's like when Bugs Bunny would violate the laws of physics and literally pick himself off the ground (floating above it) to literally carry himself elsewhere.
In testing, I've used a chair as a base object since I know for certain it can handle the push-in/out animations. I figured I can use some sort of combination of blend in/out with the animation playing direction (i.e. forward/backward) to make the illusion more complete. Since the push-in/out animations move the chair from center tile to the edge, I figured I could make it animate to look like it was moving:
1) from the center of tile A to the A-B tile border with one animation [snap-move some time here]
2) from A-B border to center of tile B with the other animation
3) repeat from center of tile B
I currently have it gliding from center of the tile to the tile's edge, then snap into the center of the next tile. Whenever I try to do what I just described to make it look smoother, it results in an even more jarring jerky motion. So, I'm much more willing to try a different approach, especially if the OOW object workaround will work. How does this sound: surfing lane (large object) + NPC (with the Sim, surfboard object, and any custom waves snapped into the NPC)?
I was thinking that the surfboard would be a separate object that would sit in the inventory. This way, it could act as a guardian bhav for the interaction (i.e. only Sims with surfboards can surf) and for other purposes (e.g. they could be given as gifts). So, the surfboard would need to either snap underneath the Sim in one of his/her slots or in a slot on the NPC underneath the slot that's holding the Sim (which may be the better of the two).
I apologize if this post has too many questions or is slightly unorganized. Even while I type, my gears are still turning and trying to reason through this. :)
Thanks again for your help and insights.
27th Jun 2010, 11:32 AM
Regarding the snap-slot movement, that's pretty much right, yes. The only thing is that it's routing slots, not container slots, so the object doesn't contain itself, it's just moving to a position relative to its original position. :)
I do see some of the issues you mention with saving generic NPC state now, given that you want them to hold more than just the current location of the sim... Certainly some of those things would be hard to keep continuous track of, particularly textures. On the NPC options list though is the remote control car. It is home-lot compatible, and while you don't get the same degree of navigational control you do with the carnival carts, you actually *do* want random movement so that's not necessarily a problem. :)
I got a little bit lost with the which of the other parts were questions and which parts were thinking aloud, so I'm just going to say "all sound like interesting ideas". ;) If some of those actually were questions, let me know which ones and I'll do my best to answer them. :)
30th Jun 2010, 08:08 AM
Sorry about my profuse display of unorganized thought process. Delphy might should program an anti-"MSD babbling" filter. :faceslap:
After some testing and reflection, I don't think that some of the things I was considering would necessarily need to be stored anywhere within a OWW object.
With the release of whatever EP or patch, items in a Sim's inventory are grouped despite recolors (i.e. 2 green apples and 3 red apples would no longer be displayed as a row of 5 apples, but as a single apple with a "x5" from which the available colors of 2 green and 3 red can be chosen).
Let's say there's a surfboard object that is more or less decorative by itself. Despite individual textures, X surfboards would be grouped or in a row in the inventory. If the presence of at least one surfboard in the inventory can be used as a guardian bhav for surfing, it may be possible to select a random surfboard (regardless of texture) from the inventory and spawn-and-snap it into place. All surfboards in a Sim's inventory would all have the same GUID, so it may choose at random anyway. So that could possibly take care of the texture issue. The texture shouldn't need to be stored anywhere out-of-world because it's set and maintained within the individual instance of the object. If I take out an apple from the inventory, it retains its texture. Thus, if Mr. Macho Surfer Dude doesn't want to use a girly surfboard, he shouldn't have had it in his possession to begin with! :lol:
I've been looking at (and consequently scratching my head over) the RC car. It does seem like it would be a good base object. From what I can tell, when the Sim initiates the "Play With" interaction, the NPC is spawned, the car snaps into the NPC, and the NPC moves around the lot. Using "moveobjects on" I placed a Bigfoot into a slot in the NPC. While he was traversing the lot via the NPC, I saved and reloaded the lot. I didn't see any problems on reload (although I haven't yet tried it without pausing before saving but I don't think that would be a problem). The Bigfoot, the RC car, and the NPC were exactly where they should be. However, at various points in its Main bhav, the NPC tests to see what is in its slot(s) before it deletes itself and whatever is there. After I canceled the the "Play With" Interaction with the Sim playing with the RC car, it deleted the Bigfoot and I had to use InSim's "Restore Family" to bring him back.
There's a bunch of stuff within the RC car NPC that I don't understand and I'm sure neither one of us has the time nor the desire for a hand-holding walkthrough node by node for each that I don't understand. ;)
I don't mean to kiss-up, but as I've said before, I love your clown (even the way it's coded is straight forward and elegant to me--I feel I understand what's going on in terms of the code). Since it's already stripped clean and doesn't seem to have any excess code, I wonder if it would be better to simply free him from his base and change his looped actions to routing to global routing slots (I've been looking at MogHughson's video demonstrations in the wiki (http://www.simswiki.info/wiki.php?title=0x002D) for which ones to use). At this point, I'm ready to at least get something pacing: go X squares forward, turn, go X squares back, turn, and repeat. From what I can tell, he is not deleted and re-spawned on lot reload. So, I don't think there would be the issue of him disappearing.
I suppose I could make the NPC spawn on top of the beach portal, right over whichever square the Sim starts to swim. When a Sim wants to surf, he/she routes directly to the ocean portal (without necessarily using the portal), performs the animation for getting into the ocean, spawns the NPC, and snaps into place on the NPC. Any miscellaneous data could be stored within the NPC.
How does all of this sound?
(I apologize if I'm still babbling.)
1st Jul 2010, 09:21 PM
I apologize for the double post.
I've been comparing the NPC for the RC car to the clown and trying to make them as similar as necessary for movement. The routing bhav (and operands) and the slot file are the same. Yet, he still doesn't want to move. He just performs my "failure test" animation meaning "[prim 0x002D] Go To Routing Slot (global 0x0001...)" is returning "False". I've attached the NPC. I use "moveobjects on" to free him from the podium and place him in a large open area, so I don't think it's anything X squares away getting in his way.
I've tried various global slots from this wiki page (http://www.simswiki.info/wiki.php?title=0x002D) as well as various True/False combinations for the "no failure trees", "ignore dest obj footprint", and "allow different altitudes" options. None of that seems to make that Sim want to take a single step in any direction.
In the RC NPC, I've noticed that there is a "Remote Control Car - Reserve Tile" object (GUID 0x8DDB5C5E) that is spawned shortly before a "[prim 0x0010] Find Location For..." and a "[prim 0x001B] Go To Relative Position (Location: Anywhere near, Direction: Facing...)" bhav are called. Is it necessary for me to to spawn something into the Global Slot and make the NPC route to it instead? Am I be missing something or do I just simply not understand how this is supposed to work?
3rd Jul 2010, 11:25 AM
Doesn't really count as a double post if (a) there's a significant amount of new information, and (b) there were several days between them. :)
I'm pretty sure the clown *does* have the "disappearing with lot reset* problem, because I remember coding some stuff into the podium to respawn him/her if he/she got deleted.
Go to routing slot can fail for a bunch of different reasons. The most common one is that the routing slot is out of bounds - it might be in the same space as an object, or in a non-traversable area like underwater. It could be that the slot doesn't exist, but that's unlikely because sims have a default set of slots, and because I think that errors rather than just returning false. The other option is that the clown actually has all his movement code stripped out, and I think that's probably the most likely. Try setting a default locomotion in the init script, even if you just grab the gliding locomotion strings from the RC car or from one of the OFB robots.
4th Jul 2010, 04:42 AM
I have nothing helpful to add to the process but I just want to say that this is one of the most awesome projects I have seen in a while and I really hope you stick with it because my neighborhood needs it! Does this kind of vapid bystander encouragement help at all?
5th Jul 2010, 04:21 AM
Echo, you're right. I misunderstood the reset problem and thus didn't do as extensive testing as I needed. I was only exiting to the neighborhood before reloading the lot, not exiting the game which does delete the clown. I've got the RC car NPC pacing back and forth in a very small radius, but I haven't completely freed it from its ties to the RC car. So, it can still do things that I don't expect or don't want. However, having banged my head against global slots repeatedly now, I'm either getting brain damage or inspiration...or a little bit of both. :lol: I feel I've actually made some form of progress!
Thanks to a hunch, I might have found a better approach. For better or for worse, each instance of the crashing ocean wave is an effect. With the help of Inge's portal revealer, I've got the GUID for the placeholder object that manages the wave effects (which is located at the far back of the lot) and the GUID for the portals along the shore. Ideally, I should be able to use "Set to Next" and "Go To Relative Position" to make movement easier with hopes of more progress. I'm trying it out on my Sim first since I can actually see what's she doing. ;)
0: [prim 0x0002] Expression (Stack Object ID 0x0000 := Literal 0x0000)
T:1 F: Error
1: [prim 0x001F] Set to Next (Stack Object, object of type: GUID 0x53351608) [this is the GUID for the wave effect placeholders]
T:2 F: False
2: [prim 0x001B] Go To Relative Position (Location: On top of, Direction: Facing, no failure trees: False, allow different altitudes: True)
T:3 F: False
3: I have the Sim dance the hula here so I know she made it. :lol: I used an Idle but I didn't like the way she froze in mid-swim. It's purely a psychological thing.
T:4 F: 4
4: [prim 0x0002] Expression (Stack Object ID 0x0000 := Literal 0x0000) [Even though it's the same as node 0, it doesn't seem to work without it]
T:5 F: Error
5: [prim 0x001F] Set to Next (Stack Object, object of type: GUID 0x132F810B) [this is the GUID for the portals that line the entire shore]
T:6 F: Error
6: [prim 0x001B] Go To Relative Position (Location: Anywhere near, Direction: Same direction, no failure trees: False, allow different altitudes: True) [this makes the Sim exit the ocean since the portal cube (which is the lead-tile, I guess) is outside the ocean --see picture directly below]
T:True F: False
It seems to work fine for the most part. The Sims enter the ocean and start to skill as they should. The downside is that I can't really control which placeholder or which portal the Sim routes to. Surely there's a fancy way to cycle to a particular instance within the "Set to Next" loop and/or only choose one that is within a certain range, right? I'm certain I don't want all the Sims to head for the same placeholder and then all the NPCs to head for the same last portal on the far edge of the lot. I tried to do a "Set to Next" to make the Sim route to a particular tile of the multi-tile portal, but that didn't work. Is that even possible, because that would be so helpful! :)
Once this movement is polished, I understand how to spawn the NPC, but I'm a little fuzzy on how I'm going to snap the Sim into and out of the NPC from within a self-interaction on the Sim. The way I imagine the interaction is this: the active Sim has a self-interaction "Surf" that routes the Sim to the effect placeholder in the far back of the lot, the active Sim spawns the NPC underneath him/her, the Sim (and eventually the surfboard pulled from the inventory) snaps into the NPC, the NPC starts to route between an effect placeholder and a portal (without leaving the ocean), and unsnaps the Sim back into the ocean when the interaction is complete or canceled (the surfboard would go back into the inventory), and finally the NPC is deleted.
Does any of this sound right? With my luck, the code is most likely within the RC car NPC staring me in the face and I simply don't see it. I know from experience that a person can spend too much time on a project. I was hoping I could make the code work and then simply transplant it into the NPC, rather than pulling out all my hair trying to figure out why the RC car NPC is concerned about the Stack Obejct's "Toddler Body Position" attribute. :blink:
lucy kemnitzer, thanks. I often make beach/tropical neighborhoods, so I have plenty of surfers with no ability to surf. I'm trying my best to correct that as it's something EA definitely should have included. As for vapid bystander encouragement, well, a project's possible abandonment is why some don't reveal what they're working on in case it doesn't work out. It may not ease my bhav-induced headaches, but at least I know I've got your moral support. :)
6th Jul 2010, 10:15 AM
Conceptually it sounds fine. :)
While you can't change the order of things that get picked up by Set To Next, you can choose which of the options to go to (if you want, it may not be enough of an issue for you to warrant the effort). If you look at the carnival cart BHAV "Get in Temp 0 - ID - Closest Touchdown" you'll see that it loops through objects by category, finding ones which are in the same room, positioned in front of the NPC, then chooses the one closest. A variation on that logic might help you control the order surfers choose their destinations.
9th Jul 2010, 04:53 AM
Thanks, Echo. :)
I may have borked it...fortunately, I made a backup in another folder. I had the NPC traveling from the square behind the effect placeholder to the square behind the last square of the portal as intended. It's just the issue of selecting reasonable destination points that's bugging me at this stage. It's a little jarring when the NPC travels well beyond a reasonable tolerance.
http://img18.imageshack.us/img18/1831/rangeo.png (http://img18.imageshack.us/i/rangeo.png/) It's been taking the path to the red square in the diagram every time. (If I'm going to use the wave effect, the Sim should remain with the wave and not go in an opposite direction. Even with a custom wave object, it would be too unrealistic to me for two waves to cross through each other, going in opposite directions, and continue going without some sort of diffusion of the two colliding forces. In short, it's worth the hassle if I don't fry too many brain cells in the process :) )
I'm trying to wrap my little head around the "Get in Temp 0 - ID - Closest Touchdown" BHAV now. :lol:
I've removed one parameter, since I won't be passing in an object category, and I have adjusted the nodes that refer to parameters.
In the "prim 0x000B] Distance..." nodes, I see "in 1/100ths tile: False" does this mean the distance value is simply an integer (e.g. value of 1 = 1 square, value of 2 = 2 squares, etc.)?
Ideally, it'd be great if the path was a straight line across from point A to point B (bright green square to bright green square in the diagram) perhaps with the occasional variation to the left or right a few squares (Point B-1 or Point B+1 so to speak...or the less happy darker green squares in my diagram). But, with the addition of this BHAV and the adjustments I've made, the NPC doesn't move from its starting position in the back of the lot. My guess is that the possible destinations it's looking for are outside its range (i.e. not close enough) and thus it's stuck in the loop. But, I'm not sure how to expand its searching radius. This is the "V1" version.
Every time I open this project up in SimPE, I must get my head around the Set Next nodes and the changes to the Stack Object ID (e.g. "why did I code this like this again?"). I'm a little outside my comfort zone, but that might be good for me. I literally did a victory dance when I figured out how to route to the square behind the last square of the portal! :D
I did get a little lost with your "Get in Temp 0 - ID - Closest Touchdown" BHAV, though. So, feeling adventurous, I tried to make my own from what I understand and looking at the "Distance Check" BHAV already in the object....aaaand I got an "Slot number out of range" error somehow. :blink: This is the "V2" version (same GUID as V1 and the original Maxis RC car NPC) with the error log.
If I can just perfect the movement, I could move on to snapping the Sim in and out of the NPC. Right now, I'm using "moveobjects on" to plop the RC car inside the ocean and directing my Sim to swim out to play with it.
I've actually considered making a replacement for the wave effect placeholder so that it will spawn the NPC automatically (hopefully so that it would be timed with the wave effect). The NPC would always be routing back and forth; the Sim would swim out to the starting position, wait until the NPC gets to the starting position, and snap into place in the NPC. The Sim would hopefully "catch" the NPC in the same sense as he/she would "catch a wave." I'd still have to prevent them from bunching up at the same effect placeholder just as I would need to prevent them from going to distant portals.
I don't know if I really want to automatically spawn the NPCs (should Sims be able to share a wave? Maybe spawn three to a placeholder, side-by-side?) or if there are any ill-effects of having the NPC always present and always routing. I'd have to update their walk-through status based upon surfer occupancy so that they won't interfere with swimmers when no one's using them to surf.
9th Jul 2010, 05:52 AM
So I'm eagerly following this. Three to a wave sounds like Steamer Lane to me! (although when the waves are good and they haven't been lately, you can get more like thirty to a wave, which is not sim-realistic).
Also, I'm sure I don't understand what you're saying very well, but if I did understand, I'd be saying that bright green to dark green or even orange square also looks more like surfing than going straight from bright green to bright green, so if it's easier to have them go that way, maybe not to fight it (I agree the red square looks wrong by physics and everything).
9th Jul 2010, 06:43 AM
I don't have the game up at the moment, so I can't comment on the exact movement of the in-coming waves. If there is any skewed movement to the left or to the right, I don't recall it being drastic (maybe a few squares?).
I think that 1-3 squares from the bright green square directly across from the starting point would be okay. But, it may be one of those things that I won't know with absolute certainty until I have a Sim on a surfboard riding a wave towards the shore.
13th Jul 2010, 01:28 PM
I haven't looked at the code, but if your NPC didn't move at all it was probably facing the wrong way. :) If you take out the part of the code which is checking what direction the NPC is facing, then it should go to the closest target it finds which, according to your above diagram, would be the very bright and happy square. :)
13th Jul 2010, 04:11 PM
Thanks, I'll try it. :) Since finishing a few things, my attention is not as divided as it once was. I'm a little glad you haven't look at the code yet, because I looked last night and saw that I had made some stupid mistakes that probably were also interfering with the movement (I didn't have time to correct them and test, though). For now, I'll leave the version I posted as a backup to before some changes that I had made.
Okay, disregarding direction, it still routes to the first portal. Using test messages, it seems that the first "Set to Next" (node 3) is returning "false" every time and thus Temp 0 gets set to Local 0x0000 every time. Attached is a version better than what I had posted earlier.
14th Jul 2010, 10:04 AM
It might just returning false at the end because it's already looped through all the ones on the lot and found none which were satisfactory - the dialog you're displaying doesn't know how many iterations have been attempted before the false got called. :)
I'm not sure why you've got that multi-part object code in there though...
I can't run this myself, because it requires more EPs than I have, but I've made a couple of changes if you want to give it a burl. :)
14th Jul 2010, 10:48 PM
As-is, it doesn't route towards the shore at all. It just gives the dialogue about node 3 returning false every time.
I had the multi-part object code because that seemed to be what made my test Sim and the NPC know to route to the last square of the portal (instead of its first square on which the yellow box with the red arrow is located). My understanding was that the code's thought process was like this: "Okay, I've found the next object of GUID such and such. Okay, you want me to find the next part of it? Okay, I've got it. Okay, you want me to route to a location relative to that part? Okay..."
Somehow, it automagically knew I wanted the sixth square and not the second, third, fourth, or fifth squares descending down the slope. I was just happy that: 1) I seemed to have figured out how to use "set to next multi-part object" on my own and 2) that the Sim was no longer exiting the ocean (using the portal) and either stopping or turning around before stamping their feet when they couldn't walk to the second square of the portal because it's in the water. (They were trying to route to a position relative to the first square and not to the second square per se.)
Adding the multi-part object node into your version, the NPC does start to repeatedly route to the first portal and give the alert that node 3 is returning false.
As expected, your code does still work for the single-tile wave effect placeholder object. I tested with 2 instances of NPCs (2 RC cars) and each would initially route to the closest placeholder. Since they both were routing to the same portal, however, both would then route to the first placeholder (since it was the closest to the portal) and would then get in the other's way (as noted by one of the RC cars being pushed up to the surface and stay there a moment or two -- they normally run along the ocean floor).
This would seem to indicate that the "multi-part object" aspect is a likely part of the issue. On one hand, it seems necessary for routing...but on the other hand, it may be an interference to the logistics/realism of the routing.
If "push comes to shove" as they say, I may look into adding routing slots to the placeholder object. (*takes slow, deep breaths until the trembling in fear subsides*)
I've never added slots of any kind to anything before, but I've shifted slots around using the XYZ translations in the CRES. So, I'm guessing I could translate them to be positioned (in effect) outside/beyond the single grid square of the object. The placeholder already has a target slot for the wave effect, so that should help a little...I think. Following this line of thought, I would likely add 1-3 routing slots to offer variety in end points (like with the green squares in my diagram).
I'm going to try routing to a routing slot in the portal first.
Well, at least it didn't go to the first portal this time. With or without the multi-tile object node, it went to some other portal that was somewhat off to the side (about the middle of the lot...not what you'd call "close" to the starting point which was on the opposite end of the lot from the infamous "first portal" it was normally routing to). I tried the other slots with the same luck. However, in other news, I may have successfully added my first slot!! :D Well, at the very least, it doesn't crash the game. ;)
The trouble is, as always, with the routing. I keep getting an error "Invalid routing slot specified (literal slotNum=X numSlots=0) Ref3" where X is the number I put as the Literal slot number. (I'm assuming I'm to use Literal since the others are variable references or the global slot). I figure I can adjust the translation value in the CRES once I get the NPC routing to the slot.
If it helps, I've attached the wave effect placeholder, the NPC, and an error log. The slot in question is "routeM." I've added "routeR" and "routeL" in the text list, but not everywhere else to officially add them as slots.
(My slot naming convention: routeM = route [straight down the] Middle; routeR = route [towards the] Right; routeL = route [towards the] Left)
15th Jul 2010, 11:23 AM
Oh! I thought you were still trying to route to individual objects, not along a single multi-tile object. :) In that case, the loop back lines are going back to the wrong node; all the nodes which point back to the "set to next guid" should be pointing at the "set to next tile of a multi-tile object" node instead.
The loop in that BHAV doesn't do any routing at all. It looks up every possible destination, one at a time, and figures out how far it is to get there from the current position. It keeps track of which one is the closest it's found so far as it goes through them. Once it runs out of nodes to check, (ie, when the set-to-next eventually returns false) then it sets temp 0 to the stack object ID of the closest one it found and returns.
15th Jul 2010, 05:15 PM
Perhaps I'm trying to do both? In effect, it's like there are lots of single beds placed side-by-side. I want to find the closest bed so that I can sit at the foot of that bed and tie my shoes. I'm not interested in what is at the head of any bed or in the middle of any bed. I would either scan across the row of beds and then focus my gaze at the foot of the closest bed or I would scan down each bed systematically looking for the closest end/foot of the bed. (Actually, I would just kneel down to tie my shoes and wonder why there are so many beds placed in such a manner. :P )
Changing the loop back lines to the multi-part code resulting in the NPC remaining stationary and the alert messages not showing up. I tried taking the multi-part out of the "Get in Temp 0" bhav, placing it in the main "move toward the shore" bhav between the "[prim 0x0002] Expression (Stack Object ID 0x0000 := Temp 0x0000)" and the "[prim 0x001B] Go To Relative Position" bhav. It followed a route very similar (if not exactly) to that of when I was trying to route to the routing slot(s) of the closest portal. That is, it consistently went to the pink square relative the starting bright green square:
...which might not be so bad, if the waves actually went in that direction. (I realize this probably makes me sound finicky, but it just looks so odd in-game.)
Now that I've gone through the process of attempting to add a routing slot, I really think that might be the best way. It could give more precise routing, I wouldn't need to fool with those darn portals at all, and it would be easier to offer multiple destinations without having to try to figure out what square is closest, second-closest and third-closest.
I'm currently looking at the code in the portal as an example of the "Go to Routing Slot" bhav. I added the slot to the CRES with the wave effect, so I assume it was the right one. I might try adding it to the other one and see if I'm more successful. If nothing else, I can say that I've at least ventured into the world of slots.
I've looked at Inge's Non-beach ocean portal, which also has 2 CRES and "route to routing slot" code. I seem to have placed the slot in the right CRES.
I may be completely talking out of my ear with this...but, I'm wondering if my routing problem with the routing slot is due to the location of the call.
In short, I'm wondering if I should have the "route to routing slot" code within the effect placeholder object and have the NPC run that code on the object. I've been calling the routing code from within the NPC once I've used the "set to next" to get the ID of the placeholder...so it could be that it thinks I'm wanting to route to a slot on the NPC. (I assume I would use a "Run Tree By Name" or a "Push Interaction"?)
19th Jul 2010, 01:12 AM
Update: It's always the simple mistakes that can make a person feel like an idiot. :lol:
Basically, I had given my replacement wave effects placeholder a new GUID. So, the NPC routing to the normal EA placeholder would then start looking for my version and apparently couldn't find it since I hadn't placed my version on the lot.
In terms of the "Go to Routing Slot" bhav, how are routing slots numbered?
The object only has one routing slot. In the CRES, I see 0x4 next to the routing slot. In the Text List, it is numbered 0x1.
The bhav "[prim 0x002D] Go To Routing Slot (0x0000, no failure trees: False,...)" works. (The NPC moves to the routing slot!!! My God, it actually works!!! :D )
So, does each routing slot number correspond to the order they were added minus 1 (such that the first = 0, the second will be 1, the third will be 2, and so forth)?
vBulletin v3.0.14, Copyright ©2000-2013, Jelsoft Enterprises Ltd.