mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-24 04:27:35 +01:00
Anomaly Refactor and Rework (#15259)
* Anomaly Refactor and Rework * tweaks * tweaks
This commit is contained in:
@@ -1,33 +1,47 @@
|
||||
/datum/event/anomaly
|
||||
var/obj/effect/anomaly/newAnomaly
|
||||
name = "Anomaly: Energetic Flux"
|
||||
var/obj/effect/anomaly/anomaly_path = /obj/effect/anomaly/flux
|
||||
announceWhen = 1
|
||||
|
||||
/datum/event/anomaly/setup(loop=0)
|
||||
var/safety_loop = loop + 1
|
||||
if(safety_loop > 50)
|
||||
kill()
|
||||
end()
|
||||
/datum/event/anomaly/proc/findEventArea()
|
||||
var/static/list/allowed_areas
|
||||
if(!allowed_areas)
|
||||
//Places that shouldn't explode
|
||||
var/list/safe_area_types = typecacheof(list(
|
||||
/area/turret_protected/ai,
|
||||
/area/turret_protected/ai_upload,
|
||||
/area/ai_monitored/storage/emergency,
|
||||
/area/engine,
|
||||
/area/solar,
|
||||
/area/holodeck,
|
||||
/area/shuttle,
|
||||
/area/maintenance,
|
||||
/area/toxins/test_area)
|
||||
)
|
||||
|
||||
//Subtypes from the above that actually should explode.
|
||||
var/list/unsafe_area_subtypes = typecacheof(list(/area/engine/break_room))
|
||||
|
||||
allowed_areas = make_associative(GLOB.the_station_areas) - safe_area_types + unsafe_area_subtypes
|
||||
var/list/possible_areas = typecache_filter_list(GLOB.all_areas, allowed_areas)
|
||||
if(length(possible_areas))
|
||||
return pick(possible_areas)
|
||||
|
||||
/datum/event/anomaly/setup()
|
||||
impact_area = findEventArea()
|
||||
if(!impact_area)
|
||||
setup(safety_loop)
|
||||
CRASH("No valid areas for anomaly found.")
|
||||
var/list/turf_test = get_area_turfs(impact_area)
|
||||
if(!turf_test.len)
|
||||
setup(safety_loop)
|
||||
if(!length(turf_test))
|
||||
CRASH("Anomaly: No valid turfs found for [impact_area] - [impact_area.type]")
|
||||
|
||||
/datum/event/anomaly/announce()
|
||||
GLOB.event_announcement.Announce("Localized hyper-energetic flux wave detected on long range scanners. Expected location of impact: [impact_area.name].", "Anomaly Alert")
|
||||
|
||||
/datum/event/anomaly/start()
|
||||
var/turf/T = pick(get_area_turfs(impact_area))
|
||||
var/newAnomaly
|
||||
if(T)
|
||||
newAnomaly = new /obj/effect/anomaly/flux(T.loc)
|
||||
|
||||
/datum/event/anomaly/tick()
|
||||
if(!newAnomaly)
|
||||
kill()
|
||||
return
|
||||
newAnomaly.anomalyEffect()
|
||||
|
||||
/datum/event/anomaly/end()
|
||||
if(newAnomaly)//Kill the anomaly if it still exists at the end.
|
||||
qdel(newAnomaly)
|
||||
newAnomaly = new anomaly_path(T)
|
||||
if(newAnomaly)
|
||||
announce_to_ghosts(newAnomaly)
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
/datum/event/anomaly/anomaly_atmos
|
||||
startWhen = 30
|
||||
announceWhen = 3
|
||||
endWhen = 100
|
||||
|
||||
/datum/event/anomaly/anomaly_atmos/announce()
|
||||
GLOB.event_announcement.Announce("Transformative gas anomaly detected on long range scanners. Expected location: [impact_area.name].", "Anomaly Alert")
|
||||
|
||||
/datum/event/anomaly/anomaly_atmos/start()
|
||||
var/turf/T = pick(get_area_turfs(impact_area))
|
||||
if(T)
|
||||
newAnomaly = new /obj/effect/anomaly/atmos(T.loc)
|
||||
|
||||
|
||||
/datum/event/anomaly/anomaly_atmos/tick()
|
||||
if(!newAnomaly)
|
||||
kill()
|
||||
return
|
||||
if(ISMULTIPLE(activeFor, 5))
|
||||
newAnomaly.anomalyEffect()
|
||||
|
||||
/datum/event/anomaly/anomaly_atmos/end()
|
||||
if(!newAnomaly || !newAnomaly.loc) //no anomaly or it is in nullspace
|
||||
return
|
||||
var/obj/effect/anomaly/atmos/A = newAnomaly
|
||||
var/gas_type = A.gas_type
|
||||
var/area/t_area = get_area(A)
|
||||
for(var/turf/T in t_area)
|
||||
if(istype(T, /turf/simulated)) //should not occur on unsimulated turfs without admemery
|
||||
var/turf/simulated/S = T
|
||||
fill_with_gas(gas_type, S)
|
||||
explosion(get_turf(newAnomaly), -1, 0, 2) // a small boom so people know something happened.
|
||||
..()
|
||||
|
||||
/**
|
||||
* Replaces all oxygen and nitrogen on the simulated turf S with the gas type specified in gas, taking N2, N20, CO2 and agent B
|
||||
*/
|
||||
/datum/event/anomaly/anomaly_atmos/proc/fill_with_gas(gas, turf/simulated/S)
|
||||
if(!S.air)//no air to transform
|
||||
return
|
||||
var/amount_to_add = S.air.oxygen + S.air.nitrogen
|
||||
S.air.oxygen = 0
|
||||
S.air.nitrogen = 0
|
||||
switch(gas)
|
||||
if(GAS_N2)
|
||||
S.air.nitrogen += amount_to_add
|
||||
if(GAS_N2O)
|
||||
S.air.sleeping_agent += amount_to_add
|
||||
if(GAS_CO2)
|
||||
S.air.carbon_dioxide += amount_to_add
|
||||
S.update_visuals()
|
||||
S.air_update_turf()
|
||||
@@ -1,69 +1,8 @@
|
||||
/datum/event/anomaly/anomaly_bluespace
|
||||
name = "Anomaly: Bluespace"
|
||||
startWhen = 3
|
||||
announceWhen = 10
|
||||
endWhen = 160
|
||||
anomaly_path = /obj/effect/anomaly/bluespace
|
||||
|
||||
/datum/event/anomaly/anomaly_bluespace/announce()
|
||||
GLOB.event_announcement.Announce("Unstable bluespace anomaly detected on long range scanners. Expected location: [impact_area.name].", "Anomaly Alert")
|
||||
|
||||
/datum/event/anomaly/anomaly_bluespace/start()
|
||||
var/turf/T = pick(get_area_turfs(impact_area))
|
||||
if(T)
|
||||
newAnomaly = new /obj/effect/anomaly/bluespace(T.loc)
|
||||
|
||||
/datum/event/anomaly/anomaly_bluespace/end()
|
||||
if(newAnomaly)//If it hasn't been neutralized, it's time to warp half the station away jeez
|
||||
var/turf/T = pick(get_area_turfs(impact_area))
|
||||
if(T)
|
||||
// Calculate new position (searches through beacons in world)
|
||||
var/obj/item/radio/beacon/chosen
|
||||
var/list/possible = list()
|
||||
for(var/obj/item/radio/beacon/W in GLOB.global_radios)
|
||||
if(!is_station_level(W.z))
|
||||
continue
|
||||
possible += W
|
||||
|
||||
if(possible.len > 0)
|
||||
chosen = pick(possible)
|
||||
|
||||
if(chosen)
|
||||
// Calculate previous position for transition
|
||||
|
||||
var/turf/FROM = T // the turf of origin we're travelling FROM
|
||||
var/turf/TO = get_turf(chosen) // the turf of origin we're travelling TO
|
||||
|
||||
playsound(TO, 'sound/effects/phasein.ogg', 100, 1)
|
||||
GLOB.event_announcement.Announce("Massive bluespace translocation detected.", "Anomaly Alert")
|
||||
|
||||
var/list/flashers = list()
|
||||
for(var/mob/living/carbon/C in viewers(TO, null))
|
||||
if(C.flash_eyes())
|
||||
flashers += C
|
||||
|
||||
var/y_distance = TO.y - FROM.y
|
||||
var/x_distance = TO.x - FROM.x
|
||||
for(var/atom/movable/A in range(12, FROM )) // iterate thru list of mobs in the area
|
||||
if(istype(A, /obj/item/radio/beacon)) // don't teleport beacons because that's just insanely stupid
|
||||
continue
|
||||
if(A.anchored || A.move_resist == INFINITY)
|
||||
continue
|
||||
var/turf/newloc = locate(A.x + x_distance, A.y + y_distance, TO.z) // calculate the new place
|
||||
if(!A.Move(newloc)) // if the atom, for some reason, can't move, FORCE them to move! :) We try Move() first to invoke any movement-related checks the atom needs to perform after moving
|
||||
A.loc = locate(A.x + x_distance, A.y + y_distance, TO.z)
|
||||
|
||||
spawn()
|
||||
if(ismob(A) && !(A in flashers)) // don't flash if we're already doing an effect
|
||||
var/mob/M = A
|
||||
if(M.client)
|
||||
var/obj/blueeffect = new /obj(src)
|
||||
blueeffect.screen_loc = "WEST,SOUTH to EAST,NORTH"
|
||||
blueeffect.icon = 'icons/effects/effects.dmi'
|
||||
blueeffect.icon_state = "shieldsparkles"
|
||||
blueeffect.layer = FLASH_LAYER
|
||||
blueeffect.plane = FULLSCREEN_PLANE
|
||||
blueeffect.mouse_opacity = MOUSE_OPACITY_TRANSPARENT
|
||||
M.client.screen += blueeffect
|
||||
sleep(20)
|
||||
M.client.screen -= blueeffect
|
||||
qdel(blueeffect)
|
||||
qdel(newAnomaly)
|
||||
|
||||
@@ -1,17 +1,8 @@
|
||||
/datum/event/anomaly/anomaly_flux
|
||||
startWhen = 3
|
||||
announceWhen = 20
|
||||
endWhen = 180
|
||||
name = "Anomaly: Hyper-Energetic Flux"
|
||||
startWhen = 10
|
||||
announceWhen = 3
|
||||
anomaly_path = /obj/effect/anomaly/flux
|
||||
|
||||
/datum/event/anomaly/anomaly_flux/announce()
|
||||
GLOB.event_announcement.Announce("Localized hyper-energetic flux wave detected on long range scanners. Expected location: [impact_area.name].", "Anomaly Alert")
|
||||
|
||||
/datum/event/anomaly/anomaly_flux/start()
|
||||
var/turf/T = pick(get_area_turfs(impact_area))
|
||||
if(T)
|
||||
newAnomaly = new /obj/effect/anomaly/flux(T.loc)
|
||||
|
||||
/datum/event/anomaly/anomaly_flux/end()
|
||||
if(newAnomaly.loc)//If it hasn't been neutralized, it's time to blow up.
|
||||
explosion(newAnomaly, -1, 3, 5, 5)
|
||||
qdel(newAnomaly)
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
/datum/event/anomaly/anomaly_grav
|
||||
name = "Anomaly: Gravitational"
|
||||
startWhen = 3
|
||||
announceWhen = 20
|
||||
endWhen = 70
|
||||
anomaly_path = /obj/effect/anomaly/grav
|
||||
|
||||
/datum/event/anomaly/anomaly_grav/announce()
|
||||
GLOB.event_announcement.Announce("Gravitational anomaly detected on long range scanners. Expected location: [impact_area.name].", "Anomaly Alert")
|
||||
|
||||
/datum/event/anomaly/anomaly_grav/start()
|
||||
var/turf/T = pick(get_area_turfs(impact_area))
|
||||
if(T)
|
||||
newAnomaly = new /obj/effect/anomaly/grav(T.loc)
|
||||
|
||||
@@ -1,31 +1,8 @@
|
||||
/datum/event/anomaly/anomaly_pyro
|
||||
startWhen = 30
|
||||
announceWhen = 3
|
||||
endWhen = 110
|
||||
name = "Anomaly: Pyroclastic"
|
||||
startWhen = 3
|
||||
announceWhen = 10
|
||||
anomaly_path = /obj/effect/anomaly/pyro
|
||||
|
||||
/datum/event/anomaly/anomaly_pyro/announce()
|
||||
GLOB.event_announcement.Announce("Atmospheric anomaly detected on long range scanners. Expected location: [impact_area.name].", "Anomaly Alert")
|
||||
|
||||
/datum/event/anomaly/anomaly_pyro/start()
|
||||
var/turf/T = pick(get_area_turfs(impact_area))
|
||||
if(T)
|
||||
newAnomaly = new /obj/effect/anomaly/pyro(T.loc)
|
||||
|
||||
/datum/event/anomaly/anomaly_pyro/tick()
|
||||
if(!newAnomaly)
|
||||
kill()
|
||||
return
|
||||
if(ISMULTIPLE(activeFor, 5))
|
||||
newAnomaly.anomalyEffect()
|
||||
|
||||
/datum/event/anomaly/anomaly_pyro/end()
|
||||
if(newAnomaly.loc)
|
||||
explosion(get_turf(newAnomaly), -1,0,3, flame_range = 4)
|
||||
|
||||
var/turf/T = get_turf(src)
|
||||
var/new_colour = pick("red", "orange")
|
||||
var/mob/living/simple_animal/slime/S = new(T, new_colour)
|
||||
S.rabid = TRUE
|
||||
S.amount_grown = SLIME_EVOLUTION_THRESHOLD
|
||||
S.Evolve()
|
||||
qdel(newAnomaly)
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
/datum/event/anomaly/anomaly_vortex
|
||||
startWhen = 20
|
||||
name = "Anomaly: Vortex"
|
||||
startWhen = 10
|
||||
announceWhen = 3
|
||||
endWhen = 80
|
||||
anomaly_path = /obj/effect/anomaly/bhole
|
||||
|
||||
/datum/event/anomaly/anomaly_vortex/announce()
|
||||
GLOB.event_announcement.Announce("Localized high-intensity vortex anomaly detected on long range scanners. Expected location: [impact_area.name]", "Anomaly Alert")
|
||||
|
||||
/datum/event/anomaly/anomaly_vortex/start()
|
||||
var/turf/T = pick(get_area_turfs(impact_area))
|
||||
if(T)
|
||||
newAnomaly = new /obj/effect/anomaly/bhole(T.loc)
|
||||
|
||||
@@ -51,6 +51,8 @@
|
||||
return 0*/
|
||||
|
||||
/datum/event //NOTE: Times are measured in master controller ticks!
|
||||
/// The human-readable name of the event
|
||||
var/name
|
||||
var/processing = 1
|
||||
/// When in the lifetime to call start().
|
||||
var/startWhen = 0
|
||||
@@ -190,3 +192,10 @@
|
||||
|
||||
setup()
|
||||
..()
|
||||
|
||||
//Called after something followable has been spawned by an event
|
||||
//Provides ghosts a follow link to an atom if possible
|
||||
//Only called once.
|
||||
/datum/event/proc/announce_to_ghosts(atom/atom_of_interest)
|
||||
if(atom_of_interest)
|
||||
notify_ghosts("[name] has an object of interest: [atom_of_interest]!", title = "Something's Interesting!", source = atom_of_interest, action = NOTIFY_FOLLOW)
|
||||
|
||||
@@ -174,7 +174,6 @@ GLOBAL_LIST_EMPTY(event_last_fired)
|
||||
new /datum/event_meta(EVENT_LEVEL_MODERATE, "Vent Clog", /datum/event/vent_clog, 250),
|
||||
new /datum/event_meta(EVENT_LEVEL_MODERATE, "Wormholes", /datum/event/wormholes, 150),
|
||||
new /datum/event_meta(EVENT_LEVEL_MODERATE, "Pyro Anomaly", /datum/event/anomaly/anomaly_pyro, 75, list(ASSIGNMENT_ENGINEER = 60)),
|
||||
new /datum/event_meta(EVENT_LEVEL_MODERATE, "Atmos Anomaly", /datum/event/anomaly/anomaly_atmos, 75, list(ASSIGNMENT_ENGINEER = 60)),
|
||||
new /datum/event_meta(EVENT_LEVEL_MODERATE, "Vortex Anomaly", /datum/event/anomaly/anomaly_vortex, 75, list(ASSIGNMENT_ENGINEER = 25)),
|
||||
new /datum/event_meta(EVENT_LEVEL_MODERATE, "Bluespace Anomaly", /datum/event/anomaly/anomaly_bluespace, 75, list(ASSIGNMENT_ENGINEER = 25)),
|
||||
new /datum/event_meta(EVENT_LEVEL_MODERATE, "Flux Anomaly", /datum/event/anomaly/anomaly_flux, 75, list(ASSIGNMENT_ENGINEER = 50)),
|
||||
|
||||
Reference in New Issue
Block a user