20th May 2006, 5:47 PM
I want to do a new social where person A initiates the interaction with person B. But part of the TEST for wether person A can initate this action is are they carrying an object.
a purely hypothetical example: the interaction is a spell, that is cast by Person A at Person B, but Person A must have a "magic wand" in their hand to do this. The catch is I don't want it to test for the guid of the magic wand in their hand since I want other people to be able to make their own magic wands of various shapes and sizes and have the interaction work for those as well as long as they are cloned off the original wand, which I will make freely clonable. As well as releasing the code for the base interaction so other interactions could be made that worked in a similar manner.
21st May 2006, 12:44 AM
Well there are a few ways you can test for a general group of objects without testing by GUID. The first involves creating a category. Most groups of objects in the sims have a category number, and each object is assigned its category number somewhere in its init. You could pick a category number that isn't used, and use it for your own item(s). Then when you're looking to see if its a wand, you can just check its category number. The downside to this is that there is no system to choosing your own category number, so there's a risk of (a) picking the same category number as someone else, and (b) picking a category number that gets used by Maxis in a future EP. This technique I'd really only recommend if you're anticipating significant numbers of wands would be made (so not just 5 or 6).
A slightly more hacky way (but quite simple) of doing it would be to give your wand two or three dummy attributes, and set each of these to a very specific value (eg - attribute 1 := 266371, attribute 2 := 72943, attribute 3 := 123456). Then, in order to check whether you have the right object, you look at each of these attributes and if they're set to the right values you assume that you have the right object. Like I said, this is quite hacky. There's always the very unlikely possibility that another object might happen to have the same attribute values purely by chance, but the main issue is that this is *not* what attributes are supposed to be used for. ;)
Probably the best option is to give your object a CT function with a unique name. The function doesn't have to do much, just something like NoOp -> true, true. Now, when you're testing to see if they're holding a wand, you use a "Run Tree By Name" on the object to try and run that function. If it fails, then the object your sims is holding doesn't have that CT function, and consequently isn't a wand. If it succeeds, the inverse is true and you do have a wand. The only risk here is that someone else comes up with the same CT name for an object that the sim can hold, which is very unlikely if you name it sensibly. It's a slightly slower and more cumbersome technique, but it should work. Any object you want to classify as a "wand" would just need to have that CT function.
If none of those are any good, then I'm all out of ideas!
21st May 2006, 5:57 AM
Thank you very much Echo, those actually are a great help :)
vBulletin v3.0.14, Copyright ©2000-2013, Jelsoft Enterprises Ltd.