Author Topic: Reading XML Files  (Read 24238 times)

Offline Seabody

  • Global Moderator
  • Watcher
  • ******
  • Posts: 5071
Reading XML Files
« on: May 26, 2012, 07:17:32 PM »
Recently I was asked by Leto85 if I could write a tutorial on how to read game files. I said yes. This is a basic guide to reading XML Files.

How to read XML Tuning Files

What you need
S3PE.
A text editor, preferably Notepad or Notepad++ if you want to edit the files (I don't go into much detail about this in this guide)
A computer running .NET framework 4 (Windows) or MONO (MacOSX or Linux). If you don't know your version, you can find out by a quick Google Search.
Note: The directory that the .package files are stored in is Read Only. Therefore, you will not be able to easily screw up your game. However, as a precaution, I recommend that you back up gameplaydata.package first.

Okay, this is fairly easy to do. There is a guide to installing S3PE written by the creators here.

Let's open GameplayData.package. This is done by going File > Open (or Ctrl+O). The file is located in C:/Program Files/Electronic Arts/The Sims 3/Game/Bin/Gameplay/GameplayData.package. You will inevitably be given a screen which states something, followed by "Retry as Read Only?". Click Yes. It will take a few seconds to open.

Now you are confronted by hundreds of smaller files. The Second Column in the left hand pane is "Tag". Click this heading once to sort the files by tag.


(In this image, the files are already sorted by tag)

XML Files are the easiest to read and make Mods from.

Click on a file. Some have more information than others.

Most files have descriptive names, and others need research to figure out.
Example:
The Buffs.XML file is, pretty clearly, the master controller for all of the Buffs.
The X-Factor.DMTR file, is, unusually, the icon for the trait "Star Quality".


Let's first go into the file "BuffFitAtmosphere". This controls the Moodlet "Fit Atmosphere" which you get at the Gym.

The file is shown on the right. Here is a complete copy of the contents of my BuffFitAtmosphere file.

EA provides comments in most of their code (Comments are surrounded by these tags: <!-- --> And are not read by the game).

Code: [Select]
<?xml version="1.0" encoding="utf-8"?>
<base>
  <Current_Tuning>
    <kFitnessMultiplier value=".5">
      <!--Range:  Multiplier.  Description:  Additional body shape multiplier when in the Fit Atmosphere (gym).-->
    </kFitnessMultiplier>
    <kAthleticSkillMultiplier value=".5">
      <!--Range:  Multiplier.  Description:  Additional athletic skill gain multiplier when in the Fit Atmosphere (gym). 2.0f means double the rate.-->
    </kAthleticSkillMultiplier>
  </Current_Tuning>
</base>

As you can see, the AthleticSkillMultiplier has a value of .5 - and if you've had the moodlet, or read this thread, you can see where the bug originates.

So, reading this information, you can easily see that your Sim will gain Athletic Skill at half the rate they are supposed to. You can fix this by editing the file, or, you can download a Mod to fix it.

Let's go again. This time, let's take a look at RealEstateManager. (It is followed by an underscore and a bunch of numbers)

Code: [Select]
<?xml version="1.0" encoding="utf-8"?>
<base>
  <Current_Tuning>
    <kPercentageOfVacationHomeValueBilled value="0.01">
      <!--Range: Float [0,1]. The percentage of a location home's value that is added to a household's bills.-->
    </kPercentageOfVacationHomeValueBilled>
    <kVisaLevelRequiredToPurchaseVacationHome value="3">
      <!--Range: [0,3]. The visa level that unlocks a sim's ability to purchase a location home.-->
    </kVisaLevelRequiredToPurchaseVacationHome>
  </Current_Tuning>
</base>

Breaking this down, you can see "<kPercentageOfVacationHomeValueBilled value="0.01">". This is, pretty understandably, the Percentage of the Value of any Vacation Homes owned that is added on to bills. Think of it as tax - you own an offshore property, so the bank is charging you for it. This information is in a decimal - and if you remember back to Maths class, you multiply a decimal by 100 to convert it to a percentage. So therefore, the percentage of value is 1%. Or $1 in every $100.

Another example. This one is of the PrivateEye file. This one is large, so I'll choose an interesting section to show.

Code: [Select]
<?xml version="1.0" encoding="utf-8"?>
    <kPrivateEyeTraitObjectsStealPerDay value="3">
      <!--Range: Number of objects.  Description:  Number of objects a Private Eye Sim is allowed to swipe per day.-->
    </kPrivateEyeTraitObjectsStealPerDay>
    <kBlackmailAllowedDurationInHours value="48">
      <!--Range: Time in hours Description: Length of time that the blackmail interaction will be available after a successful garbage search.-->
    </kBlackmailAllowedDurationInHours>

Okay, for this one, what can you see?
The first thing, is that the very first set involves the Swiping. This is the trigger to enable Private Eye's to steal objects, and is what you change if you want to make it higher. Pretty simply, it's 3 objects.
The second thing, is that after a Sim digs through a Garbage tin, they will gain the "Blackmail" interaction for this many hours. The keys here are "value="48"" and "Range: Time in hours". I wouldn't change the latter to make a mod, but I'd change the former. So any value stored in here is in hours. So let's take an example:
Say I wanted to raise it to 4 days. I would figure out how many hours in 4 days (96) and alter that. Voila, mod made.

Let's go in one more time. This time, we'll go in to the Babysitter XML file. I won't give a narration, this time, you can take a look yourself.  ;D

Code: [Select]
    <kEndTime value="23">
      <!--End time for babysitter to leave (in 24 hours)-->
    </kEndTime>
    <kMinBabysittingTime value="10">
      <!--Min time a babysitter will stay (in 24 hours)-->
    </kMinBabysittingTime>
    <kServiceTuning>
      <kMaxNumNPCsInPool value="2">
        <!--Max num NPCs at once in service-->
      </kMaxNumNPCsInPool>
      <kCost value="75">
        <!--Cost of service-->
      </kCost>
      <kIsEmergencyService value="False">
        <!--If true this service charges kCost only if falsely called, otherwise free.-->
      </kIsEmergencyService>
      <kIsRecurrent value="False">
        <!--Whether the service is recurrent (true) or one-off (false).  Recurrent services are the only type which can be cancelled through the phone dialog.-->
      </kIsRecurrent>
      <kAlwaysTryToSendSameSim value="True">
        <!--Whether or not the service always tries to send the same NPC to a specific household-->
      </kAlwaysTryToSendSameSim>
    </kServiceTuning>
    <kDriveTime value="5">
      <!--Length of time (in minutes) that babysitter takes to drive to lot-->
    </kDriveTime>
  </Current_Tuning>
</base>

Okay, here's some questions.
1. How long does the babysitter take to drive to the lot?
2. What time does the babysitter leave? (12-hour format)
3. How many babysitters are there in service at once?

Okay, once you've answered them (in your head, you don't need to post them or anything), here are the answers.

Spoiler (click to show/hide)


I can't give you a complete list of tags, due to the sheer volume of them. But, if you read the tag and combine it with the relevant comments, it's easy to read these XML Files.

Chuckles_82

  • Guest
Re: Reading XML Files
« Reply #1 on: May 26, 2012, 07:29:36 PM »
Awesome guide Seabody! Now I know where to start looking/digging for other stuff. I'm already up on the _XML files (only just) as I've spent the last 3 days sorting my store content, but still learning about the rest. One of our other members has some further info on XML Tuning files and related mods, but I can't find the exact tutorial right now. It's at Nona's Sims. Nonamena has quite a lot of knowledge on the topic, so if you get stuck she is very helpful!



Registered members do not see ads on this Forum. Register here.

Offline NonaMena

  • Townie
  • ***
  • Posts: 227
    • Nona's Sims
Re: Reading XML Files
« Reply #2 on: May 27, 2012, 05:13:16 AM »
Great post, Seabody :) I think it's great for players to be able to understand XML mods and you did a good job explaining it.  Although I recommend S3PE, for some users Nraas Packer might be a better package editor, as it is pretty basic and doesn't have all the bells and whistle of s3pe (which are very useful for modders). Just thought I'd mention that!

Chuckles, you flatter me :) I guess the post you mean is Tutorial: Tuning mods and Commodity Kinds which is focused primarily on ITUN resources. I just realized it's not linked in my tutorial list, so I've fixed that.

Leto85

  • Guest
Re: Reading XML Files
« Reply #3 on: May 27, 2012, 06:54:20 PM »
That looks interesting!
I have to try it out myself though, to completely understand it. Thank you for doing this Seabody. I admire you that you've figured all this out by yourself.

Offline Seabody

  • Global Moderator
  • Watcher
  • ******
  • Posts: 5071
Re: Reading XML Files
« Reply #4 on: May 27, 2012, 11:57:39 PM »
Thanks everyone! :)

Although I recommend S3PE, for some users Nraas Packer might be a better package editor, as it is pretty basic and doesn't have all the bells and whistle of s3pe (which are very useful for modders).

I was considering adding Packer into the "What You Need" section, but decided against, since twallan himself said that for loading packages like gameplaydata.package, it would be "abysmally slow".

I admire you that you've figured all this out by yourself.

I didn't figure it all out by myself. I have a basic knowledge of HTML, which helped me to understand some of it, and I read a fairly comprehensive guide on modding at MTS to learn the basics.

Offline NonaMena

  • Townie
  • ***
  • Posts: 227
    • Nona's Sims
Re: Reading XML Files
« Reply #5 on: May 31, 2012, 06:37:02 PM »
I was considering adding Packer into the "What You Need" section, but decided against, since twallan himself said that for loading packages like gameplaydata.package, it would be "abysmally slow".

It's certainly true that Packer is abysmally slow at loading the GameplayData, hehe :)

Chuckles_82

  • Guest
Re: Reading XML Files
« Reply #6 on: July 02, 2012, 04:00:06 AM »
Does anyone know if there is an _xml file for lifetime rewards? And if there is, what it is called? The object rewards have their own _xml, but I can't find a resource for the others.



Registered members do not see ads on this Forum. Register here.

Offline NonaMena

  • Townie
  • ***
  • Posts: 227
    • Nona's Sims
Re: Reading XML Files
« Reply #7 on: July 02, 2012, 10:53:44 AM »
Does anyone know if there is an _xml file for lifetime rewards? And if there is, what it is called? The object rewards have their own _xml, but I can't find a resource for the others.

Depends on what you want to do. If you want to modify LTR trait tuning (such as Beloved Pet, Hardly Hungry, etc.) you need the TraitTuning XML (Instance ID: 0xc4e3fd010a0b7db0).

If you want to change the cost of LTRs, you need the Traits XML (Instance ID: 0x905E2204EBCAC0B6) -- this include objects such as the Food Replicator.

Sometimes, LTRs also affect other game play aspects, so there will be tuning for them in other XMLs. For example, the Natural Born Performer trait affects the Performance Meter for show time careers. You'll find some information about that in the PerformanceMeter XML (Instance ID: 0x9712ea904535f8ec).

I recommend that you Download NotePad++. It's free and small. Then, open the GameplayData and press Ctrl+A and wait. It will take a while for S3PE to select all files. You may see that the program is not responding, but just keep waiting. Once everything is selected, right click in S3PE and choose Export to File, then choose a folder where you want to export your files. When everything is exported, open NotePad++ and hit Ctrl+Shift+F. In the Directory field, enter the path to the folder where you saved the gameplaydata files (use ... button). Now you can put in your search terms and search everything in the directory in one go.

S3PE has its own search function (Ctrl+E) but I prefer Notepad++ usually.

Chuckles_82

  • Guest
Re: Reading XML Files
« Reply #8 on: July 02, 2012, 06:43:25 PM »
Thankyou Nona! I actually didn't want to edit anything - just read it and learn more about the game mechanics :) I've learnt an amazing amount by reading through the _xml resources, and will post some interesting finds in the near future, that I haven't been able to find anywhere else on the net.

Offline Seabody

  • Global Moderator
  • Watcher
  • ******
  • Posts: 5071
Re: Reading XML Files
« Reply #9 on: July 02, 2012, 06:52:34 PM »
Thankyou Nona! I actually didn't want to edit anything - just read it and learn more about the game mechanics :) I've learnt an amazing amount by reading through the _xml resources, and will post some interesting finds in the near future, that I haven't been able to find anywhere else on the net.


This makes me think there should be a thread "Ask someone who's seen the code" where you can ask generic questions about gameplay mechanics and have someone who's seen the code respond.

Chuckles_82

  • Guest
Re: Reading XML Files
« Reply #10 on: July 22, 2012, 11:35:00 AM »
Well, after getting really annoyed with my game not registering landmarks for the architect's eye challenge for photography (since the last patch), I decided to try my first tuning mod. I tuned it down from 10 to 1. And it worked! Woot!

EDIT

On an entirely different note, the maximum sale price for the grocery store and bookstore is 50% off :)

Offline NonaMena

  • Townie
  • ***
  • Posts: 227
    • Nona's Sims
Re: Reading XML Files
« Reply #11 on: July 26, 2012, 02:52:53 AM »
Well, after getting really annoyed with my game not registering landmarks for the architect's eye challenge for photography (since the last patch), I decided to try my first tuning mod. I tuned it down from 10 to 1. And it worked! Woot!

Nice work on your first mod :) I hope more people will at least get acquainted with how XML mods work, even if they don't want to make them themselves. It takes away a certain amount of "mysteriousness" surrounding mods. Then people can understand better how mods work in their game.

Chuckles_82

  • Guest
Re: Reading XML Files
« Reply #12 on: July 26, 2012, 11:24:12 PM »
Where are the other gameplaydata packages found? I have one for the base game, one for ambitions, one for townlife stuff, but most of the recent EPs and Sps have no gameplaydata package that I can find. Do the gameplaydata packages in each EP folder differ in any way? Or is each new one an override of the previous one?

I modified the sculpting_data resource in the sims base game file, but it didn't take. Basically (short of someone answering my question in another thread), I'm trying by trial and error to find the source of the red box problem. I deleted all the info for sculptures except for one clay/wood/ice/stone sculpture, and the metal and topiary sculptures (as I know there is nothing wrong with those). When I went into the game, the first sculpture my sim made was not the only one I left in the list!

Offline Seabody

  • Global Moderator
  • Watcher
  • ******
  • Posts: 5071
Re: Reading XML Files
« Reply #13 on: July 27, 2012, 02:09:32 AM »
Where are the other gameplaydata packages found? I have one for the base game, one for ambitions, one for townlife stuff, but most of the recent EPs and Sps have no gameplaydata package that I can find. Do the gameplaydata packages in each EP folder differ in any way? Or is each new one an override of the previous one?

I don't know the function of each EP and SP's gameplaydata.package, but the Vanilla one is the one you need to modify.

Offline Zyffyr

  • Townie
  • ***
  • Posts: 193
Re: Reading XML Files
« Reply #14 on: July 27, 2012, 05:16:13 PM »
Where are the other gameplaydata packages found? I have one for the base game, one for ambitions, one for townlife stuff, but most of the recent EPs and Sps have no gameplaydata package that I can find. Do the gameplaydata packages in each EP folder differ in any way? Or is each new one an override of the previous one?

Originally, each EP/SP had its own full version of the game including the gameplaydata package. With Late Night (I think, and I am to lazy to double check which it actually was), they changed the system so that only the base game folder is actually operational. Now the EP/SP folders really just exist to contain a the new items/worlds.

 

anything