Date: 2014/07/01 21:26:33 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
# Dueling
# Citizens 2 (build #1130)
# Denizen 0.9.4 (build #1474)
#
# This is a Denizen script that allows players to use commands to duel in a designated
# Arena. You will need your own protection plugin such as WorldGuard.
#
# The Script uses simple commands which are /duel for help, /duel [player] to duel someone
# To accept or deny a duel, you type /deny or /accept. Typing partial player names is supported.
#
# Plans: Add queue system / Add default constants for spawn locations
# Allow players to place wagers / Add Spectating / Add protection
#
# @author TheRealKeith
# @script version 1.0.0
# @last-updated July 1 2014
# @irc EsperNet IRC Network #denizen-dev
# @Minecraft Server - play.insomniacraft.com
# This is the initial duel command. It checks if you specified a player, if you dueled yourself, or if the player is online.
'DuelCommand':
type: world
debug: true
events:
on duel command:
- if <context.args.size> != 1 {
- narrate "<&6>[Duel] <&c>You did not specify a player. Type /Duel [Player]"
- determine fulfilled
}
- if <global.flag[DuelInProgress]> {
- narrate "<&6>[Duel] <&c>There is currently another Duel in progress. Please wait and try again shortly."
- determine fulfilled
}
- define requested <server.match_player[<context.args.get[1]>]>
- define requester <player.name>
- if %requested% == null {
- narrate "<&6>[Duel] <&c>This player is not online or doesn't exist."
- determine fulfilled
}
- if %requested% == <player> {
- narrate "<&6>[Duel] <&c>You cannot duel your self!"
- determine fulfilled
} else {
- flag global DuelRequested:%requested%
- flag global DuelRequester:%requester%
- narrate "<&6>[Duel] <&a>You have sent a request to <global.flag[DuelRequested].as_player.name>" targets:%requester%
- narrate "<&6>[Duel] <&a><global.flag[DuelRequester].as_player.name> has requested a duel" targets:%requested%
- narrate "<&6>[Duel] <&a>You can type <WHITE>/Accept <&a>or <WHITE>/Deny" targets:%requested%
- determine fulfilled
}
# This checks to see if the player is in the "Arena" you made using world edit, and prevents dropping of items.
'DropItems':
type: world
debug: true
events:
on player drops item:
- if <player.location.in_region[pits]> {
- determine cancelled
}
# This is when the player uses the /accept command. It flags both players, the requested and the requester. If those flags are null
# or otherwise if no one has challenged you, it will state such. Otherwise, if the player accepts the duel request, it sends narrations
# to both players, and runs the next task. The null check is if no duels are going on at all. The other check is to make sure they are valid.
'DuelAccept':
type: world
debug: true
events:
on accept command:
- define requested <global.flag[DuelRequested]>
- define requester <global.flag[DuelRequester]>
- if %requested% == null || %requester% == null {
- narrate "<&6>[Duel] <&c>You have no pending duel requests."
- determine fulfilled
} else
- if <global.flag[DuelRequested]> == %requested% && <global.flag[DuelRequester]> == %requester% {
- flag global DuelInProgress
- narrate "<&6>[Duel] <&a><global.flag[DuelRequested].as_player.name> has accepted your duel request." targets:%requester%
- narrate "<&6>[Duel] <&a>You have accepted <global.flag[DuelRequester].as_player.name>'s duel request." targets:%requested%
- run DuelAccepted as:%requester% instantly
- run DuelAccepted as:%requested% instantly
- run TeleportRequester as:%requester% instantly
- run TeleportRequested as:%requested% instantly
- determine fulfilled
} else {
- narrate "<&6>[Duel] <&c>You have no pending duel requests."
- determine fulfilled
}
"TeleportRequester":
type: task
debug: true
script:
- teleport l@-2874,65,3241,world
"TeleportRequested":
type: task
debug: true
script:
- teleport %requested% l@-2917,65,3241,world
# This is when the requested player uses the /deny command. It works the same as the accept command, but drops
# the requested and requester flags to clear room for the next players, or otherwise removing them from queue.
'DuelDeny':
type: world
debug: true
events:
on deny command:
- define requested <global.flag[DuelRequested]>
- define requester <global.flag[DuelRequester]>
- if %requested% == null || %requester% == null {
- narrate "<&6>[Duel] <&c>You have no pending duel requests."
- determine fulfilled
} else
- if <global.flag[DuelRequested]> == %requested% && <global.flag[DuelRequester]> == %requester% {
- narrate "<&6>[Duel] <&c><global.flag[DuelRequested].as_player.name> has denied your duel request." targets:%requester%
- narrate "<&6>[Duel] <&c>You have denied %requester%'s duel request." targets:%player%
- flag global DuelRequested:!
- flag global DuelRequester:!
- flag global DuelInProgress:!
- determine fulfilled
} else {
- narrate "<&6>[Duel] <&c>You have no pending duel requests."
- determine fulfilled
}
# This is the task the runs if a player accepts the duel. It runs for both players just as they are teleporting.
# As a safeguard, if they are not in the arena, the script stops. It clears any potion effects the players may have had.
# Then runs a script which freezes them for 4 seconds while it counts down to begin. This also stores the players inventory.
"DuelAccepted":
type: task
debug: true
script:
- heal 20.0
- define requested <global.flag[DuelRequested]>
- define requester <global.flag[DuelRequester]>
- execute as_server 'effect <player.name> clear'
- adjust <player> walk_speed:0
- flag <player> BeforeDuelLoc:<player.location.simple>
- flag <player> ItemsBeforeDuel:<player.inventory.list_contents>
- flag <player> ItemsBeforeDuelHead:<player.equipment.helmet>
- flag <player> ItemsBeforeDuelChest:<player.equipment.chestplate>
- flag <player> ItemsBeforeDuelLegs:<player.equipment.leggings>
- flag <player> ItemsBeforeDuelBoots:<player.equipment.boots>
- inventory clear destination:<player.inventory>
- equip <player> head:<i@Duel1>
- equip <player> chest:<i@Duel2>
- equip <player> legs:<i@Duel3>
- equip <player> boots:<i@Duel4>
- equip <player> hand:<i@Duel5>
- inventory update destination:<player.inventory>
- run DuelCountDown
# This is the count down. This is in its own container because it cannot be run instantly like the DuelAccepted task.
"DuelCountDown":
type: task
debug: true
script:
- narrate "<&6>[Duel] <&a>The duel will begin in 4..."
- wait 1
- narrate "<&6>[Duel] <&a>The duel will begin in 3..."
- wait 1
- narrate "<&6>[Duel] <&a>The duel will begin in 2..."
- wait 1
- narrate "<&6>[Duel] <&a>The duel will begin in 1..."
- wait 1
- adjust <player> walk_speed:0.2
- narrate "<&a>Begin!"
# This is what happens when the duel is considered "Over", it flags a player as a winner and a loser and announces it to the server.
"DuelDeath":
type: world
debug: true
events:
on player kills player:
- if <player.location.in_region[Pits]> {
- determine passively CANCELLED
- announce "<&6>[Duel] <&b><context.damager.as_player.name> <&a>has won the duel against <&b><context.entity.as_player.name>!"
- run DuelDone as:<context.damager> instantly
- run DuelDone as:<context.entity> instantly
}
# This is what happens when the duel is over. The inventory is cleared out, the players are teleported back to their original locations
# Their inventories are restored, and all of the flags are cleared out to prepare the server for the next duelers.
"DuelDone":
type: task
debug: true
script:
- inventory clear destination:<player.inventory>
- inventory update destination:<player.inventory>
- teleport <player.flag[BeforeDuelLoc]>
- equip <player> boots:<player.flag[ItemsBeforeDuelBoots]||i@air>
- equip <player> leggings:<player.flag[ItemsBeforeDuelLegs]||i@air>
- equip <player> chestplate:<player.flag[ItemsBeforeDuelChest]||i@air>
- equip <player> helmet:<player.flag[ItemsBeforeDuelHead]||i@air>
- foreach <player.flag[ItemsBeforeDuel].exclude[i@air]> {
- give %value%
}
- flag global DuelRequested:!
- flag global DuelRequester:!
- flag global DuelInProgress:!
- flag <player> BeforeDuelLoc:!
# These are the items that get equipped when the duel starts. Customize these to fit your servers needs.
Duel1:
type: item
no_id: true
material: i@leather_helmet
display name: '<&8>Test'
color: c@075,066,045
Duel2:
type: item
no_id: true
material: i@leather_chestplate
display name: '<&8>Test'
color: c@075,066,045
Duel3:
type: item
no_id: true
material: i@leather_leggings
display name: '<&8>Test'
color: c@075,066,045
Duel4:
type: item
no_id: true
material: i@leather_boots
display name: '<&8>Test'
color: c@075,066,045
Duel5:
type: item
no_id: true
material: i@stone_sword
display name: '<&8>Test'