Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: A case for graphics templates for animal people equipment graphics  (Read 208 times)

voliol

  • Bay Watcher
    • View Profile
    • Website

This suggestion is as the title implies a case for using "graphics templates", a generalized form of the creature variation templates, for making compact raw files for the animal people equipment graphics. It assumes a familiarity with how creature variations work, if you need a refresher see the DF wiki article.
This suggestion also assumes that creature variations have not changed in how they work between 0.47.xx and 0.50.03, as I do not believe they have. 


Introduction

In an interview with Blind closely before the release of DF 0.50.01, it was mentioned that the animal people don't have layers for their equipment/body parts and that this was partially a problem with space; if each animal person had graphics files as large as those for the main civilized races, then the size of the vanilla raws would grow unreasonably much. As 0.50.01 (and .02, .03) have now released, we players can see that this holds true; the "graphics_creatures_layered.txt" file is a whopping 1423 kB, and their image files are sizable too, 1093 kB.

The creature objects in Dwarf Fortress has a similar problem, in that they would grow too long if all tokens for each creature were to be included. This may be equally (or more) an issue of readability rather than space, but the solution helps with both. Creature tokens have no less than four different templates, which by including a single token for each applicable creature, hides away many more. These templates are:
tissue templates and material templates, which hide away long definitions for things such as skin, bone, and muscles; body detail plans, which act on a higher level of abstraction, shortening away long lists of "USE_TISSUE_TOKEN" and "USE_MATERIAL_TOKEN", as well as deciding the thickness of tissues on each body part, and body parts' relation to another (the mouth being on the front of the head, eyelids being around the eyes, etc.); and creature variations. Creature variations are the newest of the bunch, and though they are "only" used for variant creatures (giant animals, animal men), gaits, and certain attacks in vanilla, their use case is even broader than that. Since they are the most evolved of the creature object templates, and have a versatility to be used with virtually all creature tokens, the suggestion below is on how to more or less lift their functionality, and use them to shorten the graphics files.

Below, I will refer to these lifted creature variations as "graphics templates", since the "variation" part of the creature variations supposedly refers to their origin in allowing "variant creatures", and the point of this suggestion is not to propose "variant graphics". 
This is related to a suggestion of renaming creature variations "creature templates", to highlight their versatility, and allow "[object] templates" for all types of raw objects. The rest of the suggestion will focus on the graphics case, though.


A solution

The objects for creature graphics are divided into tile pages and "creature graphics". The former refers to image files and divides them into a grid, and the latter tells each creature how they should use these gridded images.
Most creatures have only a few simple images to them, but a few (only the main races?) use a layering system to show e.g. hair styles and what clothes they wear. Since the dwarves, elves, humans, goblins, and kobolds all have unique body shapes, they require different sheets for these. However, many animal people don't. For example, slug people and tiger people, and wild boar people all use the same general body shape, meaning their current brown tunic is the same, with a difference only in legs, face, arms, and sometimes tail. The same goes for echidna people and porcupine people, hippo people and the bear people, and so on.

Though I do not know the numbers, it is clear that there exist fewer body shapes, maybe 5-15 for the roughly 185 kinds of animal people. Consequently, if we were to make sprites for the animal people's equipment, we would want to make sprites for these 5-15 base body shapes, and then let the tile maps correspond to as few images. Slug people and tiger people could then use the same tile map (complications do appear here, I'll get to those later), but this would only solve half of the problem. Sharing tile maps means the images won't need duplication, but the "creature graphics" objects will still look largely the same, repeating lines taking up a large chunk of storage.

An example:
Code: [Select]
[OBJECT:GRAPHICS]

[CREATURE_GRAPHICS:TIGER_MAN]
[LAYER_GROUP]
[LAYER:BELOW_CLOTHING:CREATURES_ANIMAL_PEOPLE:A:B]

[LAYER_GROUP]
[LAYER:CLOTHING_TORSO_SIMPLE_WHITE:ANIMAL_PEOPLE_TIGER_CLOTHING:X:Y]
[CONDITION_ITEM_WORN:BY_CATEGORY:BODY_UPPER:ARMOR:ITEM_ARMOR_COAT:ITEM_ARMOR_SHIRT:ITEM_ARMOR_TUNIC:ITEM_ARMOR_TOGA:ITEM_ARMOR_DRESS:ITEM_ARMOR_ROBE]
[CONDITION_PROFESSION_CATEGORY:STONEWORKER]
[LAYER:CLOTHING_TORSO_SIMPLE_BLACK:ANIMAL_PEOPLE_TIGER_CLOTHING:X2:Y]
[CONDITION_ITEM_WORN:BY_CATEGORY:BODY_UPPER:ARMOR:ITEM_ARMOR_COAT:ITEM_ARMOR_SHIRT:ITEM_ARMOR_TUNIC:ITEM_ARMOR_TOGA:ITEM_ARMOR_DRESS:ITEM_ARMOR_ROBE]
[CONDITION_PROFESSION_CATEGORY:NONE]
[CONDITION_DYE:BLACK]
...
(tens if not hundreds of lines)

[LAYER_GROUP]
[LAYER:ABOVE_CLOTHING:CREATURES_ANIMAL_PEOPLE:A2:B]

[CREATURE_GRAPHICS:SLUG_MAN]
[LAYER_GROUP]
[LAYER:BELOW_CLOTHING:CREATURES_ANIMAL_PEOPLE:C:D]

[LAYER_GROUP]
[LAYER:CLOTHING_TORSO_SIMPLE_WHITE:ANIMAL_PEOPLE_TIGER_CLOTHING:Z:W]
[CONDITION_ITEM_WORN:BY_CATEGORY:BODY_UPPER:ARMOR:ITEM_ARMOR_COAT:ITEM_ARMOR_SHIRT:ITEM_ARMOR_TUNIC:ITEM_ARMOR_TOGA:ITEM_ARMOR_DRESS:ITEM_ARMOR_ROBE]
[CONDITION_PROFESSION_CATEGORY:STONEWORKER]
[LAYER:CLOTHING_TORSO_SIMPLE_BLACK:ANIMAL_PEOPLE_TIGER_CLOTHING:X2:Y]
[CONDITION_ITEM_WORN:BY_CATEGORY:BODY_UPPER:ARMOR:ITEM_ARMOR_COAT:ITEM_ARMOR_SHIRT:ITEM_ARMOR_TUNIC:ITEM_ARMOR_TOGA:ITEM_ARMOR_DRESS:ITEM_ARMOR_ROBE]
[CONDITION_PROFESSION_CATEGORY:NONE]
[CONDITION_DYE:BLACK]
...
(tens if not hundreds of identical lines to the tiger person's)

[LAYER_GROUP]
[LAYER:ABOVE_CLOTHING:CREATURES_ANIMAL_PEOPLE:C2:D]

... (the same but for wild boar men, snail men, etc.)

If we had a "graphics template" most of these lines can be made to disappear. The "graphics template" have all the same capabilities as the creature variations, only forgo I the "ADD_TAG" when adding a token. It could look something like this instead:

Code: [Select]
[OBJECT:GRAPHICS_TEMPLATE]

[GRAPHICS_TEMPLATE:ANIMAL_PEOPLE_TIGER_CLOTHING_TEMPLATE]
[LAYER_GROUP]
[LAYER:CLOTHING_TORSO_SIMPLE_WHITE:ANIMAL_PEOPLE_TIGER_CLOTHING:Z:W]
[CONDITION_ITEM_WORN:BY_CATEGORY:BODY_UPPER:ARMOR:ITEM_ARMOR_COAT:ITEM_ARMOR_SHIRT:ITEM_ARMOR_TUNIC:ITEM_ARMOR_TOGA:ITEM_ARMOR_DRESS:ITEM_ARMOR_ROBE]
[CONDITION_PROFESSION_CATEGORY:STONEWORKER]
[LAYER:CLOTHING_TORSO_SIMPLE_BLACK:ANIMAL_PEOPLE_TIGER_CLOTHING:X2:Y]
[CONDITION_ITEM_WORN:BY_CATEGORY:BODY_UPPER:ARMOR:ITEM_ARMOR_COAT:ITEM_ARMOR_SHIRT:ITEM_ARMOR_TUNIC:ITEM_ARMOR_TOGA:ITEM_ARMOR_DRESS:ITEM_ARMOR_ROBE]
[CONDITION_PROFESSION_CATEGORY:NONE]
[CONDITION_DYE:BLACK]
...
(tens to hundreds of lines)
Code: [Select]
[OBJECT:GRAPHICS]

[CREATURE_GRAPHICS:TIGER_MAN]
[LAYER_GROUP]
[LAYER:BELOW_CLOTHING:CREATURES_ANIMAL_PEOPLE:A:B]

[APPLY_GRAPHICS_TEMPLATE:ANIMAL_PEOPLE_TIGER_CLOTHING_TEMPLATE]

[LAYER_GROUP]
[LAYER:ABOVE_CLOTHING:CREATURES_ANIMAL_PEOPLE:A2:B]

[CREATURE_GRAPHICS:SLUG_MAN]
[LAYER_GROUP]
[LAYER:BELOW_CLOTHING:CREATURES_ANIMAL_PEOPLE:C:D]

[APPLY_GRAPHICS_TEMPLATE:ANIMAL_PEOPLE_TIGER_CLOTHING_TEMPLATE]

[LAYER_GROUP]
[LAYER:ABOVE_CLOTHING:CREATURES_ANIMAL_PEOPLE:C2:D]
...

See! Much shorter! In the above case, we've made all animal people that use the tiger/slug person base body (called "ANIMAL_PEOPLE_TIGER") use a graphics template to avoid copy-pasting tokens between them. But this solution actually hides quite many lines. Though we can assume we did the same for the hippo/bear men, and the porcupine/echidna men, letting them use graphics templates maybe known as "ANIMAL_PEOPLE_HIPPO_CLOTHING_TEMPLATE", and "ANIMAL_PEOPLE_PORCUPINE_CLOTHING_TEMPLATE", this still leaves us at 5-15 graphics templates that are both long and similar. ANIMAL_PEOPLE_TIGER_CLOTHING_TEMPLATE may start
Code: [Select]
[LAYER_GROUP]
[LAYER:CLOTHING_TORSO_SIMPLE_WHITE:ANIMAL_PEOPLE_TIGER_CLOTHING:Z:W]
[CONDITION_ITEM_WORN:BY_CATEGORY:BODY_UPPER:ARMOR:ITEM_ARMOR_COAT:ITEM_ARMOR_SHIRT:ITEM_ARMOR_TUNIC:ITEM_ARMOR_TOGA:ITEM_ARMOR_DRESS:ITEM_ARMOR_ROBE]
when ANIMAL_PEOPLE_HIPPO_CLOTHING_TEMPLATE starts 
Code: [Select]
[LAYER_GROUP]
[LAYER:CLOTHING_TORSO_SIMPLE_WHITE:ANIMAL_PEOPLE_HIPPO_CLOTHING:Z:W]
[CONDITION_ITEM_WORN:BY_CATEGORY:BODY_UPPER:ARMOR:ITEM_ARMOR_COAT:ITEM_ARMOR_SHIRT:ITEM_ARMOR_TUNIC:ITEM_ARMOR_TOGA:ITEM_ARMOR_DRESS:ITEM_ARMOR_ROBE]
. This is only a difference between a "TIGER" and a "HIPPO" in the second row, and the same difference appears over and over again, as the tile page is referred to. This is where the argument functionality of the graphics templates come in. By letting part of tile page ID be an argument, we can cram all the lines for animal people clothing (almost, I'll get to the exceptions) into a single graphics template. It would look something like this:

Code: [Select]
[OBJECT:GRAPHICS_TEMPLATE]

[GRAPHICS_TEMPLATE:ANIMAL_PEOPLE_CLOTHING_TEMPLATE]
[LAYER_GROUP]
[LAYER:CLOTHING_TORSO_SIMPLE_WHITE:ANIMAL_PEOPLE_!ARG1_CLOTHING:Z:W]
[CONDITION_ITEM_WORN:BY_CATEGORY:BODY_UPPER:ARMOR:ITEM_ARMOR_COAT:ITEM_ARMOR_SHIRT:ITEM_ARMOR_TUNIC:ITEM_ARMOR_TOGA:ITEM_ARMOR_DRESS:ITEM_ARMOR_ROBE]
[CONDITION_PROFESSION_CATEGORY:STONEWORKER]
[LAYER:CLOTHING_TORSO_SIMPLE_BLACK:ANIMAL_PEOPLE_!ARG1_CLOTHING:X2:Y]
[CONDITION_ITEM_WORN:BY_CATEGORY:BODY_UPPER:ARMOR:ITEM_ARMOR_COAT:ITEM_ARMOR_SHIRT:ITEM_ARMOR_TUNIC:ITEM_ARMOR_TOGA:ITEM_ARMOR_DRESS:ITEM_ARMOR_ROBE]
[CONDITION_PROFESSION_CATEGORY:NONE]
[CONDITION_DYE:BLACK]
...
(tens to hundreds of lines)
Code: [Select]
[OBJECT:GRAPHICS]

[CREATURE_GRAPHICS:TIGER_MAN]
[LAYER_GROUP]
[LAYER:BELOW_CLOTHING:CREATURES_ANIMAL_PEOPLE:A:B]

[APPLY_GRAPHICS_TEMPLATE:ANIMAL_PEOPLE_CLOTHING_TEMPLATE:TIGER]

[LAYER_GROUP]
[LAYER:ABOVE_CLOTHING:CREATURES_ANIMAL_PEOPLE:A2:B]

[CREATURE_GRAPHICS:SLUG_MAN]
[LAYER_GROUP]
[LAYER:BELOW_CLOTHING:CREATURES_ANIMAL_PEOPLE:C:D]

[APPLY_GRAPHICS_TEMPLATE:ANIMAL_PEOPLE_CLOTHING_TEMPLATE:TIGER]

[LAYER_GROUP]
[LAYER:ABOVE_CLOTHING:CREATURES_ANIMAL_PEOPLE:C2:D]
...
[CREATURE_GRAPHICS:HIPPO_MAN]
[LAYER_GROUP]
[LAYER:BELOW_CLOTHING:CREATURES_ANIMAL_PEOPLE:E:F]

[APPLY_GRAPHICS_TEMPLATE:ANIMAL_PEOPLE_CLOTHING_TEMPLATE:HIPPO]

[LAYER_GROUP]
[LAYER:ABOVE_CLOTHING:CREATURES_ANIMAL_PEOPLE:E2:D]
...



Exceptions/complications

Some animal people are larger than others, meaning they take up more than 1 32x32 tiles. These are the ones in "creatures_animal_people_huge.png", "creatures_animal_people_tall.png", and "creatures_animal_people_wide.png". Though they have similar base bodies/tunics, like the "huge" elephant and rhino people who use the hippo/bear person base, they may not be able to use the same tile pages due to this difference in size, and the tile coordinates used in the templates may also be off. This would mean four graphics template would be needed, one for each size.

Another problem is that while the same bases/tunics are used for many animal people, these are not always offset the same. For example, the slug person's tunic is offset by 9x9 pixels from the bottom left corner, while the tiger person's is offset by 10x10.

Here some kind of functionality to shift a layer around is needed, otherwise the above suggestion wouldn't work at all. I have a vague memory of Toady implying this might exist, in some interview during Premium's development, but not having seen any proof of it this memory might simply be wrong. If/when such a functionality exists, the offsets could be plugged into the graphics templates as arguments.

Finally, the raws for a tiger person's graphics might be as simple/short as this (plus some tokens for children, undead, corpses):
Code: [Select]
[CREATURE_GRAPHICS:TIGER_MAN]
[LAYER_GROUP]
[LAYER:BELOW_CLOTHING:CREATURES_ANIMAL_PEOPLE:A:B]

[APPLY_GRAPHICS_TEMPLATE:ANIMAL_PEOPLE_CLOTHING_TEMPLATE:TIGER:10:10]

[LAYER_GROUP]
[LAYER:ABOVE_CLOTHING:CREATURES_ANIMAL_PEOPLE:A2:B]