Skip to content

Commit

Permalink
Swapping robot modules out for grippers.
Browse files Browse the repository at this point in the history
  • Loading branch information
MistakeNot4892 committed Feb 12, 2025
1 parent 58e4312 commit fc1b97a
Show file tree
Hide file tree
Showing 40 changed files with 173 additions and 621 deletions.
5 changes: 0 additions & 5 deletions code/_onclick/cyborg.dm
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,6 @@
holding.afterattack(A, src, 0, params)
return

//Middle click cycles through selected modules.
/mob/living/silicon/robot/MiddleClickOn(var/atom/A)
cycle_modules()
return

//Give cyborgs hotkey clicks without breaking existing uses of hotkey clicks
// for non-doors/apcs
/mob/living/silicon/robot/CtrlShiftClickOn(var/atom/A)
Expand Down
1 change: 1 addition & 0 deletions code/_onclick/hud/hud_elements/hud_robot.dm
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/datum/hud/robot
offset_hands_vertically = FALSE
gun_mode_toggle_type = /obj/screen/gun/mode
omit_hud_elements = list(
/decl/hud_element/health,
Expand Down
41 changes: 26 additions & 15 deletions code/_onclick/hud/hud_types/_hud.dm
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
VAR_PRIVATE/obj/screen/gun/item/gun_item_use_toggle
VAR_PRIVATE/obj/screen/gun/radio/gun_radio_use_toggle

var/offset_hands_vertically = TRUE

/datum/hud/New(mob/owner)
mymob = owner
Expand Down Expand Up @@ -315,20 +316,28 @@
// Rebuild offsets for the hand elements.
var/hand_y_offset = 21
var/list/elements = hud_elements_hands?.Copy()
while(length(elements))
var/copy_index = min(length(elements), 2)+1
var/list/sublist = elements.Copy(1, copy_index)
elements.Cut(1, copy_index)
var/obj/screen/inventory/inv_box
if(length(sublist) == 1)
inv_box = sublist[1]
inv_box.screen_loc = "CENTER,BOTTOM:[hand_y_offset]"
if(length(elements))
if(offset_hands_vertically)
while(length(elements))
var/copy_index = min(length(elements), 2)+1
var/list/sublist = elements.Copy(1, copy_index)
elements.Cut(1, copy_index)
var/obj/screen/inventory/inv_box
if(length(sublist) == 1)
inv_box = sublist[1]
inv_box.screen_loc = "CENTER,BOTTOM:[hand_y_offset]"
else
inv_box = sublist[1]
inv_box.screen_loc = "CENTER:-[world.icon_size/2],BOTTOM:[hand_y_offset]"
inv_box = sublist[2]
inv_box.screen_loc = "CENTER:[world.icon_size/2],BOTTOM:[hand_y_offset]"
hand_y_offset += world.icon_size
else
inv_box = sublist[1]
inv_box.screen_loc = "CENTER:-[world.icon_size/2],BOTTOM:[hand_y_offset]"
inv_box = sublist[2]
inv_box.screen_loc = "CENTER:[world.icon_size/2],BOTTOM:[hand_y_offset]"
hand_y_offset += world.icon_size
var/hand_x_offset = -((length(elements) * world.icon_size) / 2) + (world.icon_size/2)
for(var/obj/screen/inventory/inv_box in elements)
inv_box.screen_loc = "CENTER:[hand_x_offset],BOTTOM:[hand_y_offset]"
hand_x_offset += world.icon_size
hand_y_offset += world.icon_size

if(mymob.client && islist(hud_elements_hands) && length(hud_elements_hands))
mymob.client.screen |= hud_elements_hands
Expand Down Expand Up @@ -437,9 +446,11 @@
mymob?.client?.screen -= hud_elements_hotkeys
if(!full)
if(LAZYLEN(hud_elements_hands))
mymob?.client?.screen += hud_elements_hands // we want the hands to be visible
// we want the hands to be visible
mymob?.client?.screen += hud_elements_hands
if(LAZYLEN(hud_elements_swap))
mymob?.client?.screen += hud_elements_swap // we want the hands swap thingy to be visible
// we want the hands swap thingy to be visible
mymob?.client?.screen += hud_elements_swap
else
hud_shown = TRUE
if(LAZYLEN(hud_elements_auxilliary))
Expand Down
36 changes: 2 additions & 34 deletions code/_onclick/hud/hud_types/robot.dm
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,6 @@
/datum/hud/robot/get_ui_alpha()
return 255

// TODO: Convert robots to use inventory slots.
/datum/hud/robot/finalize_instantiation()
var/mob/living/silicon/robot/R = mymob
if(!istype(R))
return ..()
R.inv1 = new(null, mymob)
R.inv2 = new(null, mymob)
R.inv3 = new(null, mymob)
LAZYINITLIST(hud_elements_auxilliary)
hud_elements_auxilliary += R.inv1
hud_elements_auxilliary += R.inv2
hud_elements_auxilliary += R.inv3
..()

/datum/hud/proc/toggle_show_robot_modules()
if(!isrobot(mymob))
return
Expand Down Expand Up @@ -56,9 +42,6 @@
R.robot_modules_background.screen_loc = "CENTER-4:16,BOTTOM+1:7 to CENTER+3:16,BOTTOM+[display_rows]:7"
R.client.screen += R.robot_modules_background

var/x = -4 //Start at CENTER-4,SOUTH+1
var/y = 1

//Unfortunately adding the emag module to the list of modules has to be here. This is because a borg can
//be emagged before they actually select a module. - or some situation can cause them to get a new module
// - or some situation might cause them to get de-emagged or something.
Expand All @@ -69,26 +52,11 @@
if(R.module.emag in R.module.equipment)
R.module.equipment.Remove(R.module.emag)

for(var/atom/movable/A in R.module.equipment)
if( (A != R.module_state_1) && (A != R.module_state_2) && (A != R.module_state_3) )
//Module is not currently active
R.client.screen += A
if(x < 0)
A.screen_loc = "CENTER[x]:[WORLD_ICON_SIZE/2],BOTTOM+[y]:7"
else
A.screen_loc = "CENTER+[x]:[WORLD_ICON_SIZE/2],BOTTOM+[y]:7"
A.hud_layerise()

x++
if(x == 4)
x = -4
y++

else
//Modules display is hidden
var/list/held_items = R.get_held_items()
for(var/atom/A in R.module.equipment)
if( (A != R.module_state_1) && (A != R.module_state_2) && (A != R.module_state_3) )
//Module is not currently active
if(!(A in held_items))
R.client.screen -= A
R.shown_robot_modules = 0
R.client.screen -= R.robot_modules_background
5 changes: 5 additions & 0 deletions code/_onclick/hud/screen/robot/screen_robot_module.dm
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/obj/screen/robot/module
dir = SOUTHWEST
icon = 'icons/mob/screen/styles/robot/modules_inventory.dmi'
abstract_type = /obj/screen/robot/module

/obj/screen/robot/module/select
name = "module"
icon = 'icons/mob/screen/styles/robot/module.dmi'
Expand Down
30 changes: 0 additions & 30 deletions code/_onclick/hud/screen/robot/screen_robot_modules.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,3 @@
name = "module"
icon_state = "block"
icon = 'icons/mob/screen/styles/robot/modules_background.dmi'

/obj/screen/robot/module
dir = SOUTHWEST
icon = 'icons/mob/screen/styles/robot/modules_inventory.dmi'
var/module_index

/obj/screen/robot/module/handle_click(mob/user, params)
if(isrobot(user) && !isnull(module_index))
var/mob/living/silicon/robot/robot = user
robot.toggle_module(module_index)
return TRUE
return ..()

/obj/screen/robot/module/one
name = "module1"
icon_state = "inv1"
screen_loc = ui_inv1
module_index = 1

/obj/screen/robot/module/two
name = "module2"
icon_state = "inv2"
screen_loc = ui_inv2
module_index = 2

/obj/screen/robot/module/three
name = "module3"
icon_state = "inv3"
screen_loc = ui_inv3
module_index = 3
4 changes: 2 additions & 2 deletions code/_onclick/hud/screen/robot/screen_robot_panel.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@

/obj/screen/robot/panel/handle_click(mob/user, params)
if(isrobot(user))
var/mob/living/silicon/robot/R = user
R.installed_modules()
var/mob/living/silicon/robot/robit = user
robit.module?.storage?.open(user)
14 changes: 7 additions & 7 deletions code/_onclick/hud/screen/robot/screen_robot_store.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
screen_loc = ui_borg_store

/obj/screen/robot/store/handle_click(mob/user, params)
if(isrobot(user))
var/mob/living/silicon/robot/R = user
if(R.module)
R.uneq_active()
R.hud_used.update_robot_modules_display()
else
to_chat(R, "You haven't selected a module yet.")
var/mob/living/silicon/robot/robot = user
if(istype(robot) && robot.module)
var/obj/item/active_item = robot.get_active_held_item()
if(active_item)
user.try_unequip(active_item)
else
to_chat(user, "You haven't selected a module yet.")
20 changes: 3 additions & 17 deletions code/datums/inventory_slots/inventory_gripper.dm
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
/datum/inventory_slot/gripper
// For reference, grippers do not use ui_loc, they have it set dynamically during /datum/hud/proc/rebuild_hands()
quick_equip_priority = null // you quick-equip stuff by holding it in a gripper, so this ought to be skipped
fluid_height = (FLUID_SHALLOW + FLUID_OVER_MOB_HEAD) / 2 // halfway between waist and top of head, so roughly chest level, reasoning that you can just hold it up out of the water
var/hand_sort_priority = 1
var/dexterity = DEXTERITY_FULL
var/covering_slot_flags
/// If set, use this icon_state for the hand slot overlay; otherwise, use slot_id.
var/hand_overlay
quick_equip_priority = null // you quick-equip stuff by holding it in a gripper, so this ought to be skipped
fluid_height = (FLUID_SHALLOW + FLUID_OVER_MOB_HEAD) / 2 // halfway between waist and top of head, so roughly chest level, reasoning that you can just hold it up out of the water

// For reference, grippers do not use ui_loc, they have it set dynamically during /datum/hud/proc/rebuild_hands()

/datum/inventory_slot/gripper/proc/get_dexterity(var/silent)
return dexterity
Expand All @@ -32,16 +31,3 @@

/datum/inventory_slot/gripper/can_equip_to_slot(var/mob/user, var/obj/item/prop, var/disable_warning)
return ..() && user.check_dexterity(DEXTERITY_EQUIP_ITEM, silent = disable_warning)

// Stub definitions for future work and to pass CI.
/datum/inventory_slot/gripper/robot
abstract_type = /datum/inventory_slot/gripper/robot

/datum/inventory_slot/gripper/robot/one
ui_label = "1"

/datum/inventory_slot/gripper/robot/two
ui_label = "2"

/datum/inventory_slot/gripper/robot/three
ui_label = "3"
18 changes: 18 additions & 0 deletions code/datums/inventory_slots/inventory_gripper_robot.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Stub definitions for future work and to pass CI.
/datum/inventory_slot/gripper/robot
abstract_type = /datum/inventory_slot/gripper/robot

/datum/inventory_slot/gripper/robot/one
slot_name = "Module One"
slot_id = "slot_robot_one"
ui_label = "1"

/datum/inventory_slot/gripper/robot/two
slot_name = "Module Two"
slot_id = "slot_robot_two"
ui_label = "2"

/datum/inventory_slot/gripper/robot/three
slot_name = "Module Three"
slot_id = "slot_robot_three"
ui_label = "3"
33 changes: 8 additions & 25 deletions code/datums/mind/mind.dm
Original file line number Diff line number Diff line change
Expand Up @@ -396,37 +396,20 @@
if("unemag")
var/mob/living/silicon/robot/R = current
if (istype(R))
R.emagged = 0
if (R.activated(R.module.emag))
R.module_active = null
if(R.module_state_1 == R.module.emag)
R.module_state_1 = null
R.module.emag.forceMove(null)
else if(R.module_state_2 == R.module.emag)
R.module_state_2 = null
R.module.emag.forceMove(null)
else if(R.module_state_3 == R.module.emag)
R.module_state_3 = null
R.module.emag.forceMove(null)
if(R.module?.emag)
R.drop_from_inventory(R.module.emag)
R.module.emag.forceMove(null)
R.emagged = FALSE
log_admin("[key_name_admin(usr)] has unemag'ed [R].")

if("unemagcyborgs")
if (isAI(current))
var/mob/living/silicon/ai/ai = current
for (var/mob/living/silicon/robot/R in ai.connected_robots)
R.emagged = 0
if (R.module)
if (R.activated(R.module.emag))
R.module_active = null
if(R.module_state_1 == R.module.emag)
R.module_state_1 = null
R.module.emag.forceMove(null)
else if(R.module_state_2 == R.module.emag)
R.module_state_2 = null
R.module.emag.forceMove(null)
else if(R.module_state_3 == R.module.emag)
R.module_state_3 = null
R.module.emag.forceMove(null)
R.emagged = FALSE
if(R.module?.emag)
R.drop_from_inventory(R.module.emag)

log_admin("[key_name_admin(usr)] has unemag'ed [ai]'s Cyborgs.")

else if (href_list["common"])
Expand Down
2 changes: 1 addition & 1 deletion code/datums/storage/_storage.dm
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ var/global/list/_test_storage_items = list()
/datum/storage/proc/can_be_inserted(obj/item/W, mob/user, stop_messages = 0, click_params = null)
if(!istype(W)) return //Not an item

if(user && !user.canUnEquip(W))
if(user && !user.can_unequip_item(W))
return 0

if(!holder || holder.loc == W)
Expand Down
2 changes: 1 addition & 1 deletion code/game/antagonist/antagonist_equip.dm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// This could use work.
if(flags & ANTAG_CLEAR_EQUIPMENT)
for(var/obj/item/thing in player.contents)
if(player.canUnEquip(thing))
if(player.can_unequip_item(thing))
qdel(thing)
//mainly for nonhuman antag compatibility. Should not effect item spawning.
player.species.equip_survival_gear(player)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
if(istype(I, /obj/item/stock_parts/circuitboard))
var/obj/item/stock_parts/circuitboard/circuit = I
if(circuit.board_type == machine.expected_machine_type)
if(user.canUnEquip(I))
if(user.can_unequip_item(I))
TRANSFER_STATE(/decl/machine_construction/frame/awaiting_parts)
user.try_unequip(I, machine)
playsound(machine.loc, 'sound/items/Deconstruct.ogg', 50, 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@
if(board.build_path != (machine.base_type || machine.type))
to_chat(user, SPAN_WARNING("This circuitboard does not fit inside \the [machine]!"))
return TRUE
if(!user.canUnEquip(board))
if(!user.can_unequip_item(board))
return TRUE
machine.set_broken(TRUE, MACHINE_BROKEN_CONSTRUCT)
TRANSFER_STATE(diconnected_state)
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/_machines_base/machinery_components.dm
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ Standard helpers for users interacting with machinery parts.
return TRUE

/obj/machinery/proc/part_insertion(mob/user, obj/item/stock_parts/part) // Second argument may actually be an arbitrary item.
if(!user.canUnEquip(part) && !isstack(part))
if(!user.can_unequip_item(part) && !isstack(part))
return FALSE
var/number = can_add_component(part, user)
if(!number)
Expand Down
6 changes: 3 additions & 3 deletions code/game/objects/items/__item.dm
Original file line number Diff line number Diff line change
Expand Up @@ -581,13 +581,13 @@
return FALSE

/obj/item/attack_ai(mob/living/silicon/ai/user)
if (!istype(src.loc, /obj/item/robot_module))
if (!istype(loc, /obj/item/robot_module))
return
//If the item is part of a cyborg module, equip it
if(!isrobot(user))
return
var/mob/living/silicon/robot/R = user
R.activate_module(src)
R.put_in_hands(src)
if(R.hud_used)
R.hud_used.update_robot_modules_display()

Expand Down Expand Up @@ -748,7 +748,7 @@
return inv_slot?.is_accessible(user, src, disable_warning)

/obj/item/proc/can_be_dropped_by_client(mob/M)
return M.canUnEquip(src)
return M.can_unequip_item(src)

/obj/item/verb/verb_pickup()
set src in oview(1)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/food/assembled.dm
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
create_type = names[create_type]

// TODO: move reagents/matter into produced food object.
if(ispath(create_type) && user.canUnEquip(src))
if(ispath(create_type) && user.can_unequip_item(src))
var/obj/item/food/result
if(ispath(create_type, /obj/item/food))

Expand Down
2 changes: 1 addition & 1 deletion code/modules/integrated_electronics/core/assemblies.dm
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@

/obj/item/electronic_assembly/attackby(obj/item/I, mob/user)
if(istype(I, /obj/item/integrated_circuit))
if(!user.canUnEquip(I))
if(!user.can_unequip_item(I))
return FALSE
if(try_add_component(I, user))
return TRUE
Expand Down
Loading

0 comments on commit fc1b97a

Please sign in to comment.