forked from Davinais/Skript_MCTower
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfishingContest.sk
312 lines (298 loc) · 13 KB
/
fishingContest.sk
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
Options:
score: fishScore
applyCount: 30
rod: &b奈音大賽用釣竿
jammed: &f[&b釣魚妨礙&r]
InitialScore: 0
fishScore: 1
salmonScore: 2
pufferfishScore: 4
clownfishScore: 12
lilypadScore: 3
saddleScore: 3
nameTagScore: 3
enchantedScore: 5
otherScore: -1
on load:
set {-regRod} to unbreakable fishing rod named "{@rod} - 普通" with lore "&f大賽專用釣竿||&f比賽後收回"
set {-speRod} to fishing rod:62 named "{@rod} &6- 特殊" with lore "&f大賽專用釣竿||&f只能用3次||&f可以非常快速地釣到魚||&f並且得分3倍||&f比賽後收回"
enchant {-regRod} with Luck of the Sea 2
enchant {-regRod} with Lure 2
enchant {-speRod} with Luck of the Sea 3
enchant {-speRod} with Lure 5
clear {-speItem::*}
add glow fire charge named "{@jammed} &6閃瞎我狗眼" with lore "&f大賽專用妨礙道具||&f給予其他參賽者30秒失明+夜視效果||&f大賽後收回" to {-speItem::*}
add glow feather named "{@jammed} &b飛行荷蘭人" with lore "&f大賽專用妨礙道具||&f使其他參賽者往上飛32格||&f但不受墜落傷害||&f大賽後收回" to {-speItem::*}
add glow paper named "{@jammed} &a均分卡" with lore "&f大賽專用妨礙道具||&f與除去你之外的第一名均分分數||&f大賽後收回" to {-speItem::*}
add glow zombie head named "{@jammed} &2殭殭殭殭" with lore "&f大賽專用妨礙道具||&f在其他玩家旁邊生成一隻殭屍||&f大賽後收回" to {-speItem::*}
add {-speRod} to {-speItem::*}
function changeFishScore(ch: number, p: player):
add {_ch} to {{@score}.%{_p}%}
if {_ch} > 0:
cmd("/scoreboard players add %{_p}%_ {@score} %{_ch}%")
else:
set {_ch} to {_ch}*-1
cmd("/scoreboard players remove %{_p}%_ {@score} %{_ch}%")
function setFishScore(n: number, p: player):
set {{@score}.%{_p}%} to {_n}
cmd("/scoreboard players set %{_p}%_ {@score} %{_n}%")
function startFishingContest(time: number):
set {_timebar} to new bossbar
set {_timebar}'s visibility to true
set {_timebar}'s color to BLUE
set {_timebar}'s style to SEGMENTED_10
loop {fisher::*}:
add loop-value to bar {_timebar}
set {-fishingContest.stage} to 1
show bar {_timebar}
set {-fishingContest.time} to {_time}
while {-fishingContest.time} > 0:
set {_timebar}'s progress to {-fishingContest.time}/{_time}
set {_timebar}'s bar title to "&b剩餘時間: %getTimeText({-fishingContest.time})%&r"
reduce {-fishingContest.time} by 1
wait 1 second
set {-fishingContest.stage} to 3
hide bar {_timebar}
set {_timebar}'s visibility to false
remove all players in bar {_timebar}
delete {_timebar}
endFishingContest()
function endFishingContest():
clear {-fishingContest.time}
clear {-fishingContest.stage}
loop players:
loop all items in loop-player's inventory:
if name of loop-item contain "{@rod}":
remove loop-item from loop-player
if name of loop-item contain "{@jammed}":
remove loop-item from loop-player
add {fisher::1} to {_win::*}
loop {fisher::*}:
if {{@score}.%loop-value%} > {{@score}.%{_win::1}%}:
clear {_win::*}
set {_win::1} to loop-value
else if {{@score}.%loop-value%} is {{@score}.%{_win::1}%}:
if loop-value is not {_win::1}:
add loop-value to {_win::*}
if size of {_win::*} is 1:
broadcast "[&b釣魚大賽&r] 恭喜勝利者為: %{_win::1}%"
else:
loop {_win::*}:
if {_wt} is not set:
set {_wt} to "%loop-value%"
else:
set {_wt} to "%{_wt}%, %loop-value%"
broadcast "[&b釣魚大賽&r] 恭喜以下平手勝利者: %{_wt}%"
wait 6 second
clear {fisher::*}
cmd("/scoreboard objectives remove {@score}")
command fishingContest [<text>] [<number>]:
aliases: fc
trigger:
if arg 1 is "start":
player has permission "fishingContest.admin"
if arg 2 is not set:
set {_time} to 900
else:
set {_time} to arg 2 *60
if {-fishingContest.stage} is not set:
set {_sdn} to "&b&l釣魚大賽"
cmd("/scoreboard objectives add {@score} dummy %{_sdn}%")
cmd("/scoreboard objectives setdisplay sidebar {@score}")
else:
send "請勿重複開始比賽"
stop
clear {fisher::*}
set {_timebar} to new bossbar
set {_timebar}'s visibility to true
set {_timebar}'s color to RED
set {_timebar}'s style to SOLID
set {_count} to {@applyCount}
loop all players:
add loop-value to bar {_timebar}
set {-fishingContest.stage} to 0
show bar {_timebar}
broadcast "[&b釣魚大賽&r] 即將展開, 請有興趣的朋友在報名時間內"
broadcast "[&b釣魚大賽&r] 輸入 &b/fc apply&r 進行報名!"
broadcast "[&b釣魚大賽&r] 大賽中必須使用專用釣竿才計分"
broadcast "[&b釣魚大賽&r] 計分標準請輸入 &a/fc info&r 查詢"
while {_count} > 0:
set {_timebar}'s progress to {_count}/{@applyCount}
set {_timebar}'s bar title to "&c報名時間: %getTimeText({_count})%&r"
reduce {_count} by 1
wait 1 second
hide bar {_timebar}
set {_timebar}'s visibility to false
remove all players in bar {_timebar}
delete {_timebar}
if {-fishingContest.stage} is 0:
startFishingContest({_time})
else if arg 1 is "apply":
if {-fishingContest.stage} is 0:
if "%{fisher::*}%" contain "%player%":
send "[&b釣魚大賽&r] 請勿重複報名!"
else:
set {{@score}.%player%} to {@InitialScore}
add player to {fisher::*}
cmd("/scoreboard players set %player%_ {@score} %{{@score}.%player%}%")
send "[&b釣魚大賽&r] 報名成功!"
give {-regRod} to player
give {-speRod} to player
else:
send "[&b釣魚大賽&r] 現在不是報名時間喔!"
else if arg 1 is "info":
send "&b==========釣魚大賽=========="
send "&b計分標準:"
send "&a- 普通魚------[{@fishScore}分]"
send "&b- 鮭魚--------[{@salmonScore}分]"
send "&b- 河豚--------[{@pufferfishScore}分]"
send "&6- 小丑魚-----[{@clownfishScore}分]"
send "&e- 荷葉--------[{@lilypadScore}分]"
send "&e- 鞍----------[{@saddleScore}分]"
send "&e- 命名牌------[{@nameTagScore}分]"
send "&5- 附魔道具----[{@enchantedScore}分]"
send "&9- 其他垃圾---[{@otherScore}分]"
else if arg 1 is "stop":
player has permission "fishingContest.admin"
if {-fishingContest.stage} is set:
if {-fishingContest.stage} is 0:
broadcast "[&b釣魚大賽&r] 由於管理員以指令停止, 比賽停辦"
endFishingContest()
else if {-fishingContest.stage} is 1:
set {-fishingContest.time} to 3
broadcast "[&b釣魚大賽&r] 由於管理員以指令停止, 比賽將於三秒內結束"
else:
send "無進行中的比賽喔!"
else if arg 1 is "reset":
player has permission "fishingContest.admin"
set {-fishingContest.time} to 0
#clear {-fishingContest.stage}
endFishingContest()
else if arg 1 is "test":
player has permission "fishingContest.admin"
give player {-speItem::*}
give {-regRod} to player
give {-speRod} to player
#===處理釣竿問題,避免私藏===
#目前尚缺死亡時釣竿被鐵砧吸走的情形
on inventory click:
name of item contains "{@rod}" or "{@jammed}"
if inventory type of player's current inventory is not "CRAFTING":
cancel the event
on drop:
name of item contains "{@rod}" or "{@jammed}"
cancel the event
#===妨礙道具===
on rightclick with fire charge:
name of item is "{@jammed} &6閃瞎我狗眼"
cancel the event
remove 1 of item from player
message "[%player%] 閃瞎你們狗眼啦!" to {fisher::*}
loop {fisher::*}:
if loop-value is not player:
apply blindness to loop-value for 20 second
apply night vision to loop-value for 20 second
on right click with feather:
name of item is "{@jammed} &b飛行荷蘭人"
cancel the event
remove 1 of item from player
message "[%player%] See you fly, I am proud to see you fly up high" to {fisher::*}
loop {fisher::*}:
if loop-value is not player:
push loop-value upward at speed 36
set {-featherfly.%loop-value%} to true
on right click with paper:
name of item is "{@jammed} &a均分卡"
cancel the event
remove 1 of item from player
if size of {fisher::*} is 1:
stop
set {_targets::*} to {fisher::*}
remove player from {_targets::*}
loop {_targets::*}:
if {_win} is not set:
set {_win} to loop-value
else if {{@score}.%loop-value%} > {{@score}.%{_win}%}:
set {_win} to loop-value
set {_average} to floor(({{@score}.%{_win}%}+{{@score}.%player%})/2)
setFishScore({_average}, player)
setFishScore({_average}, {_win})
message "[%player%] 均值是統計中的一個重要概念" to {fisher::*}
on right click with zombie head:
name of item is "{@jammed} &2殭殭殭殭"
cancel the event
remove 1 of item from player
loop {fisher::*}:
if loop-value is not player:
spawn 1 zombie at loop-value
message "[%player%] 你知道什麼是殭殭殭殭嗎?" to {fisher::*}
on damage of a player:
damage was caused by fall
if {-featherfly.%victim%} is true:
clear {-featherfly.%victim%}
cancel the event
#===分數處理===
on fishing:
"%fishing state%" is "CAUGHT_FISH"
"%{fisher::*}%" contain "%player%"
name of player's tool contain "{@rod}"
if {-fishingContest.stage} is 1:
chance of 5%:
set {_jam} to random item of {-speItem::*}
set item within entity caught item to {_jam}
changeFishScore(3, player)
message "[&b釣魚大賽&r] 你獲得了 %name of {_jam}% &r[&e+3&r]" to player
stop
set {_temp::*} to item within entity caught item
set {_caught} to {_temp::1}
#message "%player% - %{_caught}%" to console
if {_caught} is raw fish:
set {_sc} to {@fishScore}
set {_fi} to "&a普通魚&r, [&a"
else if {_caught} is raw salmon:
set {_sc} to {@salmonScore}
set {_fi} to "&b鮭魚&r, [&b"
else if {_caught} is raw pufferfish:
set {_sc} to {@pufferfishScore}
set {_fi} to "&b河豚&r, [&b"
else if {_caught} is raw clownfish:
set {_sc} to {@clownfishScore}
set {_fi} to "&6小丑魚&r, [&6"
else if {_caught} is lily pad:
set {_sc} to {@lilypadScore}
set {_fi} to "&e荷葉&r, [&e"
else if {_caught} is saddle:
set {_sc} to {@saddleScore}
set {_fi} to "&e鞍&r, [&e"
else if {_caught} is name tag:
set {_sc} to {@nameTagScore}
set {_fi} to "&e命名牌&r, [&e"
else if {_caught} is enchanted book:
set {_sc} to {@enchantedScore}
set {_fi} to "&5附魔書&r, [&5"
else if {_caught} is bow:
set {_sc} to {@enchantedScore}
set {_fi} to "&5附魔弓&r, [&5"
else if {_caught} is fishing rod:
if {_caught} is enchanted:
set {_sc} to {@enchantedScore}
set {_fi} to "&5附魔釣竿&r, [&5"
else:
set {_sc} to {@otherScore}
set {_fi} to "&9垃圾釣竿&r, [&9"
else:
set {_sc} to {@otherScore}
set {_fi} to "&9垃圾&r, [&9"
if {_sc} > 0:
set {_fi} to "%{_fi}%+%{_sc}%&r]"
else:
set {_fi} to "%{_fi}%%{_sc}%&r]"
if {-fishingContest.time} is 1:
set {_fi} to "%{_fi}% &b- 壓線獎勵 +25分"
changeFishScore({_sc}+25, player)
else if name of player's tool contain "特殊":
set {_fi} to "%{_fi}% &6- 因特殊釣竿, 得分3倍"
changeFishScore({_sc}*3, player)
else:
changeFishScore({_sc}, player)
message "%player% 釣到 %{_fi}%" to {fisher::*}