Paste #12980: Untitled Paste

Date: 2015/01/15 15:47:17 UTC-08:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


initiate_game:
  type: task
  script:
  - if <server.flag[game_going]||false> {
    - announce format:error_format "TRIED TO START GAME THAT WAS ALREADY IN PROGRESS!"
    - queue clear
    }
  - if <server.flag[in_queue].as_list.size||0> <= 1 {
    - title "title:<&c>Not enough players in queue." "subtitle:<&e>The game will try to start again in 3 minutes!" targets:<server.list_online_players> fade_in:10t stay:5s fade_out:10t
    - run pre_game_countdown instantly delay:2m
    - flag server time_left duration:3m
    - queue clear
    }
  - foreach <server.flag[in_queue].as_list> {
    - teleport %value% <server.flag[spawnlocation.%loop_index%]>
    - modifyblock <server.flag[spawnlocation.%LOOP_INDEX%].as_location.add[1,1,0]>|<server.flag[spawnlocation.%LOOP_INDEX%].as_location.add[0,1,1]>|<server.flag[spawnlocation.%LOOP_INDEX%].as_location.add[-1,1,0]>|<server.flag[spawnlocation.%LOOP_INDEX%].as_location.add[0,1,-1]>|<server.flag[spawnlocation.%LOOP_INDEX%].as_location.add[0,2,0]> m@barrier
    - if !<server.has_flag[spawnlocation.%loop_index%]> announce format:error_format "spawnlocation.%loop_index% NOT FOUND!"
    - run prepare_player player:%value% instantly
    }
  - flag server game_going:true
  - flag server in_game:!
  - flag server in_game:|:<server.flag[in_queue].as_list||li@>
  - flag server in_queue:!
  - flag server ring_carrier:!
  - flag server time_of_start:<server.current_time_millis>
  - flag server deathmatch_countdown duration:30m
  - if !<server.has_flag[ringdestroylocation.1]> announce format:error_format "ringdestroylocation.1 NOT FOUND!"
  - if !<server.has_flag[ringdestroylocation.2]> announce format:error_format "ringdestroylocation.2 NOT FOUND!"
  - note cu@<server.flag[ringdestroylocation.1]>|<server.flag[ringdestroylocation.2]> as:mountdoom
  - drop i@ring <server.flag[ringlocation].as_location.above> save:ring speed:0
  - flag server ring_entity:<entry[ring].dropped_entities.get[1]>
  - flag server ring_last_location:<server.flag[ringlocation].as_location.above>
  - run ringannouncement instantly def:dropped|<server.flag[ringlocation]>
  - if !<server.has_flag[ringlocation]> announce format:error_format "ringlocation NOT FOUND!"
  - run ring_maintainer instantly delay:10s
  - run game_countdown instantly
  - run initiate_deathmatch instantly delay:25m def:<server.flag[time_of_start]>
Ring:
  type: item
  material: i@record_8
  display name: <&6>The Ring
  enchantments:
  - durability:10
  lore:
  - 'Destroy to win the game.'
  - 'Equip to use its power.'
ring_maintainer:
  type: task
  script:
  - if !<server.flag[game_going]||false> queue clear
  - if <server.flag[ring_entity].as_entity.is_spawned||false> {
    - firework power:0 primary:white flicker trail fade:black type:burst <server.flag[ring_entity].as_entity.location>
    - firework power:1 primary:white flicker trail fade:black type:burst <server.flag[ring_entity].as_entity.location>
    - firework power:2 primary:white flicker trail fade:black type:burst <server.flag[ring_entity].as_entity.location>
    - flag server ring_last_location:<server.flag[ring_entity].as_entity.location>
    - if !<server.flag[ring_on_ground_cooldown]||false> {
      - announce "<&4>The Ring is still on the ground!"
      - flag server ring_on_ground_cooldown duration:30s
      }
    } else {
    - if !<server.flag[in_game].contains[<server.flag[ring_carrier]||nobody>]||false> {
      - drop i@ring <server.flag[ring_last_location].as_location.find.surface_blocks.within[20].random.above> save:ring
      - flag server ring_entity:<entry[ring].dropped_entities.get[1]>
      - flag server ring_carrier:!
      }
    }
  - run ring_maintainer instantly delay:5s
ring_maintaining_events:
  type: world
  events:
    on i@ring despawns:
    - determine cancelled
    on player drops i@ring:
    - if !<context.location.is_within[cu@mountdoom]||false> determine cancelled
    - run endgame instantly def:ring_destroy
    on player clicks i@ring in inventory:
    - if li@CRAFTING|PLAYER !contains <context.inventory.inventory_type> || <context.slot_type> == CRAFTING determine cancelled
prepare_player:
  type: task
  script:
  - announce format:error_format "player.class.data not found"
  - heal
  - feed
  - adjust <player> gamemode:survival
  - inventory clear destination:<player.inventory>
game_countdown:
  type: task
  script:
    - flag server lock_players:true
    - title "title:<&6>10!" targets:<server.flag[in_game].as_list> fade_in:10t stay:2s fade_out:0t
    - wait 1s
    - title "title:<&6>9!" targets:<server.flag[in_game].as_list> fade_in:0t stay:2s fade_out:0t
    - wait 1s
    - title "title:<&6>8!" targets:<server.flag[in_game].as_list> fade_in:0t stay:2s fade_out:0t
    - wait 1s
    - title "title:<&6>7!" targets:<server.flag[in_game].as_list> fade_in:0t stay:2s fade_out:0t
    - wait 1s
    - title "title:<&6>6!" targets:<server.flag[in_game].as_list> fade_in:0t stay:2s fade_out:0t
    - wait 1s
    - title "title:<&6>5!" targets:<server.flag[in_game].as_list> fade_in:0t stay:2s fade_out:0t
    - wait 1s
    - title "title:<&6>4!" targets:<server.flag[in_game].as_list> fade_in:0t stay:2s fade_out:0t
    - wait 1s
    - title "title:<&6>3!" targets:<server.flag[in_game].as_list> fade_in:0t stay:2s fade_out:0t
    - wait 1s
    - title "title:<&6>2!" targets:<server.flag[in_game].as_list> fade_in:0t stay:2s fade_out:0t
    - wait 1s
    - title "title:<&6>1!" targets:<server.flag[in_game].as_list> fade_in:0t stay:2s fade_out:0t
    - wait 1s
    - title "title:<&6>GO!" targets:<server.flag[in_game].as_list> fade_in:0t stay:2s fade_out:10t
    - flag server lock_players:false
    - foreach <server.flag[in_game].as_list> {
      - modifyblock <server.flag[spawnlocation.%LOOP_INDEX%].as_location.add[1,1,0]>|<server.flag[spawnlocation.%LOOP_INDEX%].as_location.add[0,1,1]>|<server.flag[spawnlocation.%LOOP_INDEX%].as_location.add[-1,1,0]>|<server.flag[spawnlocation.%LOOP_INDEX%].as_location.add[0,1,-1]>|<server.flag[spawnlocation.%LOOP_INDEX%].as_location.add[0,2,0]> m@air
      }