-
-
Notifications
You must be signed in to change notification settings - Fork 452
/
meteors.dm
407 lines (341 loc) · 11.1 KB
/
meteors.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
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
396
397
398
399
400
401
402
403
404
405
406
407
#define DEFAULT_METEOR_LIFETIME 1800
GLOBAL_VAR_INIT(meteor_wave_delay, 625) //minimum wait between waves in tenths of seconds
//set to at least 100 unless you want evarr ruining every round
//Meteors probability of spawning during a given wave
GLOBAL_LIST_INIT(meteors_normal, list(/obj/effect/meteor/dust=3, /obj/effect/meteor/medium=8, /obj/effect/meteor/big=3, \
/obj/effect/meteor/flaming=1, /obj/effect/meteor/irradiated=3, /obj/effect/meteor/guardian=0.01)) //for normal meteor event
GLOBAL_LIST_INIT(meteors_threatening, list(/obj/effect/meteor/medium=4, /obj/effect/meteor/big=8, \
/obj/effect/meteor/flaming=3, /obj/effect/meteor/irradiated=3, /obj/effect/meteor/guardian=1)) //for threatening meteor event
GLOBAL_LIST_INIT(meteors_catastrophic, list(/obj/effect/meteor/medium=5, /obj/effect/meteor/big=75, \
/obj/effect/meteor/flaming=10, /obj/effect/meteor/irradiated=10, /obj/effect/meteor/guardian=2, /obj/effect/meteor/tunguska = 1)) //for catastrophic meteor event
GLOBAL_LIST_INIT(meteorsB, list(/obj/effect/meteor/meaty=5, /obj/effect/meteor/meaty/xeno=1)) //for meaty ore event
GLOBAL_LIST_INIT(meteorsC, list(/obj/effect/meteor/dust)) //for space dust event
///////////////////////////////
//Meteor spawning global procs
///////////////////////////////
/proc/spawn_meteors(number = 10, list/meteortypes)
for(var/i = 0; i < number; i++)
spawn_meteor(meteortypes)
/proc/spawn_meteor(list/meteortypes)
var/turf/pickedstart
var/turf/pickedgoal
var/max_i = 10//number of tries to spawn meteor.
while(!isspaceturf(pickedstart))
var/startSide = pick(GLOB.cardinals)
var/startZ = pick(SSmapping.levels_by_trait(ZTRAIT_STATION))
pickedstart = spaceDebrisStartLoc(startSide, startZ)
pickedgoal = spaceDebrisFinishLoc(startSide, startZ)
max_i--
if(max_i<=0)
return
var/Me = pickweight(meteortypes)
var/obj/effect/meteor/M = new Me(pickedstart, pickedgoal)
M.dest = pickedgoal
/proc/spaceDebrisStartLoc(startSide, Z)
var/starty
var/startx
switch(startSide)
if(NORTH)
starty = world.maxy-(TRANSITIONEDGE+1)
startx = rand((TRANSITIONEDGE+1), world.maxx-(TRANSITIONEDGE+1))
if(EAST)
starty = rand((TRANSITIONEDGE+1),world.maxy-(TRANSITIONEDGE+1))
startx = world.maxx-(TRANSITIONEDGE+1)
if(SOUTH)
starty = (TRANSITIONEDGE+1)
startx = rand((TRANSITIONEDGE+1), world.maxx-(TRANSITIONEDGE+1))
if(WEST)
starty = rand((TRANSITIONEDGE+1), world.maxy-(TRANSITIONEDGE+1))
startx = (TRANSITIONEDGE+1)
. = locate(startx, starty, Z)
/proc/spaceDebrisFinishLoc(startSide, Z)
var/endy
var/endx
switch(startSide)
if(NORTH)
endy = (TRANSITIONEDGE+1)
endx = rand((TRANSITIONEDGE+1), world.maxx-(TRANSITIONEDGE+1))
if(EAST)
endy = rand((TRANSITIONEDGE+1), world.maxy-(TRANSITIONEDGE+1))
endx = (TRANSITIONEDGE+1)
if(SOUTH)
endy = world.maxy-(TRANSITIONEDGE+1)
endx = rand((TRANSITIONEDGE+1), world.maxx-(TRANSITIONEDGE+1))
if(WEST)
endy = rand((TRANSITIONEDGE+1),world.maxy-(TRANSITIONEDGE+1))
endx = world.maxx-(TRANSITIONEDGE+1)
. = locate(endx, endy, Z)
///////////////////////
//The meteor effect
//////////////////////
/obj/effect/meteor
name = "the concept of meteor"
desc = "You should probably run instead of gawking at this."
icon = 'icons/obj/meteor.dmi'
icon_state = "small"
density = TRUE
anchored = TRUE
pass_flags = PASSTABLE
///The resilience of our meteor
var/hits = 4
///Level of ex_act to be called on hit.
var/hitpwr = EXPLODE_HEAVY
//Should we shake people's screens on impact
var/heavy = FALSE
///Sound to play when you hit something
var/meteorsound = 'sound/effects/meteorimpact.ogg'
///Our starting z level, prevents infinite meteors
var/z_original
///Used for determining which meteors are most interesting
var/threat = 0
//Potential items to spawn when you die
var/list/meteordrop = list(/obj/item/stack/ore/iron)
///How much stuff to spawn when you die
var/dropamt = 2
///The thing we're moving towards, usually a turf
var/atom/dest
///Lifetime in seconds
var/lifetime = DEFAULT_METEOR_LIFETIME
var/timerid = null
/obj/effect/meteor/Move()
if(z != z_original || loc == dest)
qdel(src)
return FALSE
. = ..() //process movement...
if(.)//.. if did move, ram the turf we get in
var/turf/T = get_turf(loc)
ram_turf(T)
if(prob(10) && !isspaceturf(T))//randomly takes a 'hit' from ramming
get_hit()
/obj/effect/meteor/Process_Spacemove(movement_dir = 0)
return TRUE
/obj/effect/meteor/Destroy()
if (timerid)
deltimer(timerid)
GLOB.meteor_list -= src
SSaugury.unregister_doom(src)
walk(src,0) //this cancels the walk_towards() proc
. = ..()
/obj/effect/meteor/Initialize(mapload, target)
. = ..()
z_original = z
GLOB.meteor_list += src
SSaugury.register_doom(src, threat)
SpinAnimation()
timerid = QDEL_IN(src, lifetime)
chase_target(target)
update_appearance()
/obj/effect/meteor/Bump(atom/A)
if(A)
ram_turf(get_turf(A))
playsound(src.loc, meteorsound, 40, TRUE)
get_hit()
/obj/effect/meteor/proc/ram_turf(turf/T)
//first bust whatever is in the turf
for(var/thing in T)
if(thing == src)
continue
if(isliving(thing))
var/mob/living/living_thing = thing
living_thing.visible_message(span_warning("[src] slams into [living_thing]."), span_userdanger("[src] slams into you!."))
switch(hitpwr)
if(EXPLODE_DEVASTATE)
SSexplosions.high_mov_atom += thing
if(EXPLODE_HEAVY)
SSexplosions.med_mov_atom += thing
if(EXPLODE_LIGHT)
SSexplosions.low_mov_atom += thing
//then, ram the turf if it still exists
if(T && !isspaceturf(T))
switch(hitpwr)
if(EXPLODE_DEVASTATE)
SSexplosions.highturf += T
if(EXPLODE_HEAVY)
SSexplosions.medturf += T
if(EXPLODE_LIGHT)
SSexplosions.lowturf += T
//process getting 'hit' by colliding with a dense object
//or randomly when ramming turfs
/obj/effect/meteor/proc/get_hit()
hits--
if(hits <= 0)
make_debris()
meteor_effect()
qdel(src)
/obj/effect/meteor/ex_act()
return
/obj/effect/meteor/attackby(obj/item/I, mob/user, params)
if(I.tool_behaviour == TOOL_MINING)
make_debris()
qdel(src)
else
. = ..()
/obj/effect/meteor/proc/make_debris()
for(var/throws = dropamt, throws > 0, throws--)
var/thing_to_spawn = pick(meteordrop)
new thing_to_spawn(get_turf(src))
/obj/effect/meteor/proc/chase_target(atom/chasing, delay = 1)
set waitfor = FALSE
if(chasing)
walk_towards(src, chasing, delay)
/obj/effect/meteor/proc/meteor_effect()
if(heavy)
var/sound/meteor_sound = sound(meteorsound)
var/random_frequency = get_rand_frequency()
for(var/mob/M in GLOB.player_list)
if((M.orbiting))
continue
var/turf/T = get_turf(M)
if(!T || T.z != src.z)
continue
var/dist = get_dist(M.loc, src.loc)
shake_camera(M, dist > 20 ? 2 : 4, dist > 20 ? 1 : 3)
M.playsound_local(src.loc, null, 50, 1, random_frequency, 10, S = meteor_sound)
///////////////////////
//Meteor types
///////////////////////
//Dust
/obj/effect/meteor/dust
name = "space dust"
icon_state = "dust"
pass_flags = PASSTABLE | PASSGRILLE
hits = 1
hitpwr = 3
meteorsound = 'sound/weapons/gunshot_smg.ogg'
meteordrop = list(/obj/item/stack/ore/glass)
threat = 1
//Medium-sized
/obj/effect/meteor/medium
name = "meteor"
dropamt = 3
threat = 5
/obj/effect/meteor/medium/meteor_effect()
..()
explosion(src.loc, 0, 1, 2, 3, 0)
//Large-sized
/obj/effect/meteor/big
name = "big meteor"
icon_state = "large"
hits = 6
heavy = 1
dropamt = 4
threat = 10
/obj/effect/meteor/big/meteor_effect()
..()
explosion(src.loc, 1, 2, 3, 4, 0)
//Flaming meteor
/obj/effect/meteor/flaming
name = "flaming meteor"
icon_state = "flaming"
hits = 5
heavy = 1
meteorsound = 'sound/effects/bamf.ogg'
meteordrop = list(/obj/item/stack/ore/plasma)
threat = 20
/obj/effect/meteor/flaming/meteor_effect()
..()
explosion(src.loc, 1, 2, 3, 4, 0, 0, 5)
//Radiation meteor
/obj/effect/meteor/irradiated
name = "glowing meteor"
icon_state = "glowing"
heavy = 1
meteordrop = list(/obj/item/stack/ore/uranium)
threat = 15
/obj/effect/meteor/irradiated/meteor_effect()
..()
explosion(src.loc, 0, 0, 4, 3, 0)
new /obj/effect/decal/cleanable/greenglow(get_turf(src))
radiation_pulse(src, 500)
//Meaty Ore
/obj/effect/meteor/meaty
name = "meaty ore"
icon_state = "meateor"
desc = "Just... don't think too hard about where this thing came from."
hits = 2
heavy = 1
meteorsound = 'sound/effects/blobattack.ogg'
meteordrop = list(/obj/item/reagent_containers/food/snacks/meat/slab/human, /obj/item/reagent_containers/food/snacks/meat/slab/human/mutant, /obj/item/organ/heart, /obj/item/organ/lungs, /obj/item/organ/tongue, /obj/item/organ/appendix/, /obj/item/organ/heart/freedom)
var/meteorgibs = /obj/effect/gibspawner/generic
threat = 2
/obj/effect/meteor/meaty/Initialize(mapload)
for(var/path in meteordrop)
if(path == /obj/item/reagent_containers/food/snacks/meat/slab/human/mutant)
meteordrop -= path
meteordrop += pick(subtypesof(path))
for(var/path in meteordrop)
if(path == /obj/item/organ/tongue)
meteordrop -= path
meteordrop += pick(typesof(path))
return ..()
/obj/effect/meteor/meaty/make_debris()
..()
new meteorgibs(get_turf(src))
/obj/effect/meteor/meaty/ram_turf(turf/T)
if(!isspaceturf(T))
new /obj/effect/decal/cleanable/blood(T)
/obj/effect/meteor/meaty/Bump(atom/A)
A.ex_act(hitpwr)
get_hit()
//Meaty Ore Xeno edition
/obj/effect/meteor/meaty/xeno
color = "#5EFF00"
meteordrop = list(/obj/item/reagent_containers/food/snacks/meat/slab/xeno, /obj/item/organ/tongue/alien)
meteorgibs = /obj/effect/gibspawner/xeno
/obj/effect/meteor/meaty/xeno/Initialize(mapload)
meteordrop += subtypesof(/obj/item/organ/alien)
return ..()
/obj/effect/meteor/meaty/xeno/ram_turf(turf/T)
if(!isspaceturf(T))
new /obj/effect/decal/cleanable/xenoblood(T)
//Station buster Tunguska
/obj/effect/meteor/tunguska
name = "tunguska meteor"
icon_state = "flaming"
desc = "Your life briefly passes before your eyes the moment you lay them on this monstrosity."
hits = 30
hitpwr = 1
heavy = 1
meteorsound = 'sound/effects/bamf.ogg'
meteordrop = list(/obj/item/stack/ore/plasma)
threat = 50
/obj/effect/meteor/tunguska/Move()
. = ..()
if(.)
new /obj/effect/temp_visual/revenant(get_turf(src))
/obj/effect/meteor/tunguska/meteor_effect()
..()
explosion(src.loc, 5, 10, 15, 20, 0)
/obj/effect/meteor/tunguska/Bump()
..()
if(prob(20))
explosion(src.loc,2,4,6,8)
//Stand meteor
/obj/effect/meteor/guardian
name = "glowing meteor"
icon_state = "glowing"
hits = 3
heavy = TRUE
meteorsound = 'sound/effects/bamf.ogg'
meteordrop = list(/obj/item/stand_arrow)
dropamt = 1
threat = 100
//////////////////////////
//Spookoween meteors
/////////////////////////
GLOBAL_LIST_INIT(meteorsSPOOKY, list(/obj/effect/meteor/pumpkin))
/obj/effect/meteor/pumpkin
name = "PUMPKING"
desc = "THE PUMPKING'S COMING!"
icon = 'icons/obj/meteor_spooky.dmi'
icon_state = "pumpkin"
hits = 10
heavy = 1
dropamt = 1
meteordrop = list(/obj/item/clothing/head/hardhat/pumpkinhead, /obj/item/reagent_containers/food/snacks/grown/pumpkin)
threat = 100
/obj/effect/meteor/pumpkin/Initialize(mapload)
. = ..()
meteorsound = pick('sound/hallucinations/im_here1.ogg','sound/hallucinations/im_here2.ogg')
//////////////////////////
#undef DEFAULT_METEOR_LIFETIME