-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGameManager.sk
More file actions
319 lines (276 loc) · 11.8 KB
/
GameManager.sk
File metadata and controls
319 lines (276 loc) · 11.8 KB
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
#
# GameManager.sk
# By BaeFell
# (c) All Rights Reserved
#
#
# Game status:
# - waiting
# - no game has been selected, waiting for a staff member to select one
# - voting
# - voting window is now open, waiting for a staff member to start
# - starting
# - the selected game is starting up, announcements made for 10 second countdown
# - playing
# - game is now being played
options:
P: &c&lGameManager &7»&e
on load:
#set {game::games::lava} to "Lava Rising"
#set {game::games::manhunt} to "Manhunt"
#set {game::games::squid} to "Squid Game"
set {staff::BaeFell} to true
delete {lobby::players::*}
delete {game::*}
set {game::status} to "waiting"
on join:
if {staff::%player%} is set:
set {staff::%uuid of player%} to true
if {game::selected-game} is set:
message "{@P} Welcome &a%player% &eto the &askUnity Game Night Server! &eThe selected game is &a%GameManager_Get_Game()%"
else:
message "{@P} Welcome &a%player% &eto the &askUnity Game Night Server!"
message "{@P} &cREMINDER: the skUnity rules apply on the Game Night Server. You can be timed out or banned from both here and the skUnity Discord."
set join message to ""
if {game::status} is "playing" or "starting":
message "{@P} The current round of &a%GameManager_Get_Game()% &ehas already started. You can spectate it by doing &a/spectate ðen take part next round."
set gamemode of player to adventure
teleport player to {lobby::spawn}
on quit:
delete {lobby::players::%uuid of player%}
set leave message to ""
function GameManager_Is_Game(game: string) :: boolean:
if {_game} is GameManager_Get_Game_Key():
return true
return false
function GameManager_Get_Game() :: string:
return {game::games::%{game::selected-game}%}
function GameManager_Get_Game_Key() :: string:
return {game::selected-game}
function GameManager_Get_Game_Status() :: string:
return {game::status}
function GameManager_Set_Game_Status(status: string):
set {game::status} to {_status}
function GameManager_Teleport_All_To_Spawn():
loop all players:
teleport loop-player to {lobby::spawn}
function GameManager_Teleport_To_Spawn(player: player):
teleport {_player} to {lobby::spawn}
function GameManager_Check_Starting(player: player, command: string, arguments: string, gamekey: string) :: boolean:
if GameManager_Is_Staff({_player}) is true:
if {_command} is "game":
if {_arguments} is "start":
if GameManager_Get_Game_Key() is {_gamekey}:
if GameManager_Get_Game_Status() is "voting":
return true
return false
function GameManager_Game_Ended(winner: player):
loop all players:
set gamemode of loop-player to adventure
extinguish loop-player
heal loop-player
clear inventory of loop-player
GameManager_Teleport_To_Spawn(loop-player)
delete {lobby::players::*}
GameManager_Broadcast("&a%GameManager_Get_Game()% &ehas finished! &a%{_winner}% &ewas the winner!")
GameManager_Set_Game_Status("waiting")
function GameManager_Is_Staff(player: player) :: boolean:
return skUnity_Is_Staff({_player})
function GameManager_Broadcast(message: string, two: string = "", three: string = "", four: string = "", five: string = ""):
broadcast "{@P} "
broadcast "{@P} %{_message}%"
if {_two} is not "":
broadcast "{@P} %{_two}%"
if {_three} is not "":
broadcast "{@P} %{_three}%"
if {_four} is not "":
broadcast "{@P} %{_four}%"
if {_five} is not "":
broadcast "{@P} %{_five}%"
broadcast "{@P} "
function GameManager_Multi_Line_Broadcast(message: strings):
broadcast "{@P} "
loop {_message::*}:
broadcast "{@P} %loop-value%"
broadcast "{@P} "
function GameManager_Add_Win(player: player):
set {_game} to GameManager_Get_Game()
set {_uuid} to uuid of {_player}
if {leaderboard::%{_uuid}%::%{_game}%::wins} is not set:
set {leaderboard::%{_uuid}%::%{_game}%::wins} to 1
else:
add 1 to {leaderboard::%{_uuid}%::%{_game}%::wins}
function GameManager_Add_Loss(player: player):
set {_game} to GameManager_Get_Game()
set {_uuid} to uuid of {_player}
if {leaderboard::%{_uuid}%::%{_game}%::losses} is not set:
set {leaderboard::%{_uuid}%::%{_game}%::losses} to 1
else:
add 1 to {leaderboard::%{_uuid}%::%{_game}%::losses}
function GameManager_Register_Game(gamekey: string, gamename: string, gamefile: string):
set {game::games::%{_gamekey}%} to {_gamename}
set {game::games::%{_gamekey}%::file} to {_gamefile}
function GameManager_Register_Vote(gamekey: string, votetype: string, voteitemkey: string, voteitemname: string):
set {game::games::%{_gamekey}%::votes::%{_votetype}%} to {_votetype}
add {_voteitemname} to {game::games::%{_gamekey}%::votes::%{_votetype}%::votelist::*}
set {_lindex} to size of {game::games::%{_gamekey}%::votes::%{_votetype}%::votelist::*}
set {game::games::%{_gamekey}%::votes::%{_votetype}%::votelistkeys::%{_lindex}%} to {_voteitemkey}
function GameManager_Voting_Start(map: string):
delete {game::votes::*}
if {game::games::%{game::selected-game}%::votes::map} is not set:
if {game::games::%{game::selected-game}%::votes::mode} is not set:
stop
loop {game::games::%{game::selected-game}%::votes::map::votelist::*}:
set {game::votes::map::%loop-index%} to 0
loop {game::games::%{game::selected-game}%::votes::mode::votelist::*}:
set {game::votes::mode::%loop-index%} to 0
GameManager_Voting_Announce()
function GameManager_Voting_Announce():
if {game::games::%{game::selected-game}%::votes::map} is set:
broadcast "{@P} "
broadcast "{@P} Vote for a &amap &efor &a%GameManager_Get_Game()%"
loop {game::games::%{game::selected-game}%::votes::map::votelist::*}:
broadcast "{@P} &a%loop-index%) &e%loop-value% (&a%{game::votes::map::%loop-index%}% votes&e)"
broadcast "{@P} Vote using &a/vote map <number>"
broadcast "{@P}"
if {game::games::%{game::selected-game}%::votes::mode} is set:
broadcast "{@P} "
broadcast "{@P} Vote for a &amode &efor &a%GameManager_Get_Game()%"
loop {game::games::%{game::selected-game}%::votes::mode::votelist::*}:
broadcast "{@P} &a%loop-index%) &e%loop-value% (&a%{game::votes::mode::%loop-index%}% votes&e)"
broadcast "{@P} Vote using &a/vote mode <number>"
broadcast "{@P}"
function GameManager_Get_Winning_Name(type: string) :: string:
set {_sorted::*} to {game::votes::%{_type}%::*}
set {_first} to first element out of {_sorted::*}
set {_firstindex} to 1
loop {_sorted::*}:
if loop-value is greater than {_first}:
set {_first} to loop-value
set {_firstindex} to loop-index
set {_gamekey} to GameManager_Get_Game_Key()
return {game::games::%{_gamekey}%::votes::%{_type}%::votelist::%{_firstindex}%}
function GameManager_Get_Winning_Key(type: string) :: string:
set {_sorted::*} to {game::votes::%{_type}%::*}
set {_first} to first element out of {_sorted::*}
set {_firstindex} to 1
loop {_sorted::*}:
if loop-value is greater than {_first}:
set {_first} to loop-value
set {_firstindex} to loop-index
set {_gamekey} to GameManager_Get_Game_Key()
return {game::games::%{_gamekey}%::votes::%{_type}%::votelistkeys::%{_firstindex}%}
command /game [<text>] [<text>]:
trigger:
if GameManager_Is_Staff(player) is false:
message "{@P} You don't have permission to do that"
stop
if arg 1 is "select":
if {game::games::%arg 2%} is set:
set {game::selected-game} to arg 2
GameManager_Broadcast("&a%player% &ehas selected &a%GameManager_Get_Game()%", "Use &a/ready &eto ready up")
Chat_Disable()
GameManager_Set_Game_Status("voting")
GameManager_Voting_Start(arg 2)
else:
message "{@P} That game doesn't exist"
else if arg 1 is "start":
if GameManager_Get_Game() is not set:
message "{@P} You need to select a game before you can start one"
stop
set {game::status} to "starting"
Chat_Enable()
GameManager_Broadcast("&a%player% &ehas started the countdown for &a%GameManager_Get_Game()%", "&a%GameManager_Get_Game()% &ewill start in &e10 seconds")
set {_c} to 10
loop 9 times:
set {_c} to {_c} - 1
wait 1 second
GameManager_Broadcast("&a%GameManager_Get_Game()% &ewill start in &a%{_c}% seconds")
GameManager_Broadcast("&a%GameManager_Get_Game()% &eis now &astarting!")
else if arg 1 is "stop":
delete {game::selected-game}
message "{@P} Stopped selected game"
command /lobby [<text>] [<text>]:
trigger:
if GameManager_Is_Staff(player) is false:
message "{@P} You don't have permission to do that"
stop
if arg 1 is "setspawn":
set {lobby::spawn} to location of player
message "{@P} Set lobby spawn to &a%{lobby::spawn}%"
command /vote [<text>] [<integer>]:
trigger:
if GameManager_Get_Game_Status() is "voting":
if arg 1 is "map" or "mode":
if arg 2 is set:
if {game::votes::%arg 1%::%arg 2%} is set:
if {game::votes::player::%uuid of player%::%arg 1%} is set:
subtract 1 from {game::votes::%arg 1%::%{game::votes::player::%uuid of player%::%arg 1%}%}
set {game::votes::player::%uuid of player%::%arg 1%} to arg 2
add 1 to {game::votes::%arg 1%::%arg 2%}
GameManager_Voting_Announce()
else:
message "{@P} Invalid option. Valid options between &a1 &eand &a%size of {game::games::%{game::selected-game}%::votes::%arg 1%::votelist::*}%"
else:
message "{@P} Invalid argument. Valid command: &a/vote <map|mode> <number>"
else:
message "{@P} Invalid argument. Valid command: &a/vote <map|mode> <number>"
else:
message "{@P} Voting isn't open at the moment"
command /map [<integer>]:
trigger:
if GameManager_Get_Game_Status() is "voting":
if arg 1 is set:
if {game::votes::map::%arg 1%} is set:
if {game::votes::player::%uuid of player%::map} is set:
subtract 1 from {game::votes::map::%{game::votes::player::%uuid of player%::map}%}
set {game::votes::player::%uuid of player%::map} to arg 1
add 1 to {game::votes::map::%arg 1%}
GameManager_Voting_Announce()
else:
message "{@P} Invalid option. Valid options between &a1 &eand &a%size of {game::games::%{game::selected-game}%::votes::map::votelist::*}%"
else:
message "{@P} Invalid argument. Valid command: &a/map <number>"
else:
message "{@P} Voting isn't open at the moment"
command /mode [<integer>]:
trigger:
if GameManager_Get_Game_Status() is "voting":
if arg 1 is set:
if {game::votes::mode::%arg 1%} is set:
if {game::votes::player::%uuid of player%::mode} is set:
subtract 1 from {game::votes::mode::%{game::votes::player::%uuid of player%::mode}%}
set {game::votes::player::%uuid of player%::mode} to arg 1
add 1 to {game::votes::mode::%arg 1%}
GameManager_Voting_Announce()
else:
message "{@P} Invalid option. Valid options between &a1 &eand &a%size of {game::games::%{game::selected-game}%::votes::mode::votelist::*}%"
else:
message "{@P} Invalid argument. Valid command: &a/mode <number>"
else:
message "{@P} Voting isn't open at the moment"
command /ready:
trigger:
message "{@P} You've readied up! We're just waiting on a staff member to start the game"
set {lobby::players::%uuid of player%} to player
stop
if size of {lobby::players::*} is 1:
GameManager_Broadcast("%player% has readied up (%size of {lobby::players::*}% player ready)")
else:
GameManager_Broadcast("%player% has readied up (%size of {lobby::players::*}% players ready)")
on break:
if GameManager_Get_Game_Status() is not "playing":
if skUnity_Is_Staff(player) is false:
cancel event
on weather change:
cancel event
set weather to clear
on spawn:
if spawn reason is natural:
cancel event
on hunger level change:
if GameManager_Get_Game_Status() is not "playing":
cancel event
on damage:
if GameManager_Get_Game_Status() is not "playing":
cancel event