The flag tag describes the behaviour and appearance of a cloth-like material. As a type of widget, flags can be attached to objects like weapons using model markers. They are not limited to weapons and can even be attached to bipeds, however the game only supports rendering 2 flags.

They are essentially a grid of attached point_physics vertices forming a rectangular shape with configurable density and cell sizes. One edge is deemed the attached edge and can have several attachment points to the object, while the opposite edge is deemed the trailing edge and flows freely. Because they make use of point_physics, flags are affected by wind.

Physics

The spaces between flag vertices are called cells and have configurable cell width and cell height. The cells try to maintain their size and are capable of stretching. Like antenna, flags can make use of a variety of point physics features:

  • If no gravity is set then the flag will float around rather than hang.
  • If collides with structures is set, the points may inconsistently collide with the BSP. Depending on the other settings, the flag may come to a rest on the BSP for a time before hanging through it. Collisions with model_collision_geometry seem to require much lower point velocities and are barely noticeable.
  • Density affects how "floaty" the points are. Low near-zero values will cause the flag to hang in the air, while higher values result in it falling more quickly.
  • Air friction is especially important for flags given their interaction with wind and movement when carried.
  • Elasticity determines the bounciness of collisions with structures, not how stretchy the flag is.

Simulation culling

Flags are not simulated when off-screen (based on the bounding sphere of their object). When they reappear you may notice a slight jiggle as they reach their rest state again.

Attachment points

Along the attachment edge of the flag you can define a series of 2-4 attachment points at a model marker. The flag's height will span these attachment points and be fixed in place at each of them, with a configurable number of cells between the attachment points. The markers used don't need to be unique; it would be possible for the leading edge to form a loop by reusing a marker for the first and final attachment points. The game requires that the sum of all attachment points' height to next attachment is 1 less than height. The final attachment point should use height 0.

A 9x9 vertex flag with 3 attachment points at markers flag top (A), flag bottom (B), and left hand cyborg (C). A and B have height to next attachment set to 4.

Shapes

This tag supports various shapes for the attached and trailing edges of the flag. Different trailing edge shape options result in the trailing edge of the flag being visually cut off (though the vertices still exist). The trailing edge shape offset allows you to slide this mask along the width of the flag by a positive or negative number of vertices.

The attached edge shape only supports flat or concave triangular, and occurs between each pair of attachment points.

Examples of various trailing edge shapes. The trailing edge offsets are 0 in most of these examples. In the bottom right image, an attached edge shape is used and the trailing edge offset is -3.

Limits

The game state has only 2 entries for flags in all versions of H1, so any other flags on the map will not render.

Related HaloScript

Function/global

Type

(debug_point_physics [boolean])

Renders green or red markers wherever point_physics are being simulated, except for the weather_particle_system. This includes flags, antenna, contrails, particles, and particle_systems. It can help to enable framerate_throttle for these markers to render consistently.

Red markers indicate point_physics with the collides with structures flag, which are more computationally expensive.

Global

Structure and fields

FieldTypeComments
flagsbitfield
FlagMaskComments
unused0x1
trailing edge shapeenum

The shape of the trailing edge.

OptionValueComments
flat0x0

A simple straight edge, used by the game's stock flag.

concave triangular0x1

A triangular cutout forms two points at the corners.

convex triangular0x2

The trailing edge's corners are cut off, forming an arrow.

trapezoid short top0x3

The trailing edge is cut at an angle with the top edge short.

trapezoid short bottom0x4

The trailing edge is cut at an angle with the bottom edge short.

trailing edge shape offsetint16
  • Unit: vertices

Determines the number of vertices the trailing edge shape is offset. A value 0 places the shape exactly on the trailing edge. Positive values will push it off the edge of the flag while negative values will move it inwards.

attached edge shapeenum

The shape of the attached edge. This will appear between each pair of attachment points.

OptionValueComments
flat0x0

A simple straight edge, used by the game's stock flag.

concave triangular0x1

The edge will have a triangular cutout between attachment points.

widthint16
  • Unit: vertices

Flag size from attached to trailing edge. This counts the number of vertices (cells+1), not the number of cells.

heightint16
  • Unit: vertices

Flag size along the direction of attachment. This counts the number of vertices (cells+1), not the number of cells. This value should be 1 higher than the sum of all attachment points' height to next attachment or else the flag will not appear. This must also be an odd number or else the flag will not appear or be streteched to the world origin (0, 0, 0).

cell widthfloat
  • Unit: world units

Width of the cell between each pair of vertices.

cell heightfloat
  • Unit: world units

Height of the cell between each pair of vertices.

red flag shaderTagDependency: shader

The appearance of the flag when used for red team (netgame flag team index 0).

physicsTagDependency: point_physics

The physics to use for each vertex of the flag.

wind noisefloat
  • Unit: world units per second
blue flag shaderTagDependency: shader

The appearance of the flag when used for blue team (netgame flag team index 1).

attachment pointsBlock
  • HEK max count: 4

A series of attachment points for the flag's attached edge. There must be at least 2 attachment points or the flag will be ignored.

FieldTypeComments
height to next attachmentint16
  • Unit: vertices

The number of cells between this attachment point and the next. The final attachment point should use the value 0. For example, a flag with 3 attachment points and height of 9 vertices should use attachment point heights of 4, 4, and 0 respectively.

marker nameTagString

Name of the model marker where this point attaches. If the name is empty or the marker does not exist then the point will attach to the object's root node.

Acknowledgements

Thanks to the following individuals for their research or contributions to this topic:

  • Conscars (Tag field testing)
  • Kavawuvi (Invader tag definitions)
  • MosesOfEgypt (Tag structure research)