field_animations.lua

This script contains some animations to reveal and hide fields seen by a player. This functions are currently used in the campaigns and scenarios to tell the prologue to a story.

include "scripting/field_animations.lua"
reveal_randomly(player, region, time)

Reveal a given region field by field, where the fields are chosen randomly. The region will be hidden before being revealed. The animation runs the specified time.

Parameters:
  • player (wl.game.Player) – The player who gets sight to the region

  • region (array of fields) – The region that has to be revealed. E.g. by using wl.map.Field.region()

  • time (integer) – Optional. The time the whole animation will run. Defaults to 1000 (1 sec)

  • hide (boolean) – Optional, if false automatic hiding is disabled

hide_randomly(player, region, time[, permanent=false])

Hide a given region field by field, where the fields are chosen randomly. The animation runs the specified time regardless how big the given region is. So region(6) and region(13) will take the same time.

Parameters:
  • player (wl.game.Player) – The player whose sight gets hidden

  • region (array of fields) – The region that will be hidden. E.g. by using wl.map.Field.region()

  • time (integer) – Optional. The time the whole animation will run. Defaults to 1000 (1 sec)

  • permanent (boolean) – Optional. Set to true to hide the fields permanently (they can’t be seen by any unit until revealed again by using :meth: ~wl.game.Player.reveal_fields). Set to false to make the fields unexplored (they can be rediscovered by buildings and bobs again). Defaults to false.

reveal_concentric(player, center, max_radius, hide, delay)

Reveal a part of the map in a concentric way beginning from center onto max_radius. The region get hidden prior revealing as default.

Parameters:
  • player (wl.game.Player) – The player who gets sight to the region

  • center (wl.map.Field) – The field from where the animation should start revealing

  • max_radius (integer) – The last ring to reveal

  • hide (boolean) – Optional, if false automatic hiding is disabled

  • delay (integer) – Optional, defaults to 100. The delay between revealing each ring. If you want to set the delay, you must also set hide

hide_concentric(player, center, max_radius, delay[, permanent=false])

Hide a part of the map in a concentric way beginning from max_radius onto center.

Parameters:
  • player (wl.game.Player) – The player whose sight gets hidden

  • center (wl.map.Field) – The field where the animation should end hiding

  • max_radius (integer) – The first ring to hide

  • delay – Optional, defaults to 100. The delay between revealing each ring

  • permanent (boolean) – Optional. Set to true to hide the fields permanently (they can’t be seen by any unit until revealed again by using :meth: ~wl.game.Player.reveal_fields). Set to false to make the fields unexplored (they can be rediscovered by buildings and bobs again). Defaults to false.

get_sees_fields(player)

Gather all fields a player can see in the current view. The current view is the whole area of the map in the current game window. You can use this function to get an unregular (non hexagonal) region and feed e.g. reveal_randomly() with it.

Parameters:

player (wl.game.Player) – The player for whom the fields get gathered

Returns:

A table containing all visible fields in the current view