Paste #31083: Checking

Date: 2016/03/01 17:15:05 UTC-08:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


ZombieKillQuest:
    type: assignment
    actions:
        on assignment:
        - trigger name:click state:true
        - trigger name:chat state:true radius: 3

        on click:
        # Checks in which state the player is
        - choose <player.flag[ZKQState]||0>:

            # Default case (assigns to this, if not existent)
            # Quest not started
            - case 0:
                # Introduces the mission to the player
                - narrate format:npcchat "Hi <player.name>!"
                - wait 1
                - narrate format:npcchat "I seem to have issues with zombies attacking my farm."
                - wait 2
                - narrate format:npcchat "I want you to kill some zombies using a golden sword!"
                - flag player ZKQState:1
                - narrate format:YNchat "Can you kill 50 zombies with a golden sword?"

            # The player has come back to get the question again.
            - case 1:
                - narrate format:npcchat "I see you have came back, <player.name>"
                - wait 1
                - narrate format:YNchat "So can you kill 50 zombies with a golden sword?"

            # The quest is in progress
            - case 2:
                - if ZKQCount == 50 {
                   - flag player ZKQState:3
                   - narrate format:npcchat "I see you've killed 50 zombies with a golden sword like I asked you."
                   - wait 1
                   - narrate format:npcchat "Good job! Here is your reward:"
                   - give <player.name> i@GOLD_INGOT quantity:64
                   - wait 1
                   - narrate format:npcchat "Come back tomorrow! ;)"
                } else {
                     - narrate format:npcchat "You've killed <ZKQCount> out of 50"
                    - wait 1
                    - narrate format:npcchat "Come back, when you are done with my mission!"
                }

            # The quest is finished
            - case 3:
                - narrate format:npcchat "I've nothing for you today."
                - wait 1
                - narrate format:npcchat "Come back tomorrow!"

        on chat:
        # Checks in which state the player is
        - choose <player.flag[ZKQState]||0>:

            # Dafault case (asssigns to this, if not existent)
            # Quest not yet introduced
            - case 0:
                - wait 1
                - narrate format:npcchat "I have nothing for you."

            # The player is asked about the quest
            - case 1:
                - if <context.message> == "Yes" {
                    - flag player ZKQState:2
                    - flag player ZKQCount:0
                    - narrate format:npcchat "Great!"
                    - wait 1
                    - narrate format:npccat "Come back, when you have killed 50 zombies with a golden sword!"
                } else {

                }

            # The quest is in progress
            - case 2:
                - if ZKQCount == 50 {
                   - flag player ZKQState:3
                   - narrate format:npcchat "I see you've killed 50 zombies with a golden sword like I asked you."
                   - wait 1
                   - narrate format:npcchat "Good job! Here is your reward:"
                   - give <player.name> i@GOLD_INGOT quantity:64
                   - wait 1
                   - narrate format:npcchat "Come back tomorrow! ;)"
                } else {
                     - narrate format:npcchat "You've killed <ZKQCount> out of 50"
                    - wait 1
                    - narrate format:npcchat "Come back, when you are done with my mission!"
                }

            # The quest has been completed
            - case 3:
                - narrate format:npcchat "I've nothing for you today."
                - wait 1
                - narrate format:npcchat "Come back tomorrow!"

ZKQWorld:
    type: world
    events:
        # When the zombie is killed by a player
        on zombie killed by player:
            # Checks whether the player is doing the mission and if he finished or not.
            if <player.flag[ZKQState]> == 2 && !<ZKQDone||false> {
                - if <context.damage> == entity_attack {
                    - if <player.item_in_hand> == "GOLDEN SWORD" {
                        - ZKQCount++
                        - if ZKQCount == 50 {
                            - narrate format:questUpdate "You've killed all the zombies"
                            - wait 1
                            - narrate format:questUpdate "Go back to James, to receive your reward!"
                            - wait 1
                            - set flag ZKQDone true
                        } else {
                            - narrate format:questUpdate "You've killed <ZKQCount> out of 50 zombies."
                        }
                    }
                }
            }

normalchat:
    type: format
    format: "<red><npc.name><&co><white> <text>"

YNchat:
    type: format
    format: "<white><text> <green>YES<white> or <red>NO"

questUpdate:
    type: format
    format: "<green><text>"