Hi there! You are currently browsing as a guest. Why not create an account? Then you get less ads, can thank creators, post feedback, keep a list of your favourites, and more!
Lab Assistant
Original Poster
#1 Old 16th Nov 2014 at 8:10 AM Last edited by CrazySheep808 : 17th Nov 2014 at 6:07 AM.
Default How do XMLs know which object they apply to?
Hi guys

I'm working on a mod for less frequent fires started by fireplaces (looked for one, couldn't find one - if anyone knows of one I'd appreciate it, but I still want to know how to do this stuff) - looking at the options, I reckoned the best way to proceed was to make fireplaces "ask" to start a fire less often. The EA time is every fifteen sim minutes, I'm changing it to 120 mins for my game (am prepared to upload once it's done if anyone's interested).

So I exported the XMLs from GameplayData, and changed the ask time to 120 mins. This is all good for the fireplaces which came with the basegame or expansions, but I cannot for the life of me find the XMLs for the store content installed via the launcher. I also have some store content installed in package format (down with that launcher!) and the packages don't have a _key - so, no names. I can't find anything!

I would therefore like to know if a) anyone knows where the store XML files are (specifically, for the fireplaces), b) if it's possible to link two or more objects of the same type to the same XML (so I only have to change one value to create flavours that apply to all fireplaces), and c) how XMLs and OBJDs and everything else all link up anyway (because I can put the OBJD bit in a different file and it still knows which object to apply to!).

Cheers
CrazySheep808

Edited to add: if anyone else is looking for this info, try here: http://modthesims.info/t/469283

Everything is ok in the end. If it's not ok, then it's not the end.
Advertisement
Inventor
#2 Old 16th Nov 2014 at 10:03 AM Last edited by Arsil : 16th Nov 2014 at 10:44 AM.
Quote: Originally posted by CrazySheep808
I would therefore like to know if a) anyone knows where the store XML files are (specifically, for the fireplaces), b) if it's possible to link two or more objects of the same type to the same XML (so I only have to change one value to create flavours that apply to all fireplaces), and c) how XMLs and OBJDs and everything else all link up anyway (because I can put the OBJD bit in a different file and it still knows which object to apply to!).


Hello!

a) Not sure about sim3packs, but usually in a .package file you'll find all resources
(_XMLs comprised) a store or custom object uses.

b) Not sure if I understand what you are asking. If the objects are of the same "type"
(they have the same script class/string as defined in the OBJK resource) then they
can share the same tuning XML (the instance number of the XML must be the
hashed namespace+className of the object it is referring to). Objects of the same
"family" may have a master XML resource that defines their general behaviour.
Don't know if fireplaces do.

c) for the XML I answered in the previous point (but there are many types of XML,
they are not used only for tuning scripted objects). How are all resources linked
together? I guess I'm still learning that myself, so this can be useful to me too ^^

Please don't take for granted my answer, it may contain a lot or mistakes and imprecisions
and I'm definitely forgetting/omitting a lot of things.

_KEY resources are used to associate a understandable and meaningful name to an
instance number (often the instance number is the hash of that name, but it's not a rule)
and is used mostly for the benefit of users, the game doesn't give a damn about those names.

Some resources are linked to others just by having the same instance number (thumbnails,
THUM, to say one, just have to have the same instance number of the OBJD to be associated with it).

The OBJD is, I think, the main resource of an object. It has the same instance number of the OBJK
(not sure if that is really necessary or just a convention, since the OBJD has a field to
specify the OBJK). The OBJD contains references to ... ah... I don't really know... object's presets
(XMLs?), patterns (uhm... no, patterns are not resources), and to more things (I'm not expert of that).

Most visual/graphic data is kept together by a VPXY resource, it contains references to the
meshes (MLODs and MODL), footprints (FTPT), rigs (_RIG), slots (RSLT), lighting data (LITE)
and other resources I know little or nothing about (MATD, TXTC?, etc).

I'm at a loss right now about how the OBJD is linked to the VPXY...
EDIT: Got it! Trought the OBJK.

The MODL/MLOD have references to other MLOD (there are many, used if you are looking
at the object from afar (less defined) or close up (more defined mesh), and used also to
create the object outdoors shadows), they also have references to textures resources
(_IMG) and... don't remember what else.

JAZZ scripts and CLIPs (animations) aren't tied to specific objects, they are added to the heap
and referenced directly by the programming code. Audio resources (_AUD, AUDT and maybe more)
too but may be referenced by CLIPs also (to specify what sounds to associate to an animation).

STBL resources, that contain translated strings, are linked together by the instance number
(the first two characters are used to identify the language, 00 is english) and an individual
string is referenced directly by the programming code or by the OBJD (for the object's name
and description that you see in the Buy/Build catalog).
Lab Assistant
Original Poster
#3 Old 16th Nov 2014 at 10:51 AM
Thank you, that's a ton of very useful information!!!

So, the OBJK is like the glue that holds everything together?

I'm not entirely sure what the hashed namespace+className means... hashed? It does sound like I can create a master XML.

I just found a fireplace in a merged package. I used S3OC to clone it, and there's no XML in the resulting package?!

Everything is ok in the end. If it's not ok, then it's not the end.
1978 gallons of pancake batter
#4 Old 16th Nov 2014 at 11:32 AM
Quote: Originally posted by CrazySheep808
So, the OBJK is like the glue that holds everything together?
No, that's the OBJD. It references the OBJK. The latter defines what class/script the object should use.

Quote:
I'm not entirely sure what the hashed namespace+className means... hashed? It does sound like I can create a master XML.
In S3PE click on Tools and select FNV Hash. One of the fireplaces has the full class name Sims3.Gameplay.Objects.Fireplaces.Mimics.FireplaceContemporary for example. You can see that in the code with a decompiler like ILSpy and in the OBJK of the related object. If you hash that name (FNV64) you get 0xF190522B77612ABC and that is exactly the instance ID of the tuning XML for that object. There is no hard reference to that tuning file anywhere, it gets looked up by that instance ID. Or, actually, when the game loads the XML resource, it checks if any class in the loaded script resources (S3SA) matches the instance ID and applies the values if it finds a match.

Bottom line is, no, you can't make a master XML with just XML resources. You can however make a script mod that applies tuning from a custom XML to all fireplaces in the game. You can check my Same Energy From Every Bed mod if you decide to go that way.

Quote:
I just found a fireplace in a merged package. I used S3OC to clone it, and there's no XML in the resulting package?!
s3oc only clones the object itself, not the script or tuning or anything like that.

If gotcha is all you’ve got, then you’ve got nothing. - Paul Krugman
Lab Assistant
Original Poster
#5 Old 16th Nov 2014 at 11:52 AM
So, correct me if I'm wrong, but the game finds an XML, checks its instance ID, which is linked to a script, which is linked to an object. So theoretically it would make more sense to write a script mod rather than hunt down the errant XMLs, since I can get the instance ID from the OBJKs anyway. If that makes sense!

Or, we start with the glue...the OBJD. The OBJD has the same instance number as the OBJK. The OBJK contains a name, that when converted, gives the instance number of the XML. But it is possible to force the OBJK to use a different XML using a script mod.

What if there's an object with no XML matching? Or an XML with no corresponding object?

(By the way, I just have to say, every one of my sims has access to one of your Scribbling Pads..!)

Everything is ok in the end. If it's not ok, then it's not the end.
1978 gallons of pancake batter
#6 Old 16th Nov 2014 at 12:48 PM
Quote: Originally posted by CrazySheep808
So, correct me if I'm wrong, but the game finds an XML, checks its instance ID, which is linked to a script, which is linked to an object. So theoretically it would make more sense to write a script mod rather than hunt down the errant XMLs, since I can get the instance ID from the OBJKs anyway. If that makes sense!
In a way, yes. In the scripting world you don't need to bother with that, though. You can just query the game for all objects that are fireplaces and apply your tuning to the individual objects. That's what I did in the bed/sleep mod. Or if you feel comfortable with Reflection, you can search for all classes that implement the fireplace base class and adjust the tuning directly. That would be more involved, though.

Quote:
Or, we start with the glue...the OBJD. The OBJD has the same instance number as the OBJK. The OBJK contains a name, that when converted, gives the instance number of the XML. But it is possible to force the OBJK to use a different XML using a script mod.
No, that is basic behavior that can't be altered.

Quote:
What if there's an object with no XML matching? Or an XML with no corresponding object?
If there are [Tunable] values in a class, but no related XML, then the default values defined in the class will be used. If there is no class for an XML, then the XML will just sit around having no effect at all.

If gotcha is all you’ve got, then you’ve got nothing. - Paul Krugman
Lab Assistant
Original Poster
#7 Old 16th Nov 2014 at 10:08 PM Last edited by CrazySheep808 : 17th Nov 2014 at 7:15 AM.
Quote: Originally posted by Buzzler
In a way, yes. In the scripting world you don't need to bother with that, though. You can just query the game for all objects that are fireplaces and apply your tuning to the individual objects. That's what I did in the bed/sleep mod. Or if you feel comfortable with Reflection, you can search for all classes that implement the fireplace base class and adjust the tuning directly. That would be more involved, though.


Oh, ok, thank you. So how do I query the game for stuff? Can I just search the delta and fullbuild packages?
And how do the classes work? Is it the values between the dots in the name in the OBJK (eg sims3.object.fireplace.whatever)?

Edit: found this... http://modthesims.info/t/469283#step6
I still don't really understand the "mimics" class. If the name is "Sims3.Gameplay.Objects.Fireplaces.Mimics.Fireplace[WHATEVER]", which of the four mimics does it use and how does it know?

Everything is ok in the end. If it's not ok, then it's not the end.
Inventor
#8 Old 17th Nov 2014 at 10:30 AM Last edited by Arsil : 17th Nov 2014 at 2:42 PM.
While you wait for more competent answers, settle for mine.

This post is part of the following series:
- "Too Much Information"
- "Reading more that 3 lines from you is a pain"
- "Why don't you shut up and let someone else answer?"

I don't mind answering because it can be useful to myself too as a review,
but if you're interested in these things, I suggest to search for a good OOP
online tutorial or something like that. Better have a little bit of background
information before start playing with the code of TS3.

Welcome to "Arsil's Programming 101" ^^

I think that with "query the game stuff" he meant through the code,
directly with the programming language (C#). I'm assuming you are
not familiar with coding (forgive me if I'm wrong), so, using a pseudo
programming language, with something like:
Code:
for each object of class fireplace
  change setting X with Y


I'll try to explain how classes work, but keep in mind that I'm not a professional
programmer, I don't have much experience with OOP (Object Oriented Programming)
and I'm not a native English speaker... but I'm sure you've guessed the latter already ^^

Classes are organized in a hierarchy to facilitate their understanding and
management, to modularize their functions, to have general classes and
specialized classes. Speaking of game objects, the class GameObject
is the root or the top level class. Now keep in mind that it is an abstract
class, so you'll never see an instantiated object that is actually just a
GameObject, this is used as a base from which every other class (related
to an object) is derived and it defines and contains all the features and
properties that are common to all game objects. This mechanism is called
heredity and is very useful because you can start with a very generic class
and, as you create new classes that derive from it, and new classes that derive
from them (and so on), you can create very different, specific and specialized
objects that inherit from all their "ancestors".

Don't think at the hierarchy as a family tree, it's actually a graph (I don't want
to get too technical, mostly because I'm not able too), this means that "links"
between classes are way much more complicated: a class can be derived
from any number of other classes (of course there's the risk of having conflicts
if you aren't careful) at any level of the hierarchy.

Let's make a few examples:

- class fireplace_Bubba (FB) is derived from (or inherits from) class fireplace,
this means that FB is a full fledged fireplace, but a fireplace is not a FB.

- class fireplace in turn is derived from class GameObject (only in this example,
it's not really derived from it, not directly), this means that a fireplace
is a GameObject, but not vice versa.

In this way, you don't have to define/describe each class deeply, especially if
they are very similar or share common data/properties, because the class will
have all the characteristic of the classes it derives from and with a "cascade effect":
class fireplace_Bubba is a GameObject (obviously the opposite is not valid,
a GameObject is not a fireplace_Bubba, let's not joke about that! K? K).

Now, what have things like "Mimics" or "Sims3.Gameplay" have to do with all this?

Well, these are not classes, they are just names that form a so called namespace
that is useful to keep classes organized in sets and subsets. This comes especially
in handy when, in the code, you want to to refer to a certain class without using
every time its full name (ok, that's probably not their best quality but is the only
one I can come up with ATM). Take this for example:
Sims3.Gameplay.Objects.Fireplaces.Mimics.Fireplace_Bubba
The bold part is the name of an actual class, all the rest is the namespace.

This means that the namespace "Sims3.Gameplay.Objects" is the set that
contains all fireplaces along with a bunch of other different objects, while
"Sims3.Gameplay.Objects.Fireplaces.Mimics" is one of its many subsets
(since they share the first part of the namespace) and only contains fireplaces.

When you create/declare/define a new class, you choose what its namespace is
(mmm... maybe it's more clear to say "you decide in what namespace put it in").
For convenience and convention, you usually put it in an already existant
namespace that contains other similar classes, so if you were to create a
new kind of fireplace class, a good choice would be to use:
Sims3.Gameplay.Objects.Fireplaces.Mimics

It's worth noting that modders usually put their classes in different namespaces
than the "official" ones to avoid the risk of creating classes with the same name
of existing ones (or that could have been added with a new patch/EP/SP/storeItem).
In fact, you can have two classes with the same name and that don't conflict with
each other if they belong to different namespaces:
- Sims3.Gameplay.Objects.FoodObjects.DriedFood
- Sims3.Gameplay.Objects.Arsil.DriedFood
the two classes have the same name (DriedFood) but don't conflict with each
other because the namespace is different, so you can tell with no ambiguity if
you are referencing one or the other. Modders should also care about using
unique namespaces to avoid the risk of conflict with other modders' classes,
so they usually put in it their nickname or another kind of signature.

Now, and don't worry I'm almost done, why using "Mimics" in the namespace as a intermediary?
Why not put all fireplaces directly under the "Sims3.Gameplay.Objects.Fireplaces" namespace?
I'm not sure about that, it may be a nuance of the language that I'm missing or can have some
practical usage or it's just a convention of some sort (separating abstract classes from instantiable classes?).
Lab Assistant
Original Poster
#9 Old 18th Nov 2014 at 4:43 AM
That is a very competent answer, esp in a foreign language! Thank you so much and well done :-) I'm not familiar with coding, you guessed that right.

So I have installed VisualStudio and set up a 'project' for the sims - only I can't find the sims3 corlib.dll thingy. How do I finish setting up, and is there a way to use that to search for all objects in the fireplace class?

"Now, and don't worry I'm almost done, why using "Mimics" in the namespace as a intermediary?
Why not put all fireplaces directly under the "Sims3.Gameplay.Objects.Fireplaces" namespace?" THIS. Can anyone explain this? Please?

Everything is ok in the end. If it's not ok, then it's not the end.
Inventor
#10 Old 18th Nov 2014 at 10:57 AM Last edited by Arsil : 5th Dec 2014 at 9:21 AM.
Quote: Originally posted by CrazySheep808
So I have installed VisualStudio and set up a 'project' for the sims - only I can't find the sims3 corlib.dll thingy.


THIS explains very well how to get started and how to get the game libraries (.dll files).
It can be a little tricky and remember that mscorlib.dll has a different name when you extract it
(I don't remember exactly which one CommonLanguageRuntimeLibrary.dll) and you have to
rename it to mscorlib.dll (I'm not sure if renaming is really necessary, but helps you to not get confused).

EDIT: oh, that's why you said you couldn't find it, sorry.
Use the "find the intruder" strategy to figure out which file you have to rename
(go by exclusion since the other libraries are already named correctly).
Any chance to update that wiki page? That confused me too.

Quote:
How do I finish setting up, and is there a way to use that to search for all objects in the fireplace class?


I'm confused. You want to search for all fireplaces to do what Buzzler suggested
(apply new settings using a pure scripting mod) or for another reason?
Lab Assistant
Original Poster
#11 Old 18th Nov 2014 at 8:49 PM
I attached a picture showing the libraries I extracted following those steps to the letter. I have 2 sims3storeobjects, no sims3gameplayobjects, and I searched Program Files for mscorlib.dll - none of the many returns was from the sims 3 folder. Is it possibly CommonLanguageRuntimeLibrary?

Quote:
I'm confused. You want to search for all fireplaces to do what Buzzler suggested
(apply new settings using a pure scripting mod) or for another reason?


Yeah, I want to change the default tuning for the 'fireplace' class. So all fireplaces 'ask' to catch stuff on fire less often.

I can see other versions of this mod, where in a medieval game or something you want certain fires to be more prone to it, not less. For that reason I'd like to know how to create an XML (presumably, I can copy one for another fireplace and assign it to a different one) but I don't know how to do that either! If there are XMLs hiding somewhere, that would be useful information as I can't find them all, but apparently not every fireplace has a separate tuning XML.
Screenshots

Everything is ok in the end. If it's not ok, then it's not the end.
Inventor
#12 Old 19th Nov 2014 at 9:11 AM
Quote: Originally posted by CrazySheep808
I attached a picture showing the libraries I extracted following those steps to the letter. I have 2 sims3storeobjects, no sims3gameplayobjects, and I searched Program Files for mscorlib.dll - none of the many returns was from the sims 3 folder. Is it possibly CommonLanguageRuntimeLibrary?


Where does Sims3StoreObjects2.dll come from? Looking at the file size that seems
Sims3GameplayObjects.dll. Rename it.

Yep, rename CommonLanguageRuntimeLibrary.dll to mscorlib.dll, it's our guy.

Remember: in the VisualStudio project you must reference the mscorlib.dll file you've
extracted from the game, not the one from your Operating System. Follow the tutorial
very carefully, use ".net framework 2.0" (warning: if you change this setting it will set
the option "Copy Local" as true on the mscorlib.dll reference, it must be set as false),
I insist, double or triple check all steps so you'll avoid getting trouble later.

And if you'll ever want to make other mods that involve scripting, don't use the same
VS project (I was so stupid to do that at first, just swapping the .cs files) but create a
new one using a different name for the project, in this way also to the assembly name
will automatically be assigned a new name different from those of your previous projects,
or your game will crash if there is more than a .dll file with the same name (that's what
happened to me anyway, maybe because I was also using the same namespace).

Quote:
Yeah, I want to change the default tuning for the 'fireplace' class. So all fireplaces 'ask' to catch stuff on fire less often.

I can see other versions of this mod, where in a medieval game or something you want certain fires to be more prone to it, not less. For that reason I'd like to know how to create an XML (presumably, I can copy one for another fireplace and assign it to a different one) but I don't know how to do that either! If there are XMLs hiding somewhere, that would be useful information as I can't find them all, but apparently not every fireplace has a separate tuning XML.


That's what confusing me.
If you want to follow Buzzler's suggestion then you don't need to worry about XML[s].
You can use a pure scripting mod OR you can override every XML related to fireplaces' settings.

---

About the use of "Mimics" in the namespace, I don't want to dictate how you should feel about it,
but I'm concerned that you're convinced that you need to know that in order to make your mod. You don't!

If you want to get to the bottom of it out of curiosity is fine and, damn it, you are infecting me.
It seems like there's definitely a pattern behind its use, since many other categories use it as
well (Beds, Appliances, Decorations, etc). My hypothesis about keeping separated abstract
classes from "normal" classes sometimes applies and sometimes doesn't, so there must be
other reasons than that and probably with some more analysis we can find them. On the other
hand, I'm afraid that this can turn out like asking why our neighbour named his dog "Charly":
maybe there's a practical/logical/meaningful reason or maybe not.
Lab Assistant
Original Poster
#13 Old 26th Nov 2014 at 2:32 AM
Thanks!! I have to go supermarket shopping (blah blah real life blah) but will get onto it some time soon! You're awesome.

Everything is ok in the end. If it's not ok, then it's not the end.
Lab Assistant
Original Poster
#14 Old 14th Dec 2014 at 3:20 AM
So, after a bit of a break, I'm ready to come back to this project. Here's where I'm at:

XML tuning files override FireplaceClass settings. Any fireplaces without an XML tuning file will use the class settings.
So I need to override the existing XMLs, AND adjust the class settings in order to get all the fireplaces.

For XMLs, I can copy them to a new .package file, adjust them at will, and put that in the Mods/Overrides folder. As for the others, I could adjust the class settings with a scripting mod, but I want to create XMLs for them so a) I know how and b) I can modify them easily in the future. I'm not a programmer and am in over my head with the Visual Studio stuff. I'll have a look around for instructions but are there any serious flaws in this plan?

Everything is ok in the end. If it's not ok, then it's not the end.
Inventor
#15 Old 14th Dec 2014 at 8:17 AM
There's no need to put your .package file in the Overrides folder, unless some of
the fireplaces themselves are custom content or store items in .package format.

If you are not comfortable with scripting, I think you can achieve what you want just
creating/overriding XMLs: all classes derived from Fireplace should refer to one for
their tuning (but I completely forgot what settings you want to change, so don't take
this for granted).

If you need help, you know what to do ^^
Inventor
#16 Old 16th Jan 2015 at 11:09 PM
I made a pure scripting mod to take care of the fires: http://modthesims.info/showthread.php?t=546046
Back to top