-- Class abilities: three classes whose abilities players use with their -- game mode ability keys (Settings > Keyboard & Mouse or Controller > -- Game mode abilities: X, 2, 3 and H, or the D-pad's right, left and down). -- The header declares megalo_traits[0] (invisible) and the team Slayer -- rules. -- -- Ability 4 chooses your class for your next life; you start as an -- Infiltrator. -- Infiltrator: Ability 1 turns you invisible for 8 seconds. It is ready -- again 20 seconds after you reappear. -- Engineer: you spawn with a Bubble Shield (Use equipment). Ability 1 -- deploys cover in front of you, ready again after 30 seconds. -- Ability 2 sets up a machine gun emplacement, after 60 seconds; -- a new one replaces your last. Hold Ability 3 beside a damaged -- vehicle to repair it. -- Medic: Ability 1 deploys a regenerator, which heals as Halo 3's does, -- ready again after 45 seconds. Every 5 seconds it refills the -- ammunition of everyone beside it. -- While you wait to respawn, Ability 1 chooses where you will: each object -- the map's Forge scripting labels "spawn_point" in turn, then Halo 3's -- own spawns again. --[=[ mode name = "Class Abilities" mode = "Slayer" [rules] score_to_win = 50 kill_points = 1 death_points = 0 suicide_points = -1 betrayal_points = -1 [options] "rounds.teams" = 1 "rounds.limit" = 1 "rounds.minutes" = 15 [[logic.megalo_traits]] camouflage = 4 ]=] enum Class infiltrator engineer medic end alias class = player.number[0] alias next_class = player.number[1] alias spawn_index = player.number[2] alias seconds = player.number[3] alias cooldown = player.timer[0] alias cooldown_2 = player.timer[1] alias camo = player.timer[2] alias repair_pulse = player.timer[3] alias deployed = player.object[0] alias emplacement = player.object[1] alias spawn_point = player.object[2] alias body = player.object[3] alias passed = global.number[0] alias index = global.number[1] alias distance = global.number[2] alias health = global.number[3] alias ammo_pulse = global.timer[0] alias next_point = temporaries.object[0] alias station = temporaries.object[1] declare global.timer[0] = 5 -- The next object labelled spawn_point after the current player's -- choice; after the last, none (Halo 3's own spawns). function choose_spawn() next_point = no_object passed = 0 index = 0 if current_player.spawn_point == no_object then passed = 1 end for each object with label "spawn_point" do if next_point == no_object then index += 1 if passed == 1 then next_point = current_object end end if current_object == current_player.spawn_point then passed = 1 end end current_player.spawn_point = next_point current_player.spawn_index = 0 if next_point != no_object then current_player.spawn_index = index end current_player.set_primary_respawn_object(next_point) end function start_cooldown() current_player.cooldown.set_rate(-100%) end on init: do ammo_pulse.set_rate(-100%) -- The class and its abilities at the right, above Halo 3's score. script_widget[0].set_position(all_players, 1240, 500) script_widget[0].set_anchor(all_players, bottom_right) script_widget[0].set_alignment(all_players, right) script_widget[0].set_font_size(all_players, 18) script_widget[0].set_color(all_players, 255, 210, 90, 255) script_widget[1].set_position(all_players, 1240, 528) script_widget[1].set_anchor(all_players, bottom_right) script_widget[1].set_alignment(all_players, right) script_widget[2].set_position(all_players, 1240, 554) script_widget[2].set_anchor(all_players, bottom_right) script_widget[2].set_alignment(all_players, right) -- Where you will spawn, while you wait to. script_widget[3].set_position(all_players, 640, 470) script_widget[3].set_anchor(all_players, top) script_widget[3].set_font_size(all_players, 18) script_widget[3].set_background(all_players, 8, 16, 28, 170) end on button press: do if pressed_button == button.ability_4 then current_player.next_class += 1 if current_player.next_class > Class.medic then current_player.next_class = Class.infiltrator end end if not current_player.is_not_respawning() and pressed_button == button.ability_1 then choose_spawn() end if current_player.is_not_respawning() then if current_player.class == Class.infiltrator and pressed_button == button.ability_1 and current_player.cooldown.is_zero() then current_player.camo = 8 current_player.camo.set_rate(-100%) current_player.cooldown = 28 start_cooldown() end if current_player.class == Class.engineer and pressed_button == button.ability_1 and current_player.cooldown.is_zero() then current_player.deployed = current_player.biped.place_at_me(deployable_cover, "cover", none, 15, 0, 2, none) current_player.cooldown = 30 start_cooldown() end if current_player.class == Class.engineer and pressed_button == button.ability_2 and current_player.cooldown_2.is_zero() then current_player.emplacement.delete() current_player.emplacement = current_player.biped.place_at_me(machine_gun_emplacement, "emplacement", none, 20, 0, 2, none) current_player.cooldown_2 = 60 current_player.cooldown_2.set_rate(-100%) end if current_player.class == Class.medic and pressed_button == button.ability_1 and current_player.cooldown.is_zero() then current_player.deployed.delete() current_player.deployed = current_player.biped.place_at_me(regenerator, "aid_station", none, 10, 0, 2, none) current_player.cooldown = 45 start_cooldown() end end end for each player do -- A new life takes the class chosen for it. if current_player.is_not_respawning() and current_player.body != current_player.biped then current_player.body = current_player.biped -- Another class starts with its abilities ready. if current_player.class != current_player.next_class then current_player.cooldown = 0 current_player.cooldown_2 = 0 end current_player.class = current_player.next_class current_player.camo = 0 if current_player.class == Class.engineer then current_player.give_equipment(bubble_shield) end end if not current_player.camo.is_zero() then current_player.apply_traits(script_traits[0]) end -- Engineers repair the vehicles beside them while they hold Ability 3: -- 5% twice a second. if current_player.class == Class.engineer and current_player.is_not_respawning() and current_player.is_button_held(button.ability_3) and current_player.repair_pulse.is_zero() then current_player.repair_pulse = 1 current_player.repair_pulse.set_rate(-200%) for each object do if current_object.is_of_type(vehicle) then distance = current_object.get_distance_to(current_player.biped) health = current_object.health if distance <= 30 and health > 0 and health < 100 then health += 5 if health > 100 then health = 100 end current_object.health = health end end end end end -- Regenerators refill the ammunition of everyone beside them. if ammo_pulse.is_zero() then for each player do station = current_player.deployed if current_player.class == Class.medic and station != no_object then for each player do if current_player.is_not_respawning() then distance = current_player.biped.get_distance_to(station) if distance <= 25 then current_player.refill_ammo() end end end end end ammo_pulse.reset() ammo_pulse.set_rate(-100%) end for each player do current_player.seconds = current_player.cooldown if current_player.class == Class.infiltrator then script_widget[0].set_text_for(current_player, "Infiltrator") script_widget[1].set_text_for(current_player, "Camouflage: ready") if not current_player.camo.is_zero() then current_player.seconds = current_player.camo script_widget[1].set_text_for(current_player, "Invisible: %n s", current_player.seconds) alt if not current_player.cooldown.is_zero() then script_widget[1].set_text_for(current_player, "Camouflage: %n s", current_player.seconds) end end script_widget[2].set_text_for(current_player, "") end if current_player.class == Class.engineer then script_widget[0].set_text_for(current_player, "Engineer") script_widget[1].set_text_for(current_player, "Cover: ready") if not current_player.cooldown.is_zero() then script_widget[1].set_text_for(current_player, "Cover: %n s", current_player.seconds) end current_player.seconds = current_player.cooldown_2 script_widget[2].set_text_for(current_player, "Emplacement: ready") if not current_player.cooldown_2.is_zero() then script_widget[2].set_text_for(current_player, "Emplacement: %n s", current_player.seconds) end end if current_player.class == Class.medic then script_widget[0].set_text_for(current_player, "Medic") script_widget[1].set_text_for(current_player, "Regenerator: ready") if not current_player.cooldown.is_zero() then script_widget[1].set_text_for(current_player, "Regenerator: %n s", current_player.seconds) end script_widget[2].set_text_for(current_player, "") end script_widget[0].set_value_text_for(current_player, "") if current_player.next_class != current_player.class then script_widget[0].set_value_text_for(current_player, "(next life: Infiltrator)") if current_player.next_class == Class.engineer then script_widget[0].set_value_text_for(current_player, "(next life: Engineer)") end if current_player.next_class == Class.medic then script_widget[0].set_value_text_for(current_player, "(next life: Medic)") end end script_widget[3].set_text_for(current_player, "Spawn: anywhere (Ability 1 to choose)") if current_player.spawn_index > 0 then script_widget[3].set_text_for(current_player, "Spawn: point %n (Ability 1 for the next)", current_player.spawn_index) end -- The abilities while alive, the spawn choice while waiting. script_widget[0].set_visibility(current_player, true) if current_player.is_not_respawning() then script_widget[1].set_visibility(current_player, true) script_widget[2].set_visibility(current_player, true) script_widget[3].set_visibility(current_player, false) alt script_widget[1].set_visibility(current_player, false) script_widget[2].set_visibility(current_player, false) script_widget[3].set_visibility(current_player, true) end end