Date: 2015/06/22 15:50:13 UTC-07:00
Type: Denizen Script
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
satyrquest_master:
type: world
debug: true
events:
on sq command:
- if <player.selected_npc> == null {
- narrate "<&7>Please select an npc before using SatyrQuest."
- flag player QuestEditor:!
}
else if !<player.has_flag[QuestEditor]> {
- if !<player.selected_npc.has_flag[StepCount]> {
- flag <player.selected_npc> StepCount:->:0
}
- narrate "<&0>((<&8>((<&7>( S <&f>a <&e>t y <&6>r Q <&e>u e <&f>s t <&7>! )<&8>))<&0>))"
- narrate "<&7>You are now in the quest editor for <player.selected_npc.name> (<player.selected_npc.id>)"
- narrate "<&5>Quests involving this NPC:"
- foreach <player.selected_npc.flag[Quests].as_list> {
- narrate "<&7><&l> <def[loop_index]> - <&f><&o><def[value]>"
}
- narrate "<&7>You can <&a>add<&7>, <&b>edit<&7>, <&d>rename <&7>or <&c>remove <&7>quests."
- flag player QuestEditor:SelQuest
}
else {
- narrate "<&7>Exited the quest editor. Have a nice day!"
- flag player QuestEditor:!
}
- determine fulfilled
on player chats:
- if <player.flag[QuestEditor]> == SelQuest {
- if <context.message.substring[0,3].to_lowercase> == "add " {
- define string <context.message.substring[5]>
- flag <player.selected_npc> Quests:->:%string%
- flag <player.selected_npc> StepCount[<player.selected_npc.flag[Quests].as_list.find[%string%]>]:0
- narrate "<&7>Added <&f><&o><context.message.substring[5]> <&7>to quests."
- narrate "<&5>Quests involving this NPC:"
- foreach <player.selected_npc.flag[Quests].as_list> {
- narrate "<&7><&l> - <&f><&o><def[value]>"
}
- narrate "<&7>You can <&a>add<&7>, <&b>edit<&7>, <&d>rename <&7>or <&c>remove <&7>quests."
- determine cancelled
}
else if <context.message.substring[0,6].to_lowercase> == "remove " {
- define string <context.message.substring[8]>
- define quest <player.selected_npc.flag[Quests].as_list.find[%string%]>
- flag <player.selected_npc> Quests:<-:%string%
- repeat <player.selected_npc.flag[Stepcount].as_list.get[]> {
- flag <player.selected_npc> StepDataQ%quest%S<def[value]>:!
- flag <player.selected_npc> TriggerQ%quest%S<def[value]>:!
}
- flag <player.selected_npc> StepCount[<player.selected_npc.flag[Quests].as_list.find[<context.message.substring[8]>]>]:0
- narrate "<&f><&o><context.message.substring[8]> <&7> was removed for this NPC, if it existed in the first place."
- narrate "<&5>Quests involving this NPC:"
- foreach <player.selected_npc.flag[Quests].as_list> {
- narrate "<&7><&l> - <&f><&o><def[value]>"
}
- narrate "<&7>You can <&a>add<&7>, <&b>edit<&7>, <&d>rename <&7>or <&c>remove <&7>quests."
- determine cancelled
}
else if <context.message.substring[0,6].to_lowercase> == "rename " {
- if <player.selected_npc.flag[Quests]> contains <context.message.substring[8]> {
- define string <context.message.substring[8]>
- flag player renameid:<player.selected_npc.flag[Quests].as_list.find[%string%]>
- flag player QuestEditor:RenQuest
- narrate "<&7>Enter a new name for <&f><&o>%string%<&7>."
}
- determine cancelled
}
else if <context.message.substring[0,4].to_lowercase> == "edit " {
- if <player.selected_npc.flag[Quests].as_list> contains <context.message.substring[6]> {
- define string <context.message.substring[6]>
- flag player QuestEditID:<player.selected_npc.flag[Quests].as_list.find[%string%]>
- narrate "<&7>Editing quest <&f><&o><context.message.substring[6]><&7>. (ID: <player.flag[QuestEditID]>)"
- narrate "<&7>Steps: <&6><player.selected_npc.flag[StepCount].as_list.get[<player.flag[QuestEditID]>]].as_int>"
- narrate "<&7>You can <&a>add<&7>, <&b>edit<&7> and <&c>remove<&7> steps, or go <&3>back<&7>."
- flag player QuestEditor:SelStep
}
- determine cancelled
}
}
else if <player.flag[QuestEditor]> == RenQuest {
- flag <player.selected_npc> Quests[<def[renameid]>]:<context.message>
- narrate "<&7>Quest was renamed to <&f><&o><context.message><&7>."
- flag player QuestEditor:SelQuest
- foreach <player.selected_npc.flag[Quests].as_list> {
- narrate "<&7><&l> - <&f><&o><def[value]>"
}
- narrate "<&7>You can <&a>add<&7>, <&b>edit<&7>, <&d>rename <&7>or <&c>remove <&7>quests."
- determine cancelled
}
else if <player.flag[QuestEditor]> == SelStep {
- if <context.message.substring[0,3].to_lowercase> == "add " {
- flag <player.selected_npc> StepCount[<player.flag[QuestEditID]>]:+:1
- define questid <player.flag[QuestEditID]>
- define step <player.flag[CurrentStep]>
- flag player CurrentStep:<player.selected_npc.flag[StepCount].as_list.get[%questid%].as_int>
- narrate "<&7>Added a new step at index <&f>%step%<&7>."
- narrate "<&7>Anything you type into chat will now be added to this step. Type <&3>back<&7> to return to the step selection menu, <&e>view<&7> to see any existing script, or <&b>edit<&7>, or <&c>remove<&7>. Don't forget to add a <&5>trigger<&7>."
- flag player QuestEditor:StepEdit
- determine cancelled
}
else if <context.message.substring[0,4].to_lowercase> == "edit " {
- narrate "<&7>Editing step <&f><context.message.substring[6].as_int>"
- flag player QuestEditor:StepEdit
- flag player CurrentStep:<context.message.substring[6].as_int>
- define quest <player.flag[QuestEditID]>
- define step <player.flag[CurrentStep]>
- narrate "<&7>Anything you type into chat will now be added to this step. Type <&3>back<&7> to return to the step selection menu, <&e>view<&7> to see any existing script (<&c><player.selected_npc.flag[StepDataQ%quest%S%step%].as_list.size><&7> lines), or <&b>edit<&7>, or <&c>remove<&7>. Don't forget to add a <&5>trigger<&7>."
- determine cancelled
}
else if <context.message.substring[0,6].to_lowercase> == "remove " {
- flag <player.selected_npc> StepDataQ<player.flag[QuestEditID]>S<context.message.substring[8].as_int>:!
- narrate "<&7>Step <&f><context.message.substring[8].as_int><&7> has been removed, however due to the way SatyrQuest currently works, it will leave behind a blank ID. You can type <&b>edit <&f><context.message.substring[8].as_int><&7> to put a new step in its place."
- determine cancelled
}
else if <context.message.substring[0,4].to_lowercase> == "back " {
- flag player QuestEditor:SelQuest
- foreach <player.selected_npc.flag[Quests].as_list> {
- narrate "<&7><&l> - <&f><&o><def[value]>"
}
- narrate "<&7>You can <&a>add<&7>, <&b>edit<&7>, <&d>rename <&7>or <&c>remove <&7>quests."
- determine cancelled
}
}
else if <player.flag[QuestEditor]> == StepEdit {
- if <context.message.substring[0,4].to_lowercase> == "back " {
- define quest <player.flag[QuestEditID]>
- narrate "<&7>Steps: <&6><player.selected_npc.flag[StepCount].as_list.get[%quest%]].as_int>"
- narrate "<&7>You can <&a>add<&7>, <&b>edit<&7> and <&c>remove<&7> steps, or go <&3>back<&7>."
- flag player QuestEditor:SelStep
- determine cancelled
}
else if <context.message.substring[0,4].to_lowercase> == "edit "{
- define quest <player.flag[QuestEditID]>
- define step <player.flag[CurrentStep]>
- define string <context.message.substring[6].as_int>
- narrate "<&c>%string% <&7><player.selected_npc.flag[StepDataQ%quest%S%step%].as_list.get[%string%]>"
- narrate "<&7>Enter a new line to replace this."
- flag player EditLine:%string%
- flag player QuestEditor:EditScript
- determine cancelled
}
else if <context.message.substring[0,4].to_lowercase> == "view "{
- define viewstart <context.message.substring[6].as_int.max[0]>
- define quest <player.flag[QuestEditID]>
- define step <player.flag[CurrentStep]>
- foreach <player.selected_npc.flag[StepDataQ%quest%S%step%].as_list> {
- narrate "<&c><def[loop_index]> <&7><def[value]>"
}
- determine cancelled
}
else if <context.message.substring[0,6].to_lowercase> == "remove "{
- define quest <player.flag[QuestEditID]>
- define step <player.flag[CurrentStep]>
- define string <context.message.substring[8].as_int>
- flag <player.selected_npc> StepDataQ%quest%S%step%:<-:<player.selected_npc.flag[StepDataQ%quest%S%step%].as_list.get[%string%]>
- narrate "<&7>The script at line <&c>%string%<&7> was deleted."
- determine cancelled
}
else if <context.message.substring[0,7].to_lowercase> == "trigger "{
- define quest <player.flag[QuestEditID]>
- define step <player.flag[CurrentStep]>
- if <context.message.substring[9].to_lowercase> == "talk" {
- narrate "<&7>Please click on an NPC to use as the trigger for this step."
- flag player QuestEditor:SetNPC
}
else if <context.message.substring[9].to_lowercase> == "use" {
- narrate "<&7>Please click on a usable block to use as the trigger for this step. (This includes, doors, trapdoors, chests, buttons, levers, pressure plates and tripwire hooks.)"
- flag player QuestEditor:SetBlock
}
else if <context.message.substring[9].to_lowercase> == "near" {
- narrate "<&7>Please click on an NPC to use as the trigger for this step."
- flag player QuestEditor:SetNPC
}
else {
- narrate "<&7>Please enter a valid trigger type after the word trigger. (talk|use|near)"
}
- determine cancelled
}
else {
- define quest <player.flag[QuestEditID]>
- define step <player.flag[CurrentStep]>
- flag <player.selected_npc> StepDataQ%quest%S%step%:->:<context.message>
- narrate "<&c><player.selected_npc.flag[StepDataQ%quest%S%step%].as_list.size> <&7><context.message>"
- determine cancelled
}
}
else if <player.flag[QuestEditor]> == EditScript {
- define quest <player.flag[QuestEditID]>
- define step <player.flag[CurrentStep]>
- flag <player.selected_npc> StepDataQ%quest%S%step%[<player.flag[EditLine]>]:<context.message>
- narrate "<&7>Line <&c><player.flag[EditLine]> <&7>changed to: <context.message>"
- flag player QuestEditor:StepEdit
- determine cancelled
}
on player right clicks block:
- if <player.flag[QuestEditor]> == SetBlock {
- if li@door|chest|button|lever|trapdoor|pressureplate|tripwirehook contains <context.location.material> {
- flag <player.selected_npc> TriggerLoc[<player.flag[CurrentStep]>]:<context.location>
- narrate "<&7>Trigger was successfully set to <&e><context.location.material><&7> at <&a><context.location><&7>."
}
else {
- narrate "<&7>That (<&e><context.location.material><&7>) is not a valid trigger block. Try again."
}
}
on player right clicks entity:
- if <player.flag[QuestEditor]> == SetNPC {
- if <context.entity.is_npc> == true {
- define quest <player.flag[QuestEditID]>
- define step <player.flag[CurrentStep]>
- execute as_server "npc select <context.entity.id>"
- execute as_server "npc assignment --set satyrquest_npc"
- flag <player.selected_npc.flag[TriggerQ%quest%S%step%]> Triggers:<-:"<player.selected_npc.id>,<player.flag[QuestEditID]>,<player.flag[CurrentStep]>"
- flag <player.selected_npc> TriggerQ%quest%S%step%:<context.entity.id>
- flag <context.entity> "QTrigs:<-:<player.selected_npc.id>,<player.flag[QuestEditID]>,<player.flag[CurrentStep]>"
- flag <context.entity> "QTrigs:->:<player.selected_npc.id>,<player.flag[QuestEditID]>,<player.flag[CurrentStep]>"
- narrate "<&7>Trigger was successfully set to <&e><context.entity.name><&7> (<context.entity.id>)."
- flag player QuestEditor:StepEdit
}
}
satyrquest_npc:
type: assignment
interact scripts:
- 1 sqnpc
sqnpc:
type: interact
steps:
1:
click trigger:
script:
- if !<player.has_flag[QuestEditor]> {
- foreach <npc.flag[QTrigs].as_list> {
- define parentnpc n@<def[value].split[,].get[1]>
- define quest <def[value].split[,].get[2]>
- define step <def[value].split[,].get[3]>
- if !<npc.has_flag[IndexN<npc.id>Q%quest%S%step%]> {
- flag player IndexN<%parentnpc%.id>Q%quest%S%step%:1
}
- define index <npc.flag[IndexN<npc.id>Q%quest%S%step%]>
- define script <def[parentnpc].flag[StepDataQ%quest%S%step%].as_list.get[%index%]>
- if <def[script].substring[0,2]> = "if " {
- define variable <def[script].split[ ].limit[4].get[2]>
- define operation <def[script].split[ ].limit[4].get[3]>
- define value <def[script].split[ ].limit[4].get[4]>
- if %operation% == true {
- define operation null
}
- if %operation% == null {
- define operation EQUALS
- define value true
}
- if <player.flag[%variable%]> !%operation% %value% {
- define length <def[parentnpc].flag[StepDataQ%quest%S%step%].size>
- flag player IndexN<%parentnpc%.id>Q%quest%S%step%:<def[parentnpc].flag[StepDataQ%quest%S%step%].as_list.get[%index%].to[%length%].find["end if"def[parentnpc].flag[StepDataQ%quest%S%step%].as_list.get[%index%].to[%length%].find["end if"]>
}
}
- else if <def[script].substring[0,3]> = "set " {
- define variable <def[script].split[ ].limit[3].get[2]>
- define value <def[script].split[ ].limit[3].get[3]>
- flag player %variable%:%value%
}
- else if <def[script].substring[0,4]> = "give " {
- define item i@<def[script].split[ ].limit[3].get[2]>
- define amount <def[script].split[ ].limit[3].get[3].as_int.max[1]>
- give %item% qty:%amount%
}
- else if <def[script].substring[0,3]> = "pay " {
- define amount <def[script].split[ ].limit[2].get[2].as_int.max[0]>
- give money qty:%amount%
}
- else if <def[script].substring[0,3]> = "exp " {
- define amount <def[script].split[ ].limit[2].get[2].as_int.max[0]>
- give xp qty:%amount%
}
- else if <def[script].substring[0,8]> = "goodness " {
- define amount <def[script].split[ ].limit[2].get[2].as_int>
- flag player Goodness:+:%amount%
- if %amount% > 0 {
- narrate "<&a>Your Goodness has increased by %amount%. (Now <player.flag[Goodness]>)"
}
- if %amount% < 0 {
- narrate "<&c>Your Goodness has decreased by %amount%. (Now <player.flag[Goodness]>)"
}
}
- else if <def[script].substring[0,10]> = "lawfulness " {
- define amount <def[script].split[ ].limit[2].get[2].as_int>
- flag player Lawfulness:+:%amount%
- if %amount% > 0 {
- narrate "<&a>Your Lawfulness has increased by %amount%. (Now <player.flag[Lawfulness]>)"
}
- if %amount% < 0 {
- narrate "<&c>Your Lawfulness has decreased by %amount%. (Now <player.flag[Lawfulness]>)"
}
}
- else {
- narrate "<&6><npc.name>: <&f>%script%"
}
}
}