Boss Fight or Event Organizer


Author: mythanical
Created: 2013-02-22T02:44:31-0500
Edited: 2013-10-23T05:28:09-0400
Denizen Version: 0.9.3
Views: 110
Downloads: 895
Likes: 3


WGET
Description: # Boss Fight / Event Organizer - 3 Events per NPC.
# Citizens 2 (build #991)
# Denizen 0.9.3 (build #1341)

To assign to an NPC, type:
/npc assign --set "Bossfight Organizer"

Description:

This script will allow an NPC to act as a middle-man for someone organizing players for an event. It is not the event itself, in other words, it'll only take the players where they need to go as a group. You need to decide where they get teleported to and how you trigger your own boss event.

An Organizer (player) will need to assign themselves to an event and then other Players will be able to join in.

The Organizer is automatically part of the event and will be teleported with the Players when the event is started. Organizers and Players cannot belong to multiple events at the same time.

Organizers can 'start' or 'cancel' their own event. When the Organizer uses the 'leave' command it also cancels the event.

Other Features:
* Set Min/Max group sizes
* OP's can 'Reset' or 'Lock' events. Reset will reset ALL events and Lock will allow OP to individually lock specified events in case they are under construction.
* Events are automatically reset when the Organiser disconnects from the server, allowing new organisers to take it over.

The "Spleef Organizer" script by davidcernat was used as a template for this script. Thanks man! For this and all the other help, bug fixes and new features you added for me.

# Boss Fight / Event Organizer - 3 Events per NPC.
# Citizens 2 (build #991)
# Denizen 0.9.3 (build #1341)
#
# NOTE: Script may contain bugs. Let me know if you find any!
#
# To assign to an NPC, type:
# /npc assign --set "Bossfight Organizer"
#
# Description:
#
# This script will allow an NPC to act as a middle-man for someone organizing players for an event. It is not the
# event itself, in other words, it'll only take the players where they need to go as a group. You need to decide
# where they get teleported to and how you trigger your own boss event.
#
# An Organizer (player) will need to assign themselves to an event and then other Players will be able to join in.
#
# The Organizer is automatically part of the event and will be teleported with the Players when the event is started.
# Organizers and Players cannot belong to multiple events at the same time.
#
# Organizers can 'start' or 'cancel' their own event. When the Organizer uses the 'leave' command it also 
# cancels the event.
#
# Other Features:
#   * Set Min/Max group sizes
#   * OP's can 'Reset' or 'Lock' events. Reset will reset ALL events and Lock will allow OP to individually lock
#   specified events in case they are under construction.
#   * Events are automatically reset when the Organiser disconnects from the server, allowing new organisers
#   to take it over.
#
# Credit: The "Spleef Organizer" script by davidcernat was used as a template for this script. Thanks man! For this and
#     all the other help, bug fixes and new features you added for me.
#
# @author mythanical
# @script version 1.1.2
# @last-updated October 23 2013
# @irc EsperNet IRC Network #denizen-dev
# @Minecraft Server - minecraft.geek.nz
# @Donate Bitcoin: 1Fzacc2gZ5NGRMXg5jWP6NcUkWei34xjzt
# @Donate Litecoin: LhsaGa1QzmVLjMYwg4ZPTVnmSgnBDGc75U

"Bossfight Organizer":
  type: assignment

  default constants:

    # Enter the Names of 3 Bosses on your Server
    Boss One Name: "Herobrine"
    Boss Two Name: "EnderDragon"
    Boss Three Name: "Aufdemrand"
 
    # This is purely for displaying a difficulty level next to each boss, it doesn't do anything other than that.
    Boss One Difficulty: "Easy"
    Boss Two Difficulty: "Hard"
    Boss Three Difficulty: "Insane"
 
    # Minimum number of players for each boss.
    Boss One Min Players: 2
    Boss Two Min Players: 3
    Boss Three Min Players: 6
 
    # Maximum number of players for each boss.
    Boss One Max Players: 2
    Boss Two Max Players: 7
    Boss Three Max Players: 10
 
    # These are the coordinates of where the Players will be teleported to for each event.
    Bossfight One Location: "106,64,296,world"
    Bossfight Two Location: "100,64,310,world"
    Bossfight Three Location: "61,68,329,world"

  actions:
    on assignment:
    # This enables interaction with NPC via clicking, chatting and entering/exiting proximity.
    - trigger name:chat toggle:true
    - trigger name:click toggle:true
    - trigger name:proximity toggle:true

  interact scripts:
  - 10 Bossfight Organizer Convo

'Bossfight Organizer Convo':
  type: interact
  steps:
    'Organize*':
      proximity trigger:
        entry:
          script:
          # When player enters NPC proximity, run the specified script.
          - run "Bossfight General Chat"

      click trigger:
        script:
        # When the player clicks the NPC, run the specified script.
        - run "Bossfight Initiate Conversation"

      chat trigger:
        '1':
          trigger: "I want to /join/ a boss fight event."
          script:
          # There are 5 possibilities here, checked in sequence:
          # 1) Check if player is already an organizer for an event and tell them they can't join.
          # 2) Check if player already joined another event and tell them they can't join.
          # 3) Check if all events are locked, if so tell user to come back later.
          # 4) Check if any events are currently being organized, if not tell user to type 'organize'.
          # 5) Run a script asking them which event they would like to join, located much further down.
          - ^if "<npc.flag[<cons:Boss One Name>-Organizer]>" == <player>
            narrate "<red>You are the organizer of event '<white><cons:Boss One Name><red>', you cannot join other events."
 
            else if "<npc.flag[<cons:Boss Two Name>-Organizer]>" == <player>
            narrate "<red>You are the organizer of event '<white><cons:Boss Two Name><red>', you cannot join other events."
 
            else if "<npc.flag[<cons:Boss Three Name>-Organizer]>" == <player>
            narrate "<red>You are the organizer of event '<white><cons:Boss Three Name><red>', you cannot join other events."
 
            else if "<npc.flag[<cons:Boss One Name>-Join].aslist>" contains <player>
            narrate "<red>You have already joined for event '<white><cons:Boss One Name><red>'. You can only join one event at a time."
 
            else if "<npc.flag[<cons:Boss Two Name>-Join].aslist>" contains <player>
            narrate "<red>You have already joined for event '<white><cons:Boss Two Name><red>'. You can only join one event at a time."
 
            else if "<npc.flag[<cons:Boss Three Name>-Join].aslist>" contains <player>
            narrate "<red>You have already joined for event '<white><cons:Boss Three Name><red>'. You can only join one event at a time."
 
            else if "<npc.flag[<cons:Boss One Name>-Organizer]>" == "Locked"
            && "<npc.flag[<cons:Boss Two Name>-Organizer]>" == "Locked"
            && "<npc.flag[<cons:Boss Three Name>-Organizer]>" == "Locked"
            narrate "<red>Sorry, all events are currently <white>locked<red>. Please come back later."
 
            else if "<npc.flag[<cons:Boss One Name>-Organizer]>" == null
            && "<npc.flag[<cons:Boss Two Name>-Organizer]>" == null
            && "<npc.flag[<cons:Boss Three Name>-Organizer]>" == null
            narrate "<red>There are no events running. You will need to say '<white>organize<red>' to create a new event for people to join."
 
            else run "Bossfight Join a Group"
        '2':
          trigger: "I would like to /leave/ a boss fight event."
          script:
          # There are 3 possibilities here
          # 1) If player is the organizer of an event, it will cancel the event and clear all participant flags.
          # 2) If player has joined an event, they will leave it and also clear participant flags used by the
          #  'player quits world event' to check if they are part of a group.
          # 3) Tell player they can't leave an event if they haven't joined one.
          - ^if <npc.flag[<player.flag[OrganizingBossFight]>-Organizer]> == <player> {
            - announce "<red>The boss event <gold><player.flag[OrganizingBossFight]><red>, organized by <yellow><player.name> <red>has been cancelled."
            - flag <npc> "<player.flag[OrganizingBossFight]>-Organizer:!"
            - foreach "<npc.flag[<player.flag[OrganizingBossFight]>-Join].aslist>" {
              - flag %value% "BossFightJoined:!"
              - flag %value% "BossFightNPC:!" }
            - flag <npc> <player.flag[OrganizingBossFight]>-Join:!
            - flag <player> OrganizingBossFight:! }
 
            else if <npc.flag[<player.flag[BossFightJoined]>-Join].aslist> contains <player> {
            - announce "<white><player.name> <red>has left the boss event for <gold>'<player.flag[BossFightJoined]>'"
            - flag <npc> <player.flag[BossFightJoined]>-Join:<-:<player>
            - flag <player> BossFightJoined:!
            - flag <player> BossFightNPC:! }
 
            else narrate "<white><player.name><red>, you cannot leave a group if you haven't joined one yet."

        '3':
          trigger: "Let's /start/."
          script:
          # There are 3 possibilities here
          # 1) If player is the organizer of an event and there are enough players, it will teleport the players to
          #  the event and clear the event flags so a new one can be organised and also clear participant flags used by the
          #  'player quits world event' to check if they are part of a group.
          # 2) If player is the organizer and there aren't enough player, it will say what the current count and needed count is.
          # 3) Tell player they can't start an event unless they are the organizer.
          - ^if "<npc.flag[<cons:Boss One Name>-Organizer]>" == <player> && "<npc.flag[<cons:Boss One Name>-Join].size>" >= "<cons:Boss One Min Players>" {
            - announce "<red>Teleporting players to the boss event '<gold><cons:Boss One Name><red>'."
            - narrate "<red>5..." "targets:<npc.flag[<cons:Boss One Name>-Join].aslist>"
            - wait 1
            - narrate "<red>4..." "targets:<npc.flag[<cons:Boss One Name>-Join].aslist>"
            - wait 1
            - narrate "<red>3..." "targets:<npc.flag[<cons:Boss One Name>-Join].aslist>"
            - wait 1
            - narrate "<red>2..." "targets:<npc.flag[<cons:Boss One Name>-Join].aslist>"
            - wait 1
            - narrate "<red>1..." "targets:<npc.flag[<cons:Boss One Name>-Join].aslist>"
            - wait 1
            - foreach "<npc.flag[<cons:Boss One Name>-Join].aslist>" {
              - teleport %value% "location:<cons:Bossfight One Location>"
              - flag %value% OrganizingBossFight:!
              - flag %value% BossFightJoined:!
              - flag %value% BossFightNPC:! }
            - flag <npc> "<cons:Boss One Name>-Organizer:!"
            - flag <npc> "<cons:Boss One Name>-Join:!" }
 
            else if "<npc.flag[<cons:Boss Two Name>-Organizer]>" == <player> && "<npc.flag[<cons:Boss Two Name>-Join].size>" >= "<cons:Boss Two Min Players>" {
            - announce "<red>Teleporting players to the boss event '<gold><cons:Boss Two Name><red>'."
            - narrate "<red>5..." "targets:<npc.flag[<cons:Boss Two Name>-Join].aslist>"
            - wait 1
            - narrate "<red>4..." "targets:<npc.flag[<cons:Boss Two Name>-Join].aslist>"
            - wait 1
            - narrate "<red>3..." "targets:<npc.flag[<cons:Boss Two Name>-Join].aslist>"
            - wait 1
            - narrate "<red>2..." "targets:<npc.flag[<cons:Boss Two Name>-Join].aslist>"
            - wait 1
            - narrate "<red>1..." "targets:<npc.flag[<cons:Boss Two Name>-Join].aslist>"
            - wait 1
            - foreach "<npc.flag[<cons:Boss Two Name>-Join].aslist>" {
              - teleport %value% "location:<cons:Bossfight Two Location>"
              - flag %value% OrganizingBossFight:!
              - flag %value% BossFightJoined:!
              - flag %value% BossFightNPC:! }
            - flag <npc> "<cons:Boss Two Name>-Organizer:!"
            - flag <npc> "<cons:Boss Two Name>-Join:!" }
 
            else if "<npc.flag[<cons:Boss Three Name>-Organizer]>" == <player>" && "<npc.flag[<cons:Boss Three Name>-Join].size>" >= "<cons:Boss Three Min Players>" {
            - announce "<red>Teleporting players to the boss event '<gold><cons:Boss Three Name><red>'."
            - narrate "<red>5..." "targets:<npc.flag[<cons:Boss Three Name>-Join].aslist>"
            - wait 1
            - narrate "<red>4..." "targets:<npc.flag[<cons:Boss Three Name>-Join].aslist>"
            - wait 1
            - narrate "<red>3..." "targets:<npc.flag[<cons:Boss Three Name>-Join].aslist>"
            - wait 1
            - narrate "<red>2..." "targets:<npc.flag[<cons:Boss Three Name>-Join].aslist>"
            - wait 1
            - narrate "<red>1..." "targets:<npc.flag[<cons:Boss Three Name>-Join].aslist>"
            - wait 1
            - foreach "<npc.flag[<cons:Boss Three Name>-Join].aslist>" {
              - teleport %value% "location:<cons:Bossfight Three Location>"
              - flag %value% OrganizingBossFight:!
              - flag %value% BossFightJoined:!
              - flag %value% BossFightNPC:! }
            - flag <npc> "<cons:Boss Three Name>-Organizer:!"
            - flag <npc> "<cons:Boss Three Name>-Join:!" }
 
            else if "<npc.flag[<cons:Boss One Name>-Organizer]>" == <player> && "<npc.flag[<cons:Boss One Name>-Join].size>" < "<cons:Boss One Min Players>"
            narrate "<red>Not enough players to start event! <gold><npc.flag[<cons:Boss One Name>-Join].size><red> of <gold><cons:Boss One Min Players><red> spots filled."
 
            else if "<npc.flag[<cons:Boss Two Name>-Organizer]>" == <player> && "<npc.flag[<cons:Boss Two Name>-Join].size>" < "<cons:Boss Two Min Players>"
            narrate "<red>Not enough players to start event! <gold><npc.flag[<cons:Boss Two Name>-Join].size><red> of <gold><cons:Boss Two Min Players><red> spots filled."
 
            else if "<npc.flag[<cons:Boss Three Name>-Organizer]>" == <player>" && "<npc.flag[<cons:Boss Three Name>-Join].size>" < "<cons:Boss Three Min Players>"
            narrate "<red>Not enough players to start event! <gold><npc.flag[<cons:Boss Three Name>-Join].size><red> of <gold><cons:Boss Three Min Players><red> spots filled."
 
            else narrate "<red>Sorry <white><player.name><red>, you cannot start an event unless you're the organizer of one."

        '4':
          trigger: "I want to /organize/ a boss fight."
          script:
          # There are 4 possibilities here
          # 1) If player is already the organizer of an event, tell them to leave that one first.
          # 2) If all events have been locked, tell player they are locked and to come back later.
          # 3) If all events are being organized, tell player they can't organize one right now.
          # 4) Run script asking them which boss to organize an event for - located much further down.
          - ^if <npc.flag[<player.flag[OrganizingBossFight]>-Organizer]> == <player>
            narrate "<red>You are already organizing the event for '<gold><player.flag[OrganizingBossFight]><red>'. Leave that one first before you create a new one."
 
            else if "<npc.flag[<cons:Boss One Name>-Organizer]>" == "Locked"
            && "<npc.flag[<cons:Boss Two Name>-Organizer]>" == "Locked"
            && "<npc.flag[<cons:Boss Three Name>-Organizer]>" == "Locked"
            narrate "<red>Sorry, all events are currently <white>locked<red>. Please come back later."
 
            else if "<npc.flag[<cons:Boss One Name>-Organizer]>" != null
            && "<npc.flag[<cons:Boss Two Name>-Organizer]>" != null
            && "<npc.flag[<cons:Boss Three Name>-Organizer]>" != null
            narrate "<red>Sorry, all events are currently being organized by other players. Please come back later."
 
            else run "Bossfight Organize a Boss"

        '5':
          trigger: "I want to /cancel/ a boss fight."
          script:
          # There are 2 possibilities here
          # 1) If player is the organizer of an event, it will cancel the event and clear all participant player flags.
          # 2) If player is not the organizer of any events, tell them they can't cancel.
          - ^if <npc.flag[<player.flag[OrganizingBossFight]>-Organizer]> == <player> {
            - announce "<red>The boss event <gold><player.flag[OrganizingBossFight]><red>, organized by <yellow><player.name> <red>has been cancelled."
            - flag <npc> <player.flag[OrganizingBossFight]>-Organizer:!
            - foreach <npc.flag[<player.flag[OrganizingBossFight]>-Join].aslist> {
              - flag %value% BossFightJoined:!
              - flag %value% BossFightNPC:! }
            - flag <npc> <player.flag[OrganizingBossFight]>-Join:!
            - flag <player> OrganizingBossFight:!
            }
 
            else narrate "<red>You are not the organizer for any events and you cannot cancel events being organized by other players."

        '6':
          trigger: "I want to see the /events/ list."
          script:
          # This section simply shows which events have been booked, the organizer, 
          # the number of players and the names of players that has joined for the event.
          # It uses a IF statements to figure out which information to return depending on the status of the event.
          # It decides on what to display depending on whether:
          #   1) the event has been locked
          #   2) the event has an organizer
          #   3) return a list of players if the event does have an organizer but it's not the organizer called 'Locked'
          - ^narrate "<green>------------------------------------------------"
 
          - ^if "<npc.flag[<cons:Boss One Name>-Organizer]>" == "Locked" narrate " <gold><cons:Boss One Name><gray> - <red>Event Locked"
            else if "<npc.flag[<cons:Boss One Name>-Organizer]>" != null
            narrate " <gold><cons:Boss One Name> <Dark_Purple><italic>(<cons:Boss One Difficulty>)<gray> - Org. <yellow><npc.flag[<cons:Boss One Name>-Organizer]><gray> Cur. <white><npc.flag[<cons:Boss One Name>-Join].size><gray> Min.<white> <cons:Boss One Min Players><gray>. Max.<white> <cons:Boss One Max Players><gray>."
            else narrate " <gold><cons:Boss One Name> <Dark_Purple><italic>(<cons:Boss One Difficulty>)<gray> -<red> No Organizer<gray> - Min.<white> <cons:Boss One Min Players><gray>. Max.<white> <cons:Boss One Max Players><gray>."
 
          - ^if "<npc.flag[<cons:Boss One Name>-Organizer]>" !contains null|Locked
            narrate "   <aqua> Players| <aqua><npc.flag[<cons:Boss One Name>-Join].formatted>"
 
          - ^if "<npc.flag[<cons:Boss Two Name>-Organizer]>" == "Locked" narrate " <gold><cons:Boss Two Name><gray> - <red>Event Locked"
            else if "<npc.flag[<cons:Boss Two Name>-Organizer]>" != null
            narrate " <gold><cons:Boss Two Name> <Dark_Purple><italic>(<cons:Boss Two Difficulty>)<gray> - Org. <yellow><npc.flag[<cons:Boss Two Name>-Organizer]><gray> Cur. <white><npc.flag[<cons:Boss Two Name>-Join].size><gray> Min.<white> <cons:Boss Two Min Players><gray>. Max.<white> <cons:Boss Two Max Players><gray>."
            else narrate " <gold><cons:Boss Two Name> <Dark_Purple><italic>(<cons:Boss Two Difficulty>)<gray> -<red> No Organizer<gray> - Min.<white> <cons:Boss Two Min Players><gray>. Max.<white> <cons:Boss Two Max Players><gray>."
 
          - ^if "<npc.flag[<cons:Boss Two Name>-Organizer]>" !contains null|Locked
            narrate "   <aqua> Players| <aqua><npc.flag[<cons:Boss Two Name>-Join].formatted>"
 
          - ^if "<npc.flag[<cons:Boss Three Name>-Organizer]>" == "Locked" narrate " <gold><cons:Boss Three Name><gray> - <red>Event Locked"
            else if "<npc.flag[<cons:Boss Three Name>-Organizer]>" != null
            narrate " <gold><cons:Boss Three Name> <Dark_Purple><italic>(<cons:Boss Three Difficulty>)<gray> - Org. <yellow><npc.flag[<cons:Boss Three Name>-Organizer]><gray> Cur. <white><npc.flag[<cons:Boss Three Name>-Join].size><gray> Min.<white> <cons:Boss Three Min Players><gray>. Max.<white> <cons:Boss Three Max Players><gray>."
            else narrate " <gold><cons:Boss Three Name> <Dark_Purple><italic>(<cons:Boss Three Difficulty>)<gray> -<red> No Organizer<gray> - Min.<white> <cons:Boss Three Min Players><gray>. Max.<white> <cons:Boss Three Max Players><gray>."
 
          - ^if "<npc.flag[<cons:Boss Three Name>-Organizer]>" !contains null|Locked
            narrate "   <aqua> Players| <aqua><npc.flag[<cons:Boss Three Name>-Join].formatted>"
 
          - ^narrate "<green>------------------------------------------------"

        '7':
          trigger: "/reset/"
          script:
          # This is a hidden server OP feature that will reset all boss events and clear all flags.
          # When a player types this, it will check to see if they are an OP. If they are, it
          # will work through all 3 events, reset the NPC flags and also all the flags set
          # against the participants of the events.
          - ^if <player.is_op> {
            - if "<npc.flag[<cons:Boss One Name>-Join].size>" >= 1 {
            - foreach "<npc.flag[<cons:Boss One Name>-Join].aslist>" {
              - flag %value% OrganizingBossFight:!
              - flag %value% BossFightJoined:!
              - flag %value% BossFightNPC:! }
            }
 
            - if "<npc.flag[<cons:Boss Two Name>-Join].size>" >= 1 {
            - foreach "<npc.flag[<cons:Boss Two Name>-Join].aslist>" {
              - flag %value% OrganizingBossFight:!
              - flag %value% BossFightJoined:!
              - flag %value% BossFightNPC:! }
            }
 
            - if "<npc.flag[<cons:Boss Three Name>-Join].size>" >= 1 {
            - foreach "<npc.flag[<cons:Boss Three Name>-Join].aslist>" {
              - flag %value% OrganizingBossFight:!
              - flag %value% BossFightJoined:!
              - flag %value% BossFightNPC:! }
            }
            - narrate "<red>All Events Have Been Reset."
            - flag <npc> "<cons:Boss One Name>-Join:!"
            - flag <npc> "<cons:Boss One Name>-Organizer:!"
            - flag <npc> "<cons:Boss Two Name>-Join:!"
            - flag <npc> "<cons:Boss Two Name>-Organizer:!"
            - flag <npc> "<cons:Boss Three Name>-Join:!"
            - flag <npc> "<cons:Boss Three Name>-Organizer:!" }
 
            else narrate "<red>You are not an OP, nice try."

        '8':
          trigger: "/lock/"
          script:
          # This is the hidden dialogue that shows if you are an OP and said 'lock' to the NPC.
          # It shows whether the event is 'locked' or not. It then zaps to the 'Lock Event'
          # step where its waiting for the OP to type in which boss they want to lock/unlock.
          - ^if <player.is_op> {
            - ^narrate "<red>Which event do you want to lock or unlock?"
            - ^narrate "<red>Say<&co>"
            - if "<npc.flag[<cons:Boss One Name>-Organizer]>" == "Locked" narrate " <gold><cons:Boss One Name><gray> - <red>Locked"
            else narrate " <gold><cons:Boss One Name><gray> - <green>Unlocked"
            - if "<npc.flag[<cons:Boss Two Name>-Organizer]>" == "Locked" narrate " <gold><cons:Boss Two Name><gray> - <red>Locked"
            else narrate " <gold><cons:Boss Two Name><gray> - <green>Unlocked"
            - if "<npc.flag[<cons:Boss Three Name>-Organizer]>" == "Locked" narrate " <gold><cons:Boss Three Name><gray> - <red>Locked"
            else narrate " <gold><cons:Boss Three Name><gray> - <green>Unlocked"
            - ^zap "[email protected] Organizer Convo" "step:Lock Event" }
 
            else narrate "<red>You are not an OP, nice try."

        '9':
          trigger: /REGEX:\w+/
          # This is a catch-all trigger that will repeat what the player said if what they
          # typed didn't match any of the chat triggers above.
          script:
          - narrate "<red>Sorry, I don't know what '<white><context.message><red>' means."

    'Create Group':
      chat trigger:
        'Which Boss':
          trigger: I want to start a group for event '/REGEX:^\w+$/'.
          script:
          # There are 6 possibilities here
          # 1) If player is already the organizer of an event, tell them to leave that one first.
          # 2) If player has joined another event, tell them they can only be part of one event at a time.
          # 3) If the event has been locked by OP, tell player they can't create group because event is locked.
          # 4) If the event the player asked for is already being organized, tell them.
          # 5) If the event is available, create 2 flags on the NPC. One is to indicate this player is now the
          #  the organizer and another to add them to the party. It'll create an additional 2 flags on the player which
          #  is checked/used when they quit Minecraft to clear the event so other players can organise it.
          # 6) A catch-all telling player the NPC doesn't know what they said.
          - ^if <player.flag[OrganizingBossFight]> != null
            narrate "<red>You are already organizing the event for '<gold><player.flag[OrganizingBossFight]><red>'. Leave that one first before you create a new one."
 
            else if <player.flag[BossFightJoined]> != null
            narrate "<red>You have already joined for event '<gold><player.flag[BossFightJoined]><red>'. You can only partake in one event at a time."
 
            else if <context.message> == "<cons:Boss One Name>" && "<npc.flag[<cons:Boss One Name>-Organizer]>" == "Locked" 
            narrate "<red>Sorry <white><player.name><red>, but the boss fight event <gold><cons:Boss One Name><red> is currently <white>locked<red>."
 
            else if <context.message> == "<cons:Boss Two Name>" && "<npc.flag[<cons:Boss Two Name>-Organizer]>" == "Locked" 
            narrate "<red>Sorry <white><player.name><red>, but the boss fight event <gold><cons:Boss Two Name><red> is currently <white>locked<red>."
 
            else if <context.message> == "<cons:Boss Three Name>" && "<npc.flag[<cons:Boss Three Name>-Organizer]>" == "Locked" 
            narrate "<red>Sorry <white><player.name><red>, but the boss fight event <gold><cons:Boss Three Name><red> is currently <white>locked<red>."
 
            else if <context.message> == "<cons:Boss One Name>" && "<npc.flag[<cons:Boss One Name>-Organizer]>" != null
            narrate "<red>Sorry <white><player.name><red>, but the boss fight event <gold><cons:Boss One Name><red> is already being organized by <white><npc.flag[<cons:Boss One Name>-Organizer]><red>."
 
            else if <context.message> == "<cons:Boss Two Name>" && "<npc.flag[<cons:Boss Two Name>-Organizer]>" != null
            narrate "<red>Sorry <white><player.name><red>, but the boss fight event <gold><cons:Boss Two Name><red> is already being organized by <white><npc.flag[<cons:Boss Two Name>-Organizer]><red>."
 
            else if <context.message> == "<cons:Boss Three Name>" && "<npc.flag[<cons:Boss Three Name>-Organizer]>" != null
            narrate "<red>Sorry <white><player.name><red>, but the boss fight event <gold><cons:Boss Three Name><red> is already being organized by <white><npc.flag[<cons:Boss Three Name>-Organizer]><red>."
 
            else if <context.message> == "<cons:Boss One Name>" {
            - flag <npc> "<cons:Boss One Name>-Organizer:<player>"
            - flag <npc> "<cons:Boss One Name>-Join:->:<player>"
            - flag <player> "OrganizingBossFight:<cons:Boss One Name>"
            - flag <player> "BossFightJoined:<cons:Boss One Name>"
            - flag <player> BossFightNPC:<npc>
            - chat "<white><player.name><yellow>, you are now the organizer for event '<gold><cons:Boss One Name><yellow>'. Tell players to come and talk to me and I'll add them to the group."
            - ^announce "<white><player.name> <red>is organizing a boss event for <gold><cons:Boss One Name><red>." }
 
            else if <context.message> == "<cons:Boss Two Name>" {
            - flag <npc> "<cons:Boss Two Name>-Organizer:<player>"
            - flag <npc> "<cons:Boss Two Name>-Join:->:<player>"
            - flag <player> "OrganizingBossFight:<cons:Boss Two Name>"
            - flag <player> "BossFightJoined:<cons:Boss Two Name>"
            - flag <player> BossFightNPC:<npc>
            - narrate "<white><player.name><yellow>, you are now the organizer for event '<gold><cons:Boss Two Name><yellow>'. Tell players to come and talk to me and I'll add them to the group."
            - ^announce "<white><player.name> <red>is organizing a boss event for <gold><cons:Boss Two Name><red>." }
 
            else if <context.message> == "<cons:Boss Three Name>" {
            - flag <npc> "<cons:Boss Three Name>-Organizer:<player>"
            - flag <npc> "<cons:Boss Three Name>-Join:->:<player>"
            - flag <player> "OrganizingBossFight:<cons:Boss Three Name>"
            - flag <player> "BossFightJoined:<cons:Boss Three Name>"
            - flag <player> BossFightNPC:<npc>
            - narrate "<white><player.name><yellow>, you are now the organizer for event '<gold><cons:Boss Three Name><yellow>'. Tell players to come and talk to me and I'll add them to the group."
            - ^announce "<white><player.name> <red>is organizing a boss event for <gold><cons:Boss Three Name><red>." }
 
            else narrate "<red>I'm sorry <white><player.name><red>, but there is no event named '<white><context.message><red>'."
          - zap step:Organize

      click trigger:
        script:
        # Run this script when the player click the NPC at any point during this step.
        - run "Bossfight Initiate Conversation"

      proximity trigger:
        exit:
          script:
          # When the player leaves the NPC proximity, this step here will put their dialogue back to the beginning so
          # they don't come back 2 days later and have to continue with an old dialogue.
          - zap step:Organize

    'Join Group':
      chat trigger:
        'Which Boss':
          trigger: I want to join the group for event '/REGEX:^\w+$/'.
          script:
          # There are 3 possibilities here
          # 1) If player wants to join an event that isn't being organized, tell them they can't.
          # 2) If the player is trying to join an event that has been locked, tell them they can't.
          # 3) If the event is available, add the player into the NPC flag so they become part of the event. Add
          #  a couple of extra flags to the player that is used to automatically remove them from the event when
          #  they quit Minecraft.
          # 4) Catch-all at the end that tells the player they entered an unexpected value.
          - ^if <context.message> == "<cons:Boss One Name>" && "<npc.flag[<cons:Boss One Name>-Organizer]>" == null
            narrate "<red>Sorry <white><player.name><red>, but the boss fight event <yellow><cons:Boss One Name><red> doesn't currently have an organizer."
 
            else if <context.message> == "<cons:Boss Two Name>" && "<npc.flag[<cons:Boss Two Name>-Organizer]>" == null
            narrate "<red>Sorry <white><player.name><red>, but the boss fight event <yellow><cons:Boss Two Name><red> doesn't currently have an organizer."
 
            else if <context.message> == "<cons:Boss Three Name>" && "<npc.flag[<cons:Boss Three Name>-Organizer]>" == null
            narrate "<red>Sorry <white><player.name><red>, but the boss fight event <yellow><cons:Boss Three Name><red> doesn't currently have an organizer."
 
            else if <context.message> == "<cons:Boss One Name>" && "<npc.flag[<cons:Boss One Name>-Organizer]>" == "Locked"
            narrate "<red>Sorry <white><player.name><red>, but the boss fight event <gold><cons:Boss One Name><red> is currently <white>locked<red>."
 
            else if <context.message> == "<cons:Boss Two Name>" && "<npc.flag[<cons:Boss Two Name>-Organizer]>" == "Locked" 
            narrate "<red>Sorry <white><player.name><red>, but the boss fight event <gold><cons:Boss Two Name><red> is currently <white>locked<red>."
 
            else if <context.message> == "<cons:Boss Three Name>" && "<npc.flag[<cons:Boss Three Name>-Organizer]>" == "Locked" 
            narrate "<red>Sorry <white><player.name><red>, but the boss fight event <gold><cons:Boss Three Name><red> is currently <white>locked<red>."
 
            else if <context.message> == "<cons:Boss One Name>" && "<npc.flag[<cons:Boss One Name>-Join].size>" >= "<cons:Boss One Max Players>"
            narrate "<red>You are unable to join the event <gold><cons:Boss One Name><red> because it is full."
 
            else if <context.message> == "<cons:Boss Two Name>" && "<npc.flag[<cons:Boss Two Name>-Join].size>" >= "<cons:Boss Two Max Players>"
            narrate "<red>You are unable to join the event <gold><cons:Boss Two Name><red> because it is full."
 
            else if <context.message> == "<cons:Boss Three Name>" && "<npc.flag[<cons:Boss Three Name>-Join].size>" >= "<cons:Boss Three Max Players>"
            narrate "<red>You are unable to join the event <gold><cons:Boss Three Name><red> because it is full."
 
            else if <context.message> == "<cons:Boss One Name>" && <player.flag[BossFightJoined]> == null {
            - flag <npc> "<cons:Boss One Name>-Join:->:<player>"
            - flag <player> "BossFightJoined:<cons:Boss One Name>"
            - flag <player> BossFightNPC:<npc>
            - announce "<yellow><player.name> <red>has joined the boss event <gold><cons:Boss One Name>" }
 
            else if <context.message> == "<cons:Boss Two Name>" && <player.flag[BossFightJoined]> == null {
            - flag <npc> "<cons:Boss Two Name>-Join:->:<player>"
            - flag <player> "BossFightJoined:<cons:Boss Two Name>"
            - flag <player> "BossFightNPC:<npc>"
            - ^announce "<yellow><player.name> <red>has joined the boss event <gold><cons:Boss Two Name>" }
 
            else if <context.message> == "<cons:Boss Three Name>" && <player.flag[BossFightJoined]> == null {
            - flag <npc> "<cons:Boss Three Name>-Join:->:<player>"
            - flag <player> "BossFightJoined:<cons:Boss Three Name>"
            - flag <player> BossFightNPC:<npc>
            - announce "<yellow><player.name> <red>has joined the boss event <gold><cons:Boss Three Name>" }
 
            else narrate "<red>I'm sorry <white><player.name><red>, but there is no event called '<white><context.message><red>'."
          - zap step:Organize

      click trigger:
        script:
        - run "Bossfight Initiate Conversation"
      
      proximity trigger:
        exit:
          script:
          - zap step:Organize

    'Lock Event':
      chat trigger:
        'Which Event':
          trigger: '/REGEX:^\w+$/'
          script:
          # There are 3 possibilities here
          # 1) If the OP specifies the event and the event is not locked, flag the Organizer flag with the 
          #  value 'Locked' and remove all participants and their flags.
          # 2) If the OP specifies the event and the event is locked, clear the Organizer flag, making it
          #  available again.
          # 3) Else, if nothing matches, assume the OP typed in something wrong and show them what they typed.
          - ^if <context.message> == "<cons:Boss One Name>" && "<npc.flag[<cons:Boss One Name>-Organizer]>" != "Locked" {
            - flag <npc> "<cons:Boss One Name>-Organizer:Locked"
            - foreach "<npc.flag[<cons:Boss One Name>-Join].aslist>" {
              - flag %value% OrganizingBossFight:!
              - flag %value% BossFightJoined:!
              - flag %value% BossFightNPC:! }
            - flag <npc> "<cons:Boss One Name>-Join:!"
            - announce "<red>The event '<gold><cons:Boss One Name><red>' has been locked." }
 
            else if <context.message> == "<cons:Boss One Name>" && "<npc.flag[<cons:Boss One Name>-Organizer]>" == "Locked" {
            - flag <npc> "<cons:Boss One Name>-Organizer:!"
            - announce "<red>The event '<gold><cons:Boss One Name><red>' has been <green>unlocked." }
 
            else if <context.message> == "<cons:Boss Two Name>" && "<npc.flag[<cons:Boss Two Name>-Organizer]>" != "Locked" {
            - flag <npc> "<cons:Boss Two Name>-Organizer:Locked"
            - foreach "<npc.flag[<cons:Boss Two Name>-Join].aslist>" {
              - flag %value% OrganizingBossFight:!
              - flag %value% BossFightJoined:!
              - flag %value% BossFightNPC:! }
            - flag <npc> "<cons:Boss Two Name>-Join:!"
            - announce "<red>The event '<gold><cons:Boss Two Name><red>' has been locked." }
 
            else if <context.message> == "<cons:Boss Two Name>" && "<npc.flag[<cons:Boss Two Name>-Organizer]>" == "Locked" {
            - flag <npc> "<cons:Boss Two Name>-Organizer:!"
            - announce "<red>The event '<gold><cons:Boss Two Name><red>' has been <green>unlocked." }
 
            else if <context.message> == "<cons:Boss Three Name>" && "<npc.flag[<cons:Boss Three Name>-Organizer]>" != "Locked" {
            - flag <npc> "<cons:Boss Three Name>-Organizer:Locked"
            - foreach "<npc.flag[<cons:Boss Three Name>-Join].aslist>" {
              - flag %value% OrganizingBossFight:!
              - flag %value% BossFightJoined:!
              - flag %value% BossFightNPC:! }
            - flag <npc> "<cons:Boss Three Name>-Join:!"
            - announce "<red>The event '<gold><cons:Boss Three Name><red>' has been locked." }
 
            else if <context.message> == "<cons:Boss Three Name>" && "<npc.flag[<cons:Boss Three Name>-Organizer]>" == "Locked" {
            - flag <npc> "<cons:Boss Three Name>-Organizer:!"
            - announce "<red>The event '<gold><cons:Boss Three Name><red>' has been <green>unlocked." }
 
            else narrate "<red>I am sorry, I don't know how '<white><context.message><red>' is relevant to the context."

      click trigger:
        script:
        - run "Bossfight Initiate Conversation"
      
      proximity trigger:
        exit:
          script:
          - zap step:Organize

"Bossfight General Chat":
  type: task

  script:
  # This script runs when the player enters the NPC proximity. It uses 'random' to pick
  # any one of the lines underneath it.
  - ^random 4
  - ^chat "<yellow>Hey <white><player.name><yellow>, come talk to me if you're up for a challenge!"
  - ^chat "<yellow>I've done my fair share of fighting, now I'm just helping to get groups together."
  - ^chat "<yellow>I used to join in on the boss fights, but then I took an arrow in the knee."
  - ^chat "<yellow>Ahh, nothing like the cheer of a successful party coming back with their spoils of war!"

"Bossfight Initiate Conversation":
  type: task

  script:
  # Present the initial dialogue options to the player.
  # If player is an OP, also show the 'Lock' and 'Reset' options.
  - chat "<yellow>Welcome <white><player.name><yellow>. I organize group events for bosses <gold><cons:Boss One Name><yellow>,<gold> <cons:Boss Two Name><yellow> and <gold><cons:Boss Three Name><yellow>."
  - chat "<yellow>What would you like to do?"
  - ^narrate "<red>Say<&co>"
  - ^narrate "   - <red>'Join'<gray> or <red>'Leave'<gray> a boss event."
  - ^narrate "   - <red>'Organize'<gray> or <red>'Cancel'<gray> a boss event."
  - ^narrate "   - <red>'Start'<gray> organized boss event or see current <red>'Events'<gray> list." 
  - if <player.is_op> == true narrate "<gray>Additional OP commands<&co> '<red>Lock<gray>' or '<red>Reset<gray>' events."
  - ^zap "[email protected] Organizer Convo" "step:Organize"

"Bossfight Organize a Boss":
  type: task

  script:
  # This is another list that presents the available events to start a group for. It does some checks to decide
  # what data it should display for the user. Basically it checks:
  # 1) Is the event locked, if so display a 'Event Locked' after the event name.
  # 2) If there is no organizer, display some information about the event, like difficulty level, minimum players needed and the fact that there is no organizer assigned.
  # 3) Else display pretty much the same info but with the organizers name this time.
  - chat "<yellow>Which boss event would you like to start a group for?"
  - ^narrate "<red>Say<&co>"
  - ^narrate "<green>------------------------------------------------"
 
  - if "<npc.flag[<cons:Boss One Name>-Organizer]>" == "Locked" 
    narrate " <gold><cons:Boss One Name><gray> - <red>Event Locked"
    else if "<npc.flag[<cons:Boss One Name>-Organizer]>" == null
    narrate " <gold><cons:Boss One Name> <Dark_Purple><italic>(<cons:Boss One Difficulty>)<gray> - <red>No Organizer<gray> - Min.<white> <cons:Boss One Min Players><gray>. Max.<white> <cons:Boss One Max Players><gray>."
    else narrate " <gold><cons:Boss One Name> <Dark_Purple><italic>(<cons:Boss One Difficulty>)<gray> - Org. <yellow><npc.flag[<cons:Boss One Name>-Organizer]><gray> Cur. <white><npc.flag[<cons:Boss One Name>-Join].size><gray> Min.<white> <cons:Boss One Min Players><gray>. Max.<white> <cons:Boss One Max Players><gray>."
 
  - if "<npc.flag[<cons:Boss Two Name>-Organizer]>" == "Locked"
    narrate " <gold><cons:Boss Two Name><gray> - <red>Event Locked"
    else if "<npc.flag[<cons:Boss Two Name>-Organizer]>" == null
    narrate " <gold><cons:Boss Two Name> <Dark_Purple><italic>(<cons:Boss Two Difficulty>)<gray> - <red>No Organizer<gray> - Min.<white> <cons:Boss Two Min Players><gray>. Max.<white> <cons:Boss Two Max Players><gray>."
    else narrate " <gold><cons:Boss Two Name> <Dark_Purple><italic>(<cons:Boss Two Difficulty>)<gray> - Org. <yellow><npc.flag[<cons:Boss Two Name>-Organizer]><gray> Cur. <white><npc.flag[<cons:Boss Two Name>-Join].size><gray> Min.<white> <cons:Boss Two Min Players><gray>. Max.<white> <cons:Boss Two Max Players><gray>."
 
  - if "<npc.flag[<cons:Boss Three Name>-Organizer]>" == "Locked" 
    narrate " <gold><cons:Boss Three Name><gray> - <red>Event Locked"
    else if "<npc.flag[<cons:Boss Three Name>-Organizer]>" == null
    narrate " <gold><cons:Boss Three Name> <Dark_Purple><italic>(<cons:Boss Three Difficulty>)<gray> - <red>No Organizer<gray> - Min.<white> <cons:Boss Three Min Players><gray>. Max.<white> <cons:Boss Three Max Players><gray>."
    else narrate " <gold><cons:Boss Three Name> <Dark_Purple><italic>(<cons:Boss Three Difficulty>)<gray> - Org. <yellow><npc.flag[<cons:Boss Three Name>-Organizer]><gray> Cur. <white><npc.flag[<cons:Boss Three Name>-Join].size><gray> Min.<white> <cons:Boss Three Min Players><gray>. Max.<white> <cons:Boss Three Max Players><gray>."
 
  - ^narrate "<green>------------------------------------------------"
  - ^zap "[email protected] Organizer Convo" "step:Create Group"

"Bossfight Join a Group":
  type: task

  script:
  # Present the player with a list of events and whether they are available or not, who is organizing them and the number of players joined.
  # Similar to 'Bossfight Organize a Boss' above.
  - chat "<yellow>Which boss event would you like to join?"
  - ^narrate "<red>Say<&co>"
  - ^narrate "<green>------------------------------------------------"
  - ^if "<npc.flag[<cons:Boss One Name>-Organizer]>" == "Locked" 
    narrate " <gold><cons:Boss One Name><gray> - <red>Event Locked"
    else if "<npc.flag[<cons:Boss One Name>-Organizer]>" != null
    narrate " <gold><cons:Boss One Name> <Dark_Purple><italic>(<cons:Boss One Difficulty>)<gray> - Org. <yellow><npc.flag[<cons:Boss One Name>-Organizer]><gray> Cur. <white><npc.flag[<cons:Boss One Name>-Join].size><gray> Min.<white> <cons:Boss One Min Players><gray>. Max.<white> <cons:Boss One Max Players><gray>."
    else narrate " <gold><cons:Boss One Name> <Dark_Purple><italic>(<cons:Boss One Difficulty>)<gray> -<red> No Organizer<gray> - Min.<white> <cons:Boss One Min Players><gray>. Max.<white> <cons:Boss One Max Players><gray>."
  - ^if "<npc.flag[<cons:Boss Two Name>-Organizer]>" == "Locked" 
    narrate " <gold><cons:Boss Two Name><gray> - <red>Event Locked"
    else if "<npc.flag[<cons:Boss Two Name>-Organizer]>" != null
    narrate " <gold><cons:Boss Two Name> <Dark_Purple><italic>(<cons:Boss Two Difficulty>)<gray> - Org. <yellow><npc.flag[<cons:Boss Two Name>-Organizer]><gray> Cur. <white><npc.flag[<cons:Boss Two Name>-Join].size><gray> Min.<white> <cons:Boss Two Min Players><gray>. Max.<white> <cons:Boss Two Max Players><gray>."
    else narrate " <gold><cons:Boss Two Name> <Dark_Purple><italic>(<cons:Boss Two Difficulty>)<gray> -<red> No Organizer<gray> - Min.<white> <cons:Boss Two Min Players><gray>. Max.<white> <cons:Boss Two Max Players><gray>."
  - ^if "<npc.flag[<cons:Boss Three Name>-Organizer]>" == "Locked" 
    narrate " <gold><cons:Boss Three Name><gray> - <red>Event Locked"
    else if "<npc.flag[<cons:Boss Three Name>-Organizer]>" != null
    narrate " <gold><cons:Boss Three Name> <Dark_Purple><italic>(<cons:Boss Three Difficulty>)<gray> - Org. <yellow><npc.flag[<cons:Boss Three Name>-Organizer]><gray> Cur. <white><npc.flag[<cons:Boss Three Name>-Join].size><gray> Min.<white> <cons:Boss Three Min Players><gray>. Max.<white> <cons:Boss Three Max Players><gray>."
    else narrate " <gold><cons:Boss Three Name> <Dark_Purple><italic>(<cons:Boss One Difficulty>)<gray> -<red> No Organizer<gray> - Min.<white> <cons:Boss Three Min Players><gray>. Max.<white> <cons:Boss Three Max Players><gray>."
  - ^narrate "<green>------------------------------------------------"
  - ^zap "[email protected] Organizer Convo" "step:Join Group"

"Cancel Bossfight on Logout":
  type: world
  events:
    on player quits:
    # This world event will run for every user that disconnects from the server.
    # 1) If they are part of an event:
    #  a. Check to see if they are the organizer. If they are, then clear the flags for all other players that are part
    #     of the event. Then clear the "organizer" and "join" flags set against NPC for the particular boss.
    #  b. If they are not the organiser, simply clear the player flags and remove them from the list flag set against
    #     the NPC.
    - if <player.flag[BossFightJoined]> != null || <player.flag[OrganizingBossFight]> != null {
      - if <npc[<player.flag[BossFightNPC]>].flag[<player.flag[BossFightJoined]>-Organizer]> == <player> {
      - announce "<red>The boss event <gold><player.flag[BossFightJoined]><red>, organized by <yellow><player.name> <red>has been cancelled."
      - flag <npc[<player.flag[BossFightNPC]>]> <player.flag[BossFightJoined]>-Organizer:!
      - foreach <npc[<player.flag[BossFightNPC]>].flag[<player.flag[BossFightJoined]>-Join].aslist> {
        - flag %value% OrganizingBossFight:!
        - flag %value% BossFightJoined:!
        - flag %value% BossFightNPC:! }
      - flag <npc[<player.flag[BossFightNPC]>]> <player.flag[BossFightJoined]>-Join:! }
 
        else {
          - announce "<white><player.name> <red>has left the boss event for '<gold><player.flag[BossFightJoined]><red>'."
          - flag <npc[<player.flag[BossFightNPC]>]> <player.flag[BossFightJoined]>-Join:<-:<player>
          - flag <player> OrganizingBossFight:!
          - flag <player> BossFightJoined:!
          - flag <player> BossFightNPC:! }
      }




Comments
2013-12-26 23:09:17 - Tacoaloto:

wow there's a lot to this script. I can't seem to figure out something.. I can't damage it or the minions, the boss can't damage me, but the minions can hit me. that's rather unusual
2013-12-26 23:11:57 - Tacoaloto:

wait wrong script, I meant to comment this on the actual boss fight script