Paste #20346: guide npc

Date: 2015/09/23 18:49:29 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


cchat:
    type: format
    format: "<&b><npc.name><&f><&co><&a><text>"
world1:
    type: world
    events:
        on player joins:
        - if <player.is_op> {
            - wait 10
            - ^adjust <player> gamemode:creative
         }
world2:
    type: world
    events:
        on player joins:
         - if <server.list_online_players.is[!equals].than[li@]> {
            - wait 10
            - spawn <global.flag[masternpc]> <global.flag[masternpc].anchor[spot1]>
            - ^run chunkloadpath npc:<global.flag[masternpc]>
            - ^run masterpath npc:<global.flag[masternpc]>
            - if <player.flag[active]> {
                - ^adjust <player> hide_entity:<global.flag[masternpc]>
             }
          }
        on player quits:
        - if <player.flag[questaccepted].is[equals].than[1]> {
                - ^flag global questaccepted:0
                - ^flag global questaccepted:0
                - zap clonequest 1
         }
        - wait 1
        - if <server.list_online_players.is[equals].than[li@]> {
           - ^run chunkremovepath npc:<global.flag[masternpc]>
           - despawn <global.flag[masternpc]>
         }
chunkloadpath:
    type: task
    script:
    - ^chunkload add <npc.anchor[spot1].chunk>
    - ^chunkload add <npc.anchor[spot2].chunk>
    - ^chunkload add <npc.anchor[spot3].chunk>
    - ^chunkload add <npc.anchor[spot5].chunk>
    - ^chunkload add <npc.anchor[spot6].chunk>
    - ^chunkload add <npc.anchor[spot7].chunk>
    - ^chunkload add <npc.anchor[spot8].chunk>
    - ^chunkload add <npc.anchor[spot9].chunk>
    - ^chunkload add <npc.anchor[spot10].chunk>
    - ^chunkload add <npc.anchor[spot11].chunk>
    - ^chunkload add <npc.anchor[spot12].chunk>
    - ^chunkload add <npc.anchor[spot13].chunk>
chunkremovepath:
    type: task
    script:
    - ^chunkload remove <npc.anchor[spot1].chunk>
    - ^chunkload remove <npc.anchor[spot2].chunk>
    - ^chunkload remove <npc.anchor[spot3].chunk>
    - ^chunkload remove <npc.anchor[spot5].chunk>
    - ^chunkload remove <npc.anchor[spot6].chunk>
    - ^chunkload remove <npc.anchor[spot7].chunk>
    - ^chunkload remove <npc.anchor[spot8].chunk>
    - ^chunkload remove <npc.anchor[spot9].chunk>
    - ^chunkload remove <npc.anchor[spot10].chunk>
    - ^chunkload remove <npc.anchor[spot11].chunk>
    - ^chunkload remove <npc.anchor[spot12].chunk>
    - ^chunkload remove <npc.anchor[spot13].chunk>
masterpath:
    type: task
    script:
    - while <server.list_online_players.is[!equals].than[li@]> {
        - ~walk <npc.anchor[spot1]> auto_range
        - inject checkplayer
        - wait 3
        - ~walk <npc.anchor[spot2]> auto_range
        - inject checkplayer
        - wait 3
        - ~walk <npc.anchor[spot3]> auto_range
        - inject checkplayer
        - wait 3
        - ~walk <npc.anchor[spot5]> auto_range
        - inject checkplayer
        - wait 3
        - ~walk <npc.anchor[spot6]> auto_range
        - inject checkplayer
        - wait 3
        - ~walk <npc.anchor[spot7]> auto_range
        - inject checkplayer
        - wait 3
        - ~walk <npc.anchor[spot8]> auto_range
        - inject checkplayer
        - wait 3
        - ~walk <npc.anchor[spot9]> auto_range
        - inject checkplayer
        - wait 3
        - ~walk <npc.anchor[spot10]> auto_range
        - inject checkplayer
        - wait 3
        - ~walk <npc.anchor[spot11]> auto_range
        - inject checkplayer
        - wait 3
        - ~walk <npc.anchor[spot12]> auto_range
        - inject checkplayer
        - wait 3
        - ~walk <npc.anchor[spot13]> auto_range
        - inject checkplayer
        }

checkplayer:
    type: task
    script:
    - if <server.list_online_players].is[equals].than[li@]> {
        - teleport <npc> <npc.anchor[spot1]>
     }
enderknight3:
    type: assignment
    actions:
        on assignment:
        - ^flag global questaccepted:0
        - lookclose <npc> state:true
        - ^adjust <npc> skin:leonellus
        - ^flag global masternpc:<^npc>
        - trigger name:click state:true
        - trigger name:proximity state:true
        - trigger name:chat state:true
        on click:
        - narrate format:cchat "please do not touch me i am in a hurry i must find someone who can help me!"
    interact scripts:
    - 10 enderquest
enderquest:
    type: interact
    steps:
        1:
            proximity trigger:
                entry:
                    script:
                    - flag player active:false
                    - narrate format:cchat "excuse me! i am in a hurry. i must find someone who can help me!"
                exit:
                    script:
                    - narrate format:cchat "Wait your <player.name> you might be able to help me. i have heard of you in the castle. i have an urgent quest can you help me?"
                    - ^create player EnderKnight <npc.location> save:EnderKnight
                    - ^flag player active:true
                    - ^adjust <player> hide_entity:<npc>
                    - ^adjust <server.list_online_players.exclude[<player>]> hide_entity:<entry[EnderKnight].created_npc>
                    - ^run clonetask npc:<entry[EnderKnight].created_npc>
                    - zap 2
clonetask:
    type: task
    script:
    - adjust <npc> skin:leonellus
    - assignment set script:cloneassignment
    - if <global.flag[questaccepted].is[less].than[1]> {
        - if <player.flag[questaccepted].is[less].than[1] {
                - narrate format:cchat the quest has been accepted. i am sorry you could not help me.
                - inject ending
         }
     }
cloneassignment:
    type: assignment
    actions:
        on assignment:
        - flag npc move:true
        - flag npc player:<player>
        - lookclose <npc> state:true
        - trigger name:click state:true
        - trigger name:proximity state:true 
        - trigger name:chat state:true
        - adjust <npc> skin:leonellus
        - inject findplayer
        on exit proximity:
        - if <npc.flag[move]> { 
            - narrate format:cchat "please wait i need to talk to you"
            - wait 2
            - inject findplayer
            - adjust <npc> skin:leonellus
         }
    interact scripts:
    - 10 clonequest
findplayer:
    type: task
    script:
    - ^define X <player.location.x>
    - ^define Y <player.location.y>
    - ^define Z <player.location.z>
    - ^define NX <npc.location.x>
    - ^define NY <npc.location.y>
    - ^define NZ <npc.location.z>
    - ^define Dx <player.location.x.distance[<npc.location.x>]>
    - ^define Dy <player.location.y.distance[<npc.location.y>]>
    - ^define Dz <player.location.z.distance[<npc.location.z>]>
    - ^if <def[X].is[more].than[<def[NX]>]> { - ^define x <def[X].sub[2]> } else { - ^define x <def[X].add[2]> }
    - ^if <def[Z].is[more].than[<def[NZ]>]> { - ^define z <def[Z].sub[2]> } else { - ^define z <def[Z].add[2]> }
    - ^define out l@<def[x]>,<player.location.y>,<def[z]>,<player.location.pitch>,<player.location.yaw>,<player.world.name>
    - if <def[Dx].is[or_more].than[5]> { - teleport <npc> <def[out]> }
    - if <def[Dz].is[or_more].than[5]> { - teleport <npc> <def[out]> }
clonequest:
    type: interact
    steps:
        1:
            chat trigger:
                1:
                    trigger: /help/ me i dont know what you want!
                    script:
                    - narrate format:cchat "my current options are yes,help,leavemealone"
                2:    
                    trigger: /leave/ me alone!
                    script:
                    - narrate format:cchat "very well than i will find someone else"
                    - ^inject ending
                3:
                    trigger: /yes/ i can help you. this evil must not be left as it is.
                    script:
                    - ^flag player questaccepted:1
                    - ^flag global questaccepted:1
                    - ^narrate format:cchat "very well follow me to the depths of the abyss. to find the monster beyond the dank and dark." 
                    - ^trigger name:click state:false
                    - ^trigger name:proximity state:false
                    - ^flag npc move:false
                    - ^run waittime npc:<npc>
                    - ^run questpath npc:<npc> def:<global.flag[masternpc]>
                    - ^run questtalk npc:<npc>
                    - zap clonequest 3
        2:
            chat trigger:
                1:
                    trigger: /yes/ i am ready to continue
                    script:
                    trigger: /no/ i quit i cannot go on.
                    script:
                    - narrate format:cchat very well i will try to find someone else.
                    - ^flag player questaccepted:0
                    - ^flag global questaccepted:0
                    - inject ending
                    - zap clonequest 1
waittime:
    type: task
    script:
    - while <npc.flag[queststep].is[or_more].than[1]> {
        - while <player.location.distance[<npc.location>].is[or_more].than[5]> {
            - narrate format:cchat please try to catch up
            - wait 5
            - if <player.location.distance[<npc.location>].is[more].than[20]> { 
                -inject ending
             }
         }
     }
questpath:
    type: task
    definitions: masternpc
    script:
    - ^flag npc queststep:1
    - narrate <def[masternpc]>
    - ~walk <def[masternpc].anchor[dentrance]> auto_range
    - wait 3
    - ^flag npc queststep:2
    - while <npc.flag[queststep].is[less].than[3]> {
        - wait 0
     }
    - zap clonequest 2
questtalk:
    type: task
    script:
    - while <npc.flag[queststep].is[or_more].than[1]>{
        - if <npc.flag[queststep].is[more].than[1]> {
            - narrate format:cchat "here we are are you sure you are ready?"
            - if <npc.flag[queststep].is[equals].than[3]> {
                - narrate format:cchat "be careful i have no idea what could be lurking down here. i will get you as close as i can to the entrance to the lair."
             }
         }
     }
ending:
    type: task
    script:
    - ^adjust <player> show_entity:<global.flag[masternpc]>
    #- narrate <npc.flag[playerinfo]>
    - ^adjust <global.flag[masternpc]> skin:leonellus
    - ^zap enderquest 1
    - ^flag global accepted:false
    - ^flag player active:false
    - ^flag npc queststep:0
    - ^assignment remove script:cloneassignment
    - remove <npc>