mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-26 17:41:05 +00:00
* Converts A && A.B into A?.B (#54342) Implements the ?. operator, replacing code like A && A.B with A?.B BYOND Ref: When reading A?.B, it's equivalent to A && A.B except that A is only evaluated once, even if it's a complex expression like a proc call. * Converts all A && A.B into A?.B Co-authored-by: ZeWaka <zewakagamer@gmail.com>
177 lines
5.2 KiB
Plaintext
177 lines
5.2 KiB
Plaintext
#define PROXIMITY_NONE ""
|
|
#define PROXIMITY_ON_SCREEN "_red"
|
|
#define PROXIMITY_NEAR "_yellow"
|
|
|
|
/**
|
|
* Multitool -- A multitool is used for hacking electronic devices.
|
|
*
|
|
*/
|
|
|
|
|
|
|
|
|
|
/obj/item/multitool
|
|
name = "multitool"
|
|
desc = "Used for pulsing wires to test which to cut. Not recommended by doctors."
|
|
icon = 'icons/obj/device.dmi'
|
|
icon_state = "multitool"
|
|
inhand_icon_state = "multitool"
|
|
lefthand_file = 'icons/mob/inhands/equipment/tools_lefthand.dmi'
|
|
righthand_file = 'icons/mob/inhands/equipment/tools_righthand.dmi'
|
|
force = 5
|
|
w_class = WEIGHT_CLASS_SMALL
|
|
tool_behaviour = TOOL_MULTITOOL
|
|
throwforce = 0
|
|
throw_range = 7
|
|
throw_speed = 3
|
|
drop_sound = 'sound/items/handling/multitool_drop.ogg'
|
|
pickup_sound = 'sound/items/handling/multitool_pickup.ogg'
|
|
custom_materials = list(/datum/material/iron=50, /datum/material/glass=20)
|
|
custom_premium_price = 450
|
|
toolspeed = 1
|
|
usesound = 'sound/weapons/empty.ogg'
|
|
var/obj/machinery/buffer // simple machine buffer for device linkage
|
|
var/mode = 0
|
|
|
|
/obj/item/multitool/examine(mob/user)
|
|
. = ..()
|
|
. += "<span class='notice'>Its buffer [buffer ? "contains [buffer]." : "is empty."]</span>"
|
|
|
|
/obj/item/multitool/suicide_act(mob/living/carbon/user)
|
|
user.visible_message("<span class='suicide'>[user] puts the [src] to [user.p_their()] chest. It looks like [user.p_theyre()] trying to pulse [user.p_their()] heart off!</span>")
|
|
return OXYLOSS//theres a reason it wasn't recommended by doctors
|
|
|
|
|
|
// Syndicate device disguised as a multitool; it will turn red when an AI camera is nearby.
|
|
|
|
/obj/item/multitool/ai_detect
|
|
var/track_cooldown = 0
|
|
var/track_delay = 10 //How often it checks for proximity
|
|
var/detect_state = PROXIMITY_NONE
|
|
var/rangealert = 8 //Glows red when inside
|
|
var/rangewarning = 20 //Glows yellow when inside
|
|
var/hud_type = DATA_HUD_AI_DETECT
|
|
var/hud_on = FALSE
|
|
var/mob/camera/ai_eye/remote/ai_detector/eye
|
|
var/datum/action/item_action/toggle_multitool/toggle_action
|
|
|
|
/obj/item/multitool/ai_detect/Initialize()
|
|
. = ..()
|
|
START_PROCESSING(SSobj, src)
|
|
eye = new /mob/camera/ai_eye/remote/ai_detector()
|
|
toggle_action = new /datum/action/item_action/toggle_multitool(src)
|
|
|
|
/obj/item/multitool/ai_detect/Destroy()
|
|
STOP_PROCESSING(SSobj, src)
|
|
if(hud_on && ismob(loc))
|
|
remove_hud(loc)
|
|
QDEL_NULL(toggle_action)
|
|
QDEL_NULL(eye)
|
|
return ..()
|
|
|
|
/obj/item/multitool/ai_detect/ui_action_click()
|
|
return
|
|
|
|
/obj/item/multitool/ai_detect/equipped(mob/living/carbon/human/user, slot)
|
|
..()
|
|
if(hud_on)
|
|
show_hud(user)
|
|
|
|
/obj/item/multitool/ai_detect/dropped(mob/living/carbon/human/user)
|
|
..()
|
|
if(hud_on)
|
|
remove_hud(user)
|
|
|
|
/obj/item/multitool/ai_detect/process()
|
|
if(track_cooldown > world.time)
|
|
return
|
|
detect_state = PROXIMITY_NONE
|
|
if(eye.eye_user)
|
|
eye.setLoc(get_turf(src))
|
|
multitool_detect()
|
|
update_icon()
|
|
track_cooldown = world.time + track_delay
|
|
|
|
/obj/item/multitool/ai_detect/proc/toggle_hud(mob/user)
|
|
hud_on = !hud_on
|
|
if(user)
|
|
to_chat(user, "<span class='notice'>You toggle the ai detection HUD on [src] [hud_on ? "on" : "off"].</span>")
|
|
if(hud_on)
|
|
show_hud(user)
|
|
else
|
|
remove_hud(user)
|
|
|
|
/obj/item/multitool/ai_detect/proc/show_hud(mob/user)
|
|
if(user && hud_type)
|
|
var/obj/screen/plane_master/camera_static/PM = user.hud_used.plane_masters["[CAMERA_STATIC_PLANE]"]
|
|
PM.alpha = 150
|
|
var/datum/atom_hud/H = GLOB.huds[hud_type]
|
|
if(!H.hudusers[user])
|
|
H.add_hud_to(user)
|
|
eye.eye_user = user
|
|
eye.setLoc(get_turf(src))
|
|
|
|
/obj/item/multitool/ai_detect/proc/remove_hud(mob/user)
|
|
if(user && hud_type)
|
|
var/obj/screen/plane_master/camera_static/PM = user.hud_used.plane_masters["[CAMERA_STATIC_PLANE]"]
|
|
PM.alpha = 255
|
|
var/datum/atom_hud/H = GLOB.huds[hud_type]
|
|
H.remove_hud_from(user)
|
|
if(eye)
|
|
eye.setLoc(null)
|
|
eye.eye_user = null
|
|
|
|
/obj/item/multitool/ai_detect/proc/multitool_detect()
|
|
var/turf/our_turf = get_turf(src)
|
|
for(var/mob/living/silicon/ai/AI in GLOB.ai_list)
|
|
if(AI.cameraFollow == src)
|
|
detect_state = PROXIMITY_ON_SCREEN
|
|
break
|
|
|
|
if(detect_state)
|
|
return
|
|
var/datum/camerachunk/chunk = GLOB.cameranet.chunkGenerated(our_turf.x, our_turf.y, our_turf.z)
|
|
if(chunk?.seenby.len)
|
|
for(var/mob/camera/ai_eye/A in chunk.seenby)
|
|
if(!A.ai_detector_visible)
|
|
continue
|
|
var/turf/detect_turf = get_turf(A)
|
|
if(get_dist(our_turf, detect_turf) < rangealert)
|
|
detect_state = PROXIMITY_ON_SCREEN
|
|
break
|
|
if(get_dist(our_turf, detect_turf) < rangewarning)
|
|
detect_state = PROXIMITY_NEAR
|
|
break
|
|
|
|
/mob/camera/ai_eye/remote/ai_detector
|
|
name = "AI detector eye"
|
|
ai_detector_visible = FALSE
|
|
use_static = USE_STATIC_TRANSPARENT
|
|
visible_icon = FALSE
|
|
|
|
/datum/action/item_action/toggle_multitool
|
|
name = "Toggle AI detector HUD"
|
|
check_flags = NONE
|
|
|
|
/datum/action/item_action/toggle_multitool/Trigger()
|
|
if(!..())
|
|
return 0
|
|
if(target)
|
|
var/obj/item/multitool/ai_detect/M = target
|
|
M.toggle_hud(owner)
|
|
return 1
|
|
|
|
/obj/item/multitool/abductor
|
|
name = "alien multitool"
|
|
desc = "An omni-technological interface."
|
|
icon = 'icons/obj/abductor.dmi'
|
|
icon_state = "multitool"
|
|
toolspeed = 0.1
|
|
|
|
/obj/item/multitool/cyborg
|
|
name = "electronic multitool"
|
|
desc = "Optimised version of a regular multitool. Streamlines processes handled by its internal microchip."
|
|
icon = 'icons/obj/items_cyborg.dmi'
|
|
icon_state = "multitool_cyborg"
|
|
toolspeed = 0.5
|