From d09577b8699c31606e8630d4c90cb78e291616d7 Mon Sep 17 00:00:00 2001 From: HDanke Date: Fri, 27 Feb 2026 15:14:36 +0200 Subject: [PATCH] Updated smart template info Based off the following research: Center template is also serialized and has group parent set when serialized. If the template contains a group parent besides the center template, the center of the object group will be calculated as the average of all objects' sprite origin positions. Since the game assumes the center is always X 0 Y -90 when pasting the objects regardless of the center template's position, this results in a bug where all objects inside the template are offset from their actual position. kCEK 10 1 - template id: int 2 - name: str 3 - variations: dict[template_match_string,list[dict_kCEK_11]] 4 - allow rotation: int 5 - allow flip x: int 6 - allow flip y: int 7 - ignore corners: int 4-7 are set upon first selection to value 1 while the template is in use, once saved they cannot be removed and the template does not remember the last selected options when loaded in-game. kCEK 11 1 - serialized objects: str 2 - weight: int Template match string 9-character string that encodes the template's 3x3 block layout. The character's index encodes position while its value encodes template type. The directions represent what side the legs of the slope point towards. 1x Slopes have equal legs so they are interchangeable while for 2x slopes the first direction is the one the longer leg of the slope points towards while the second direction is for the shorter leg. 2x slopes cover 2 blocks so they are represented by 2 different templates where center is the smaller half of the slope while side is the larger half. Index 0 - Center 1 - Top 2 - Bottom 3 - Left 4 - Right 5 - Top-Left 6 - Top-Right 7 - Bottom-Left 8 - Bottom-Right Values 0 - None 1 - Square 2 - 1x Slope Bottom-Right 3 - 1x Slope Bottom-Left 4 - 1x Slope Top-Left 5 - 1x Slope Top-Right 6 - 2x Slope Center Bottom-Right 7 - 2x Slope Side Bottom-Right 8 - 2x Slope Center Bottom-Left 9 - 2x Slope Side Bottom-Left A - 2x Slope Center Top-Right B - 2x Slope Side Top-Right C - 2x Slope Center Top-Left D - 2x Slope Side Top-Left E - 2x Slope Center Right-Top F - 2x Slope Side Right-Top G - 2x Slope Center Right-Bottom H - 2x Slope Side Right-Bottom I - 2x Slope Center Left-Bottom J - 2x Slope Side Left-Bottom K - 2x Slope Center Left-Top L - 2x Slope Side Left-Top --- docs/resources/client/gamesave/template.md | 101 +++++++++++++-------- 1 file changed, 63 insertions(+), 38 deletions(-) diff --git a/docs/resources/client/gamesave/template.md b/docs/resources/client/gamesave/template.md index d632bea..353f6ce 100644 --- a/docs/resources/client/gamesave/template.md +++ b/docs/resources/client/gamesave/template.md @@ -13,44 +13,69 @@ Smart Templates are user-made templates used for the Auto Build feature. They ar | 1 | Smart Template ID | integer | | 2 | Name | string | | 3 | Template Variations | dict | -| 4 | Unknown | integer | -| 5 | Unknown | integer | -| 6 | Unknown | integer | -| 7 | Unknown | integer | +| 4 | Allow Rotation | integer | +| 5 | Allow Flip X | integer | +| 6 | Allow Flip Y | integer | +| 7 | Ignore Corners | integer | + +Keys 4 to 7 are set upon first selection to value 1 while the template is selected in-game, once saved these keys cannot be removed. The keys are functionally useless as the template does not remember the last selected options when loaded. + +Key 3 stores a dictionary that maps a 9-character long string key (representing the template's 3x3 layout) to a list of kCEK 11 dictionaries. + +The character's index represents its position inside the layout: + +| Char | Position | +| ---- | ------------- | +| 1 | Center | +| 2 | Top | +| 3 | Bottom | +| 4 | Left | +| 5 | Right | +| 6 | Top Left | +| 7 | Top Right | +| 8 | Bottom Left | +| 9 | Bottom Right | + +The character's value represents the type of template that will be matched at that position: + +| Value | Template | +| ---- | ---------------------------- | +| 0 | None | +| 1 | Square | +| 2 | 1x Slope Bottom-Right | +| 3 | 1x Slope Bottom-Left | +| 4 | 1x Slope Top-Left | +| 5 | 1x Slope Top-Right | +| 6 | 2x Slope Center Bottom-Right | +| 7 | 2x Slope Side Bottom-Right | +| 8 | 2x Slope Center Bottom-Left | +| 9 | 2x Slope Side Bottom-Left | +| A | 2x Slope Center Top-Right | +| B | 2x Slope Side Top-Right | +| C | 2x Slope Center Top-Left | +| D | 2x Slope Side Top-Left | +| E | 2x Slope Center Right-Top | +| F | 2x Slope Side Right-Top | +| G | 2x Slope Center Right-Bottom | +| H | 2x Slope Side Right-Bottom | +| I | 2x Slope Center Left-Bottom | +| J | 2x Slope Side Left-Bottom | +| K | 2x Slope Center Left-Top | +| L | 2x Slope Side Left-Top | + +The directions represent what side the legs of the slope point towards. 1x Slopes have equal legs so they are interchangeable while for 2x slopes the first direction is the one the longer leg sits on while the second direction is for the shorter leg. + +2x slopes cover 2 blocks so they are represented by 2 different templates where center is the smaller half of the slope while side is the larger half. ## kCEK 11 -kCEK 11's are stored in key 3 of kCEK 10 in the following format: - -``` -100010000 - - _isArr - - k_0 - - kCEK11 - 11,1,2,0,3,-90;1,2895,2,0,3,-90,34,1; - - k_1 - - kCEK11 - 1... - - -``` - -kCEK 11 key 1 is the [object string](/resources/client/level-components/level-string.md) of the template variation. The object string is **unencoded** and stored raw. The center point is at X: 0, Y: -90. - -The keys of the dictionary are 9-bit bitfields (binary numbers) representing the exact type of template variation. The first bit is reserved and is always set to `1`. Other bits represent: - -| Bit | Position | -| --- | ------------- | -| 2 | Top Middle | -| 3 | Bottom Middle | -| 4 | Center Left | -| 5 | Center Right | -| 6 | Top Left | -| 7 | Top Right | -| 8 | Bottom Left | -| 9 | Bottom Right | +| Key | Value | Type | +| --- | ------------- | ------ | +| 1 | Object String | string | +| 2 | Weight | int | + +Key 1 is the [object string](/resources/client/level-components/level-string.md) of the template variation. The object string is **unencoded** and stored raw. The center point is at X: 0, Y: -90. + +The center smart template object is also encoded alongside the rest of the template variation's objects and is given property 34 (group parent) when serialized. + +Key 2 is the variation's weight used to calculate the template's random chance to be picked.