Date: 2020/07/01 10:07:54 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
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
# +--------------------
# |
# | H i d e a n d S e e k
# |
# | A script for the Hide and Seek minigame!
# |
# +----------------------
#
# @author Spirion
# @date 2020/07/01
# @denizen-build REL-1712
#
# Installation:
# Just put the script in your scripts folder and reload.
#
# Usage:
# First of all you will need to configurate the stage for the game.
# When the players join the game, they will appear on the stage inside an area where
# they can't move far away. This area should have blocks surrounding it
# When they start the game, this area will be replaced to another one without blocks.
#
# It is needed a LOBBY POINT where players will appear in the world,
# also a WAIT AREA where players will stay when joining the game, and
# a WAIT POINT inside this area.
#
# Type '/has lobby' and '/has wait' to set the lobby point and the wait point in your position.
# Type '/has pos1' and '/has pos2' to set the corners of the area you are going to create.
# Then, type '/has create normal|blocked' to set the area of the stage with and withouth obstacles
#
# ---------------------------- END HEADER ----------------------------
hideAndSeekCommand:
type: command
name: hideAndSeek
usage: /hideAndSeek [join|leave|start]
description: Play hide and seek.
script:
# We check por players permissions. Change 'permission.node' to a real permission
# If everyone will be able to use this command, just comment the lines.
- if !<player.has_permission[permission.node]>:
- narrate "<&c>You don't have permission to use this command.."
- stop
# We check what have written the player
- define size <context.args.size>
- choose <[size]>:
- case 1:
- define arg1 <context.args.get[1]>
- choose <[arg1]>:
- case join:
# We check that there isn't a game already going on
- if <server.has_flag[hideAndSeek_Running]>:
- narrate "<&c>There's already a game going on. It ends in <server.flag[hideAndSeek_Running].expiration.formatted>."
- stop
# The player joins the game
- teleport <player> <server.flag[hideAndSeek_loc]>
- flag player hideAndSeek
- flag server hideAndSeek:->:<player>
- narrate "<&e>You have joined the game. When you're all ready, write <&a>/hideAndSeek start<&e>. No one else will be able to join."
# We load the schematic to open the game
- if <server.flag[hideAndSeek].size> < 2:
- ~schematic load name:hideAndSeek_schemAir
- case leave:
- if !<server.has_flag[hideAndSeek_Running]>:
- narrate "<&e>You have left the game."
- teleport <player> <server.flag[hideAndSeek_lobbyLoc]>
- schematic unload name:hideAndSeek_schemAir
- sidebar remove
- stop
# The player leaves the game
- narrate "<&e>You have left the game."
- inject hideAndSeek_Leave
- teleport <player> <server.flag[hideAndSeek_lobbyLoc]>
- if <server.has_flag[hideAndSeek_Running]>:
# We check how is going on the game
- if <server.flag[hideAndSeek_Seeker].size> >= <server.flag[hideAndSeek].size>:
- narrate "<&e>There aren't Hiddens in the game. Seekers win!" targets:<server.flag[hideAndSeek]>
- inject hideAndSeek_GlobalEnd
# Check if there are Hiddens
- else if !<server.has_flag[hideAndSeek_Seeker]>:
- narrate "<&e>There aren't Seekers in the game. Hiddens win!" targets:<server.flag[hideAndSeek]>
- inject hideAndSeek_GlobalEnd
- case start:
- if <server.has_flag[hideAndSeek_Running]>:
- narrate "<&c>The game has already started."
- stop
- if <server.flag[hideAndSeek].size> < 2:
- narrate "<&c>You can't start the game with just one player."
- stop
- flag server hideAndSeek_Counter:++
# The game starts
- narrate "<&a><player.name> <&e>starts the game. There are <server.flag[hideAndSeek].size> players." targets:<server.flag[hideAndSeek]>
# It's choosen randomly a Seeker
- define seeker <server.flag[hideAndSeek].random>
# Before he can start looking for Hiddens, we apply on him some parameters with delay
- run hideAndSeek_EffectSeeker def:<[seeker]>
# We establish a 30 seconds timer
- run hideAndSeek_TimerSeeker def:<[seeker]>
# This parameters are for the Hiddens
- foreach <server.flag[hideAndSeek].exclude[<[seeker]>]>:
- team name:hideAndSeek add:<[value].name>
- team name:hideAndSeek option:name_tag_visibility status:never
- adjust <[value]> food_level:20
- narrate "<&e>You are a <&a>Hidden<&e>! You have 30 seconds to hide." targets:<server.flag[hideAndSeek].exclude[<[seeker]>]>
# Timer
- define counter <server.flag[hideAndSeek_Counter]>
- run hideAndSeek_TimerGlobal def:<[counter]>
- flag server hideAndSeek_Running duration:10m
# Scoreboard for the players
- run hideAndSeek_Scoreboard
# We paste the schematic opening the scene
- ~schematic paste name:hideAndSeek_schemAir <server.flag[hideAndSeek_loc]>
- schematic unload name:hideAndSeek_schemAir
- ~schematic load name:hideAndSeek_schemBlock
- default:
- narrate "<&c>Unknown command. Try:"
- narrate "<&c>/hideAndSeek [join|leave|start]"
- stop
- default:
- narrate <empty>
- narrate "<&e>----- Hide and Seek commands -----"
- narrate "<&6>/hideAndSeek join<&r> - Join the game if is not already started."
- narrate "<&6>/hideAndSeek leave<&r> - Quit the game."
- narrate "<&6>/hideAndSeek start<&r> - Start the game with the available players."
- stop
hideAndSeekConfig:
type: command
name: has
usage: /has [pos1|pos2|create|lobby|wait] [normal|blocked]
description: To configurate the scene for the game.
script:
# Only admins should have permission to run this commands
- if !<player.has_permission[permission.node]>:
- narrate "<&c>You don't have permission to use this command."
- stop
# We check what have written the player
- define size <context.args.size>
- choose <[size]>:
- case 1:
- define arg1 <context.args.get[1]>
- choose <[arg1]>:
# Corner 1
- case pos1:
- narrate "<&e>Corner 1 selected in your position."
- flag player hideAndSeek_pos1:<player.location>
# Corner 2
- case pos2:
- narrate "<&e>Corner 2 selected in your position."
- flag player hideAndSeek_pos2:<player.location>
# Set the lobby location
- case lobby:
- narrate "<&e>You've set the spawn point on the lobby on your position."
- flag server hideAndSeek_lobbyLoc:<player.location>
# Set the waiting point on the stage
- case wait:
- narrate "<&e>You've set the waiting point on the stage at your position."
- flag server hideAndSeek_loc:<player.location>
- default:
- narrate "<&c>Unknown command. Try:"
- narrate "<&c>/has [pos1|pos2|create|lobby|wait] [normal|blocked]"
- stop
- case 2:
- define arg1 <context.args.get[1]>
- choose <[arg1]>:
# Creation
- case create:
- define arg2 <context.args.get[2]>
- choose <[arg2]>:
# Schematica without blocks on the way
- case normal:
- if !<player.has_flag[hideAndSeek_pos1]> && !<player.has_flag[hideAndSeek_pos2]> && !<server.has_flag[hideAndSeek_loc]>:
- narrate "<&c>You have to set the corners and a wait point on the stage first."
- stop
- schematic unload name:hideAndSeek_schemAir
- narrate "<&e>You've set the stage <&a>without obstacles<&e> and your corner selections have been removed."
- schematic create name:hideAndSeek_schemAir <cuboid[<player.flag[hideAndSeek_pos1]>|<player.flag[hideAndSeek_pos2]>]> <server.flag[hideAndSeek_loc]>
- ~schematic save name:hideAndSeek_schemAir
- schematic unload name:hideAndSeek_schemAir
- flag player hideAndSeek_pos1:!
- flag player hideAndSeek_pos2:!
# Schematica with blocks on the way
- case blocked:
- if !<player.has_flag[hideAndSeek_pos1]> && !<player.has_flag[hideAndSeek_pos2]> && !<server.has_flag[hideAndSeek_loc]>:
- narrate "<&c>You have to set the corners and a wait point on the stage first."
- stop
- schematic unload name:hideAndSeek_schemBlock
- narrate "<&e>You've set the stage <&a>with obstacles<&e> and your corner selections have been removed."
- schematic create name:hideAndSeek_schemBlock <cuboid[<player.flag[hideAndSeek_pos1]>|<player.flag[hideAndSeek_pos2]>]> <server.flag[hideAndSeek_loc]>
- ~schematic save name:hideAndSeek_schemBlock
- schematic unload name:hideAndSeek_schemBlock
- flag player hideAndSeek_pos1:!
- flag player hideAndSeek_pos2:!
- default:
- narrate "<&c>Unknown command. Try:"
- narrate "<&c>/has [pos1|pos2|create|lobby|wait] [normal|blocked]"
- stop
- default:
- narrate "<&c>Unknown command. Try:"
- narrate "<&c>/has [pos1|pos2|create|lobby|wait] [normal|blocked]"
- stop
- default:
- narrate <empty>
- narrate "<&e>----- Configure the scen for <&a>Hide and Seek <&e>-----"
- narrate "<&6>/has lobby<&r> - Set the spawn point on the lobby."
- narrate "<&6>/has wait<&r> - Set the wait point on the stage."
- narrate "<&6>/has pos1<&r> - Set corner 1."
- narrate "<&6>/has pos2<&r> - Set corner 2."
- narrate "<&6>/has create [normal|blocked]<&r> - Creates the region of the stage with or withouth obstacles on the wait point. It is needed both."
- stop
hideAndSeekDelflag:
type: command
name: hasdelflag
usage: /hasdelflag [player]
description: Removes a player's flag.
script:
# This command it is not needed for playing the game. If an error occurs, you can reset players' params with this.
# You sholdn't don't need this. If any problem, please report on Denizen Forum.
# Only an admin should have acces to this command
- if !<player.has_permission[permission.node]>:
- narrate "<&c>You don't have permission to use this command."
- stop
# Check that the command is written properly
- if <context.args.size> != 1:
- narrate "<red>/hasdelflag [player]"
- stop
# Check that the name written is a player
- define target:<server.match_player[<context.args.get[1]>]||null>
- if <[target]> == null:
- narrate "<red>Unknown user '<yellow><context.args.get[1]><red>'."
- stop
# If everything is right
- flag <[target]> hideAndSeek:!
- flag server hideAndSeek:<-:<[target].name>
- if <[target].has_flag[hideAndSeek_Seeker]>:
- flag <[target]> hideAndSeek_Seeker:!
- flag server hideAndSeek_Seeker:<-:<[target].name>
- team name:hideAndSeek remove:<[target].name>
- adjust <[target]> walk_speed:0.2
- if <[target].has_effect[blindness]>:
- cast blindness remove <[target]>
- if <[target].inventory.contains.scriptname[hideAndSeekItem]>:
- take scriptname:hideAndSeekItem
hideAndSeekEvents:
type: world
events:
# We keep them from getting hungry when they sprint
on player changes food level flagged:hideAndSeek:
- determine cancelled
# This event records when a Hidden is hit by the Seeker's item
on player damaged with:hideAndSeekItem:
- if !<context.entity.has_flag[hideAndSeek_Seeker]>:
- narrate "<&e>You've been caught by a Seeker!" targets:<context.entity>
# It converts to Seeker
- define seeker <context.entity>
- teleport <[seeker]> <server.flag[hideAndSeek_loc]>
- flag <[seeker]> hideAndSeek_Seeker
- flag server hideAndSeek_Seeker:->:<[seeker]>
- team name:hideAndSeek remove:<[seeker].name>
- give hideAndSeekItem to:<[seeker].inventory> slot:1
- wait 1t
- narrate "<&e>A new Seeker appears. <&a><server.flag[hideAndSeek_Seeker].size><&f> seekers <&e>/ <&a><server.flag[hideAndSeek].size.sub[<server.flag[hideAndSeek_Seeker].size>]> <&f>hiddens." targets:<server.flag[hideAndSeek].exclude[<[seeker]>]>
- narrate "<&e>Find the Hiddens and punch them with the fish!" targets:<[seeker]>
# We check how is going on the game
- if <server.flag[hideAndSeek_Seeker].size> >= <server.flag[hideAndSeek].size>:
- narrate "<&e>There aren't Hiddens in the game. Seekers win!" targets:<server.flag[hideAndSeek]>
- inject hideAndSeek_GlobalEnd
# Check if there are any seekers left
- else if !<server.has_flag[hideAndSeek_Seeker]>:
- narrate "<&e>There aren't Seekers in the game. Hiddens win!" targets:<server.flag[hideAndSeek]>
- inject hideAndSeek_GlobalEnd
# Prevent throwing away the Seeker item
on player drops hideAndSeekItem:
- determine cancelled
# Prevent eating the Seeker item
on player consumes hideAndSeekItem:
- determine cancelled
# Prevent from moving the Seeker Item in the inventory
on player clicks in inventory with:hideAndSeekItem flagged:hideAndSeek:
- determine cancelled
# If the player quits the server, we force on the to leave the game.
on player quits flagged:hideAndSeek:
- inject hideAndSeek_Leave
# We check how is going on the game
- if <server.flag[hideAndSeek_Seeker].size> >= <server.flag[hideAndSeek].size>:
- narrate "<&e>There aren't Hiddens in the game. Seekers win!" targets:<server.flag[hideAndSeek]>
- inject hideAndSeek_GlobalEnd
# Check if there are any seekers left
- else if !<server.has_flag[hideAndSeek_Seeker]>:
- narrate "<&e>There aren't Seekers in the game. Hiddens win!" targets:<server.flag[hideAndSeek]>
- inject hideAndSeek_GlobalEnd
hideAndSeekItem:
type: item
material: tropical_fish
display name: <&6>The Salmonazo
lore:
- "<&9>The Hiddens you must seek"
- "<&9>and with the salmonazo you must punch"
- "<&9>Go get'em!"
hideAndSeek_TimerSeeker:
type: task
definitions: seeker
script:
- wait 30s
# Check that the player has not left the server.
- if <[seeker].has_flag[hideAndSeek]>:
# We check how is going on the game
- if <server.flag[hideAndSeek_Seeker].size> >= <server.flag[hideAndSeek].size>:
- narrate "<&e>There aren't Hiddens in the game. Seekers win!" targets:<server.flag[hideAndSeek]>
- inject hideAndSeek_GlobalEnd
# We enable the search
- else:
- adjust <[seeker]> walk_speed:0.2
- cast blindness remove <[seeker]>
- give hideAndSeekItem to:<[seeker].inventory> slot:1
- narrate "<&e>A new Seeker appears. <&a><server.flag[hideAndSeek_Seeker].size><&f> seekers <&e>/ <&a><server.flag[hideAndSeek].size.sub[<server.flag[hideAndSeek_Seeker].size>]> <&f>hiddens." targets:<server.flag[hideAndSeek].exclude[<[seeker]>]>
- narrate "<&e>Find the Hiddens and punch them with the fish!" targets:<[seeker]>
# Comprobamos si quedan buscadores en la partida
- else if !<server.has_flag[hideAndSeek_Seeker]>:
- narrate "<&e>There aren't Seekers in the game. Hiddens win!" targets:<server.flag[hideAndSeek]>
- inject hideAndSeek_GlobalEnd
hideAndSeek_TimerGlobal:
type: task
definitions: counter
script:
- wait 10m
# We check that the game isn't already finished
- if <server.has_flag[hideAndSeek_Running]> && <[counter]> == <server.flag[hideAndSeek_Counter]>:
- narrate "<&e>Time out, Hiddens wins!" targets:<server.flag[hideAndSeek]>
- inject hideAndSeek_GlobalEnd
hideAndSeek_GlobalEnd:
type: task
script:
# We reset all the flags and values from the players
- flag server hideAndSeek_Running:!
- foreach <server.online_players_flagged[hideAndSeek_Seeker]>:
- flag <[value]> hideAndSeek_Seeker:!
- flag server hideAndSeek_Seeker:!
- foreach <server.flag[hideAndSeek]>:
- team name:hideAndSeek remove:<[value].name>
- adjust <[value]> walk_speed:0.2
- if <[value].has_effect[blindness]>:
- cast blindness remove <[value]>
- if <[value].inventory.contains.scriptname[hideAndSeekItem]>:
- take scriptname:hideAndSeekItem player:<[value]>
- sidebar remove players:<[value]>
- flag <[value]> hideAndSeek:!
# We took them out of the game
- teleport <[value]> <server.flag[hideAndSeek_lobbyLoc]>
- flag server hideAndSeek:!
# We return the stage to its original state
- ~schematic paste name:hideAndSeek_schemBlock <server.flag[hideAndSeek_loc]>
- schematic unload name:hideAndSeek_schemBlock
hideAndSeek_EffectSeeker:
type: task
definitions: seeker
script:
- narrate "<&e>You are now a <&a>Seeker<&e>! You must wait 30 seconds before starting." targets:<[seeker]>
- teleport <[seeker]> <server.flag[hideAndSeek_loc]>
- flag <[seeker]> hideAndSeek_Seeker
- flag server hideAndSeek_Seeker:->:<[seeker]>
- team name:hideAndSeek remove:<[seeker].name>
- adjust <[seeker]> walk_speed:0.0
- cast blindness amplifier:1 <[seeker]>
hideAndSeek_Leave:
type: task
script:
- flag player hideAndSeek:!
- flag server hideAndSeek:<-:<player>
- if <player.has_flag[hideAndSeek_Seeker]>:
- flag player hideAndSeek_Seeker:!
- flag server hideAndSeek_Seeker:<-:<player>
- team name:hideAndSeek remove:<player.name>
- adjust <player> walk_speed:0.2
- if <player.has_effect[blindness]>:
- cast blindness remove <player>
- if <player.inventory.contains.scriptname[hideAndSeekItem]>:
- take scriptname:hideAndSeekItem
- sidebar remove
hideAndSeek_Scoreboard:
type: task
script:
- while <server.has_flag[hideAndSeek_Running]>:
- sidebar set title:<&e>Hide and Seek "values:Game ends in:" players:<server.flag[hideAndSeek]>
- sidebar add "values:<&6> <server.flag[hideAndSeek_Running].expiration.formatted>" players:<server.flag[hideAndSeek]>
- sidebar add "values:<&a> <server.flag[hideAndSeek_Seeker].size> <&f>seekers" players:<server.flag[hideAndSeek]>
- sidebar add "values:<&a> <server.flag[hideAndSeek].size.sub[<server.flag[hideAndSeek_Seeker].size>]> <&f>hiddens" players:<server.flag[hideAndSeek]>
- wait 5s