Homeworld Effects Manual: alternate, alt()

alternate
{
	alt(weight):
	statements
	alt(weight):
	statements
	...
}

Selects one of several weighted choices

weight can vary between alt() statements, i.e., not every choice must have the same probability of occuring. weight may be an integer or floating-point, but must be a literal, not a variable. Negative values are allowed, but have the same effect as 0.

the alternate-alt structure is like a randomized switch-case statement. One block of statements is executed each time through the structure, but instead of picking based on the value of some variable, each code segment is assigned a probability of being selected. These probabilities do not have to sum to 1. An alt(2) is twice as likely as an alt(1). There can be any number of alt() statements in an alternate block, and any number of statements after each alt().Usually this is used for randomizing smoke by selecting one of several smoke animations. It could also be used for more advanced features, like replacing one out of every thousand Klingon disruptor bolts with a Bat'leth. (Sadly, this feature did not make it into SOA v0.9)