diff --git a/code/controllers/subsystems/planets.dm b/code/controllers/subsystems/planets.dm index a163a3b1e79..f7fc49b6612 100644 --- a/code/controllers/subsystems/planets.dm +++ b/code/controllers/subsystems/planets.dm @@ -57,6 +57,7 @@ SUBSYSTEM_DEF(planets) else P.planet_walls -= T T.vis_contents -= P.weather_holder.visuals + T.vis_contents -= P.weather_holder.special_visuals /datum/controller/subsystem/planets/proc/allocateTurfs(var/initial = FALSE) var/list/currentlist = new_outdoor_turfs @@ -67,6 +68,7 @@ SUBSYSTEM_DEF(planets) var/datum/planet/P = z_to_planet[OT.z] P.planet_floors |= OT OT.vis_contents |= P.weather_holder.visuals + OT.vis_contents |= P.weather_holder.special_visuals if(!initial && MC_TICK_CHECK) return @@ -85,6 +87,7 @@ SUBSYSTEM_DEF(planets) var/datum/planet/P = z_to_planet[T.z] P.planet_floors -= T T.vis_contents -= P.weather_holder.visuals + T.vis_contents -= P.weather_holder.special_visuals /datum/controller/subsystem/planets/fire(resumed = 0) diff --git a/code/game/objects/effects/misc.dm b/code/game/objects/effects/misc.dm index aaebab43550..13e7501bb1c 100644 --- a/code/game/objects/effects/misc.dm +++ b/code/game/objects/effects/misc.dm @@ -46,4 +46,20 @@ /obj/effect/temporary_effect/shuttle_landing/initialize() flick("shuttle_warning", src) // flick() forces the animation to always begin at the start. + . = ..() + +// The manifestation of Zeus's might. Or just a really unlucky day. +// This is purely a visual effect, this isn't the part of the code that hurts things. +/obj/effect/temporary_effect/lightning_strike + name = "lightning" + desc = "How shocked you must be, to see this text. You must have lightning reflexes. \ + The humor in this description is just so electrifying." + icon = 'icons/effects/96x256.dmi' + icon_state = "lightning_strike" + plane = PLANE_LIGHTING_ABOVE + time_to_die = 1 SECOND + pixel_x = -32 + +/obj/effect/temporary_effect/lightning_strike/initialize() + icon_state += rand(1,2) // To have two variants of lightning sprites. . = ..() \ No newline at end of file diff --git a/code/game/objects/structures/flora/trees.dm b/code/game/objects/structures/flora/trees.dm index f0a7498390f..5b3a74ad03c 100644 --- a/code/game/objects/structures/flora/trees.dm +++ b/code/game/objects/structures/flora/trees.dm @@ -4,7 +4,7 @@ anchored = 1 density = 1 pixel_x = -16 - plane = MOB_LAYER // You know what, let's play it safe. + plane = MOB_PLANE // You know what, let's play it safe. layer = ABOVE_MOB_LAYER var/base_state = null // Used for stumps. var/health = 200 // Used for chopping down trees. diff --git a/code/modules/planet/sif.dm b/code/modules/planet/sif.dm index b8bbf7ba6a4..250a688ec8d 100644 --- a/code/modules/planet/sif.dm +++ b/code/modules/planet/sif.dm @@ -264,6 +264,9 @@ datum/weather/sif temp_low = 233.15 // -40c light_modifier = 0.3 flight_failure_modifier = 10 + var/next_lightning_strike = 0 // world.time when lightning will strike. + var/min_lightning_cooldown = 5 SECONDS + var/max_lightning_cooldown = 1 MINUTE transition_chances = list( @@ -298,6 +301,43 @@ datum/weather/sif L.water_act(2) to_chat(L, "Rain falls on you, drenching you in water.") + handle_lightning() + +// This gets called to do lightning periodically. +// There is a seperate function to do the actual lightning strike, so that badmins can play with it. +/datum/weather/sif/storm/proc/handle_lightning() + if(world.time < next_lightning_strike) + return // It's too soon to strike again. + next_lightning_strike = world.time + rand(min_lightning_cooldown, max_lightning_cooldown) + var/turf/T = pick(holder.our_planet.planet_floors) // This has the chance to 'strike' the sky, but that might be a good thing, to scare reckless pilots. + lightning_strike(T) + +// This is global until I can figure out a better place for it. +// T is the turf that is being struck. If cosmetic is true, the lightning won't actually hurt anything. +/proc/lightning_strike(turf/T, cosmetic = FALSE) + world << "Going to strike turf [T] ([T.x],[T.y],[T.z])." + // First, visuals. + // Do a lightning flash for the whole planet, if the turf belongs to a planet. + var/datum/planet/P = null + P = SSplanets.z_to_planet[T.z] + if(P) + world << "Planet [P] ([P.name]) is hopefully not null." + var/datum/weather_holder/holder = P.weather_holder + world << "Weather holder is hopefully not null." + flick("lightning_flash", holder.special_visuals) + + // Now make the lightning strike sprite. It will delete itself in a second. + new /obj/effect/temporary_effect/lightning_strike(T) + + // Todo: Thunder. + + if(cosmetic) // Everything beyond here involves damaging things. If we don't want to do that, stop now. + return + +// Test verb +/mob/verb/test_lightning() + lightning_strike(get_turf(src)) + /datum/weather/sif/hail name = "hail" icon_state = "hail" diff --git a/code/modules/planet/weather.dm b/code/modules/planet/weather.dm index 724540c875a..55ddfbee2a0 100644 --- a/code/modules/planet/weather.dm +++ b/code/modules/planet/weather.dm @@ -10,6 +10,7 @@ // Holds the weather icon, using vis_contents. Documentation says an /atom/movable is required for placing inside another atom's vis_contents. var/atom/movable/weather_visuals/visuals = null + var/atom/movable/weather_visuals/special/special_visuals = null /datum/weather_holder/New(var/source) ..() @@ -19,6 +20,7 @@ if(istype(W)) W.holder = src visuals = new() + special_visuals = new() /datum/weather_holder/proc/change_weather(var/new_weather) var/old_light_modifier = null @@ -87,3 +89,9 @@ icon = 'icons/effects/weather.dmi' mouse_opacity = 0 plane = PLANE_PLANETLIGHTING + +// This is for special effects for specific types of weather, such as lightning flashes in a storm. +// It's a seperate object to allow the use of flick(). +/atom/movable/weather_visuals/special + plane = PLANE_LIGHTING_ABOVE + alpha = 127 \ No newline at end of file diff --git a/icons/effects/96x256.dmi b/icons/effects/96x256.dmi new file mode 100644 index 00000000000..978f0fbcdad Binary files /dev/null and b/icons/effects/96x256.dmi differ diff --git a/icons/effects/weather.dmi b/icons/effects/weather.dmi index d0df90a44a7..b6b38c55cd9 100644 Binary files a/icons/effects/weather.dmi and b/icons/effects/weather.dmi differ