Training Sites

Trainingsites are a special type of productionsite building where soldiers are housed and wares are being consumed to train the soldiers to better levels. They also have workers working at them.

Trainingsites are defined in data/tribes/buildings/trainingsites/<tribe_name>/<building_name>/init.lua. The building will also need its help texts, which are defined in data/tribes/initialization/<tribe_name>/units.lua

new_trainingsite_type{table}

This function adds the definition of a training site building to the engine.

Parameters

table – This table contains all the data that the game engine will add to this building. It is a special type of production site, so it has all the entries that Production Sites can have, plus the following entries:

soldier_capacity

Mandatory. An int describing how many soldiers this building can house.

trainer_patience

Mandatory. An int describing how patient the trainer is. If trainer patience runs out, a soldier will be kicked out.

soldier attack

Deprecated. A table describing what is needed to train a soldier in attack.

soldier defense

Deprecated. Just like soldier attack, but for defense training.

soldier health

Deprecated. Just like soldier attack, but for health training.

soldier evade

Deprecated. Just like soldier attack, but for evade training.

messages

Mandatory. A table with translatable production tooltips, containing the keys no_soldier and no_soldier_for_level. See example below for details.

For making the UI texts translateable, we also need to push/pop the correct textdomain.

Example:

push_textdomain("tribes")

dirname = path.dirname(__file__)

wl.Descriptions():new_trainingsite_type {
   name = "empire_arena",
   descname = pgettext("empire_building", "Arena"),
   icon = dirname .. "menu.png",
   animation_directory = dirname,
   size = "big",

   buildcost = {
      log = 2,
      granite = 4,
      marble = 5,
      planks = 5,
      marble_column = 2
   },
   return_on_dismantle = {
      log = 1,
      granite = 3,
      marble = 3,
      planks = 2,
      marble_column = 1
   },

   enhancement = {
      name = "empire_colosseum",
      enhancement_cost = {
         planks = 2,
         granite = 4,
         marble = 4,
         cloth = 2,
         gold = 4,
         marble_column = 4
      },
      enhancement_return_on_dismantle = {
         planks = 1,
         granite = 2,
         marble = 2,
         gold = 2,
         marble_column = 2
      }
   },

   animations = {
      idle = {
         hotspot = { 81, 82 }
      },
      build = {
         hotspot = { 82, 83 },
      }
   },

   aihints = {
      trainingsites_max_percent = 10,
      prohibited_till = 900,
      very_weak_ai_limit = 1,
      weak_ai_limit = 2
   },

   working_positions = {
      empire_trainer = 1
   },

   inputs = {
      { name = "fish", amount = 6 },
      { name = "meat", amount = 6 },
      { name = "empire_bread", amount = 10 }
   },

   programs = {
      sleep = {
         descname = _("sleeping"),
         actions = {
            "sleep=duration:5s",
            "return=skipped",
         }
      },
      upgrade_soldier_evade_0 = {
         descname = pgettext("empire_building", "upgrading soldier evade from level 0 to level 1"),
         actions = {
            "checksoldier=soldier:evade level:0", -- Fails when aren't any soldier of level 0 evade
            "return=failed unless site has empire_bread",
            "return=failed unless site has fish,meat",
            "sleep=duration:30s",
            "checksoldier=soldier:evade level:0", -- Because the soldier can be expelled by the player
            "consume=empire_bread fish,meat",
            "train=soldier:evade level:1"
         }
      },
   },

   soldier_capacity = 8,
   trainer_patience = 8,

   messages = {
      -- Make this translatable with pgettext: Empire training site tooltip when it has no soldiers assigned
      no_soldier = "No soldier to train!"
      -- Make this translatable with pgettext: Empire training site tooltip when none of the present soldiers match the current training program
      no_soldier_for_level = "No soldier found for this training level!",
   },
}

pop_textdomain()