Skip to content

Commit

Permalink
Xenobiology features
Browse files Browse the repository at this point in the history
  • Loading branch information
Zap-zapper committed Jan 23, 2020
1 parent 42076b1 commit 969fd27
Show file tree
Hide file tree
Showing 19 changed files with 840 additions and 112 deletions.
7 changes: 7 additions & 0 deletions code/__DEFINES/components.dm
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,10 @@
// /atom/movable signals
#define COMSIG_MOVABLE_CROSSED "movable_crossed" //from base of atom/movable/Crossed(): (/atom/movable)
#define COMSIG_MOVABLE_MOVED "movable_moved" //from base of atom/movable/Moved(): (/atom, dir)


#define COMSIG_XENO_SLIME_CLICK_CTRL "xeno_slime_click_ctrl" //from slime CtrlClickOn(): (/mob)
#define COMSIG_XENO_SLIME_CLICK_SHIFT "xeno_slime_click_shift" //from slime ShiftClickOn(): (/mob)
#define COMSIG_XENO_TURF_CLICK_SHIFT "xeno_turf_click_shift" //from turf ShiftClickOn(): (/mob)
#define COMSIG_XENO_TURF_CLICK_CTRL "xeno_turf_click_alt" //from turf AltClickOn(): (/mob)
#define COMSIG_XENO_MONKEY_CLICK_CTRL "xeno_monkey_click_ctrl" //from monkey CtrlClickOn(): (/mob)
4 changes: 4 additions & 0 deletions code/__DEFINES/maps.dm
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
#define ZTRAITS_SPACE list(ZTRAIT_LINKAGE = CROSSLINKED, ZTRAIT_SPACE_RUINS = TRUE)
#define ZTRAITS_ASTEROID list(ZTRAIT_LINKAGE = CROSSLINKED, ZTRAIT_MINING = TRUE)

#define CAMERA_LOCK_STATION 1
#define CAMERA_LOCK_MINING 2
#define CAMERA_LOCK_CENTCOM 4

#define DL_NAME "name"
#define DL_TRAITS "traits"
#define DECLARE_LEVEL(NAME, TRAITS) list(DL_NAME = NAME, DL_TRAITS = TRAITS)
Expand Down
236 changes: 236 additions & 0 deletions code/game/machinery/camera/camera_advanced.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,236 @@
/obj/machinery/computer/camera_advanced
name = "advanced camera console"
desc = "Used to access the various cameras on the station."
icon_state = "cameras"
var/list/z_lock = list() // Lock use to these z levels
var/lock_override = NONE
var/mob/camera/Eye/remote/eyeobj
var/mob/living/current_user = null
var/list/networks = list("ss13")
var/datum/action/camera_off/off_action = new
var/datum/action/camera_jump/jump_action = new
var/list/actions = list()

circuit = /obj/item/weapon/circuitboard/camera_advanced

light_color = "#a91515"

/obj/machinery/computer/camera_advanced/atom_init()
. = ..()
for(var/i in networks)
networks -= i
networks += lowertext(i)
if(lock_override)
if(lock_override & CAMERA_LOCK_STATION)
z_lock |= SSmapping.levels_by_trait(ZTRAIT_STATION)
if(lock_override & CAMERA_LOCK_MINING)
z_lock |= SSmapping.levels_by_trait(ZTRAIT_MINING)
if(lock_override & CAMERA_LOCK_CENTCOM)
z_lock |= SSmapping.levels_by_trait(ZTRAIT_CENTCOM)

/obj/machinery/computer/camera_advanced/proc/CreateEye()
eyeobj = new()
eyeobj.origin = src

/obj/machinery/computer/camera_advanced/proc/GrantActions(mob/living/user)
if(off_action)
off_action.target = user
off_action.Grant(user)
actions += off_action

if(jump_action)
jump_action.target = user
jump_action.Grant(user)
actions += jump_action

/obj/machinery/proc/remove_eye_control(mob/living/user)
CRASH("[type] does not implement ai eye handling")

/obj/machinery/computer/camera_advanced/remove_eye_control(mob/living/user)
if(!user)
return
for(var/V in actions)
var/datum/action/A = V
A.Remove(user)
actions.Cut()
for(var/V in eyeobj.visibleCameraChunks)
var/datum/camerachunk/C = V
C.remove(eyeobj)
if(user.client)
user.reset_view(null)
if(eyeobj.visible_icon && user.client)
user.client.images -= eyeobj.user_image
eyeobj.master = null
user.remote_control = null

current_user = null
user.unset_machine()

/obj/machinery/computer/camera_advanced/check_eye(mob/user)
if( (stat & (NOPOWER|BROKEN)) || (!Adjacent(user) && !user.has_unlimited_silicon_privilege) || user.eye_blind || user.incapacitated() )
user.unset_machine()
return FALSE
return TRUE

/obj/machinery/computer/camera_advanced/Destroy()
if(current_user)
current_user.unset_machine()
if(eyeobj)
qdel(eyeobj)
QDEL_LIST(actions)
return ..()

/obj/machinery/computer/camera_advanced/on_unset_machine(mob/M)
if(M == current_user)
remove_eye_control(M)
..()

/obj/machinery/computer/camera_advanced/proc/can_use(mob/living/user)
return TRUE

/obj/machinery/computer/camera_advanced/abductor/can_use(mob/user)
if(!isabductor(user))
return FALSE
return ..()

/obj/machinery/computer/camera_advanced/interact(mob/user)
user.machine = src
var/mob/living/L = user

if(!can_use(user))
return
if(!eyeobj)
CreateEye()

if(!eyeobj.eye_initialized)
var/camera_location
var/turf/myturf = get_turf(src)
camera_location = myturf
if(z_lock.len && !(myturf.z in z_lock))
camera_location = locate(round(world.maxx/2), round(world.maxy/2), z_lock[1])

if(camera_location)
eyeobj.eye_initialized = TRUE
give_eye_control(L)
eyeobj.setLoc(camera_location)
else
user.unset_machine()
else
give_eye_control(L)
eyeobj.setLoc(eyeobj.loc)


/obj/machinery/computer/camera_advanced/attack_hand(mob/user)
if(!is_operational())
return
if(current_user)
to_chat(user, "<span class='warning'>The console is already in use!</span>")
return
..()

/obj/machinery/computer/camera_advanced/attack_robot(mob/user)
return attack_hand(user)

/obj/machinery/computer/camera_advanced/attack_ai(mob/user)
return //AIs would need to disable their own camera procs to use the console safely. Bugs happen otherwise.

/obj/machinery/computer/camera_advanced/proc/give_eye_control(mob/user)
GrantActions(user)
current_user = user
eyeobj.master = user
eyeobj.name = "Camera Eye ([user.name])"
user.remote_control = eyeobj
user.reset_view(eyeobj)
eyeobj.setLoc(eyeobj.loc)
if(eyeobj.visible_icon && user.client)
user.client.images += eyeobj.user_image

/mob/camera/Eye/remote
name = "Inactive Camera Eye"
var/sprint = 10
var/cooldown = 0
var/acceleration = 0
var/obj/machinery/origin
var/eye_initialized = 0
var/visible_icon = 0
var/image/user_image = null


/mob/camera/Eye/remote/Destroy()
if(origin && master)
origin.remove_eye_control(master,src)
origin = null
master = null
. = ..()

/mob/camera/Eye/remote/atom_init()
if(!user_image && visible_icon)
user_image = image(icon,src,icon_state,LIGHTING_LAYER+1)
. = ..()


/mob/camera/Eye/remote/relaymove(mob/user,direct)
var/initial = initial(sprint)
var/max_sprint = 50

if(cooldown && cooldown < world.timeofday) // 3 seconds
sprint = initial

for(var/i = 0; i < max(sprint, initial); i += 20)
var/turf/step = get_turf(get_step(src, direct))
if(step)
setLoc(step)

cooldown = world.timeofday + 5
if(acceleration)
sprint = min(sprint + 0.5, max_sprint)
else
sprint = initial

/datum/action/camera_off
name = "End Camera View"
button_icon = 'icons/mob/actions.dmi'
button_icon_state = "camera_off"
action_type = AB_INNATE

/datum/action/camera_off/Activate()
if(!target || !isliving(target))
return
var/mob/living/C = target
var/mob/camera/Eye/remote/remote_eye = C.remote_control
var/obj/machinery/computer/camera_advanced/console = remote_eye.origin
console.remove_eye_control(target)

/datum/action/camera_jump
name = "Jump To Camera"
button_icon = 'icons/mob/actions.dmi'
button_icon_state = "camera_jump"
action_type = AB_INNATE

/datum/action/camera_jump/Activate()
if(!target || !isliving(target))
return
var/mob/living/C = target
var/mob/camera/Eye/remote/remote_eye = C.remote_control
var/obj/machinery/computer/camera_advanced/origin = remote_eye.origin

var/list/L = list()

for (var/obj/machinery/camera/cam in cameranet.cameras)
if(origin.z_lock.len && !(cam.z in origin.z_lock))
continue
L.Add(cam)

camera_sort(L)

var/list/T = list()

for (var/obj/machinery/camera/netcam in L)
var/list/tempnetwork = netcam.network & origin.networks
if (tempnetwork.len)
T["[netcam.c_tag][netcam.can_use() ? null : " (Deactivated)"]"] = netcam

var/camera = input("Choose which camera you want to view", "Cameras") as null|anything in T
var/obj/machinery/camera/final = T[camera]
if(final)
remote_eye.setLoc(get_turf(final))
8 changes: 8 additions & 0 deletions code/game/machinery/computer/buildandrepair.dm
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@
name = "Circuit board (Message Monitor)"
build_path = /obj/machinery/computer/message_monitor
origin_tech = "programming=3"
/obj/item/weapon/circuitboard/camera_advanced
name = "circuit board (Advanced Camera Console)"
build_path = /obj/machinery/computer/camera_advanced
req_access = list(access_security)
/obj/item/weapon/circuitboard/camera_advanced/xenobio
name = "circuit board (Slime management console)"
build_path = /obj/machinery/computer/camera_advanced/xenobio
origin_tech = "biotech=3;bluespace=3"
/obj/item/weapon/circuitboard/security
name = "Circuit board (Security)"
build_path = /obj/machinery/computer/security
Expand Down

0 comments on commit 969fd27

Please sign in to comment.