[MIRROR] Robot upgrades (#9412)

Co-authored-by: Kashargul <144968721+Kashargul@users.noreply.github.com>
This commit is contained in:
CHOMPStation2StaffMirrorBot
2024-11-05 00:28:01 -07:00
committed by GitHub
parent 040cbbe106
commit 302cc08221
13 changed files with 663 additions and 152 deletions

View File

@@ -89,6 +89,13 @@
.["target"]["components"] = get_components()
.["cell"] = list("name" = target.cell?.name, "charge" = target.cell?.charge, "maxcharge" = target.cell?.maxcharge)
.["cell_options"] = get_cells()
.["camera_options"] = get_component("camera")
.["radio_options"] = get_component("radio")
.["actuator_options"] = get_component("actuator")
.["diagnosis_options"] = get_component("diagnosis")
.["comms_options"] = get_component("comms")
.["armour_options"] = get_component("armour")
.["current_gear"] = get_gear()
// Access
.["id_icon"] = icon2html(target.idcard, user, sourceonly=TRUE)
var/list/active_access = list()
@@ -198,7 +205,7 @@
target.module.contents.Add(add_item)
spawn(0)
SEND_SIGNAL(add_item, COMSIG_OBSERVER_MOVED)
target.hud_used.update_robot_modules_display()
target.hud_used?.update_robot_modules_display()
if(istype(add_item, /obj/item/stack/))
var/obj/item/stack/item_with_synth = add_item
for(var/synth in item_with_synth.synths)
@@ -243,7 +250,7 @@
if("rem_module")
var/obj/item/rem_item = locate(params["module"])
target.uneq_all()
target.hud_used.update_robot_modules_display(TRUE)
target.hud_used?.update_robot_modules_display(TRUE)
target.module.emag.Remove(rem_item)
target.module.modules.Remove(rem_item)
target.module.contents.Remove(rem_item)
@@ -262,14 +269,14 @@
source.emag_items = 1
// Target
target.uneq_all()
target.hud_used.update_robot_modules_display(TRUE)
target.hud_used?.update_robot_modules_display(TRUE)
qdel(target.module)
target.modtype = mod_type
module_type = robot_modules[mod_type]
target.transform_with_anim()
new module_type(target)
target.hands.icon_state = target.get_hud_module_icon()
target.hud_used.update_robot_modules_display()
target.hud_used?.update_robot_modules_display()
return TRUE
if("ert_toggle")
target.crisis_override = !target.crisis_override
@@ -299,7 +306,7 @@
if(!U.action(target))
return FALSE
U.loc = target
target.hud_used.update_robot_modules_display()
target.hud_used?.update_robot_modules_display()
return TRUE
if("install_modkit")
var/new_modkit = text2path(params["modkit"])
@@ -348,22 +355,34 @@
var/datum/robot_component/C = locate(params["component"])
if(C.wrapped)
qdel(C.wrapped)
var/new_component = text2path(params["new_part"])
if(istype(C, /datum/robot_component/actuator))
C.wrapped = new /obj/item/robot_parts/robot_component/actuator(target)
if(!new_component)
new_component = /obj/item/robot_parts/robot_component/actuator
C.wrapped = new new_component(target)
else if(istype(C, /datum/robot_component/radio))
C.wrapped = new /obj/item/robot_parts/robot_component/radio(target)
if(!new_component)
new_component = /obj/item/robot_parts/robot_component/radio
C.wrapped = new new_component(target)
else if(istype(C, /datum/robot_component/cell))
var/new_cell = text2path(params["cell"])
target.cell = new new_cell(target)
target.cell = new new_component(target)
C.wrapped = target.cell
else if(istype(C, /datum/robot_component/diagnosis_unit))
C.wrapped = new /obj/item/robot_parts/robot_component/diagnosis_unit(target)
if(!new_component)
new_component = /obj/item/robot_parts/robot_component/diagnosis_unit
C.wrapped = new new_component(target)
else if(istype(C, /datum/robot_component/camera))
C.wrapped = new /obj/item/robot_parts/robot_component/camera(target)
if(!new_component)
new_component = /obj/item/robot_parts/robot_component/camera
C.wrapped = new new_component(target)
else if(istype(C, /datum/robot_component/binary_communication))
C.wrapped = new /obj/item/robot_parts/robot_component/binary_communication_device(target)
if(!new_component)
new_component = /obj/item/robot_parts/robot_component/binary_communication_device
C.wrapped = new new_component(target)
else if(istype(C, /datum/robot_component/armour))
C.wrapped = new /obj/item/robot_parts/robot_component/armour(target)
if(!new_component)
new_component = /obj/item/robot_parts/robot_component/armour
C.wrapped = new new_component(target)
C.brute_damage = 0
C.electronics_damage = 0
C.install()
@@ -533,7 +552,7 @@
target.clear_inherent_laws()
target.laws = new global.using_map.default_law_type
target.laws.show_laws(target)
target.hud_used.update_robot_modules_display()
target.hud_used?.update_robot_modules_display()
else
target.emagged = 1
target.lawupdate = 0
@@ -545,7 +564,7 @@
if(!target.bolt.malfunction)
target.bolt.malfunction = MALFUNCTION_PERMANENT
target.laws.show_laws(target)
target.hud_used.update_robot_modules_display()
target.hud_used?.update_robot_modules_display()
return TRUE
/datum/eventkit/modify_robot/proc/get_target_items(var/mob/user)
@@ -672,14 +691,59 @@
continue
if(cell_options[initial(C.name)]) // empty cells are defined after normal cells!
continue
cell_options += list(initial(C.name) = list("path" = "[C]", "charge" = initial(C.maxcharge), "max_charge" = initial(C.maxcharge), "charge_amount" = initial(C.charge_amount) , "self_charge" = initial(C.self_recharge))) // our cells do not have their charge predefined, they do it on init, so both maaxcharge for now
cell_options += list(initial(C.name) = list("path" = "[C]", "charge" = initial(C.maxcharge), "max_charge" = initial(C.maxcharge), "charge_amount" = initial(C.charge_amount) , "self_charge" = initial(C.self_recharge), "max_damage" = initial(C.robot_durability))) // our cells do not have their charge predefined, they do it on init, so both maaxcharge for now
return cell_options
/datum/eventkit/modify_robot/proc/get_component(var/type)
var/path
switch(type)
if("camera")
path = /obj/item/robot_parts/robot_component/camera
if("radio")
path = /obj/item/robot_parts/robot_component/radio
if("actuator")
path = /obj/item/robot_parts/robot_component/actuator
if("diagnosis")
path = /obj/item/robot_parts/robot_component/diagnosis_unit
if("comms")
path = /obj/item/robot_parts/robot_component/binary_communication_device
if("armour")
path = /obj/item/robot_parts/robot_component/armour
if(!path)
return
var/list/components = list()
for(var/component in typesof(path))
var/obj/item/robot_parts/robot_component/C = component
components += list("[initial(C.name)]" = list("path" = "[component]", "idle_usage" = "[C.idle_usage]", "active_usage" = "[C.active_usage]", "max_damage" = "[C.max_damage]"))
return components
/datum/eventkit/modify_robot/proc/get_gear()
var/list/equip = list()
for (var/V in target.components)
var/datum/robot_component/C = target.components[V]
var/component_name
if(istype(C.wrapped, /obj/item/robot_parts/robot_component))
component_name = C.wrapped?.name
switch(V)
if("actuator")
equip += list("[lowertext(C.name)]" = "[component_name]")
if("radio")
equip += list("[lowertext(C.name)]" = "[component_name]")
if("diagnosis unit")
equip += list("[lowertext(C.name)]" = "[component_name]")
if("camera")
equip += list("[lowertext(C.name)]" = "[component_name]")
if("comms")
equip += list("[lowertext(C.name)]" = "[component_name]")
if("armour")
equip += list("[lowertext(C.name)]" = "[component_name]")
return equip
/datum/eventkit/modify_robot/proc/get_components()
var/list/components = list()
for(var/entry in target.components)
var/datum/robot_component/C = target.components[entry]
components += list(list("name" = C.name, "ref" = "\ref[C]", "brute_damage" = C.brute_damage, "electronics_damage" = C.electronics_damage, "max_damage" = C.max_damage, "installed" = C.installed, "exists" = (C.wrapped ? TRUE : FALSE)))
components += list(list("name" = C.name, "ref" = "\ref[C]", "brute_damage" = C.brute_damage, "electronics_damage" = C.electronics_damage, "max_damage" = C.max_damage, "idle_usage" = C.idle_usage, "active_usage" = C.active_usage, "installed" = C.installed, "exists" = (C.wrapped ? TRUE : FALSE)))
return components
/datum/eventkit/modify_robot/proc/package_laws(var/list/data, var/field, var/list/datum/ai_law/laws)