--[[ --Elimination v2.2 --By Darren Watts (W'rkncacnter) --]] Triggers = {} just_reset = true reset_timer = 90 last_player_to_die = nil team = false timer_on = false SPAWN_TIMER = 600 end_game = false end_timer = 210 dead_body_repository = nil -- Keep those dead bastards out of liquid color_go = [[ 20 #11111100 A000000 B003300 C007700 D077707 E177717 F277727 G377737 H477747 I00BB00 J0cbb0c K00ff00 L11ff11 M33ff33 N55ff55 O77ff77 P99ff99 Qbbffbb Rddffdd Sffffff ]] color_wait = [[ 20 #11111100 A000000 B330000 C770000 D770707 E771717 F772727 G773737 H774747 Ibb0000 Jbb0c0c Kff0000 Lff1111 Mff3333 Nff5555 Off7777 Pff9999 Qffbbbb Rffdddd Sffffff ]] icon_shape = [[ #####AAAAAA##### ###AAGGFFEDAA### ##AGHPPOONMDCA## #AGPQQQPONMJCBA# #AHQRRRQPONMJCA# AGPQRSRQPONMJCBA AGPQRRRQPONMJCBA AFOPQQQPONMLICBA AFOOPPPOONMLICBA AENNOOONNMLKICBA ADMMNNNMMLLIICBA #ADJMMMLLKIICBA# #ACCJJJIIIICCBA# ##ABCCCCCCCBBA## ###AABBBBBBAA### #####AAAAAA##### ]] function Triggers.init() for p in Players() do -- Set up custom fields for player p._spawn = p.monster.polygon p._timer = SPAWN_TIMER p._score = 0 p._waiting = false p._able_to_win = true p._wants_cameras = true p._camera = Cameras.new() if(p.color ~= p.team) then teams = true end p.color = p.team end for poly in Polygons() do if(poly.type == "hill") then beacon_x = poly.x beacon_y = poly.y if(poly.media == nil) then dead_body_repository = poly -- I find that hills are always the best places to hide dead bodies end break end end if(dead_body_repository == nil) then for poly in Polygons() do if(poly.media == nil) then dead_body_repository = poly break end end end end function Triggers.idle() if(end_game) then end_timer = end_timer - 1 if(end_timer < 0) then Game.over = true end end if(Game.type == "netscript") then lolstuff() else Players.print("Hey numbnuts, you're supposed to host this with the netscript gametype.") Players.print(" ") Players.print(" ") Players.print(" ") Players.print(" ") Players.print(" ") Players.print(" ") end_game = true end end function lolstuff() set_score() update_reset_timer() check_if_round_over() player_stays_dead() disconnected_players() control_revives() use_overlay() omgcameras() loldeadbody() end function set_score() for p in Players() do p.points = p._score end end function update_reset_timer() if(reset_timer > 0) then reset_timer = reset_timer - 1 else just_reset = false end end function check_if_round_over() for p in Players() do if(only_one_not_waiting(p) and p._able_to_win and not just_reset) then reset(p) elseif(only_one_not_waiting(p) and last_player_to_die ~= nil and last_player_to_die._able_to_win and not just_reset) then reset(last_player_to_die) elseif(only_one_not_waiting(p) and not p._able_to_win and last_player_to_die ~= nil and not last_player_to_die._alble_to_win and not just_reset) then reset(nil) end if(teams and not just_reset and only_team_standing(p.team)) then reset(p) break end end end function player_stays_dead() for p in Players() do if(p.dead and p._timer == 0) then p._waiting = true end end end function disconnected_players() for p in Players() do if(p.disconnected) then p._waiting = true end end end function control_revives() for p in Players() do if(p._waiting) then if(p.action_flags.action_trigger == true) then if(p._wants_cameras) then p._wants_cameras = false else p._wants_cameras = true end end p.action_flags.action_trigger = false end if(p.dead and not p._waiting) then p.action_flags.action_trigger = true end end end function Triggers.player_killed(player, aggressor_player, action, projectile) if(just_reset) then return end local only_team_survives = false if (teams and aggressor_player ~= nil) then only_team_survives = only_team_standing(aggressor_player.team); end local was_waiting = false if(player._waiting == true) then was_waiting = true end player._waiting = true --Player did not commit suicide, round still continues if(player ~= aggressor_player and (not only_one_not_waiting(player) or not only_team_survives)) then last_player_to_die = player if(not was_waiting and not only_one_not_waiting(aggressor_player)) then Players.print(player.name.." has been eliminated from the round!") end --Player did not commit suicide, but was suicided against. Last person to die, so wins. elseif(player ~= aggressor_player and ((only_one_not_waiting(player) or only_team_survives) and not just_reset)) then last_player_to_die = player reset(player) --Player suicides, round continues elseif(player == aggressor_player and not only_one_not_waiting(player)) then player._able_to_win = false Players.print(player.name.." has been eliminated from the round!") --Player suicides, and everyone is dead. round ends elseif(player == aggressor_player and (only_one_not_waiting(player) or only_team_survives) and not just_reset) then player._able_to_win = false if(last_player_to_die._able_to_win) then reset(last_player_to_die) else reset(nil) end end end function Triggers.player_revived(player) player._able_to_win = true player._camera:deactivate() end function got_item(type, player) if(type == "invincibility") then send_inviz_msg(player) end end function send_inviz_msg(player) for p in Players() do if(p.team == player.team) then p:play_sound("computer login", 1.5) p:print(player.name.." is invisible!") end end end function reset(player) just_reset = true reset_timer = 90 if(player == nil) then Players.print("No one wins this round!") else if(not teams) then Players.print(player.name.." wins the round!") else print_winning_team(player.team) end player._score = player._score + 1 end for p in Players() do p._timer = SPAWN_TIMER p._waiting = false if(p.dead) then p._able_to_win = false end p:damage(1000) end end function use_overlay() local players_left = 0 for p in Players() do if(p._able_to_win and not p.dead) then players_left = players_left + 1 end end for p in Players() do local icon = nil --No teams. --Overlay 0 is # of players left. if(not teams) then p.overlays[0].color = "green" p.overlays[0].text = "Plrs Left: "..players_left --Teams. --Overlay 0 is tms/tmates/plrs. --Overlay 1 is blank for spacing. else p.overlays[0].color = "green" p.overlays[0].text = "Tms/Tmates/Plrs: "..get_teams_left().."/"..get_teammate_num(p).."/"..players_left p.overlays[1].color = "green" p.overlays[1].text = " " end --This icon overlay is the same for any case. if(p.dead and p._waiting) then icon = color_wait .. icon_shape p.overlays[2].icon = icon p.overlays[2].color = "green" p.overlays[2].text = " " elseif(p.dead and not p._waiting) then icon = color_go .. icon_shape p.overlays[2].icon = icon p.overlays[2].color = "green" p.overlays[2].text = " " elseif(not p.dead) then p.overlays[2].text = "" end end end function only_one_not_waiting(player) for p in Players() do if(p ~= player and p._waiting == false) then return false end end return true end function print_winning_team(a_team) Players.print(string.upper(a_team.mnemonic).." team wins the round!") end function get_teams_left() local teams = {} for p in Players() do if(not p.dead) then local team = p.team if(# teams == 0) then teams[1] = team end for k = 1, # teams, 1 do if(teams[k] == team) then break elseif(teams[k] ~= team and k == # teams) then teams[# teams+1] = team end end end end return # teams end function get_teammate_num(player) local teammates = 0 for p in Players() do if(p.team == player.team and p._able_to_win and not p.dead) then teammates = teammates + 1 end end return teammates end function only_team_standing(a_team) local all = true for p in Players() do local team = p.team if(not p._waiting) then if(team ~= a_team) then all = false break end end end return all end function Triggers.item_created(item) if(item == "infravision") then item:delete() end end function omgcameras() local plr_to_watch for p in Players() do plr_to_watch = nil if(p._waiting and p._wants_cameras) then -- Check teammates first for plr in Players() do if(p.team == plr.team and not plr.dead) then plr_to_watch = plr break end end -- Check remaining alive players if(plr_to_watch == nil) then for plr in Players() do if(not plr.dead) then plr_to_watch = plr break end end end -- Set up camera to follow the MUTHAFUCKA TARGET if(plr_to_watch ~= nil) then p:view_player(plr_to_watch) else p:view_player(p) end else p:view_player(p) end end end function loldeadbody() -- There's nothing funnier than a dead body. for p in Players() do if(p.dead and p._waiting and p.monster.polygon ~= dead_body_repository and p.head_below_media) then p:position(dead_body_repository.x, dead_body_repository.y, dead_body_repository.z, dead_body_repository) p.external_velocity.x = 0 p.external_velocity.y = 0 p.external_velocity.z = 0 end end end