Paste #9992: Untitled Paste

Date: 2014/09/22 22:42:03 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


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
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444


################################################################################
#
#                          M a s t e r C h e f   N P C 
#                           Feed those hungry denizens
#
#
#   Author: |Anthony|
#   Version: 0.1
#   dScript Version: 0.9.5-b1522
#
# 
#
################################################################################
#
MasterChefNPC:
  type: assignment
  debug: false

  actions:
    on assignment:
      - run locally assignment instantly
    on spawn:
      - run locally spawn instantly
    on despawn:
      - run locally despawn instantly
    on click:
      - if <player.has_permission[chef.admin]> {
        - run locally click instantly
        }
        else {
        - chat "<&7>You can tell me to find the <&f>sink<&7>, <&f>prep<&7>, <&f>oven<&7>, <&f>stove<&7>, <&f>grill<&7>, or <&f>fridge<&7> and I will find it."
        - chat "<&7>Or you can tell me <&f>potato<&7> and I will make a baked potato for you."
        }
    on damage:
      - run locally damage instantly
    on chat:
      - wait 10t
      - run locally chat instantly def:<c.message>

  assignment:
    - trigger name:chat state:true radius:5 cooldown:5s
    - trigger name:click state:true radius:5 cooldown:5s
    - trigger name:proximity state:false
    - trigger name:damage state:true radius:5 cooldown:5s
    - vulnerable state:false
    - lookclose true range:5 realistic
    - flag npc respawn_location:<npc.location>
    - flag npc Pathfind.FidgetRadius:5
    - flag npc Pathfind.FidgetSpeed:0.7
    - flag npc Pathfind.FidgetWait:10
    - flag npc Pathfind.FidgetLocation:<npc.location>
    - flag npc Pathfind.FidgetHeight:1
    - flag npc Pathfind.FidgetPathMaterial:<npc.location.standing_on.material.name>
    - inject locally spawn instantly


  spawn:
    - chat "Alright, time to start work..." no_target
#    - run s@Fidget id:fidgetQueue_<npc.id>


  despawn:
    - chat "Phew... I<&sq>m glad to be done work for the day!" no_target


  damage:
    - chat "Why would you do that?" no_target


  click:
    - if <npc.has_flag[following]> {
      - if <npc.flag[following].as_player.is[==].to[<player>]> {
        - follow stop
        - if <queue.exists[Following_<npc.id>]> queue queue:Following_<npc.id> stop
        - chat "Ok. I<&sq>ll wait right here..."
        - flag npc following:!
#        - run s@Fidget id:fidgetQueue_<npc.id>
        - queue stop
        }
        else {
        - chat "I<&sq>m a little busy right now..."
        - queue stop
        }
      }
      else {
      - if <queue.exists[fidgetQueue_<npc.id>]> queue queue:fidgetQueue_<npc.id> stop
      - flag npc following:<player>
      - run locally follow id:Following_<npc.id>
      }

  follow:
    - if !<npc.flag[following].as_player.is_online> {
      - flag npc following:!
      - follow stop
      - run s@Fidget id:fidgetQueue_<npc.id>
      - queue stop
      }
    - follow target:<npc.flag[following].as_player>
    - wait 5s
    - inject locally follow

  chat:
    - ^if <npc.has_flag[following]> {
      - chat "I<&sq>m a little busy right now following <npc.flag[following].as_player.name>..."
      - queue stop
      }
    - ^define foodItems li@potato
    - ^define food '<def[1].split[ ].get[1].escaped||null>'
    - ^narrate "%1%"
    - ^if <def[1].is[==].to[potato]> {
      - chat "Ok, one baked potato coming up!"
      - inject locally bakedPotato
      - queue stop
      }
    - ^define options li@fridge|fancyFridge|grill|sink|prep|oven|stove
    - ^define equipment '<def[1].split[ ].get[1].escaped||null>'
    - ^define range '<def[1].split[ ].get[2].escaped||15>'
    - ^if !<def[range].is[MATCHES].to[number]> {
      - chat "Hey, that<&sq> s not a number!"
      }
    - ^if !<def[options].contains[%equipment%]> {
      - chat "I don<&sq>t know anything about that."
      - queue stop
      }
    - ^if <queue.exists[fidgetQueue_<npc.id>]> queue queue:fidgetQueue_<npc.id> stop
    - ^inject locally find%equipment% instantly
    - ^if <def[locations].as_list.is_empty> {
      - chat "I couldn<&sq>t find the %equipment%."
      - queue stop
      }
    - ^chat "I found <def[locations].size.as_int> %equipment%."
    - ^define destination <def[locations].random>
#    - ^showfake glowstone %destination% d:5s
    - ~walkto '<def[destination].split[/].get[2].as_location>' speed:0.7
    - ^chat "Ok, I made it to the %equipment%."
    - ^wait 5s
#    - ^run s@Fidget id:fidgetQueue_<npc.id>


################################################################################
#
#  Kitchen Equipment Locators
#
  findFridge:
  # The Fridge is 2 ironblocks tall with a stone button on the front of the top block
    - define ironBlocks <npc.location.find.blocks[iron_block].within[%range%]||null>
    - if <def[ironBlocks].is[!=].to[null]>
      && !<def[ironBlocks].is_empty> {
      - define locations li@
      - foreach %ironBlocks% {
        - define iron '%value%'
        - if <def[iron].below.material.is[!=].to[m@iron_block]||true> foreach next

        - define east '<def[iron].add[1,0,0]>'
        - define west '<def[iron].add[-1,0,0]>'
        - define north '<def[iron].add[0,0,1]>'
        - define south '<def[iron].add[0,0,-1]>'
        - define cardinals li@east|west|north|south

        - foreach %cardinals% {
          - define location '<def[%value%]>'

          - if <def[location].material.is[==].to[m@stone_button]>
            && <def[location].sub[0,1,0].material.is[==].to[m@air]>
            && <def[location].sub[0,2,0].material.is_solid> {
            - define locations <def[locations].include[%iron%/<def[location].below>]>
            }
          }
        }
      }


  findFancyFridge:
  # The Fridge is 2 ironblocks tall with an iron door on the front
    - define ironBlocks <npc.location.find.blocks[iron_block].within[%range%]||null>
    - if <def[ironBlocks].is[!=].to[null]>
      && !<def[ironBlocks].is_empty> {
      - define locations li@
      - foreach %ironBlocks% {
        - define iron '%value%'
        - if <def[iron].below.material.is[!=].to[m@iron_block]||true> foreach next

        - define east '<def[iron].add[1,0,0]>'
        - define west '<def[iron].add[-1,0,0]>'
        - define north '<def[iron].add[0,0,1]>'
        - define south '<def[iron].add[0,0,-1]>'
        - define cardinals li@east|west|north|south

        - foreach %cardinals% {
          - define location '<def[%value%]>'

          - if <def[location].material.name.is[==].to[iron_door_block]>
            && <def[location].sub[0,1,0].material.name.is[==].to[m@iron_door_block]>
            && <def[location].sub[0,2,0].material.is_solid> {
            - define locations <def[locations].include[%iron%/<def[location].below>]>
            }
          }
        }
      }


  findGrill:
  # The Grill is a trapdoor over fire
  # This currently sets the location to walk to as the solid block the player
  #  would stand on. This differs from all of the other equipment search
  #  functions since they all return the air block in front of the equipment.
  #  I want to keep this just to see if there is a noticeable difference.
    - define fireBlocks <npc.location.find.blocks[m@fire].within[%range%]||null>
    - if <def[fireBlocks].is[!=].to[null]>
      && !<def[fireBlocks].is_empty> {
      - define locations li@
      - foreach %fireBlocks% {
        - define fire '%value%'
        - if <def[fire].above.material.is[!=].to[m@trap_door]||true> foreach next

        - define east '<def[fire].add[1,0,0]>'
        - define west '<def[fire].add[-1,0,0]>'
        - define north '<def[fire].add[0,0,1]>'
        - define south '<def[fire].add[0,0,-1]>'
        - define cardinals li@east|west|north|south

        - foreach %cardinals% {
          - define location '<def[%value%]>'

          - if <def[location].material.is_solid>
            && <def[location].above.material.is[==].to[m@air]>
            && <def[location].add[0,2,0].material.is[==].to[m@air]> {
            - define locations <def[locations].include[%fire%/%location%]>
            }
          }
        }
      }


  findSink:
  # The sink is a Cauldron full of water with a tripwire hook above
    - define cauldronBlocks <npc.location.find.blocks[cauldron,3].within[%range%]||null>
    - if <def[cauldronBlocks].is[!=].to[null]>
      && !<def[cauldronBlocks].is_empty> {
      - define locations li@
      - foreach %cauldronBlocks% {
        - define cauldron '%value%'
        - if <def[cauldron].above.material.is[!=].to[m@tripwire_hook]||true> foreach next

        - define east '<def[cauldron].add[1,0,0]>'
        - define west '<def[cauldron].add[-1,0,0]>'
        - define north '<def[cauldron].add[0,0,1]>'
        - define south '<def[cauldron].add[0,0,-1]>'
        - define cardinals li@east|west|north|south

        - foreach %cardinals% {
          - define location '<def[%value%]>'

          - if <def[location].material.is[==].to[m@air]>
            && <def[location].above.material.is[==].to[m@air]>
            && <def[location].below.material.is_solid> {
            - define locations <def[locations].include[%cauldron%/%location%]>
            }
          }
        }
      }


  findPrep:
  # The Prep station is the top half stone slab with a wood pressure plate on top
    - define prepBlocks <npc.location.find.blocks[stone_slab_up].within[%range%]||null>
    - if <def[prepBlocks].is[!=].to[null]>
      && !<def[prepBlocks].is_empty> {
      - define locations li@
      - foreach %prepBlocks% {
        - define prep '%value%'
        - if <def[prep].above.material.is[!=].to[m@wood_plate]||true> foreach next

        - define east '<def[prep].add[1,0,0]>'
        - define west '<def[prep].add[-1,0,0]>'
        - define north '<def[prep].add[0,0,1]>'
        - define south '<def[prep].add[0,0,-1]>'
        - define cardinals li@east|west|north|south

        - foreach %cardinals% {
          - define location '<def[%value%]>'

          - if <def[location].material.is[==].to[m@air]>
            && <def[location].above.material.is[==].to[m@air]>
            && <def[location].below.material.is_solid> {
            - define locations <def[locations].include[%prep%/%location%]>
            }
          }
        }
      }


  findOven:
  # The oven is a 2 tall by 2 wide set of furnaces.
  # We will accept furnaces that are on or off
    - define furnaceBlocks <npc.location.find.blocks[furnace|burning_furnace].within[%range%]||null>
    - if <def[furnaceBlocks].is[!=].to[null]>
      && !<def[furnaceBlocks].is_empty> {
      - define locations li@
      - foreach %furnaceBlocks% {
        - define furnace1 '%value%'
        - if <def[furnace1].below.material.is[!=].to[m@furnace]||true>
          && <def[furnace1].below.material.is[!=].to[m@burning_furnace]||true> foreach next

        - define east '<def[furnace1].add[1,0,0]>'
        - define west '<def[furnace1].add[-1,0,0]>'
        - define north '<def[furnace1].add[0,0,1]>'
        - define south '<def[furnace1].add[0,0,-1]>'
        - define cardinals li@east|west|north|south

        - foreach %cardinals% {
          - define furnace2 '<def[%value%]>'

          - if <el@[<def[furnace2].material.is[!=].to[m@furnace]>].or[<def[furnace2].material.is[!=].to[m@burning_furnace]>]>
            && <el@[<def[furnace2].below.material.is[!=].to[m@furnace]>].or[<def[furnace2].below.material.is[!=].to[m@burning_furnace]>]> foreach next

          - define east '<def[furnace2].add[1,0,0]>'
          - define west '<def[furnace2].add[-1,0,0]>'
          - define north '<def[furnace2].add[0,0,1]>'
          - define south '<def[furnace2].add[0,0,-1]>'
          - define cardinals li@east|west|north|south

          - foreach %cardinals% {
            - define location '<def[%value%]>'

            - if <def[location].material.is[==].to[m@air]>
              && <def[location].sub[0,1,0].material.is[==].to[m@air]>
              && <def[location].sub[0,2,0].material.is_solid> {
              - define locations <def[locations].include[%furnace2%/<def[location].sub[0,1,0]>]>
              }
            }
          }
        }
      }


  findStove:
  # The Stove is a furnace with a stone pressure plate on top
    - define stoveBlocks <npc.location.find.blocks[furnace|burning_furnace].within[%range%]||null>
    - if <def[stoveBlocks].is[!=].to[null]>
      && !<def[stoveBlocks].is_empty> {
      - define locations li@
      - foreach %stoveBlocks% {
        - define stove '%value%'
        - if <def[stove].above.material.is[!=].to[m@stone_plate]||true> foreach next

        - define east '<def[stove].add[1,0,0]>'
        - define west '<def[stove].add[-1,0,0]>'
        - define north '<def[stove].add[0,0,1]>'
        - define south '<def[stove].add[0,0,-1]>'
        - define cardinals li@east|west|north|south

        - foreach %cardinals% {
          - define location '<def[%value%]>'

          - if <def[location].material.is[==].to[m@air]>
            && <def[location].above.material.is[==].to[m@air]>
            && <def[location].below.material.is_solid> {
            - define locations <def[locations].include[%stove%/%location%]>
            }
          }
        }
      }


################################################################################
#
#  Recipes
#
  bakedPotato:
  # Walk to fridge and get potato
    - ^lookclose <npc> state:false
    - ^inject locally findFancyFridge instantly
    - ^define destination '<def[locations].random>'
    - ^define door '<def[destination].split[/].get[2].as_location>'
    - ~walkto %door% speed:0.7
    - ^look <npc> '<def[destination].split[/].get[1].as_location>'
#    - ^playsound <npc.location> sound:door_open
    - ^switch %door% state:toggle
    - ^wait 15t
    - ~equip <npc> hand:<i@potato_item>
    - ^switch %door% state:toggle
#    - ^playsound <npc.location> sound:door_close
    - ^wait 5t
  # Walk to sink and wash potato
    - ^inject locally findSink instantly
    - ^define destination '<def[locations].random>'
    - ~walkto '<def[destination].split[/].get[2].as_location>' speed:0.7
    - ^look <npc> '<def[destination].split[/].get[1].as_location>'
    - ~equip <npc> hand:<i@air>
    - ^displayitem <i@potato_item> '<def[destination].split[/].get[1].as_location>' d:50t
    - ^animate <npc> animation:SNEAK
    - ^animate <npc> animation:ARM_SWING
    - ^playsound <npc.location> sound:splash2
    - ^repeat 5 {
      - animate <npc> animation:ARM_SWING
      - playsound <npc.location> sound:swim
      - wait 5t
      }
    - ^playsound <npc.location> sound:splash2
    - ^animate <npc> animation:ARM_SWING
    - ^animate <npc> animation:STOP_SNEAKING
    - ~equip <npc> hand:<i@potato_item>
    - ^wait 10t
  # Walk to prep area and prep potato
    - ^inject locally findPrep instantly
    - ^define destination '<def[locations].random>'
    - ~walkto '<def[destination].split[/].get[2].as_location>' speed:0.7
    - ^look <npc> '<def[destination].split[/].get[1].as_location>'
    - ^animate <npc> animation:SNEAK
    - ^animate <npc> animation:ARM_SWING
    - ~equip <npc> hand:<i@air>
    - ^displayitem <i@potato_item> '<def[destination].split[/].get[1].as_location>' d:50t
    - ^repeat 5 {
      - animate <npc> animation:ARM_SWING
      - playsound <npc.location> sound:step_ladder
      - wait 5t
      }
    - ~equip <npc> hand:<i@potato_item>
    - ^animate <npc> animation:STOP_SNEAKING
  # Walk to oven and cook potato
    - ^wait 5t
    - ^inject locally findOven instantly
    - ^define destination '<def[locations].random>'
    - ~walkto '<def[destination].split[/].get[2].as_location>' speed:0.7
    - ^define furnace '<def[destination].split[/].get[1].as_location>'
    - ^look <npc> %furnace%
    - ~equip <npc> hand:<i@air>
    - ^animate <npc> animation:ARM_SWING
    - ^wait 5t
    - ^playsound <npc.location> sound:ghast_fireball
    - ^showfake m@burning_furnace,<def[furnace].material.data> %furnace% to:<npc.location.find.players.within[10]> d:200t
    - ^repeat 20 {
      - ^define sound '<li@fuse|fire.random>'
      - ^playsound <npc.location> sound:%sound%
      - ^wait 5t
      }
    - ^animate <npc> animation:ARM_SWING
    - ~equip <npc> hand:<i@baked_potato>
    - ^lookclose <npc> state:true
    - ^chat "Here it is, one baked potato!" no_targets
    - ^wait 15t
    - ~equip <npc> hand:<i@air>
    - ^give i@baked_potato