forked from jacobabrennan/CasualQuest-DM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjoining.dm
323 lines (320 loc) · 6.54 KB
/
joining.dm
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
client{
perspective = EYE_PERSPECTIVE
var{
subscription = FALSE
regressia_sub = FALSE
haz_sub = FALSE
decadence_sub = FALSE
pg_sub = FALSE
member = FALSE
host = FALSE
}
New(){
. = ..()
spawn(){
subscription = CheckPassport(PASSPORT)
regressia_sub = CheckPassport(REGRESSIA_PASS)
haz_sub = CheckPassport(HAZ_PASS)
decadence_sub = CheckPassport(DECADENCE_PASS)
pg_sub = CheckPassport(PLUNDERGNOME_PASS)
member = IsByondMember()
world << "<i>+ [html_encode(key)] has joined.</i>"
if(world.host){
if(world.host == key){
host = TRUE
}
}
else if(!address || address == world.address || address == "127.0.0.1"){
host = TRUE
}
if(host){
winset(src, "main_menu.moderation", "is-disabled=false;")
}
else{
winset(src, "main_menu.moderation", "is-disabled=true;")
}
}
eye = locate("title_screen")
}
Del(){
world << "<i>- [html_encode(key)] has left.</i>"
if(hero){
hero.die()
}
. = ..()
}
verb{
spectate(){
set name = ".spectate"
game.spectate(src)
}
join(){
set name = ".join"
game.join(src)
}
join_hard(){
set name = ".joinhard"
game.join(src, 60)
}
pause(){
set name = ".pause"
game.pause(src)
}
}
}
game/hero{
var{
tombing = TRUE
}
die(){
var/game/map/mover/intelligence/afk_check/_afk = intelligence
if(istype(_afk) && player){
_afk.increase_afk(src)
if(!_afk){
return
}
}
if(tombing){
var/game/hero/tomb/T = new(src)
T.store(src)
}
if(istype(player)){
player.reset_score()
game.waiting.Add(player)
}
game.heros.Remove(src)
. = ..()
}
Del(){
game.heros.Remove(src)
. = ..()
}
tomb{
parent_type = /game/item
icon = 'rectangles.dmi'
icon_state = "tomb"
lifespan = 1024
height = 15
width = 13
activate(){}
var{
client/stored_player
hero_type
stored_score
stored_waves
stored_aura
}
proc{
store(var/game/hero/H){
hero_type = H.type
stored_player = H.player
if(istype(stored_player)){
stored_score = stored_player.score
stored_waves = stored_player.waves
stored_aura = H.aura
}
}
restore(var/player_type){
if(!istype(stored_player)){
Del()
return
}
game.waiting.Remove(stored_player)
var/game/hero/H
if(player_type){
H = new player_type()
}
else{
H = new hero_type()
}
H.player = stored_player
H.player.score = stored_score
H.player.waves = stored_waves
stored_player.hero = H
stored_player.eye = game.eye
H.c.x = c.x + (width - H.width )/2
H.c.y = c.y + (height - H.height)/2
H.health = 1
H.aura = min(stored_aura, H.max_aura)
H.invulnerable = INVULNERABLE_TIME
H.adjust_health(0)
H.adjust_aura(0)
H.redraw()
. = H
var/game/hero/H2 = src
src = null
H2.Del()
}
}
}
}
game{
var{
list/waiting = new()
list/spectators = new()
}
proc{
join(var/client/client, start_wave=0){
switch(stage){
if(STAGE_EMPTY){
if(!map){
map = new()
}
add_hero(client)
map.wave = start_wave
map.load()
}
if(STAGE_JOIN){
if(heros.len >= MAX_HEROS){
wait(client)
}
else{
add_hero(client)
}
}
if(STAGE_PLAY, STAGE_WIN){
wait(client)
}
if(STAGE_LOOSE){
return
}
}
}
wait(var/client/client){
waiting.Add(client)
client.eye = eye
client.skin.notify_wait()
if(!heros.len){
client.eye = locate("game_over_screen")
}
}
spectate(var/client/client){
client.reset_score()
if(client.timed_selection){
del client.timed_selection
}
if(client.hero){
var/game/map/mover/intelligence/afk_check/_afk = client.hero.intelligence
if(istype(_afk)){
del _afk
}
client.hero.die()
}
if(!game.heros.len && game.map && game.map.pause){
game.pause(client)
}
if(client in waiting){
for(var/game/hero/tomb/tomb){
if(tomb.stored_player == src){
tomb.stored_player = null
tomb.hero_type = null
break
}
}
waiting.Remove(client)
}
if(stage == STAGE_EMPTY){
spawn(){
alert(client, "There is no game currently in progress.", "Spectate")
}
return
}
if(stage == STAGE_LOOSE){
return
}
if(client){
if(!(client in spectators)){ // Add to Spectators
spectators.Add(client)
client.eye = eye
client.skin.notify_spectate()
if(!heros.len){
client.eye = locate("game_over_screen")
}
}
else{ // Remove from Spectators
spectators.Remove(client)
client.eye = locate("title_screen")
winset(client, null, "main.notify.is-visible='false';")
}
}
}
add_hero(var/client/client, hero_type){
if(!hero_type){
spawn(){
var/game/hero/subscriber/timed_selection/ts = new()
var/result = ts.select(client)
if(result){
hero_type = result
game.add_hero(client, result)
}
}
}
var/coord/storage_coord
if(client.hero){
storage_coord = client.hero.c.Copy()
game.heros.Remove(client.hero)
del client.hero
}
if(client in waiting){
waiting.Remove(client)
}
if(!hero_type){
hero_type = /game/hero/_blank
}
var/game/hero/H = new hero_type()
client.hero = H
H.player = client
client.eye = eye
if(stage == STAGE_JOIN && !H.player_indicator){
map.prep_player(H)
}
if(storage_coord){
H.c = storage_coord
H.redraw()
}
}
}
}
client{
var/game/hero/subscriber/timed_selection/timed_selection
}
game/hero/subscriber/timed_selection{
parent_type = /datum
New(){
spawn(50){
del src
}
}
proc{
select(var/client/client){
client.timed_selection = src
var/list/choices = new()
choices["Adventurer"] = /game/hero/_blank
var/subscription_path = text2path("/game/hero/subscriber/[client.ckey]")
if(subscription_path){
choices["Custom Class"] = subscription_path
}
if(client.regressia_sub){
choices["Regressia Hero"] = /game/hero/_regressia
}
if(client.haz_sub){
choices["Hazordhu Orc"] = /game/hero/_hazordhu
}
if(client.decadence_sub){
choices["Decadence Crossbowman"] = /game/hero/_decadence
}
if(client.pg_sub){
choices["Plunder Gnome"] = /game/hero/_plunder_gnome
}
if(client.member){
choices["Members' Adventurer"] = /game/hero/_member
}
var/choice = input(client, "Select a Bonus", "Respawn") in choices
choice = choices[choice]
var/game/hero/new_hero = new choice
new_hero.output_class_link(world, client)
del(new_hero)
return choice
}
}
}