Files
S.P.L.U.R.T-Station-13/code/modules/events/wormholes.dm
SandPoot 54641ce201 send
2023-01-23 20:44:28 -03:00

71 lines
2.0 KiB
Plaintext

/datum/round_event_control/wormholes
name = "Wormholes"
typepath = /datum/round_event/wormholes
max_occurrences = 3
weight = 2
min_players = 2
category = EVENT_CATEGORY_SPACE
description = "Space time anomalies appear on the station, randomly teleporting people who walk into them."
/datum/round_event/wormholes
announce_when = 10
end_when = 60
var/list/pick_turfs = list()
var/list/wormholes = list()
var/shift_frequency = 3
var/number_of_wormholes = 400
/datum/round_event/wormholes/setup()
announce_when = rand(0, 20)
end_when = rand(40, 80)
/datum/round_event/wormholes/start()
for(var/turf/open/floor/T in world)
if(is_station_level(T.z))
var/area/A = get_area(T)
if(A.outdoors)
continue
pick_turfs += T
for(var/i = 1, i <= number_of_wormholes, i++)
var/turf/T = pick(pick_turfs)
wormholes += new /obj/effect/portal/wormhole(T, 0, null, FALSE)
/datum/round_event/wormholes/announce(fake)
priority_announce("Space-time anomalies detected on the station. There is no additional data.", "Anomaly Alert", "spanomalies", has_important_message = TRUE)
/datum/round_event/wormholes/tick()
if(activeFor % shift_frequency == 0)
for(var/obj/effect/portal/wormhole/O in wormholes)
var/turf/T = pick(pick_turfs)
if(T)
O.forceMove(T)
/datum/round_event/wormholes/end()
QDEL_LIST(wormholes)
wormholes = null
/obj/effect/portal/wormhole
name = "wormhole"
desc = "It looks highly unstable; It could close at any moment."
icon = 'icons/obj/objects.dmi'
icon_state = "anom"
mech_sized = TRUE
/obj/effect/portal/wormhole/teleport(atom/movable/M)
if(iseffect(M)) //sparks don't teleport
return
if(M.anchored)
if(!(ismecha(M) && mech_sized))
return
if(ismovable(M))
if(GLOB.portals.len)
var/obj/effect/portal/P = pick(GLOB.portals)
if(P && isturf(P.loc))
hard_target = P.loc
if(!hard_target)
return
do_teleport(M, hard_target, 1, 1, 0, 0, channel = TELEPORT_CHANNEL_WORMHOLE) ///You will appear adjacent to the beacon