mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-10 17:04:36 +00:00
* Change transmission_method to use defines rather than magic numbers * Use MIN and MAX_FREE_FREQ defines when bounds-checking radios * Remove violently broken "Debug Signals" verb The relevant Destroy() is never called, making the static pointers list take lots of memory and be large enough, even at roundstart, to crash the chat when invoked (25k+ entries). * Remove unnecessary checks for SSradio not existing * Move department frequencies from GLOB to defines * Replace all hardcoded radio frequencies with named defines * Change the radio filters to be defines * Use a define for the default signaler code
235 lines
7.9 KiB
Plaintext
235 lines
7.9 KiB
Plaintext
|
|
#define SOURCE_PORTAL 1
|
|
#define DESTINATION_PORTAL 2
|
|
|
|
/* Teleportation devices.
|
|
* Contains:
|
|
* Locator
|
|
* Hand-tele
|
|
*/
|
|
|
|
/*
|
|
* Locator
|
|
*/
|
|
/obj/item/locator
|
|
name = "locator"
|
|
desc = "Used to track those with locater implants."
|
|
icon = 'icons/obj/device.dmi'
|
|
icon_state = "locator"
|
|
var/temp = null
|
|
var/frequency = FREQ_LOCATOR_IMPLANT
|
|
var/broadcasting = null
|
|
var/listening = 1
|
|
flags_1 = CONDUCT_1
|
|
w_class = WEIGHT_CLASS_SMALL
|
|
item_state = "electronic"
|
|
lefthand_file = 'icons/mob/inhands/misc/devices_lefthand.dmi'
|
|
righthand_file = 'icons/mob/inhands/misc/devices_righthand.dmi'
|
|
throw_speed = 3
|
|
throw_range = 7
|
|
materials = list(MAT_METAL=400)
|
|
|
|
/obj/item/locator/attack_self(mob/user)
|
|
user.set_machine(src)
|
|
var/dat
|
|
if (src.temp)
|
|
dat = "[src.temp]<BR><BR><A href='byond://?src=[REF(src)];temp=1'>Clear</A>"
|
|
else
|
|
dat = {"
|
|
<B>Persistent Signal Locator</B><HR>
|
|
Frequency:
|
|
<A href='byond://?src=[REF(src)];freq=-10'>-</A>
|
|
<A href='byond://?src=[REF(src)];freq=-2'>-</A> [format_frequency(src.frequency)]
|
|
<A href='byond://?src=[REF(src)];freq=2'>+</A>
|
|
<A href='byond://?src=[REF(src)];freq=10'>+</A><BR>
|
|
|
|
<A href='?src=[REF(src)];refresh=1'>Refresh</A>"}
|
|
user << browse(dat, "window=radio")
|
|
onclose(user, "radio")
|
|
return
|
|
|
|
/obj/item/locator/Topic(href, href_list)
|
|
..()
|
|
if (usr.stat || usr.restrained())
|
|
return
|
|
var/turf/current_location = get_turf(usr)//What turf is the user on?
|
|
if(!current_location || current_location.z == ZLEVEL_CENTCOM)//If turf was not found or they're on CentCom
|
|
to_chat(usr, "[src] is malfunctioning.")
|
|
return
|
|
if(usr.contents.Find(src) || (in_range(src, usr) && isturf(loc)))
|
|
usr.set_machine(src)
|
|
if (href_list["refresh"])
|
|
src.temp = "<B>Persistent Signal Locator</B><HR>"
|
|
var/turf/sr = get_turf(src)
|
|
|
|
if (sr)
|
|
src.temp += "<B>Located Beacons:</B><BR>"
|
|
|
|
for(var/obj/item/device/radio/beacon/W in GLOB.teleportbeacons)
|
|
if (W.frequency == src.frequency)
|
|
var/turf/tr = get_turf(W)
|
|
if (tr.z == sr.z && tr)
|
|
var/direct = max(abs(tr.x - sr.x), abs(tr.y - sr.y))
|
|
if (direct < 5)
|
|
direct = "very strong"
|
|
else
|
|
if (direct < 10)
|
|
direct = "strong"
|
|
else
|
|
if (direct < 20)
|
|
direct = "weak"
|
|
else
|
|
direct = "very weak"
|
|
src.temp += "[W.code]-[dir2text(get_dir(sr, tr))]-[direct]<BR>"
|
|
|
|
src.temp += "<B>Extranneous Signals:</B><BR>"
|
|
for (var/obj/item/implant/tracking/W in GLOB.tracked_implants)
|
|
if (!W.imp_in || !ismob(W.loc))
|
|
continue
|
|
else
|
|
var/mob/M = W.loc
|
|
if (M.stat == DEAD)
|
|
if (M.timeofdeath + 6000 < world.time)
|
|
continue
|
|
|
|
var/turf/tr = get_turf(W)
|
|
if (tr.z == sr.z && tr)
|
|
var/direct = max(abs(tr.x - sr.x), abs(tr.y - sr.y))
|
|
if (direct < 20)
|
|
if (direct < 5)
|
|
direct = "very strong"
|
|
else
|
|
if (direct < 10)
|
|
direct = "strong"
|
|
else
|
|
direct = "weak"
|
|
src.temp += "[W.imp_in.name]-[dir2text(get_dir(sr, tr))]-[direct]<BR>"
|
|
|
|
src.temp += "<B>You are at \[[sr.x],[sr.y],[sr.z]\]</B> in orbital coordinates.<BR><BR><A href='byond://?src=[REF(src)];refresh=1'>Refresh</A><BR>"
|
|
else
|
|
src.temp += "<B><FONT color='red'>Processing Error:</FONT></B> Unable to locate orbital position.<BR>"
|
|
else
|
|
if (href_list["freq"])
|
|
src.frequency += text2num(href_list["freq"])
|
|
src.frequency = sanitize_frequency(src.frequency)
|
|
else
|
|
if (href_list["temp"])
|
|
src.temp = null
|
|
if (ismob(src.loc))
|
|
attack_self(src.loc)
|
|
else
|
|
for(var/mob/M in viewers(1, src))
|
|
if (M.client)
|
|
src.attack_self(M)
|
|
return
|
|
|
|
|
|
/*
|
|
* Hand-tele
|
|
*/
|
|
/obj/item/hand_tele
|
|
name = "hand tele"
|
|
desc = "A portable item using blue-space technology."
|
|
icon = 'icons/obj/device.dmi'
|
|
icon_state = "hand_tele"
|
|
item_state = "electronic"
|
|
lefthand_file = 'icons/mob/inhands/misc/devices_lefthand.dmi'
|
|
righthand_file = 'icons/mob/inhands/misc/devices_righthand.dmi'
|
|
throwforce = 0
|
|
w_class = WEIGHT_CLASS_SMALL
|
|
throw_speed = 3
|
|
throw_range = 5
|
|
materials = list(MAT_METAL=10000)
|
|
armor = list(melee = 0, bullet = 0, laser = 0, energy = 0, bomb = 30, bio = 0, rad = 0, fire = 100, acid = 100)
|
|
resistance_flags = INDESTRUCTIBLE | LAVA_PROOF | FIRE_PROOF | ACID_PROOF
|
|
var/list/active_portal_pairs
|
|
var/max_portal_pairs = 3
|
|
|
|
/obj/item/hand_tele/Initialize()
|
|
. = ..()
|
|
active_portal_pairs = list()
|
|
|
|
/obj/item/hand_tele/pre_attackby(atom/target, mob/user, params)
|
|
if(try_dispel_portal(target, user))
|
|
return FALSE
|
|
return ..()
|
|
|
|
/obj/item/hand_tele/proc/try_dispel_portal(atom/target, mob/user)
|
|
if(is_parent_of_portal(target))
|
|
qdel(target)
|
|
to_chat(user, "<span class='notice'>You dispel [target] with \the [src]!</span>")
|
|
return TRUE
|
|
return FALSE
|
|
|
|
/obj/item/hand_tele/afterattack(atom/target, mob/user)
|
|
try_dispel_portal(target, user)
|
|
. = ..()
|
|
|
|
/obj/item/hand_tele/attack_self(mob/user)
|
|
var/turf/current_location = get_turf(user)//What turf is the user on?
|
|
var/area/current_area = current_location.loc
|
|
if(!current_location || current_area.noteleport || current_location.z > ZLEVEL_SPACEMAX || !isturf(user.loc))//If turf was not found or they're on z level 2 or >7 which does not currently exist. or if user is not located on a turf
|
|
to_chat(user, "<span class='notice'>\The [src] is malfunctioning.</span>")
|
|
return
|
|
var/list/L = list( )
|
|
for(var/obj/machinery/computer/teleporter/com in GLOB.machines)
|
|
if(com.target)
|
|
var/area/A = get_area(com.target)
|
|
if(!A || A.noteleport)
|
|
continue
|
|
if(com.power_station && com.power_station.teleporter_hub && com.power_station.engaged)
|
|
L["[get_area(com.target)] (Active)"] = com.target
|
|
else
|
|
L["[get_area(com.target)] (Inactive)"] = com.target
|
|
var/list/turfs = list( )
|
|
for(var/turf/T in urange(10, orange=1))
|
|
if(T.x>world.maxx-8 || T.x<8)
|
|
continue //putting them at the edge is dumb
|
|
if(T.y>world.maxy-8 || T.y<8)
|
|
continue
|
|
var/area/A = T.loc
|
|
if(A.noteleport)
|
|
continue
|
|
turfs += T
|
|
if(turfs.len)
|
|
L["None (Dangerous)"] = pick(turfs)
|
|
var/t1 = input(user, "Please select a teleporter to lock in on.", "Hand Teleporter") as null|anything in L
|
|
if (!t1 || user.get_active_held_item() != src || user.incapacitated())
|
|
return
|
|
if(active_portal_pairs.len >= max_portal_pairs)
|
|
user.show_message("<span class='notice'>\The [src] is recharging!</span>")
|
|
return
|
|
var/atom/T = L[t1]
|
|
var/area/A = get_area(T)
|
|
if(A.noteleport)
|
|
to_chat(user, "<span class='notice'>\The [src] is malfunctioning.</span>")
|
|
return
|
|
current_location = get_turf(user) //Recheck.
|
|
current_area = current_location.loc
|
|
if(!current_location || current_area.noteleport || current_location.z > ZLEVEL_SPACEMAX || !isturf(user.loc))//If turf was not found or they're on z level 2 or >7 which does not currently exist. or if user is not located on a turf
|
|
to_chat(user, "<span class='notice'>\The [src] is malfunctioning.</span>")
|
|
return
|
|
user.show_message("<span class='notice'>Locked In.</span>", 2)
|
|
var/list/obj/effect/portal/created = create_portal_pair(current_location, get_teleport_turf(get_turf(T)), src, 300, 1)
|
|
if(!(LAZYLEN(created) == 2))
|
|
return
|
|
try_move_adjacent(created[1])
|
|
active_portal_pairs[created[1]] = created[2]
|
|
var/obj/effect/portal/c1 = created[1]
|
|
var/obj/effect/portal/c2 = created[2]
|
|
investigate_log("was used by [key_name(user)] at [COORD(user)] to create a portal pair with destinations [COORD(c1)] and [COORD(c2)].", INVESTIGATE_PORTAL)
|
|
add_fingerprint(user)
|
|
|
|
/obj/item/hand_tele/proc/on_portal_destroy(obj/effect/portal/P)
|
|
active_portal_pairs -= P //If this portal pair is made by us it'll be erased along with the other portal by the portal.
|
|
|
|
/obj/item/hand_tele/proc/is_parent_of_portal(obj/effect/portal/P)
|
|
if(!istype(P))
|
|
return FALSE
|
|
if(active_portal_pairs[P])
|
|
return SOURCE_PORTAL
|
|
for(var/i in active_portal_pairs)
|
|
if(active_portal_pairs[i] == P)
|
|
return DESTINATION_PORTAL
|
|
return FALSE
|