Back Previous Next

Fun with paintings

Maxis offers for download a free tool, Art Studio, to make paintings for the Sims. This tool will do fine for the average fan wanting to insert a graphic in the game, but has its limitations:

Only the second and third issue will be addressed here. If I want to make a huge wall covering, I can always clone a suitable object. The painting's GUID can be changed using IFF Pencil, which is also what I'll use to throw out all the extra junk. The last issue can only be solved by changing the template painting, which I won't go into here. This tool is useful in that it takes a graphic, skews it at the right angle (37 degrees, I seem to remember from a tutorial, although 27 degrees looks better to me), frames it, makes the z-buffer, adds a menu option and allows the user to input a catalogue description.

To test this tool, I used a graphic from a Calvin Klein ad with the model looking straight into the camera, that I'd scanned to test the Sims Creator Photo Wizard, as it's hard to find a face snapshot that is symmetrical in both form and lighting. The scan was lost in a disk crash, but not before I'd tried it for size with the largest frame Art Studio had to offer. The face fitted in very comfortably, and so did part of the torso, making the end result a bit tacky. At that time I had just finished the cheesy teen dream party house for the junior Bisons, in which a tacky semi-nude poster would look right in place. So the file was called "PaintingHotStuff.iff", its catalogue name "Hot Stuff", and its description ran: "Wall decoration for hormone-ridden adolescents who feel they're not getting it often enough. Guaranteed to make them break out in a sweat."

This done, I opened the painting in IFF Pencil to copy the catalogue text to all languages and translated it in the one language I feel proficient enough in to get across the typical Maxis tongue-in-cheek tone:

I tried to do the same for the menu text, which I'd expected to find under #129, but #129 is just a remnant, and the menu items are under #130. Trying to remedy this by recreating the menu table, I made the object altogether unusable. To cut a very long story of research and frustrations short: in a painting created with this tool, simply delete the TTAB block with number 129.

I then double-click on the TTAB block to open it, add an interaction item "Drool", fill in "4100" for the action tree and "4101" for the check tree, and make it available to visitors, children and adults. Then I set the advertisements. Sim people are little self-perpetuating computer programs who constantly lose resources and try to replenish them; "advertisement" is the promise of resources that Sim objects constantly broadcast. This object is meant to give Sims a little jolt, so it promises Energy, Room and Fun in a range from 0 to 20, which is quite mild, varied by none, ie. the attraction is equally strong for Sims of any character, with the attenuation "High", meaning the broadcasting range is far (an attenuation of "None" theoretically means the broadcasting range is infinite, or, more accurately, it doesn't diminish regardless of distance) and the attenuation threshold is "0", the only value that allows Sims to use the object of their own free will.

The TTAs item should have been generated automatically with the making of the TTAB item; if not, add it, copy its content to all languages and translate what you want. Unsure of how to do all this? It's covered in the simple hack sections Wrong names/descriptions and Editing menu options.

After that, I alter whatever needs altering in the OBJD block: first the GUID, by replacing the bytes in the middle with my magic cookie number. Under "Price information" I find the original price, how much the value drops after buying, how much it drops per day and what the minimum price is: 30 simoleons. What, for this piece of, er, art? I'm knocking that back up to 100 in the field "Depreciation limit". Going all the way down to Room, Function and Category flag, I assign the painting to Bedroom, Decorative, Paintings. Do I want it to be buyable outside residential lots? In Downtown, maybe. It doesn't belong in Street or Outdoors; it might put off the customers in Dining and Shopping; into Misc it goes. "Unknown HD value 1" is set to 128. "Unknown HD value 2" stays at 0, unlike chairs and box hedges this is not a "keep buying" article. Before leaving the OBJD block altogether, I check if the "Base Graphic ID" is 100, the "Catalog ID" is 2000, the "Number of graphics" is 1 and the ratings are what I want to see in the catalogue: 2 for Energy, Fun and Room, and -1 for Hygiene (remember that catalogue description?) Having closed the OBJD editing scheen with "OK", I may edit the OBJD block properties to change the title from whatever it was to "Hot Stuff" so that even if the catalogue description is lost, the game will still give the article its right name in the catalogue.

The next thing I do, on finding the object has no catalogue/speech bitmaps, is to add them as explained in Adding speech balloon bitmaps. If I'd wanted the usual Sim reaction to paintings, I would have added a block of type GLOB, id 128, no title, double-clicked it and filled in "ArtGlobals", gone to the TTAB block, filled in "8196" and "8197" in the Action and Check Tree, and deleted the now superflous 4100, 4101 and 4107 in the BHAV block. I would then have done a bit of code-cleaning by deleting DGRP ids 200 to 800 and PALT ids 1 to 7, saved the IFF file, and put it in the Downloads directory. But I want my Sims to drool and sweat, so I'll just skip the globals, do the code-cleaning and then dive into the BHAV block.

This is the place where the promises of fun and energy made in the catalogue and advertised to Sims come true. However, my first concern is having that painting pop up in a speech bubble; simply importing the speech bitmaps isn't enough, the Sim has to be told what to think. Opening any old object that has its own thought balloon code shows something like this:

What I want to happen is: the Sim looks at the painting and thinks about it. Next follows the standard approve/disapprove/shrug routine, a boost in Fun and Energy and a decrease in Hygiene. The action tree, I already saw, is 4100. This one refers to another tree, 4107 "react". Its last line is 21, which plays a sound event, but Simantics instructions tend to jump to and fro, so the actual last line to be executed may well be another line. Looking for a suitable spot to insert the balloons, I find a line that plays "sound event 2", which, in the FWAV block, is called "art_consider_vox". This is the spot. I create a new line, function 41, parameters 0, 1792, 150, 256. The third parameter is how long (in "ticks") the thought bubble is shown. The default for viewing paintings is 150, but I could change it to "FF FF" or "-1" (although the prog has a problem with directly entering negative decimal parameters) for the setting "forever". I link from the considering line, 17, to my line, and from my line to 17's original True value: line 8. This one iterates until an animation is completed, then goes to 6, which goes down the possible values of a variable. If the variable is 0, the Sim likes the painting and an approval sound is played, the Fun points go up - that's already in the code - and the tree exits. If not, go to line 7 for the next test: is the value 1, meaning the Sim is indifferent? Then follows a shrug, and exit. If not, go to line 18, which tests whether the Sim dislikes the painting, or really hates it. In the first case, there's simply a nuh-uh sound, but in the second, the Fun points actually go down. This is not all in one line, of course, I can see it by following the progression from line 18 to 21 to 14 to 16, the terminus. When a code line's outcomes are True/Error, that means it's the last line in its particular sequence.

That gives me a devilish idea. Firstly, it has occurred to me that child Sims will also be looking at this painting, and do I expect them to sweat and drool? Hardly. So I'm going to build in a check that prevents the decrease in hygiene and the slight energy jolt if the watcher has Sim age 9. (I could also say "if age < 18" or call the global "Am I a Child?" but I may want to create teenage NPCs at some time - NPCs can be any age the creator wants - and I'd certainly expect them to drool.) Secondly, there is another reaction adults have to (suggested) nudity which is totally lacking in young children. One of my childhood memories is standing in the supermarket and staring long and hard at a romantic novel cover with bare breasts on it, because there was something unusual about the picture and I couldn't figure out what. My mother dragged me away, probably red in the face. Sims don't know embarrassment, but lowering their Comfort score should come close enough. So, the plan is: if Sim really likes painting, check if adult enough, raise energy, decrease hygiene. If Sim really hates painting, check if adult enough, decrease comfort. And, as I've found that Sims don't only have thought bubbles of objects when considering them but also when passing judgement, I need three more thought bubble lines, each following an evaluation of the "how does the Sim like it" variable. There are three possible values, the "dislike/hate" reactions sharing a common value.

First, let's get the bubbles done. These are simply the same line repeated four times, function 42, parameters 0, 1792, 150, 256. The first is between 17 and 8, that is, the True outcome of line 17 links to it and its own True outcome is line 8. The second is between 6 and 9, the third between 7 and 11, the fourth between 7 and 18. (Line 7 branches into 11 and 18, so now it will branch into two "thought balloon" lines which lead to 11 and 18.) The False outcomes of all four lines is "Error".

Next, the child check. The standard Maxis child check is function 363, global "Am I a child?" with parameters -1, -1, -1, -1; looking at the corresponding BHAV tree in "Global.far", I see that "child" is anything older than 0 (that would be a baby) and younger than 18.


A peek in Global.iff.

In this case, "child" means anything of nine or younger, and the line is: function 2, parameters 58, 9, 128, 1810. The last parameter stands for "my person data", attributes of the Sim concerned; 58 is the age attribute, 9 is the age, 128 is the "greater than" sign. Translated, the line says "is this Sim older than 9 (and therefore not a regular Simkid)?" This line also comes twice, after line 15 and line 16. These two lines are at the end of a course of action, so I don't have to worry about connecting from my added lines back into the standard code. Their True outcome, for now, is True, as the next lines they jump to haven't been created yet. The False outcome is True.

And what comes after the child checks? The first one follows the positive reaction and should be followed by an increase in energy. I'll borrow the same value as was used for the increase in fun: the first value in line 4096 of the BCON block, "6". That's not very much, is it? I think I'll change that to 20, which is more in keeping with the advertised value. The code line is really easy: duplicate line 15, then change parameter 1 from 15 to 5. The whole line is: function 2, parameters 5, 0, 768, 6670. Then duplicate the new line and change the first parameter to 8 and the third to 1024. The first new line should point to the second, and the second ends the sequence. That means, the first line's outcome should be Line#/Error and the second line's outcome, True/Error. From now on, I'll simply say that a line points to another line, or ends the sequence.

Duplicate the very last line again, the one that decreases hygiene, and change the first parameter to 6 for a decrease in comfort; this line ends the sequence. Go back to the second child check and have it point to this last line. Go back to the first child chack and have it point to the line that raises the energy. The BHAV code is now done.


A screenshot of the added code, starting from the highlighted line.

There's something that bugs me, though. Kids don't get to drool, so why do they have "Drool" in the menu? There's a really easy solution to this. Two menu items can point at the same action tree. The first menu item, "Drool", is available to visitors, adults and children. Visitors can be children, but their reactions are programmed in the BHAV block and as I can't set them tasks, I won't see a menu option for them. So, in the TTAB block, I'll add an item "View", which is available only to children. I'll set this item to the same values as "Drool", except for the energy advertisement, because Simkids don't get energy from this painting. If I simply wanted to exclude minors, I would untick "Available to children" for "Drool", and the object would be finished. However, I want the "Drool" option available to Sims who are minors, but older than regular Simkids, and "View" to Simkids only. That means two check trees instead of one, and another dip into the BHAV section. In preparation for this, the Check Tree for "Drool" is changed from 4101 to 4108, and that of "View", from 4101 to 4109. These two don't exist yet, but the editor won't protest when I save the TTAB block.

Back to BHAV. I add a BHAV, id 4108, title "Drool - TEST". It should contain all the code in the original check, 4101, plus an age test. I don't want to write code twice if I don't have to, so line 0 will be the age check and, if that's passed, line 1 will call BHAV 4101. The age check is a matter of copying the values of the child check described above. Calling 4101 is simply done by filling in that number in the "Function" field; the parameters don't matter and should be made empty. Line 0's outcome should be Line1/False, line 1 should end in True/False; not True/Error, as an outcome "Error" may make the object re-initialize, which is not the desired outcome of a test. I duplicate BHAV 4108 to BHAV 4109, and reverse the outcome of line 0, so that it is False/Line1. And now the object is really finished! Time to test it in the game.


Success!



Back Previous Next