| Search this Thread |
|
|
|
|
szielins
Original Poster
Lab Assistant
Join Date: May 2006 |
Say I have a rug or something; I want it to react when a Sim enters the room. That is, the Sim enters the room, and a BHAV in the rug gets run. For the life of me, I can't figure out what the idiom for this is. The closest I've gotten is to set the action in the rug's Object Functions for "awareness"-- but that won't have time to react if the room is small and the Sim runs through. I can see that portals (in Function - Portal - SG) invoke the global "Trigger - Sim Enters Room" (0x021D), which itself invokes the Message primitive (0x0077). That implies there's some way to set up the rug to receive messages broadcast to all objects in the room-- via some sort of registered message handler, I presume-- but I can't find an example of anything that seems to do that. (There's a global-- "CT - Message Handler"-- it's a do-nothing, which gave me hope it was there to catch all messages not handled by specifying a "CT - Message Handler" earlier in scope-- but just creating a private BHAV with that name in the rug didn't seem to do anything. At least it never got called-- so I figure there may have to be an actual registration somewhere...) What should I be reading to become Enlightened? |
|
|
Last edited by szielins : 11th Mar 2008 at 11:18 AM.
|
|
|
#2 |
|
Inge Jones
|
You could use the door's portal function to look for a rug in the destination room, set an attribute on that rug and then notify the rug out of idle. The rug then tests the attribute and if it is set to the right value, runs its little routine. |
|
simlogical Please do not PM me with questions about modding. Please post in an appropriate forum and send me a link to the thread if you would like me to try and help. |
|
|
|
|
|
|
#3 |
|
szielins
Original Poster
Lab Assistant
Join Date: May 2006 |
That could, indeed, solve the immediate problem-- but since it'd entail either building a/an custom portal(s) to contact the rug directly or changing a fairly critical semiglobal (which I'm loath to do-- it's incompatibility-bait), that mitigates against doing it for cheapie little throwaways. (Say, a stern portrait that winces momentarily whenever an additional Sim enters the room, and changes to a broad smile only when totally alone. Doesn't give the player more than a slight chuckle, might be worth having if it's a cool portrait otherwise-- but I wouldn't want to dirty a core function with the changes necessary to get it done.) I'm hoping this is a solved-long-ago problem and I'm just ignorant. (Uh, let me rephrase that. I'm hoping it's a solved-long-ago problem in addition to my being ignorant...) I mean, does anyone do anything with 0x0077 Message and message handlers at all, or...? I've never seen it in a BHAV, but I haven't looked at very many of them... |
|
|
|
|
|
#4 |
|
Inge Jones
|
Well if the Sim is definitely going to have to walk over the rug, you could try doing something with its allow intersect function (I think there might be a walkover function too but my memory is hazy) Anyway look in the OBJf and see if there is anything you could try using. |
|
simlogical Please do not PM me with questions about modding. Please post in an appropriate forum and send me a link to the thread if you would like me to try and help. |
|
|
|
|
|
|
#5 |
|
J. M. Pescado
|
I do not believe there is any method for doing this other than bruteforcing. If you want the rug to test for overrun, you could just rig the rug, so every tick or two, the rug performs a "set to next object on tile" for every tile of itself, to see if anyone is on it, and then performing an action if a sim is detected as one of these objects. You'd then want to store that sim's ID somewhere, probably an array, so that the same sim will not trigger the object again until he leaves (and then, as part of the process, clean the array of sims that did NOT appear, because they moved away). Lots of fun, but this is the approach I'm currently using for my in-testing "GO AWAY" mat. Woah. I have another funny symbol by my name. When did THAT happen? |
|
Grant me the serenity to accept the things I cannot change, the courage to change the things I cannot accept, and the wisdom to hide the bodies of those I had to kill because they pissed me off. |
|
|
|
|
|
|
#6 | |
|
szielins
Original Poster
Lab Assistant
Join Date: May 2006 |
Quote:
Drat. That you're taking a poll-rug-tiles-every-tick approach suggests to me that perhaps I'm also not alone in not being able to get "Walk Over" in OBJf to do anything? (When I tried, the routine simply never got run under any circumstances. Even after I faint-hoped making the rug multi-tile friendly and tossing the Maya footprint...) |
|
|
|
|
|
|
#7 |
|
Echo
|
Hey ![]() Well I can't help you much with a "walk over" check. The "walk over" is actually, I believe, linked to the "can be stepped over" and only works for very small objects that are specifically step-overable. (I have a feeling that's how the death by flies is set up btw!) BUT I can probably point you in the right direction as far as running something when a sim enters a room. Whenever a sim enters a room the door triggers a message to all the objects in the room. The message is of type Const 0x012B:0x02 (0x03EB). (Yep, you were well on the right track with your first thoughts!) I've never actually done this myself so my explaination may not be foolproof, but I've seen it in a few objects so it should be accurate enough to get you started. You can set your object to receive messages by giving it a function in the "Message Handler" line of the objf. That function can take up to 5 parameters, but for your purpose you probably only really care about the first two which are, respectively, message id and the stack object at the time the message was sent. You'll need to check if the message ID is the one I said above. If it's not, just exit straight away - this is not a message that is of any importance to you. If it is, then you need to run your code. I'm not certain whether param 0x01 (the caller's stack object) is going to be the door or the sim, so you might need to check that. Either way, that much should be enough to get your object to react to a sim entering if nothing else.
|
|
|
|
|
|
#8 | ||
|
J. M. Pescado
|
Quote:
Quote:
| ||
|
Grant me the serenity to accept the things I cannot change, the courage to change the things I cannot accept, and the wisdom to hide the bodies of those I had to kill because they pissed me off. |
|||
|
|
|
|
|
#9 |
|
szielins
Original Poster
Lab Assistant
Join Date: May 2006 |
Testing seems to indicate no messages flying around as the result of entering through an arch, either-- which strikes me as odd, since it was via eyeballing an arch that I first found the Trigger thing-- but hey. At least this can handle the specific case that was annoying me-- getting something to happen even if the Sim runs through a small room quickly. As long as one remembers to document that one's widget such-and-thus only reliably detects Sims walking or running into the room via a door of conventional design, it'll have uses. Although something seems unexpectedly off about its ability to cache data and recall it correctly-- for no reason I can fathom-- the attached object at least demonstrates the OBJf Action "Message Handler" initiating code after a doors' use of the 0x077 Message primitive. It prints out its parameters for all messages it receives. Thanks to all for looking into this question! |
|
|
Last edited by szielins : 13th Mar 2008 at 02:43 PM.
|
|
|
#10 |
|
szielins
Original Poster
Lab Assistant
Join Date: May 2006 |
Subtlety: the data available to the message hander includes what door the Sim is entering through-- but at the instant the Const 0x012B:0x02 message is delivered, the Sim is not actually in the room with the message-receiving object. The Sim is still in transit-- and check that Sim's "room" field, and it'll contain the room the Sim is leaving. (The message handler is running in the transiting Sim's stack, so "My" is set to the Sim about to enter the room with the object receiving the message.) |
|
|
Last edited by szielins : 13th Mar 2008 at 10:49 PM.
|
![]() |




Twitter
del.icio.us
StumbleUpon
Google