Object Intersection
#1 13-05-2013 
so, I have this object ( a door) which is on three tiles. What I would like is to make the two outer tiles intersectable by objects but not sims, but leave the door tiles (in the middle) out of it.

Any idea how to accomplish this?
The site don't jive? PRESS F5 Flower

0
#2 15-05-2013 
I haven't tested this, so we're relying on the "I hope this works principle" Wink


Step 1: Adding a BHAV (Reference: Echo's Tutorial: Making Your First Custom BHAV)
Select the "Behaviour Function" (BHAV) files from the Resource Tree. You will likely find two functions already in your object: "Function - Init" and "Function - Main."

Right click on one and select "Clone." A new BHAV will be added an in italics. Select it and, while in the "Plugin View," change the "Filename" (e.g. from "Function - Init" to whatever you want). Switch over to the "Resource" view and change the instance to a unique number (e.g. if you already have "0x00001000" or "0x00001001", try "0x00001002"). This sets this BHAV a part from the others and you will be using this number later.

Also from Echo's tutorial, you will be making use of the Expression primitive (OpCode 0x0002). You will be using this for evaluations.


Step 2: Making the BHAV behave (Reference: Data Types for Simantics Users).

From Echo:
Quote:Passing variables to functions

A parameter is a value that you can send to a BHAV that you are calling, so that BHAV can use it like a local [variable]. For example, if you were writing a BHAV to give skill points to every sim on the lot, then you might have a parameter which said which skill type to give points to, and another to say how many skill points. That way, you could reuse that function for all sorts of different skills and values.

The function calling a BHAV can specify all of these values using parameters, and then the BHAV which is called will modify its behaviour based on them. These parameters are entered into the "operands" boxes. For any non-primitive functions, the order of the values follows one of two patterns.

The first option allows only literal values. If the parameters are being read this way, then two operand boxes represent one parameter. The first parameter goes in boxes one and two, the second parameter goes in boxes three and four, and so on. The only hitch is that the two boxes need to be read in reverse order. For example, if boxes one and two read 0x01 and 0x23 respectively, then the value of parameter one is 0x2301.

The second way to pass parameters is even more useful though, because it allows you send values from within variables. If the thirteenth operand box (fifth on the second row) is set to '1', this tells the game that instead of using two operand boxes per parameter, it should use three. In this case, the first of each set of three boxes is the "data owner", and the remaining two represent the data value. The "data owner" is the part that says what sort of data to use - literals, locals, constants, sim and object attributes, etc. The remaining two boxes specify the data value, that is, local *0x00* or, literal *0x05*. Like the first way of passing parameters, the two boxes need to be read in reverse order to get the actual value.

Using parameters in your own functions

Making your function use parameters is almost exactly like making your function use variables. You have to make sure that the function knows that it will have parameters, so you need to enter the number of parameters into the box labelled "Arg count". Once you have declared them in this box, you can use them anywhere in your code where you would use locals, but instead of selecting "Local 0x1" you would select "Param 0x1". Like locals, parameter labels start counting at 0x0.

So in your Expression 0x2 node, you will be making comparisons by Param 0x0.

I will have to do some further investigation into how to test if the object in Param 0x0 is a Sim or not. For now, just have it return either True or False to blindly allow/disallow intersection for that tile.

Step Whatever. The OBJF

Off hand, I don't know how to tell which OBJF corresponds with which OBJD, so you might have some try some "trial and error." Select a OBJF and, in the Plugin View, select the lne that says "Allow intersection." In the "Action Bhav" text box, put that instance number you gave your BHAV node from step 1. (Alternatively, you can use the Arrow button next to it to select it). Depending upon the True/False path

From the Modding InfoCenter:
Quote:0x06: allow intersection (This tree is a last resort hook for object intersection tests. If all the normal intersection tests pass, this tree is called to determine if two objects are allowed to intersect. Parameter 0 is the id of the object that is being tested.)
.

This is how the tile will run the BHAV and allow/disallow intersection.


Step ?: Update the footprint to use the OBJD

It's all here...again, thanks to Echo.




Again, I'm not 100% certain this will work.
MSD, proud to be a member of LeeFish since Jan 2013.

2


Sorry, that is a members only option