Skip to content
This repository has been archived by the owner on Oct 15, 2023. It is now read-only.

Commit

Permalink
feat: Changed AI/Cyborg laws upload (#23)
Browse files Browse the repository at this point in the history
* feat: Changed laws upload

* fix: Check if computer still exists

* fix: More conditions for stopping transmissions

* fix: Broken consoles don't speak

* feat: Cyborg upload requires Robotics access

* ref: Minor changes for readibility

* tweak: We have two hands, not one

* update tgui bundle

* ref: better proc for checking hands

* ref: Better checks

* ref: Aiupload argument

* ref: even better js?

* tgui bundle update

* tgui bundle update

* update maps

* fix: new refactored inventory logic
  • Loading branch information
larentoun committed Jun 27, 2023
1 parent 8363b6d commit f00ba83
Show file tree
Hide file tree
Showing 9 changed files with 263 additions and 128 deletions.
2 changes: 1 addition & 1 deletion _maps/map_files/Delta/delta.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -32709,7 +32709,7 @@
},
/area/construction/hallway)
"diX" = (
/obj/machinery/computer/borgupload{
/obj/machinery/computer/aiupload/cyborg{
dir = 1
},
/obj/item/radio/intercom/private{
Expand Down
2 changes: 1 addition & 1 deletion _maps/map_files/cerestation/cerestation.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -68489,7 +68489,7 @@
/obj/machinery/atmospherics/pipe/simple/hidden/scrubbers{
dir = 10
},
/obj/machinery/computer/borgupload{
/obj/machinery/computer/aiupload/cyborg{
dir = 1
},
/obj/machinery/door/window/eastright{
Expand Down
2 changes: 1 addition & 1 deletion _maps/map_files/cyberiad/cyberiad.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -29811,7 +29811,7 @@
/turf/simulated/floor/bluegrid,
/area/turret_protected/ai_upload)
"bCL" = (
/obj/machinery/computer/borgupload{
/obj/machinery/computer/aiupload/cyborg{
dir = 1
},
/obj/item/radio/intercom/private{
Expand Down
2 changes: 1 addition & 1 deletion _maps/map_files/generic/CentComm.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -35927,7 +35927,7 @@
},
/area/centcom/specops)
"rLk" = (
/obj/machinery/computer/borgupload,
/obj/machinery/computer/aiupload/cyborg,
/turf/simulated/floor/plasteel{
icon_state = "dark"
},
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/computer/buildandrepair.dm
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
origin_tech = "programming=4;engineering=4"
/obj/item/circuitboard/borgupload
name = "Circuit board (Cyborg Upload)"
build_path = /obj/machinery/computer/borgupload
build_path = /obj/machinery/computer/aiupload/cyborg
origin_tech = "programming=4;engineering=4"
/obj/item/circuitboard/med_data
name = "Circuit board (Medical Records)"
Expand Down
201 changes: 137 additions & 64 deletions code/game/machinery/computer/law.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
icon_screen = "command"
icon_keyboard = "med_key"
circuit = /obj/item/circuitboard/aiupload
var/mob/living/silicon/ai/current = null
var/opened = 0
var/authorization_access = ACCESS_AI_UPLOAD
var/mob/living/silicon/current = null
var/opened = FALSE
var/obj/item/aiModule/installed_module = null
var/obj/item/card/id/id = null
var/hacked = FALSE

light_color = LIGHT_COLOR_WHITE
light_range_on = 2


// What the fuck even is this
/obj/machinery/computer/aiupload/verb/AccessInternals()
set category = "Object"
Expand All @@ -26,84 +29,154 @@
to_chat(usr, "<span class='notice'>The access panel is now closed.</span>")
return


/obj/machinery/computer/aiupload/attackby(obj/item/O as obj, mob/user as mob, params)
/obj/machinery/computer/aiupload/attackby(obj/item/O, mob/user, params)
if(istype(O, /obj/item/aiModule))
if(!current)//no AI selected
to_chat(user, "<span class='danger'>No AI selected. Please chose a target before proceeding with upload.")
return
var/turf/T = get_turf(current)
if(!atoms_share_level(T, src))
to_chat(user, "<span class='danger'>Unable to establish a connection</span>: You're too far away from the target silicon!")
return
if(current.on_the_card)
to_chat(user, "<span class='danger'>Unable to establish a connection</span>: Target silicon is on an inteliCard or undergoing a repair procedure!")
return
add_fingerprint(user)
var/obj/item/aiModule/M = O
M.install(src)
install_module(user, O)
ui_interact(user)
return
if(istype(O, /obj/item/card/id))
check_id(user, O)
ui_interact(user)
return
return ..()


/obj/machinery/computer/aiupload/attack_hand(var/mob/user as mob)
/obj/machinery/computer/aiupload/attack_hand(mob/user)
if(src.stat & NOPOWER)
to_chat(usr, "The upload computer has no power!")
to_chat(usr, span_notice("The upload computer has no power!"))
return
if(src.stat & BROKEN)
to_chat(usr, "The upload computer is broken!")
to_chat(usr, span_notice("The upload computer is broken!"))
return
ui_interact(user)

src.current = select_active_ai(user)

if(!src.current)
to_chat(usr, "No active AIs detected.")
else
to_chat(usr, "[src.current.name] selected for law changes.")
return

/obj/machinery/computer/aiupload/attack_ghost(user as mob)
return 1
/obj/machinery/computer/aiupload/proc/choose_target(mob/user)
current = select_active_ai(user)
if(!current)
atom_say("No active AIs detected.")
return
to_chat(usr, span_notice("[current.name] selected for law changes."))

/obj/machinery/computer/aiupload/proc/install_module(mob/user, obj/item/aiModule/new_module)
if(installed_module)
if(!user.put_in_hands(installed_module))
installed_module.forceMove(get_turf(src))
installed_module = null
hacked = FALSE
if(!istype(new_module))
return
if(!user.drop_from_active_hand())
to_chat(usr, span_warning("[new_module] is stuck to your hand!"))
return
new_module.forceMove(src)
installed_module = new_module
if(istype(installed_module, /obj/item/aiModule/syndicate))
hacked = TRUE

/obj/machinery/computer/aiupload/proc/check_id(mob/user, obj/item/card/id/new_id)
if(id)
if(!user.put_in_hands(id))
id.forceMove(get_turf(src))
id = null
if(!istype(new_id))
return
if(!hacked)
if(!(authorization_access in new_id.access))
to_chat(usr, span_warning("Unauthorized access."))
return
if(!user.drop_from_active_hand())
to_chat(usr, span_warning("[new_id] is stuck to your hand!"))
return
new_id.forceMove(src)
id = new_id

// Why is this not a subtype
/obj/machinery/computer/borgupload
/obj/machinery/computer/aiupload/proc/upload_module()
if(!installed_module || !isAI(current) || (hacked ? FALSE : !id))
return
var/mob/living/silicon/ai/ai = current
if(!atoms_share_level(get_turf(ai), src))
to_chat(usr, span_notice("Unable to establish a connection: You're too far away from the target silicon!"))
return
if(ai.on_the_card)
to_chat(usr, span_notice("Unable to establish a connection: Target silicon is on an inteliCard or undergoing a repair procedure!"))
return
if(installed_module.transmitting)
installed_module.stopUpload(src)
return
installed_module.install(src, id?.registered_name)

/obj/machinery/computer/aiupload/power_change()
. = ..()
if(!powered())
if(installed_module?.transmitting)
installed_module.stopUpload(src, TRUE)

/obj/machinery/computer/aiupload/on_deconstruction()
. = ..()
if(installed_module?.transmitting)
installed_module.stopUpload(src, TRUE)

/obj/machinery/computer/aiupload/obj_break(damage_flag)
if(installed_module?.transmitting)
installed_module.stopUpload(src, TRUE)
. = ..()

/obj/machinery/computer/aiupload/ui_interact(mob/user, ui_key, datum/tgui/ui, force_open, datum/tgui/master_ui, datum/ui_state/state)
ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
if(!ui)
ui = new(user, src, ui_key, "UploadPanel", name, 450, 200, master_ui, state)
ui.open()

/obj/machinery/computer/aiupload/ui_data(mob/user)
var/list/data = list()
data["selected_target"] = current?.name
data["new_law"] = installed_module
data["id"] = id?.registered_name
data["transmitting"] = installed_module?.transmitting
data["hacked"] = hacked
return data

/obj/machinery/computer/aiupload/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
if(..())
return
if(issilicon(ui.user))
to_chat(usr, span_danger("Access Denied (silicon detected)"))
return
add_fingerprint(usr)
switch(action)
if("target_select")
choose_target(ui.user)
if("law_select")
install_module(ui.user, ui.user.get_active_hand())
if("authorization")
check_id(ui.user, ui.user.get_active_hand())
if("change_laws")
upload_module()

/obj/machinery/computer/aiupload/attack_ghost(mob/dead/observer/user)
return TRUE

/obj/machinery/computer/aiupload/cyborg
name = "cyborg upload console"
desc = "Used to upload laws to Cyborgs."
icon_screen = "command"
icon_keyboard = "med_key"
authorization_access = ACCESS_ROBOTICS
circuit = /obj/item/circuitboard/borgupload
var/mob/living/silicon/robot/current = null


/obj/machinery/computer/borgupload/attackby(obj/item/aiModule/module as obj, mob/user as mob, params)
if(istype(module, /obj/item/aiModule))
if(!current)//no borg selected
to_chat(user, "<span class='danger'>No borg selected. Please chose a target before proceeding with upload.")
return
var/turf/T = get_turf(current)
if(!atoms_share_level(T, src))
to_chat(user, "<span class='danger'>Unable to establish a connection</span>: You're too far away from the target silicon!")
return
module.install(src)
/obj/machinery/computer/aiupload/cyborg/choose_target(mob/user)
current = freeborg()
if(!current)
to_chat(usr, span_notice("No free cyborgs detected."))
return
return ..()
to_chat(usr, span_notice("[current.name] selected for law changes."))


/obj/machinery/computer/borgupload/attack_hand(var/mob/user as mob)
if(src.stat & NOPOWER)
to_chat(usr, "The upload computer has no power!")
/obj/machinery/computer/aiupload/cyborg/upload_module()
if(!installed_module || !isrobot(current) || (hacked ? FALSE : !id))
return
if(src.stat & BROKEN)
to_chat(usr, "The upload computer is broken!")
if(!atoms_share_level(get_turf(current), src))
to_chat(usr, span_notice("Unable to establish a connection: You're too far away from the target silicon!"))
return

src.current = freeborg()

if(!src.current)
to_chat(usr, "No free cyborgs detected.")
else
to_chat(usr, "[src.current.name] selected for law changes.")
return

/obj/machinery/computer/borgupload/attack_ghost(user as mob)
return 1
if(installed_module.transmitting)
installed_module.stopUpload(src)
return
installed_module.install(src, id?.registered_name)
Loading

0 comments on commit f00ba83

Please sign in to comment.