- Site Map >
- Modding and Creation >
- Sims 3 Creation >
- Modding Discussion >
- Looking for methods to locate custom object in world
- Site Map >
- Modding and Creation >
- Sims 3 Creation >
- Modding Discussion >
- Looking for methods to locate custom object in world
Replies: 15 (Who?), Viewed: 4729 times.
#1
4th May 2018 at 6:32 AM
Posts: 52
Looking for methods to locate custom object in world
I know my objects TGIWhat I want to do is have any sim in the world run an interaction (which I can make happen) then locate that specific objects position in the world and route to it.
The problem I am having is I seem to have no way to convert the resource key of the specific object to a vector 3 position to build the route.
I've tried parsing the resource key then trying to find it with a List... I can do that, but I can't find the specific position.
Does anyone have a method they've used to establish a specific vector 3 position from a custom object being referenced from this:
ResourceKey resourceKey = new ResourceKey();
resourceKey = ResourceKey.Parse("0x025ED6F4-0x00000000-0xBA71CE5049BB0759");
Thanks!
Advertisement
Space Pony
#2
4th May 2018 at 5:32 PM
Posts: 433
Thanks: 782 in 6 Posts
Well the Resourcekey doesnt guarantee that there is an instance of the object in the world, the resourcekey itself isnt much more than a few numbers.
Whats the resource key for and how is the object that is linked to the reskey instanced (can't you look for that object instead ?).
I think we need some more information about your setup.
Whats the resource key for and how is the object that is linked to the reskey instanced (can't you look for that object instead ?).
I think we need some more information about your setup.
#3
4th May 2018 at 11:27 PM
Posts: 1,491
Thanks: 4231 in 39 Posts
If your custom object has a custom class and script. Then you could import the DLL file as a reference. Then you can search for it the same way you search for EA's object.
I may be wrong but worth a shot maybe.
I may be wrong but worth a shot maybe.
#4
5th May 2018 at 11:40 AM
Posts: 52
Quote: Originally posted by skydome
If your custom object has a custom class and script. Then you could import the DLL file as a reference. Then you can search for it the same way you search for EA's object. I may be wrong but worth a shot maybe. |
It is a cloned copy of a statue.
What i am trying to do with it is have one, and only one, instance of it in the world...
The general idea is to have a sim do something, then when they are done doing that thing, they find that unique statue and go to it, but I'm trying to do it all from within the original social interaction code
I tried a method that used this
ResourceKey resourceKey = new ResourceKey();
resourceKey = ResourceKey.Parse("0x025ED6F4-0x00000000-0xBA71CE5049BB0759");
Then List<IGameObject> statue = new List<IGameObject>();
if (statue == resourceKey)
but this didn't work...
I've also tried various methods to search for with List and then get the position of the actual object and can't seem to make that happen
I think I may be able to do all of that with GUID, but the problem I am having there is I haven't had much experience working with actual GUIDs intentionally.
I am confused as to how to determine exactly where to find the information for that particular objects GUID and i am not entirely sure how to implement it although I have seen a lot of code in IlSpy that seems to be make specifically for that...
Thanks for the response! It is much appreciated.
#5
5th May 2018 at 11:42 AM
Posts: 52
Fast additional note:
I did have the assemblies required for all that code above to work, but the primary problem is defining position of the resourceKey...
It's an object in the world, but I can't find via referenceKey alone.
I did have the assemblies required for all that code above to work, but the primary problem is defining position of the resourceKey...
It's an object in the world, but I can't find via referenceKey alone.
#6
5th May 2018 at 12:08 PM
Posts: 3,856
Thanks: 8483 in 67 Posts
Weird question maybe, but are you trying to refer to a routing slot, a container/containment slot or a VFX (visual effects) slot?
Space Pony
#7
5th May 2018 at 12:22 PM
Posts: 433
Thanks: 782 in 6 Posts
If you got the guid you could ty to use the following
Yoursatue statue = GlobalFunctions.ConvertGuidToObject<Yoursatue >(guid);
ok just read that you dont have the guid sorry.
Yoursatue statue = GlobalFunctions.ConvertGuidToObject<Yoursatue >(guid);
ok just read that you dont have the guid sorry.
#8
5th May 2018 at 12:35 PM
Posts: 52
Quote: Originally posted by Lyralei
Weird question maybe, but are you trying to refer to a routing slot, a container/containment slot or a VFX (visual effects) slot? |
I tried referring to a slot originally, but that didn't work because something was wrong with my code at first... and then, quite honestly, I think I got so befuddled trying to get the referenceKey to associate with IGameObject I completely forgot to try to reference that again.
I couldn't force (statue == resourceKey) because it kept throwing an error. I tried that every which way I knew. Be advised about that 'things I knew to do' I am a fair Frankenstein of already extant code but I am still not very great with being creative/original in code... so my understanding is limited.
I can understand, usually, what's there if it's somewhat straightforward, but I also find myself at a loss when others might zoom right through.
#9
5th May 2018 at 12:36 PM
Posts: 52
Quote: Originally posted by Battery
If you got the guid you could ty to use the following Yoursatue statue = GlobalFunctions.ConvertGuidToObject<Yoursatue >(guid); ok just read that you dont have the guid sorry. |
Ok, really dumb question with likely an extremely obvious answer... can I figure out my objects GUID with s3pe?
Space Pony
#10
5th May 2018 at 12:53 PM
Last edited by Battery : 5th May 2018 at 1:04 PM.
Posts: 433
Thanks: 782 in 6 Posts
Have you full control over the cloned object ? (so as skydome mentioned you could attach an empty script and target that one)
As for your other uestion im looking into it no promises thou
one thing since your clone inherits from the base object you could try this code
Sims3.Gameplay.Objects.Decorations.Sculpture target;
foreach (Sims3.Gameplay.Objects.Decorations.Sculpture current in Sims3.Gameplay.Queries.GetObjects<Sims3.Gameplay.Objects.Decorations.Sculpture>())
{
if (current != null)
{
current.GetResourceKey () == resourceKey;
target = current;
break;
}
}
just a quick writeup
As for your other uestion im looking into it no promises thou
one thing since your clone inherits from the base object you could try this code
Sims3.Gameplay.Objects.Decorations.Sculpture target;
foreach (Sims3.Gameplay.Objects.Decorations.Sculpture current in Sims3.Gameplay.Queries.GetObjects<Sims3.Gameplay.Objects.Decorations.Sculpture>())
{
if (current != null)
{
current.GetResourceKey () == resourceKey;
target = current;
break;
}
}
just a quick writeup
#11
5th May 2018 at 1:04 PM
Posts: 52
Quote: Originally posted by Battery
Have you full control over the cloned object ? (so as skydome mentioned you could attach an empty script and target that one) As for your other uestion im looking into it no promises thoug |
I haven't written any unique code for it yet, so no s3sa specifically for it in any package.
I can do that, but I had hoped to just use the resourceKey and derive the location that way somehow.
Might be that I am barking up the wrong, or too complicated a tree, in hopes of keeping the process slick...
I may be better off scrapping the concept and going for an object-based approach to start with.
Really do appreciate the help, especially in either finding or establishing a unique GUID. I think that will probably lead to a solution without having to go to object-based interaction... and instead just having it referenced in the social interaction.
#12
5th May 2018 at 1:06 PM
Posts: 3,856
Thanks: 8483 in 67 Posts
Another thing you could do is (And this works for all 3 types of slots), I think when you get more into object creating you'll see what is what. Routing is basically the slot the object has and need to have a sim walk towards it and start interacting with it, which is usually routingslot_1. Containment slots are for example slots where sims can put objects on the surface but also (if we take the pet beds as an example) Where the pet will finally lay down. ANd the VFX speaks for itself.
There is another way of doing it where you don't necessarily have to refer to the TGI but mainly the hash that it has. (given that it's a custom slot). Look at this reference:
( more references on slots can be found in Sims3.SimIFace.slots)
Or if wanting to try out the GUID some more as Battery suggested:
Now if we look back at the Slot Hash one, slots work with 32bits hashes. Now we all know ILspy converts hashes as decimals, which if you were to look at the slot enum, is what the = is. Let's take a look at S3PE to get more of an understanding.
if we were to open the RSLT file with Grid, expand chuckentries>RCOLentries>Routes (containers or even effects) you will see the slotname as a hash right? Use that for the slot hash. Just so you know how they're linked and it's easier to understand rather than picking the entire TGI, take the files within it
There is another way of doing it where you don't necessarily have to refer to the TGI but mainly the hash that it has. (given that it's a custom slot). Look at this reference:
Code:
public static Slot Hash(string slotName) { return (Slot)ResourceUtils.HashString32(slotName); }
( more references on slots can be found in Sims3.SimIFace.slots)
Or if wanting to try out the GUID some more as Battery suggested:
Code:
public static ObjectGuid GetContainedObject(ObjectGuid handle, uint slotNameHash) { return Slots.gSlots.GetContainedObject(handle, slotNameHash); }
Now if we look back at the Slot Hash one, slots work with 32bits hashes. Now we all know ILspy converts hashes as decimals, which if you were to look at the slot enum, is what the = is. Let's take a look at S3PE to get more of an understanding.
if we were to open the RSLT file with Grid, expand chuckentries>RCOLentries>Routes (containers or even effects) you will see the slotname as a hash right? Use that for the slot hash. Just so you know how they're linked and it's easier to understand rather than picking the entire TGI, take the files within it
#13
5th May 2018 at 1:07 PM
Posts: 52
Quote: Originally posted by clang2
one thing since your clone inherits from the base object you could try this code Sims3.Gameplay.Objects.Decorations.Sculpture target; foreach (Sims3.Gameplay.Objects.Decorations.Sculpture current in Sims3.Gameplay.Queries.GetObjects<Sims3.Gameplay.Objects.Decorations.Sculpture>()) { if (current != null) { current.GetResourceKey () == resourceKey; target = current; break; } } |
I saw code similar but didn't try it yet... I will try that when I start to rewrite it again.
This is the specific kind of thing I was hoping to get. New eyes with more experience are so helpful.
I butchered my way failingly through about 6 hours of trying to make my stuff work. So, thank you!
#14
5th May 2018 at 1:11 PM
Posts: 52
Quote: Originally posted by Lyralei
Another thing you could do is (And this works for all 3 types of slots), I think when you get more into object creating you'll see what is what. Routing is basically the slot the object has and need to have a sim walk towards it and start interacting with it, which is usually routingslot_1. Containment slots are for example slots where sims can put objects on the surface but also (if we take the pet beds as an example) Where the pet will finally lay down. ANd the VFX speaks for itself. There is another way of doing it where you don't necessarily have to refer to the TGI but mainly the hash that it has. (given that it's a custom slot). Look at this reference:
Code:
public static Slot Hash(string slotName) { return (Slot)ResourceUtils.HashString32(slotName); } ( more references on slots can be found in Sims3.SimIFace.slots) Or if wanting to try out the GUID some more as Battery suggested:
Code:
public static ObjectGuid GetContainedObject(ObjectGuid handle, uint slotNameHash) { return Slots.gSlots.GetContainedObject(handle, slotNameHash); } Now if we look back at the Slot Hash one, slots work with 32bits hashes. Now we all know ILspy converts hashes as decimals, which if you were to look at the slot enum, is what the = is. Let's take a look at S3PE to get more of an understanding. if we were to open the RSLT file with Grid, expand chuckentries>RCOLentries>Routes (containers or even effects) you will see the slotname as a hash right? Use that for the slot hash. Just so you know how they're linked and it's easier to understand rather than picking the entire TGI, take the files within it |
I have been wondering how to do this very thing for ages... I didn't understand it before but I think I am starting to now.
It makes sense to me, at least in terms of the slots, because I have actually added slots to objects before or referenced them in code. But, you know, in my frankenstien way... so, without having a clear understanding of how they were derived in the code specifically.
Thank you!
Space Pony
#15
5th May 2018 at 1:12 PM
Posts: 433
Thanks: 782 in 6 Posts
Quote: Originally posted by clang2
I saw code similar but didn't try it yet... I will try that when I start to rewrite it again. This is the specific kind of thing I was hoping to get. New eyes with more experience are so helpful. I butchered my way failingly through about 6 hours of trying to make my stuff work. So, thank you! |
i have forgotten to write the if statement heres another iteration of my attempt to help xd
Sims3.Gameplay.Objects.Decorations.Sculpture target;
foreach (Sims3.Gameplay.Objects.Decorations.Sculpture current in Sims3.Gameplay.Queries.GetObjects<Sims3.Gameplay.Objects.Decorations.Sculpture>())
{
if (current != null)
{
if (current.GetResourceKey () == key) {
target = current;
break;
}
}
}
but be aware that i have done no testing on that code i just wrote what came to mind !
#16
8th May 2018 at 9:48 PM
Posts: 52
I haven't had a chance to check this yet. I will either tonight or the next day off work.
When I do, I will mark this resolved.
I just wanted to mention that so no one thinks this thread is done just yet...
And also so, once again, thank you!
When I do, I will mark this resolved.
I just wanted to mention that so no one thinks this thread is done just yet...
And also so, once again, thank you!
Who Posted
|