-- Conquest: native Territories captures, with script-owned tickets and victory. -- Red = team[0], Blue = team[1]. -- Options (sorted): bleed_interval, death_cost, round_seconds, tickets. --[=[ mode name = "MEGALO CONQUEST" mode = "Territories" [rules] score_to_win = 0 kill_points = 0 death_points = 0 suicide_points = 0 betrayal_points = 0 [options] "mode.capture" = 10 "mode.lock_on_capture" = 0 "mode.one_sided" = 0 "mode.sudden_death" = 0 "rounds.limit" = 1 "rounds.minutes" = 0 "rounds.team_changing" = 0 "rounds.teams" = 1 [logic] scripted_round_end = true seed = 0 [logic.options] bleed_interval = { value = 1.0, min = 1.0, max = 10.0 } death_cost = { value = 1.0, min = 0.0, max = 10.0 } round_seconds = { value = 1800.0, min = 30.0, max = 3600.0 } tickets = { value = 300.0, min = 1.0, max = 10000.0 } ]=] alias phase = global.number[0] alias red = global.number[1] alias blue = global.number[2] alias red_flags = global.number[3] alias blue_flags = global.number[4] alias total_flags = global.number[5] alias scratch = global.number[6] alias seconds = global.number[7] alias invalid_team = global.number[8] alias deaths = player.number[0] alias pulse = global.timer[0] alias remaining = global.timer[1] on init: do red = script_option[3] blue = script_option[3] pulse = script_option[0] remaining = script_option[2] -- The HUD: Blue and Red tickets either side of the screen's top -- center, then the flags and the time below them. script_widget[0].set_position(all_players, 628, 18) script_widget[0].set_anchor(all_players, top_right) script_widget[0].set_size(all_players, 250, 0) script_widget[0].set_alignment(all_players, right) script_widget[0].set_color(all_players, 90, 170, 255, 255) script_widget[0].set_background(all_players, 8, 16, 28, 170) script_widget[0].set_font_size(all_players, 18) script_widget[1].set_position(all_players, 652, 18) script_widget[1].set_size(all_players, 250, 0) script_widget[1].set_color(all_players, 255, 100, 100, 255) script_widget[1].set_background(all_players, 8, 16, 28, 170) script_widget[1].set_font_size(all_players, 18) script_widget[2].set_position(all_players, 640, 84) script_widget[2].set_anchor(all_players, top) script_widget[2].set_font_size(all_players, 14) script_widget[3].set_position(all_players, 640, 106) script_widget[3].set_anchor(all_players, top) script_widget[3].set_color(all_players, 190, 198, 210, 255) script_widget[3].set_font_size(all_players, 13) end if phase != 2 then total_flags = game.get_territory_count() red_flags = team[0].get_territory_count() blue_flags = team[1].get_territory_count() invalid_team = 0 for each player do if current_player.team != team[0] and current_player.team != team[1] then invalid_team = 1 end scratch = current_player.get_death_count() scratch -= current_player.deaths if phase == 1 and scratch > 0 then scratch *= script_option[1] if current_player.team == team[0] then red -= scratch end if current_player.team == team[1] then blue -= scratch end end current_player.deaths = current_player.get_death_count() end if phase == 0 then script_widget[2].set_text("Waiting for Red and Blue players and native territories") if invalid_team == 1 then script_widget[2].set_text("Conquest requires only Red and Blue teams") end if team[0].has_any_players() and team[1].has_any_players() and total_flags > 0 and invalid_team == 0 then phase = 1 pulse.set_rate(-100%) remaining.set_rate(-100%) end end if phase == 1 then if pulse.is_zero() then -- A strict majority of ALL flags (including neutral) causes bleed. scratch = red_flags scratch *= 2 if scratch > total_flags then blue -= 1 end scratch = blue_flags scratch *= 2 if scratch > total_flags then red -= 1 end pulse = script_option[0] pulse.set_rate(-100%) end if red < 0 then red = 0 end if blue < 0 then blue = 0 end seconds = remaining script_widget[2].set_text("Flags Red %n / Blue %n / Total %n", red_flags, blue_flags, total_flags) script_widget[3].set_text("Time %n | Capture a majority to drain enemy tickets", seconds) if red == 0 or blue == 0 or remaining.is_zero() then phase = 2 if red > blue then script_widget[2].set_text("Red wins Conquest") team[0].end_round() end if blue > red then script_widget[2].set_text("Blue wins Conquest") team[1].end_round() end if red == blue then script_widget[2].set_text("Conquest draw") game.end_round() end end end script_widget[1].set_text("Red tickets: %n", red) script_widget[1].set_meter_params(number, red, script_option[3]) script_widget[0].set_text("Blue tickets: %n", blue) script_widget[0].set_meter_params(number, blue, script_option[3]) script_widget[1].set_visibility(all_players, true) script_widget[0].set_visibility(all_players, true) script_widget[2].set_visibility(all_players, true) script_widget[3].set_visibility(all_players, true) end