Page 1 of 1

Unit Design - unit property sheet/visuals

Posted: Fri Nov 23, 2018 2:11 pm
by Stratego (dev)
Here i describe the visual definition part

contents:


- General
- Wall like auto-join definitions
- Visual definition TYPE-s
- Image positioning
- Animation definitions (procedural)



"visuals" part is a list, a list of visuality types of a unit eg: DEFAULT, CONSTRUCTION, JOIN, JOINX, OCCUPIED

General

here a sample:

Code: Select all

   "uiDefinition":{
      "imageFacingDirection":"RIGHT",
      "trnDecorMoveSpriteID":"SPRITE_DECOR_MOVE_TANK_ANIM",
      "animationDefs":[
         "case:die,t:foot",
         "case:atktype,a:flame"
      ],      
      "visuals":[
      
      
         {
            "imgName":"64_unit_celt.png",
            "type":"DEFAULT",
            "shiftIndicatorsDown":32,
            "typeExtra":0.0,
            "imgColumns":1,
            "imageDefParts":[
	                   {
	                      "cropToRect":{"top":0, "left":0,"bottom":32,"right":32},
	                      "layer":"OVERLAPS",
	                      "shiftCol":0,
	                      "shiftRow":-1,
	                      "clickable":false
	                   },
	                   {
	                      "cropToRect":{"top":32,"left":0,"bottom":64,"right":32},
	                      "layer":"UNITS",
	                      "shiftCol":0,
	                      "shiftRow":0,
	                      "clickable":true
	                   }
            ]
         }

         
         ]
         
         ...
     }
         
"imageFacingDirection": "RIGHT" / "LEFT" / "NOFLIP" you ca set the image direction, and if you dont want it to flip by movement/attack.
"trnDecorMoveSpriteID": you can reference a sprite in graphics.json to show when the unit moves (eg. dust cloud under the wheels), it is shown during movement and fades out (in the defined fadeout amount) sec after movement.
"trnDecorAttackSpriteID": you can reference a sprite in graphics.json to show when the unit attacks (ranged or melee) (eg. sword swing), it is shown during attack and fades out in (on texture defined) amount of sec after attack.
"trnDecorMendSpriteID": you can reference a sprite in graphics.json to show when the unit Mends (ranged or melee) (eg. sword swing), it is shown during mending and fades out in (on texture defined) amount of sec after mend.
"trnDecorSpellcastSpriteID": you can reference a sprite in graphics.json to show when the unit attacks (ranged or melee) (eg. sword swing), it is shown during spellcast and fades out in (on texture defined) amount of sec after spellcast.
"animationDefs": each string entry is a list of procedural animation setting (defining the case to be handled eg. on Die, defining the animation object type to use, the attack type can be set.
"imgName": here u give the asset image name under the assets/gfx folder (name must only contain a..z, 0..9 and _ charcters, so no capital letters and no space characters either)
"type":"DEFAULT", this is the visuality type, DEFAULT is the normal image for unit it can be: DEFAULT, CONSTRUCTION, JOIN, JOINX, OCCUPIED
* DEFAULT: the default image - where no one around
* DEFAULT_DIR: the default image but with directional changes (looking north, north-east, set in typeExtra)
* CONSTRUCTION: when it is under cosntruction (and their phases), what should be shown
* OCCUPIED: god knows what this is
* JOIN: if you do not deal with diagonal joins.
* JOINX: if you deal with diagonals too
"shiftIndicatorsDown": a value how much pixe the indicators needed to be shifted down from the top left position.
"imgColumns": how many columns of the image or animation: 1: single, 2: can be 2 tile animation or an occupiable building, more: animation.
"animFrameDuration": sets the duration of a frame in millisecs, if null than default is 200ms
"animFrameDurations": eg: [6000,200,200,200,200,200,200,200,200,200], sets the frame duration for all frames in millisecs(if set, animFrameDuration is omitted)
int[] "animFramePreDelayRandom": !only work with animFrameDurations!: 2 values in array, 0th: randomFrom 1th:randomTo, rnd between values, and delay that amount of ms before starting animation.

"typeExtra": some extra input for some options.
"imageDefParts": here you can define which part of the image you define to which layer
"imageDefShort" this is a simpler way to set imageDefParts


Image positioning
Use imageDefParts or imageDefShort?
if u have non animating simple unit image i suggest the short version, in any complex case the detailly configurable version.

instead of this

Code: Select all

            "imageDefParts":[
               {
                  "cropToRect":{"top": 0,"left":0,"bottom":32,"right":32},
                  "layer":"UNITS",
                  "shiftCol":0,
                  "shiftRow":0,
                  "clickable":true
               }
            ]
you can write this:

Code: Select all

"imageDefShort":"NORMAL_1x1"
also instead of this

Code: Select all

            "imageDefParts":[
               {
	       	                      "cropToRect":{"top":0, "left":0,"bottom":32,"right":32},
	       	                      "layer":"OVERLAPS",
	       	                      "shiftCol":0,
	       	                      "shiftRow":-1,
	       	                      "clickable":false
	       	                   },
	       	                   {
	       	                      "cropToRect":{"top":32,"left":0,"bottom":64,"right":32},
	       	                      "layer":"UNITS",
	       	                      "shiftCol":0,
	       	                      "shiftRow":0,
	       	                      "clickable":true
	                   }
            ]
you can write this

Code: Select all

"imageDefShort":"OVERLAP_1x2"
and we have 4 options currently:
- NORMAL_1x1 for a normal 1x1 tile unit
- OVERLAP_1x2 for a tall unit like a trebuchet, this will overlap the tile above its "foot" tile.
- NORMAL_COL2_2x1 OBSOLETE! (dont use doubled image anymore!) this is for a 1x1 building that shows occupacy so image is 2x1 sized
- OVERLAP_COL2_2x2 OBSOLETE! (dont use doubled image anymore!) this is for a 1x2 building that shows occupacy so image is 2x2 sized


Visual definition TYPE-s
"type":"DEFAULT", this is the visuality type, DEFAULT is the normal image for unit
other options:
CONSTRUCTION - this is used when the unit is under construction, set in "typeExtra" the readiness limits (over this limit this image is used)
OCCUPIED - this image is used if the eg. building is occupied (carried some units)
JOIN and JOINX: use these to autotile this unit: eg a wall that transforms as u put an other wall next to it (it joins)


Wall like auto-join definitions
see here written on discord:
https://discord.com/channels/3735904559 ... 0091156551

obraz.png
obraz.png (6.72 KiB) Viewed 334 times
So when looking at start of json - first column deals only with case of UL DR, so
obraz2.png
obraz2.png (1.26 KiB) Viewed 333 times
11th column also only has one set:
UL,UR,DL, so:
obraz3.png
obraz3.png (1.49 KiB) Viewed 333 times
The hard ones are those:

Code: Select all

{
            "imgName":"units/unit_palisade_set.png",
            "type":"JOINX",
        "types": [
          {
            "type":"JOINX",
            "typeExtraString": "UR"
          },
          {
            "type":"JOINX",
            "typeExtraString": "UR,DN"
          },
          {
            "type":"JOINX",
            "typeExtraString": "UR,DN,DR"
          },
          {
            "type":"JOINX",
            "typeExtraString": "DN,UR,DR,DL"
          },
          {
            "type":"JOINX",
            "typeExtraString": "DN,UR,DL"
          }
        ],
            "shiftIndicatorsDown":20,
            "typeExtra":0.1,
            "imgColumns":1
      },
It can be assigned when there is UR, DN, so:
obraz4.png
obraz4.png (1.22 KiB) Viewed 333 times
Just UR (even before):
obraz5.png
obraz5.png (1.04 KiB) Viewed 333 times
UR,DN,DR, so:
obraz6.png
obraz6.png (1.32 KiB) Viewed 333 times
DN,UR,DR,DL, so:
obraz7.png
obraz7.png (1.44 KiB) Viewed 333 times
And lastly DN,UR,DL, so:
obraz8.png
obraz8.png (1.33 KiB) Viewed 333 times
Wildcard feature Feature!
if you use * after the direction a tile is than that mean it will "fit" even if there is wall or not! so means the setup do not care if there is or not tile (as irrelevant for the given definition)
example:
means:
RT+LT+DN : should be from the "unit" type (eg. wall)
DR,DL: also below right and below left should be a unit(eg. wall)
UL*,UR*: on these positions it is irrelevant if there is unit (wall) or not (as not affects if this tile to be used or not)

Code: Select all

         {
            "c":"COL 2 middle topborder",
            "imgName":"terrain/terrain_format_city_wall.png",
            "type":"JOINX",
            "types":[
               {
                  "type":"JOINX",
                  "typeExtraString":"RT,LT,DN,DR,DL,UL*,UR*"
               }
            ],
            "shiftIndicatorsDown":0,
            "typeExtra":0.1,
            "imgColumns":1
         },
wall.png
wall.png (12.43 KiB) Viewed 318 times

Procedural Animations
This setting is using some algorithms that will manipulate the sprite to look if it were animationg, making smoke over it, cutting it to pieces to make them collapse after or split unit sprite for an exploding effect.

These setting can be set on Units and Effect Affects (both are in the units folder)

example Setting on a unit :

Code: Select all

      "animationDefs":[
         "case:die,t:foot",
         "case:atktype,a:flame"
      ],      
case:die: This will make the unit call the "foot" units type of animation on the event "on-die"
case:atktype: Also it defines this unit that this unit's attack is a flame attack (meaning killing with this attack the enemy will be burnt - not exploding or other type of default effects)

The possible case names, animation names and attack type names are listed in unit editor.
Currently they called like
events: case:die case:atktype
attacks: a:explosion a:flame a:beam
types: t:vehicle t:equipment t:foot t:plane t:non-plane t:building
(these types are just fictive names, eg. building is not necessary building but the building animation will smoke and crumble to ground like a building)

Re: Unit Design - unit property sheet/visuals

Posted: Mon Aug 19, 2019 9:26 am
by Stratego (dev)
new setting :
"imageFacingDirection": "RIGHT" / "LEFT" / "NOFLIP" you ca set the image direction, and if you dont want it to flip by movement/attack.

Re: Unit Design - unit property sheet/visuals

Posted: Fri Sep 06, 2019 3:48 pm
by Dagravian
On an animated img, can i define the speed the game does reproduce each frame? For example, can or how i imput to game reproduce the frames at 100ms, 120ms, 150ms or some other speed? Also, whats the default speed of the animations?

Re: Unit Design - unit property sheet/visuals

Posted: Sat Sep 07, 2019 9:57 am
by Stratego (dev)
please always try to check in modders lunge, maybe there is answer.

check here maybe that andwers the question:
Game definition jsons - Sprites and Textures

Re: Unit Design - unit property sheet/visuals

Posted: Fri Dec 20, 2019 10:14 pm
by Stratego (dev)
"trnMoveDecorSpriteID": you can reference a sprite in graphics.json to show when the unit moves (eg. dust cloud under the wheels), it is shown during movement and fades out in 0.5 sec after movement.

Re: Unit Design - unit property sheet/visuals

Posted: Thu Mar 11, 2021 12:28 pm
by Stratego (dev)
new unit decor animations options
"trnDecorMoveSpriteID": you can reference a sprite in graphics.json to show when the unit moves (eg. dust cloud under the wheels), it is shown during movement and fades out (in the defined fadeout amount) sec after movement.
"trnDecorAttackSpriteID": you can reference a sprite in graphics.json to show when the unit attacks (ranged or melee) (eg. sword swing), it is shown during attack and fades out in (on texture defined) amount of sec after attack.
"trnDecorMendSpriteID": you can reference a sprite in graphics.json to show when the unit Mends (ranged or melee) (eg. sword swing), it is shown during mending and fades out in (on texture defined) amount of sec after mend.
"trnDecorSpellcastSpriteID": you can reference a sprite in graphics.json to show when the unit attacks (ranged or melee) (eg. sword swing), it is shown during spellcast and fades out in (on texture defined) amount of sec after spellcast.

(also the trnDecorMoveSpriteID is the new name of the movement decoration)

Re: Unit Design - unit property sheet/visuals

Posted: Tue Oct 26, 2021 8:43 am
by Stratego (dev)
new option in visuals section
"animFrameDuration": sets the duration of a frame in millisecs, if null than default is 200ms

Re: Unit Design - unit property sheet/visuals

Posted: Thu Jun 22, 2023 10:35 pm
by Stratego (dev)
new option:
"animFrameDurations": eg: [6000,200,200,200,200,200,200,200,200,200], sets the frame duration for all frames in millisecs (if set, animFrameDuration is omitted)

Re: Unit Design - unit property sheet/visuals

Posted: Sat Sep 23, 2023 7:56 pm
by Stratego (dev)
new option:

public int[] animFramePreDelayRandom = null; //!only work with animFrameDurations!: 2 values in array, 0th: randomFrom 1th:randomTo, rnd between values, and delay that amount of ms before starting animation.

Re: Unit Design - unit property sheet/visuals

Posted: Sat Mar 14, 2026 10:27 am
by Stratego (dev)
new description how to use the procedural animations

Code: Select all

      "animationDefs":[
         "case:die,t:foot",
         "case:atktype,a:flame"
      ],