mirror of
https://github.com/vgstation-coders/vgstation13.git
synced 2025-12-10 18:32:03 +00:00
Multitool cloning. Add a device to a multitool's linking buffer, click on the multitool in your hand, and any other devices of said type will have ID and frequency "cloned". Currently works for the following things: * Unary vents. * DP vents. * Air injectors. * Emitters. * Scrubbers. See merge request !159
351 lines
12 KiB
Plaintext
351 lines
12 KiB
Plaintext
var/global/list/reagents_to_log = list("fuel" = "welder fuel", "plasma"= "plasma", "pacid" = "polytrinic acid", "sacid" = "sulphuric acid" )
|
|
/obj
|
|
var/origin_tech = null //Used by R&D to determine what research bonuses it grants.
|
|
var/reliability = 100 //Used by SOME devices to determine how reliable they are.
|
|
var/crit_fail = 0
|
|
var/unacidable = 0 //universal "unacidabliness" var, here so you can use it in any obj.
|
|
animate_movement = 2
|
|
var/throwforce = 1
|
|
var/siemens_coefficient = 0 // for electrical admittance/conductance (electrocution checks and shit) - 0 is not conductive, 1 is conductive - this is a range, not binary
|
|
var/sharpness = 0 //not a binary - rough guide is 0.8 cutting, 1 cutting well, 1.2 specifically sharp (knives, etc) 1.5 really sharp (scalpels, e-weapons)
|
|
var/heat_production = 0
|
|
|
|
var/edge = 0
|
|
var/in_use = 0 // If we have a user using us, this will be set on. We will check if the user has stopped using us, and thus stop updating and LAGGING EVERYTHING!
|
|
|
|
var/damtype = "brute"
|
|
var/force = 0
|
|
|
|
//Should we alert about reagents that should be logged?
|
|
var/log_reagents = 1
|
|
|
|
var/list/mob/_using // All mobs dicking with us.
|
|
|
|
// Shit for mechanics. (MECH_*)
|
|
var/mech_flags=0
|
|
|
|
/obj/Destroy()
|
|
for(var/mob/user in _using)
|
|
user.unset_machine()
|
|
|
|
if(src in processing_objects)
|
|
processing_objects -= src
|
|
|
|
..()
|
|
|
|
/obj/item/proc/is_used_on(obj/O, mob/user)
|
|
//writepanic("[__FILE__].[__LINE__] ([src.type])([usr ? usr.ckey : ""]) \\/obj/item/proc/is_used_on() called tick#: [world.time]")
|
|
|
|
/obj/recycle(var/datum/materials/rec)
|
|
if(..())
|
|
return 1
|
|
return w_type
|
|
|
|
/*
|
|
/obj/melt()
|
|
var/obj/effect/decal/slag/slag=locate(/obj/effect/decal/slag) in get_turf(src)
|
|
if(!slag)
|
|
slag = new(get_turf(src))
|
|
slag.slaggify(src)
|
|
*/
|
|
|
|
/obj/proc/is_conductor(var/siemens_min = 0.5)
|
|
//writepanic("[__FILE__].[__LINE__] ([src.type])([usr ? usr.ckey : ""]) \\/obj/proc/is_conductor() called tick#: [world.time]")
|
|
if(src.siemens_coefficient >= siemens_min)
|
|
return 1
|
|
return
|
|
|
|
/obj/proc/cultify()
|
|
//writepanic("[__FILE__].[__LINE__] ([src.type])([usr ? usr.ckey : ""]) \\/obj/proc/cultify() called tick#: [world.time]")
|
|
qdel(src)
|
|
|
|
/obj/proc/is_sharp()
|
|
//writepanic("[__FILE__].[__LINE__] ([src.type])([usr ? usr.ckey : ""]) \\/obj/proc/is_sharp() called tick#: [world.time]")
|
|
return sharpness
|
|
|
|
/obj/proc/is_hot()
|
|
//writepanic("[__FILE__].[__LINE__] ([src.type])([usr ? usr.ckey : ""]) \\/obj/proc/is_hot() called tick#: [world.time]")
|
|
return heat_production
|
|
|
|
/obj/proc/process()
|
|
//writepanic("[__FILE__].[__LINE__] ([src.type])([usr ? usr.ckey : ""]) \\/obj/proc/process() called tick#: [world.time]")
|
|
processing_objects.Remove(src)
|
|
|
|
/obj/assume_air(datum/gas_mixture/giver)
|
|
if(loc)
|
|
return loc.assume_air(giver)
|
|
else
|
|
return null
|
|
|
|
/obj/remove_air(amount)
|
|
if(loc)
|
|
return loc.remove_air(amount)
|
|
else
|
|
return null
|
|
|
|
/obj/return_air()
|
|
if(loc)
|
|
return loc.return_air()
|
|
else
|
|
return null
|
|
|
|
/obj/proc/handle_internal_lifeform(mob/lifeform_inside_me, breath_request)
|
|
//writepanic("[__FILE__].[__LINE__] ([src.type])([usr ? usr.ckey : ""]) \\/obj/proc/handle_internal_lifeform() called tick#: [world.time]")
|
|
//Return: (NONSTANDARD)
|
|
// null if object handles breathing logic for lifeform
|
|
// datum/air_group to tell lifeform to process using that breath return
|
|
//DEFAULT: Take air from turf to give to have mob process
|
|
if(breath_request>0)
|
|
return remove_air(breath_request)
|
|
else
|
|
return null
|
|
|
|
/atom/movable/proc/initialize()
|
|
//writepanic("[__FILE__].[__LINE__] ([src.type])([usr ? usr.ckey : ""]) \\/atom/movable/proc/initialize() called tick#: [world.time]")
|
|
return
|
|
|
|
/obj/proc/updateUsrDialog()
|
|
//writepanic("[__FILE__].[__LINE__] ([src.type])([usr ? usr.ckey : ""]) \\/obj/proc/updateUsrDialog() called tick#: [world.time]")
|
|
if(in_use)
|
|
var/is_in_use = 0
|
|
if(_using && _using.len)
|
|
var/list/nearby = viewers(1, src)
|
|
for(var/mob/M in _using) // Only check things actually messing with us.
|
|
if (!M || !M.client || M.machine != src)
|
|
_using.Remove(M)
|
|
continue
|
|
|
|
if(!M in nearby) // NOT NEARBY
|
|
// AIs/Robots can do shit from afar.
|
|
if (isAI(M) || isrobot(M))
|
|
is_in_use = 1
|
|
src.attack_ai(M)
|
|
|
|
// check for TK users
|
|
if(M.mutations && M.mutations.len)
|
|
if(M_TK in M.mutations)
|
|
is_in_use = 1
|
|
src.attack_hand(M, TRUE) // The second param is to make sure brain damage on the user doesn't cause the UI to not update but the action to still happen.
|
|
else
|
|
// Remove.
|
|
_using.Remove(M)
|
|
continue
|
|
else // EVERYTHING FROM HERE DOWN MUST BE NEARBY
|
|
is_in_use = 1
|
|
attack_hand(M, TRUE)
|
|
in_use = is_in_use
|
|
|
|
/obj/proc/updateDialog()
|
|
//writepanic("[__FILE__].[__LINE__] ([src.type])([usr ? usr.ckey : ""]) \\/obj/proc/updateDialog() called tick#: [world.time]")
|
|
// Check that people are actually using the machine. If not, don't update anymore.
|
|
if(in_use)
|
|
var/list/nearby = viewers(1, src)
|
|
var/is_in_use = 0
|
|
for(var/mob/M in _using) // Only check things actually messing with us.
|
|
// Not actually using the fucking thing?
|
|
if (!M || !M.client || M.machine != src)
|
|
_using.Remove(M)
|
|
continue
|
|
// Not robot or AI, and not nearby?
|
|
if(!isAI(M) && !isrobot(M) && !(M in nearby))
|
|
_using.Remove(M)
|
|
continue
|
|
is_in_use = 1
|
|
src.interact(M)
|
|
in_use = is_in_use
|
|
|
|
/obj/proc/interact(mob/user)
|
|
//writepanic("[__FILE__].[__LINE__] ([src.type])([usr ? usr.ckey : ""]) \\/obj/proc/interact() called tick#: [world.time]")
|
|
return
|
|
|
|
/obj/singularity_act()
|
|
ex_act(1)
|
|
if(src)
|
|
qdel(src)
|
|
return 2
|
|
|
|
/obj/shuttle_act(datum/shuttle/S)
|
|
return qdel(src)
|
|
|
|
/obj/singularity_pull(S, current_size)
|
|
if(anchored)
|
|
if(current_size >= STAGE_FIVE)
|
|
anchored = 0
|
|
step_towards(src, S)
|
|
else step_towards(src, S)
|
|
|
|
/obj/proc/multitool_menu(var/mob/user,var/obj/item/device/multitool/P)
|
|
//writepanic("[__FILE__].[__LINE__] ([src.type])([usr ? usr.ckey : ""]) \\/obj/proc/multitool_menu() called tick#: [world.time]")
|
|
return "<b>NO MULTITOOL_MENU!</b>"
|
|
|
|
/obj/proc/linkWith(var/mob/user, var/obj/buffer, var/link/context)
|
|
//writepanic("[__FILE__].[__LINE__] ([src.type])([usr ? usr.ckey : ""]) \\/obj/proc/linkWith() called tick#: [world.time]")
|
|
return 0
|
|
|
|
/obj/proc/unlinkFrom(var/mob/user, var/obj/buffer)
|
|
//writepanic("[__FILE__].[__LINE__] ([src.type])([usr ? usr.ckey : ""]) \\/obj/proc/unlinkFrom() called tick#: [world.time]")
|
|
return 0
|
|
|
|
/obj/proc/canLink(var/obj/O, var/link/context)
|
|
//writepanic("[__FILE__].[__LINE__] ([src.type])([usr ? usr.ckey : ""]) \\/obj/proc/canLink() called tick#: [world.time]")
|
|
return 0
|
|
|
|
/obj/proc/isLinkedWith(var/obj/O)
|
|
//writepanic("[__FILE__].[__LINE__] ([src.type])([usr ? usr.ckey : ""]) \\/obj/proc/isLinkedWith() called tick#: [world.time]")
|
|
return 0
|
|
|
|
/obj/proc/getLink(var/idx)
|
|
//writepanic("[__FILE__].[__LINE__] ([src.type])([usr ? usr.ckey : ""]) \\/obj/proc/getLink() called tick#: [world.time]")
|
|
return null
|
|
|
|
/obj/proc/canClone(var/obj/O)
|
|
return 0
|
|
|
|
/obj/proc/clone(var/obj/O)
|
|
return 0
|
|
|
|
/obj/proc/linkMenu(var/obj/O)
|
|
//writepanic("[__FILE__].[__LINE__] ([src.type])([usr ? usr.ckey : ""]) \\/obj/proc/linkMenu() called tick#: [world.time]")
|
|
var/dat=""
|
|
if(canLink(O, list()))
|
|
dat += " <a href='?src=\ref[src];link=1'>\[Link\]</a> "
|
|
return dat
|
|
|
|
/obj/proc/format_tag(var/label,var/varname, var/act="set_tag")
|
|
//writepanic("[__FILE__].[__LINE__] ([src.type])([usr ? usr.ckey : ""]) \\/obj/proc/format_tag() called tick#: [world.time]")
|
|
var/value = vars[varname]
|
|
if(!value || value=="")
|
|
value="-----"
|
|
return "<b>[label]:</b> <a href=\"?src=\ref[src];[act]=[varname]\">[value]</a>"
|
|
|
|
|
|
/obj/proc/update_multitool_menu(mob/user as mob)
|
|
//writepanic("[__FILE__].[__LINE__] ([src.type])([usr ? usr.ckey : ""]) \\/obj/proc/update_multitool_menu() called tick#: [world.time]")
|
|
var/obj/item/device/multitool/P = get_multitool(user)
|
|
|
|
if(!istype(P))
|
|
return 0
|
|
|
|
// Cloning stuff goes here.
|
|
if(P.clone && P.buffer) // Cloning is on.
|
|
if(!canClone(P.buffer))
|
|
user << "<span class='attack'>A red light flashes on \the [P]; you cannot clone to this device!</span>"
|
|
return
|
|
|
|
if(!clone(P.buffer))
|
|
user << "<span class='attack'>A red light flashes on \the [P]; something went wrong when cloning to this device!</span>"
|
|
return
|
|
|
|
user << "<span class='confirm'>A green light flashes on \the [P], confirming the device was cloned to.</span>"
|
|
return
|
|
|
|
var/dat = {"<html>
|
|
<head>
|
|
<title>[name] Configuration</title>
|
|
<style type="text/css">
|
|
html,body {
|
|
font-family:courier;
|
|
background:#999999;
|
|
color:#333333;
|
|
}
|
|
|
|
a {
|
|
color:#000000;
|
|
text-decoration:none;
|
|
border-bottom:1px solid black;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h3>[name]</h3>
|
|
"}
|
|
dat += multitool_menu(user,P)
|
|
if(P)
|
|
if(P.buffer)
|
|
var/id = null
|
|
if(istype(P.buffer, /obj/machinery/telecomms))
|
|
var/obj/machinery/telecomms/buffer = P.buffer//Casting is better than using colons
|
|
id = buffer.id
|
|
else if(P.buffer.vars["id_tag"])//not doing in vars here incase the var is empty, it'd show ()
|
|
id = P.buffer:id_tag//sadly, : is needed
|
|
|
|
dat += "<p><b>MULTITOOL BUFFER:</b> [P.buffer] [id ? "([id])" : ""]"//If you can't into the ? operator, that will make it not display () if there's no ID.
|
|
|
|
dat += linkMenu(P.buffer)
|
|
|
|
if(P.buffer)
|
|
dat += "<a href='?src=\ref[src];flush=1'>\[Flush\]</a>"
|
|
dat += "</p>"
|
|
else
|
|
dat += "<p><b>MULTITOOL BUFFER:</b> <a href='?src=\ref[src];buffer=1'>\[Add Machine\]</a></p>"
|
|
dat += "</body></html>"
|
|
user << browse(dat, "window=mtcomputer")
|
|
user.set_machine(src)
|
|
onclose(user, "mtcomputer")
|
|
|
|
/obj/proc/update_icon()
|
|
//writepanic("[__FILE__].[__LINE__] ([src.type])([usr ? usr.ckey : ""]) \\/obj/proc/update_icon() called tick#: [world.time]")
|
|
return
|
|
|
|
/mob/proc/unset_machine()
|
|
//writepanic("[__FILE__].[__LINE__] ([src.type])([usr ? usr.ckey : ""]) \\/mob/proc/unset_machine() called tick#: [world.time]")
|
|
if(machine)
|
|
if(machine._using)
|
|
machine._using -= src
|
|
|
|
if(!machine._using.len)
|
|
machine._using = null
|
|
|
|
machine = null
|
|
|
|
/mob/proc/set_machine(const/obj/O)
|
|
//writepanic("[__FILE__].[__LINE__] ([src.type])([usr ? usr.ckey : ""]) \\/mob/proc/set_machine() called tick#: [world.time]")
|
|
unset_machine()
|
|
|
|
if(istype(O))
|
|
machine = O
|
|
|
|
if(!machine._using)
|
|
machine._using = new
|
|
|
|
machine._using += src
|
|
machine.in_use = 1
|
|
|
|
/obj/item/proc/updateSelfDialog()
|
|
//writepanic("[__FILE__].[__LINE__] ([src.type])([usr ? usr.ckey : ""]) \\/obj/item/proc/updateSelfDialog() called tick#: [world.time]")
|
|
var/mob/M = src.loc
|
|
if(istype(M) && M.client && M.machine == src)
|
|
src.attack_self(M)
|
|
|
|
|
|
/obj/proc/alter_health()
|
|
//writepanic("[__FILE__].[__LINE__] ([src.type])([usr ? usr.ckey : ""]) \\/obj/proc/alter_health() called tick#: [world.time]")
|
|
return 1
|
|
|
|
/obj/proc/hide(h)
|
|
//writepanic("[__FILE__].[__LINE__] ([src.type])([usr ? usr.ckey : ""]) \\/obj/proc/hide() called tick#: [world.time]")
|
|
return
|
|
|
|
/obj/proc/container_resist()
|
|
//writepanic("[__FILE__].[__LINE__] ([src.type])([usr ? usr.ckey : ""]) \\/obj/proc/container_resist() called tick#: [world.time]")
|
|
return
|
|
|
|
/obj/proc/can_pickup(mob/living/user)
|
|
//writepanic("[__FILE__].[__LINE__] ([src.type])([usr ? usr.ckey : ""]) \\/obj/proc/can_pickup() called tick#: [world.time]")
|
|
return 0
|
|
|
|
/obj/proc/verb_pickup(mob/living/user)
|
|
//writepanic("[__FILE__].[__LINE__] ([src.type])([usr ? usr.ckey : ""]) \\/obj/proc/verb_pickup() called tick#: [world.time]")
|
|
//writepanic("[__FILE__].[__LINE__] ([src.type])([usr ? usr.ckey : ""]) \\/obj/proc/verb_pickup() called tick#: [world.time]")
|
|
//writepanic("[__FILE__].[__LINE__] ([src.type])([usr ? usr.ckey : ""]) \\\\/obj/proc/verb_pickup() called tick#: [world.time]")
|
|
return 0
|
|
|
|
/**
|
|
* If a mob logouts/logins in side of an object you can use this proc.
|
|
*/
|
|
/obj/proc/on_log()
|
|
//writepanic("[__FILE__].[__LINE__] ([src.type])([usr ? usr.ckey : ""]) \\/obj/proc/on_log() called tick#: [world.time]")
|
|
if (isobj(loc))
|
|
var/obj/location = loc
|
|
location.on_log()
|