- D1 Meta Docs - Denizen Script -
Home Page / Pi to one million places / Contact mcmonkey / Donate / Paste Scripts / Denizen Help /
You are browsing as a guest.
Login | Register


Click here to create your own public paste ~ ~ click to duplicate and edit this paste


Titlequest manager
TypeDenizen Script
Date2015/05/14 16:42:24 UTC-07:00
Byzozer_firehood
Other
Paste
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
19900
questmanager:
  type: world
  events:
    on server starts:
      - inject locally loadYAML 'def:quests|quests
    on player clicks sign:
      - define quest '<c.location.sign_contents.get[1]>'
      - if <yaml[quests].read[quests.%quest%.trigger.location]>.is[==].to[<c.location>]> {
        - if <player.has_flag[%quest%_complete]> {
          - narrate "<green>you have completed %quest% quest"
          - foreach <yaml[quests].list_keys[quests.%quest%.reward]> {
            - define reward <yaml[quests].list_keys[quest.%quest%.reward.%value%]>
            - if %value% == 'drpg_xp' {
              - flag player drpg_xp:++:%reward%
              - queue clear
              }
            - if %value% == 'gold' {
              - flag player drpg_gold:++:%reward%
              - queue clear
              }
            - narrate "here is %reward% %value% as a reward"
            - give %value% qty:%reward%
            }
          - flag player active_quests:<-:%quest%
          - flag player %quest%_complete:!
          - flag player %quest%_wait duration:24h
          - queue clear
          }
        - if <player.has_flag[%quest%_wait]> {
          - narrate "you can repeat this quest in <player.flag[%quest%_wait].expiration>"
          - queue clear
          }
        - if <player.flag[active_quests].contains[%quest%]> {
          - narrate "you already have this quest"
          - queue clear
          }
        - if !<player.has_flag[%quest%_confirm]> {
          - narrate "click again to accept the %quest% quest"
          - flag player %quest%_confirm duration:120
          - queue clear
          }
        - flag player %quest%_confirm:!
        - inject locally start_quest
        }
    on player kills entity:
      - if !<player.has_flag[active_quests]> {
        - queue clear
        }
      - define entity <c.entity>
      - foreach <player.flag[active_quests]> {
        - define possible_flag '%value%_%entity%_count'
        - if !<player.has_flag[%possible_flag%]> {
          - foreach next
          }
        - define flag '%value%_%entity%_count'
        - player flag %flag%:++:1
        - if <player.flag[%flag%].is[>=].to[quests.%value%.type.kill_list.%entity%]> {
          - flag player %flag%:!
          - if <yaml[quests].read[quests.%value%.type.return]> {
              - if <yaml[quests].read[quests.%value%.trigger.is[==].to[quest_sign]> {
                - define msg 'the quest_sign'
                }
              - if <yaml[quests].read[quests.%value%.trigger].is[==].to[npc]> {
                - define msg '<yaml[quests].read[quests.%value%.trigger.npc].name>'
                }
              - narrate "go back to %msg% to get your reward"
              - flag player %1%_complete
              }
              else {
              - define quest '%value%'
              - foreach <yaml[quests].list_keys[quests.%quest%.reward]> {
                - define reward <yaml[quests].list_keys[quest.%quest%.reward.%value%]>
                - if %value% == 'drpg_xp' {
                  - flag player drpg_xp:++:%reward%
                  - queue clear
                  }
                - if %value% == 'gold' {
                  - flag player drpg_gold:++:%reward%
                  - queue clear
                  }
                - narrate "here is %reward% %value% as a reward"
                - give %value% qty:%reward%
                }
              }
          }
        }
    on player picks up item:
      - if !<player.has_flag[active_quests]> {
        - queue clear
        }
      - define item <c.item>
      - foreach <player.flag[active_quests]> {
        - define possible_flag '%value%_%item%_count'
        - if !<player.has_flag[%possible_flag%]> {
          - foreach next
          }
        - define flag '%value%_%item%_count'
        - player flag %flag%:++:1
        - if <player.flag[%flag%].is[>=].to[quests.%value%.type.gather_list.%item%]> {
          - flag player %flag%:!
          - if <yaml[quests].read[quests.%value%.type.return]> {
              - if <yaml[quests].read[quests.%value%.trigger.is[==].to[quest_sign]> {
                - define msg 'the quest_sign'
                }
              - if <yaml[quests].read[quests.%value%.trigger].is[==].to[npc]> {
                - define msg '<yaml[quests].read[quests.%value%.trigger.npc].name>'
                }
              - narrate "go back to %msg% to get your reward"
              - flag player %1%_complete
              }
              else {
              - define quest '%value%'
              - foreach <yaml[quests].list_keys[quests.%quest%.reward]> {
                - define reward <yaml[quests].list_keys[quest.%quest%.reward.%value%]>
                - if %value% == 'drpg_xp' {
                  - flag player drpg_xp:++:%reward%
                  - queue clear
                  }
                - if %value% == 'gold' {
                  - flag player drpg_gold:++:%reward%
                  - queue clear
                  }
                - narrate "here is %reward% %value% as a reward"
                - give %value% qty:%reward%
                }
              }
          }
        }
    on player enters notable cuboid:
      - if !<player.has_flag[active_quests]> {
        - queue clear
        }
      - define cuboid '<context.cuboids>'
      - foreach <player.flag[active_quests]> {
        - if !<player.has_flag[%value%]> {
          - foreach next
          }
        - define flag '%value%'
        - if <player.flag[%flag%].is[==].to[%cuboid%]>
        - player flag %flag%:!
        - if <yaml[quests].read[quests.%value%.type.return]> {
          - if <yaml[quests].read[quests.%value%.trigger.is[==].to[quest_sign]> {
            - define msg 'the quest_sign'
            }
          - if <yaml[quests].read[quests.%value%.trigger].is[==].to[npc]> {
            - define msg '<yaml[quests].read[quests.%value%.trigger.npc].name>'
            }
          - narrate "go back to %msg% to get your reward"
          - flag player %1%_complete
          }
          else {
          - define quest '%value%'
          - foreach <yaml[quests].list_keys[quests.%quest%.reward]> {
            - define reward <yaml[quests].list_keys[quest.%quest%.reward.%value%]>
            - if %value% == 'drpg_xp' {
              - flag player drpg_xp:++:%reward%
              - queue clear
              }
            - if %value% == 'gold' {
              - flag player drpg_gold:++:%reward%
              - queue clear
              }
            - narrate "here is %reward% %value% as a reward"
            - give %value% qty:%reward%
            }
          }
        }
    on player flag cleared:
      - define flag '<c.name>'
      - foreach <yaml[quests].list_keys[quests]> {
        - if <yaml[quests].read[quests.%value%.trigger]>.is[==].to[auto]> {
          - if <yaml[quests].read[quests.%value%.trigger.previous_quest].is[==].to[<def[flag].split[_].get[1]>]> {
            - inject locally start_quest
            }
          }
        }
  start_quest:
    - flag player active_quests:->:%quest%
    - define type <yaml[quests].read[quests.%quest%.type]>
    - if %type% == goto {
      - define loc '<yaml[quests].read[quests.%quest%.type.location]>'
      - note cu@<def[loc].add[-5,-5,-5]>|<def[loc].add[5,5,5]> 'as:%quest%_cu'
      - flag player %quest%:'%quest%_cu'
      - queue clear
      }
    - foreach <yaml[quests].list_keys[quests.%quest%.type.%type%_list]> {
      - flag player %quest%_%value%_count:0
      }
  loadYAML:
    - if !<yaml.list.contains[quests]> {
      - if !<server.has_file[drpg/quests/quests.yml]> {
        - yaml create 'id:quests'
        - yaml 'savefile:drpg/quests/quests.yml' 'id:quests'
        }
        else {
        - yaml 'load:drpg/quests/quests.yml' 'id:quests'
        }
      }  



RawRaw



Pastes made: 70270