Table of Contents

Animals

Animals basically are models as any other object in the game, but they have some unique events and a special metadata struct so they are spawned and move around the map.

Metadata

In addition to the general .mdl properties, animals use the cameraConfig struct as players can follow animals in first person view. Furthermore, there is a metadata struct called animal:

function data()
return {
  -- bounding box
  -- collider
  -- lods
 
  metadata = {
    description = {
      name = _("Salmon"),
    },
    cameraConfig = {...},
    animal = {
      config = {...},
      flockName = "",
      flockFormationFn = { 
        fileName = "/animal/animal.script@flock.salmon",
        params = { },
      },
      movement = {...},
      movementTypes = {...},
      suitableAreas = {...},
    },
    categoryList = { 
      categories = { "temperate.clima", "subarctic.clima", },
    },
  },
  version = 1,
}
end

The name is shown as the default name if the user clicks on an animal. It can be translated in a strings.json file.

The cameraConfig struct is used for the first person view. To learn how to define camera views, read the relevant section in the model definition documentation.

The animal struct contains several property structs, these are described below.

Config


highlighted area around predators

The config struct contains several general properties for animals:

Flocks

Birds and Fishes may travel around in flock formations. If an animal has a configured flock, it will move in this group. Otherwise the animal will move alone.

The flock formations have a name that is specified in flockName. The formation is configured in an external .script.lua file. This is referenced in flockFormationFn. The .script.lua looks like this:

function data()
return {
  flock = {
    salmon = function()
    ...
    return { 
      positions = {...},
      overrides = {...},
    }
    end
  },
  ...
}
end

The functions do not have any parameters. The expected result struct contains two properties:

Movement

The movement struct describes some restrictions regarding where the animals move:

Movement Types

It is possible to define several movement types. For example, land animals can stay around (idle), walk and run. For each of the movement types, there is a struct in the movementTypes list with the following properties:

Suitable Areas

The suitableAreas struct is used to limit the occurance and movement of animals to certain areas. There are several terrain related factors as well as factors related to other animals. All factors are mapped to scores. The overall sum of scores summarizes the likelyhood of the animal existing in a certain spot. If an animal gets into an area with negative score, it will try to run away. If it fails to leave the non suitable area it will eventually die.

It is possible to analyze the score factor maps with the ingame debug tools.

Events

The events of animals are mostly defined by their movementTypes. The most common events are: