Classes and class pickers
[logic.deployment] in the header declares the classes players choose from before each life, bought with deployment points. A mode with classes needs "rounds.teams" = 1. A free, unlimited class on each team is required, so nobody is ever stuck.
--[=[ mode
name = "Two Classes"
[rules]
kill_points = 1
score_to_win = 25
[options]
"rounds.teams" = 1
[logic.deployment]
title = "Choose a class"
teams = ["Red", "Blue"]
[[logic.deployment.classes]]
name = "Rifle"
description = "A Battle Rifle and two frag grenades."
team = 0
cost = 0
biped = "spartan"
primary = "battle_rifle"
grenades = [2, 0, 0, 0]
[[logic.deployment.classes]]
name = "Sniper"
description = "A Sniper Rifle, for 100 points."
team = 0
cost = 100
max_active = 1
biped = "spartan"
primary = "sniper_rifle"
[[logic.deployment.classes]]
name = "Rifle"
description = "A Carbine and two plasma grenades."
team = 1
cost = 0
biped = "elite"
primary = "carbine"
grenades = [0, 2, 0, 0]
[[logic.deployment.classes]]
name = "Sniper"
description = "A Beam Rifle, for 100 points."
team = 1
cost = 100
max_active = 1
biped = "elite"
primary = "beam_rifle"
]=]
-- 50 deployment points a kill.
alias kills = player.number[0]
for each player do
global.number[0] = current_player.get_kill_count()
if global.number[0] != current_player.kills then
current_player.kills = global.number[0]
global.number[1] = current_player.get_deployment_points()
global.number[1] += 50
current_player.set_deployment_points(global.number[1])
end
end
title- The picker's title, up to 48 bytes.
teams- 2 to 8 team names, up to 24 bytes each.
script_menutrue: the script draws its own picker with its widgets (deploy_class), and the built-in one stays hidden.[[logic.deployment.classes]]- 2 to 128 classes, at most 48 a team, numbered from 0 in their order: the numbers
deploy_classandget_deployment_…take. Each team needs a free class without a limit.
name,description- Up to 32 and 120 bytes. A team's classes have different names.
team- Its team's number; 0 is the first of
teams. cost- The deployment points it takes, 0 to 100,000.
max_active- The most players in it at once; 0 for any number. A choice waiting to deploy counts.
biped- The body, from the body list.
model_variant- The body's model variant.
camera"native", Halo 3's, or"third_person", on foot.primary,secondary- Weapons by name, from the weapon list, or by tag path. A path can name a mod's or another game's weapon loaded on the map; the class picker shows the tag's own name. If the map lacks it, the class starts without that weapon. Reach's own names include
dmr,needle_rifle,plasma_repeater,spike_rifle,grenade_launcher,plasma_launcherandflak_cannon(its fuel rod gun); therebrute_shotis its concussion rifle andbeam_rifleits focus rifle. dual_wieldtrue: the secondary in the left hand. Two plasma rifles only.grenades- Frag, plasma, spike and firebomb grenades, 0 to 4 each:
[2, 0, 0, 0]. traits- Traits while in the class, as a table:
[logic.deployment.classes.traits]. health- The damage the body takes is divided by this, 0.1 to 10; 1 by default.
Without script_menu, players choose in the built-in class cards, or on the deployment map when the mode has deploy points. With the built-in picker, widget 3 shows each player's class and points, and the other widgets are the script's. A roster with script_menu leaves all 32 to the script.
current_player.deploy_class(n)- A waiting player of class n's team, with its cost and no class chosen this life, takes it while it has room: 1 if they did, else 0. It gives a value: assign it.
get_deployment_class()- The class chosen for their next life, −1 while they choose.
get_last_deployment_class()- The class of their last life, kept after they die; −1 before their first.
get_deployment_points(),set_deployment_points(n)- Their points, 0 to 100,000.
game.get_deployment_class_count()- How many classes there are.
game.get_deployment_cost(n),game.get_deployment_limit(n),game.get_deployment_team(n)- Class n's cost,
max_activeand team; −1 for no such class. game.get_deployment_occupied(n)- Players in it now, waiting choices too.
Your own class picker
With script_menu = true, the script draws the picker with widgets. Purchases, class limits, the respawn countdown and spawning work as with the built-in one. The script opens each player's script menu, draws cards with placed, clickable widgets, and deploys the clicked class with deploy_class, which spends the player's points:
alias choosing = player.number[0]
alias class = global.number[0]
alias deployed = global.number[1]
alias wait = global.number[2]
on init: do
script_widget[8].set_position(all_players, 80, 190)
script_widget[8].set_size(all_players, 270, 88)
script_widget[8].set_background(all_players, 15, 27, 39, 255)
script_widget[8].set_clickable(all_players, true)
end
on widget click: do
if clicked_widget == 8 then
class = 0
if current_player.team == team[1] then class = 2 end
deployed = current_player.deploy_class(class)
end
end
for each player do
current_player.choosing = 0
class = current_player.get_deployment_class()
wait = current_player.get_respawn_time()
if not current_player.is_not_respawning() and class == -1 and wait == 0 then
current_player.choosing = 1
end
current_player.set_ui_menu(current_player.choosing)
script_widget[8].set_text_for(current_player, "Free infantry")
script_widget[8].set_visibility(current_player, current_player.choosing)
end
A dead player without a class whose respawn countdown has ended is choosing: the script opens their menu and shows them the card, and closes it once they have a class. This fragment assumes class 0 is a free class of the first team and class 2 a free class of the second.
Class names, costs and loadouts stay in the header; write the card text to match. faction-battlefront.rmeg draws its whole picker this way: a backdrop, the faction's title, the player's points, a line that explains a refused click, and cards that dim when the player can't afford them and show live counts for limited classes.

