Skip to content

Commit

Permalink
Meteor shower now with rocks
Browse files Browse the repository at this point in the history
  • Loading branch information
TobleroneSwordfish committed Apr 20, 2023
1 parent 86cd21a commit 37747cf
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 37 deletions.
88 changes: 54 additions & 34 deletions code/modules/events/meteor_shower.dm
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ var/global/meteor_shower_active = 0
var/list/oredrops = list(/obj/item/raw_material/rock)
var/list/oredrops_rare = list(/obj/item/raw_material/rock)
var/transmute_material = null
var/transmute_range = 4
var/meteorhit_chance = 100

proc/set_transmute(datum/material/mat)
Expand Down Expand Up @@ -295,16 +296,19 @@ var/global/meteor_shower_active = 0
if (sound_impact)
playsound(src.loc, sound_impact, 40, 1)
if (--src.hits <= 0)
if(istype(A, /obj/forcefield)) src.explodes = 0
shatter()
if(istype(A, /obj/forcefield))
src.explodes = 0
shatter()
else
shatter(TRUE)

return

Move(atom/NewLoc, Dir)
if(src.x == world.maxx || src.y == world.maxy || src.x == 1 || src.y == 1)
qdel(src)
if(src.loc == target)
shatter()
shatter(TRUE)
return
. = ..()
if(src.loc == last_tile)
Expand Down Expand Up @@ -332,7 +336,7 @@ var/global/meteor_shower_active = 0
if(src.x == world.maxx || src.y == world.maxy || src.x == 1 || src.y == 1)
qdel(src)
if(src.loc == target)
shatter()
shatter(TRUE)
return
if (src.loc == last_tile)
walk_towards(src, target, speed, pix_speed)
Expand All @@ -356,12 +360,14 @@ var/global/meteor_shower_active = 0
step(M,get_dir(src,M))
if (prob(meteorhit_chance))
M.meteorhit(src)

var/dump_ore = TRUE
for(var/obj/O in range(1,src))
if (O == src) continue
if (!O.density) continue
hit_object = 1
hits--
if (istype(O, /obj/forcefield))
dump_ore = FALSE
if (prob(meteorhit_chance))
O.meteorhit(src)
if (O && !O.anchored)
Expand All @@ -372,8 +378,7 @@ var/global/meteor_shower_active = 0
playsound(src.loc, sound_impact, 40, 1)

if(hits <= 0)
dump_ore()
shatter()
shatter(dump_ore)

proc/transmute_effect(range)
var/range_squared = range**2
Expand Down Expand Up @@ -409,18 +414,19 @@ var/global/meteor_shower_active = 0
else
G.setMaterial(transmute_material)

proc/shatter()
proc/shatter(dump_ore = FALSE, turf_safe = FALSE)
if(exploded) return
exploded = TRUE
if(isnull(src.loc)) return
playsound(src.loc, sound_explode, 50, 1)
if (explodes)
if(transmute_material)
transmute_effect(4)
transmute_effect(src.transmute_range)
else
explosion(src, get_turf(src), exp_dev, exp_hvy, exp_lit, exp_fsh)
var/atom/source = src
qdel(source)
explosion(src, get_turf(src), exp_dev, exp_hvy, exp_lit, exp_fsh, turf_safe)
if (dump_ore)
src.dump_ore()
qdel(src)

proc/dump_ore()
playsound(src.loc, sound_explode, 50, 1)
Expand All @@ -434,6 +440,7 @@ var/global/meteor_shower_active = 0
if(transmute_material)
A.setMaterial(transmute_material)


/////////////////////////HUGE

/obj/newmeteor/massive
Expand All @@ -455,32 +462,45 @@ var/global/meteor_shower_active = 0
exp_fsh = 3
oredrops = list(/obj/item/raw_material/char, /obj/item/raw_material/molitz, /obj/item/raw_material/rock)
oredrops_rare = list(/obj/item/raw_material/starstone, /obj/item/raw_material/syreline)
var/shatter_types = list(/obj/newmeteor, /obj/newmeteor/small)
transmute_range = 10
///Do we spawn a solid lump of rock on impact?
var/solid_rock = TRUE

shark
name = "robotic shark"
icon = 'icons/misc/64x32.dmi'
icon_state = "gunshark"
shatter_types = list(/obj/newmeteor/shark, /obj/newmeteor/small/shark)
solid_rock = FALSE
var/shatter_types = list(/obj/newmeteor/shark, /obj/newmeteor/small/shark)

shatter()
if(exploded) return
exploded = TRUE
if(isnull(src.loc)) return
playsound(src.loc, sound_explode, 50, 1)
if (explodes)
if(transmute_material)
transmute_effect(10)
else
explosion(src, get_turf(src), exp_dev, exp_hvy, exp_lit, exp_fsh)
for(var/A in alldirs)
if(prob(15))
shatter()
for(var/A in alldirs)
if(prob(15))
continue
var/type = pick(shatter_types)
var/atom/trg = get_step(src, A)
var/obj/newmeteor/met = new type(src.loc, trg)
met.meteorhit_chance = src.meteorhit_chance
..()

shatter(dump_ore = FALSE, turf_safe = FALSE)
if (prob(50)) //chance to do normal ore spawn
src.solid_rock = FALSE
if (src.solid_rock)
..(dump_ore, TRUE)
else
..()

dump_ore()
if (!src.solid_rock)
return ..()

var/list/turfs = list()
for(var/turf/T in range(src,1))
if (T.density || prob(40))
continue
var/type = pick(shatter_types)
var/atom/trg = get_step(src, A)
var/obj/newmeteor/met = new type(src.loc, trg)
met.meteorhit_chance = src.meteorhit_chance
if(transmute_material)
met.set_transmute(transmute_material)
var/atom/source = src
qdel(source)
var/turf/simulated/wall/auto/asteroid/asteroid = new(T)
if (src.transmute_material)
asteroid.setMaterial(src.transmute_material)
turfs += asteroid
Turfspawn_Asteroid_SeedOre(turfs, rand(1,2), pick(90;1, 10;2, 1;3), FALSE)
4 changes: 2 additions & 2 deletions code/procs/explosion_new.dm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
proc/explosion(atom/source, turf/epicenter, devastation_range, heavy_impact_range, light_impact_range, flash_range)
proc/explosion(atom/source, turf/epicenter, devastation_range, heavy_impact_range, light_impact_range, flash_range, turf_safe = FALSE)
var/power = max(devastation_range+heavy_impact_range+0.25, 0.75)
//boutput(world, "<span class='notice'>[devastation_range] [heavy_impact_range] [power]</span>")
explosion_new(source, epicenter, (power*1.5)**2, max(light_impact_range/(power*1.5), 1))
explosion_new(source, epicenter, (power*1.5)**2, max(light_impact_range/(power*1.5), 1), turf_safe = turf_safe)
//boutput(world, "<span class='alert'>[power]</span>")

proc/explosion_new(atom/source, turf/epicenter, power, brisance=1, angle = 0, width = 360, turf_safe=FALSE)
Expand Down
4 changes: 3 additions & 1 deletion strings/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

(t)thu apr 20 23
(u)LeahTheTech
(+)Meteor showers can now leave behind solid lumps of rock containing ore.
(t)wed apr 19 23
(u)Azrun
(p)13590
Expand Down

0 comments on commit 37747cf

Please sign in to comment.