From 92226dff35e5a891cccab637de2ea9c5d39956b0 Mon Sep 17 00:00:00 2001 From: jack-fractal Date: Sat, 23 May 2015 00:18:57 -0400 Subject: [PATCH] Refresh problems and hotkeys Ooohkay, so I added a bit more to this while fixing the issue with the backpack module select screen not refreshing when you stored items. I did a pass over the hotkeys! Hurray! All right. Lets do this: Key X Previously, this hotkey wouldn't start cycling if your first inventory slot wasn't filled. So if you had slots 2 and 3 full, but 1 empty, clicking X would do nothing. Now it works how you'd expect. It cycles if you have something selected, and if you have nothing selected, it selects the first item. Key C This deselects everything, leaving you able to interact with computers and distant AI objects. Previously, to do this you had to click on an empty area of your selected module. It was very awkward. Key V This stores your currently selected item. Key Q Previously this would just tell you that you weren't allowed to drop items as a robot. Now it toggles your inventory open or closed. Key 1,2,3 Previously hitting 1 would activate Help intent, and 4 would activate Harm intent. Robots have only two intent types, making the toggle key F more useful. These now select the respective modules. I also revised how clicking on items in the backpack works. Now, clicking on an item in the module storage, with a tool selected, will hot-swap the item into your current module. Taken together, these changes reduce an enormous amount of unnecessary clicking. --- code/_onclick/cyborg.dm | 10 ++- code/_onclick/hud/screen_objects.dm | 5 +- code/game/objects/items.dm | 4 +- code/modules/mob/living/carbon/carbon.dm | 6 ++ .../mob/living/silicon/robot/inventory.dm | 74 +++++++++++++++---- code/modules/mob/mob_helpers.dm | 59 +++++++++++++++ interface/skin.dmf | 32 ++++++-- 7 files changed, 163 insertions(+), 27 deletions(-) diff --git a/code/_onclick/cyborg.dm b/code/_onclick/cyborg.dm index 5f007bbe..e003b697 100644 --- a/code/_onclick/cyborg.dm +++ b/code/_onclick/cyborg.dm @@ -57,7 +57,10 @@ RestrainedClickOn(A) return */ - + // handle equipping modules + if (A.equip_robot(src)) + return + var/obj/item/W = get_active_hand() // Cyborgs have no range-checking unless there is item use @@ -126,6 +129,9 @@ /atom/proc/attack_robot(mob/user as mob) attack_ai(user) return + +/atom/proc/equip_robot(mob/user as mob) + return /mob/living/silicon/robot/MiddleClickOn(var/atom/A) cycle_modules() @@ -142,6 +148,6 @@ var/locked_door=A.AICtrlClick(src) if (!locked_door) ..(A) - + /mob/living/silicon/robot/AltClickOn(var/atom/A) A.AIAltClick(src) \ No newline at end of file diff --git a/code/_onclick/hud/screen_objects.dm b/code/_onclick/hud/screen_objects.dm index 69dcde47..9109d339 100644 --- a/code/_onclick/hud/screen_objects.dm +++ b/code/_onclick/hud/screen_objects.dm @@ -385,8 +385,9 @@ usr:installed_modules() if("store") - if(issilicon(usr)) - usr:uneq_active() + if(isrobot(usr)) + var/mob/living/silicon/robot/R = usr + R.uneq_active() if("Toggle Sensor Augmentation") if(isrobot(usr)) diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm index 8570fb0b..4821ac8d 100644 --- a/code/game/objects/items.dm +++ b/code/game/objects/items.dm @@ -180,13 +180,15 @@ user.put_in_active_hand(src) return -/obj/item/attack_ai(mob/user as mob) + +/obj/item/equip_robot(mob/user as mob) if (istype(src.loc, /obj/item/weapon/robot_module)) //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.hud_used.update_robot_modules_display() + return TRUE // Due to storage type consolidation this should get used more now. // I have cleaned it up a little, but it could probably use more. -Sayu diff --git a/code/modules/mob/living/carbon/carbon.dm b/code/modules/mob/living/carbon/carbon.dm index 98964af5..d0fddc9a 100644 --- a/code/modules/mob/living/carbon/carbon.dm +++ b/code/modules/mob/living/carbon/carbon.dm @@ -282,6 +282,12 @@ if(src.throw_icon) src.throw_icon.icon_state = "act_throw_on" +/mob/living/carbon/key_pressed_q() + if(!get_active_hand()) + usr << "\red You have nothing to drop in your hand." + return + return drop_item() + /mob/proc/throw_item(atom/target) return diff --git a/code/modules/mob/living/silicon/robot/inventory.dm b/code/modules/mob/living/silicon/robot/inventory.dm index 1c310d63..afa2d685 100644 --- a/code/modules/mob/living/silicon/robot/inventory.dm +++ b/code/modules/mob/living/silicon/robot/inventory.dm @@ -37,14 +37,21 @@ else if(module_state_3 == O) module_state_3 = null inv3.icon_state = "inv3" + + hud_used.update_robot_modules_display() // update the display + return 1 - + + /mob/living/silicon/robot/proc/activate_module(var/obj/item/O) if(!(locate(O) in src.module.modules) && O != src.module.emag) return if(activated(O)) src << "Already activated" return + var/selected=get_selected_module() // this makes you swap your selected module if you've got one selected + if (selected) + uneq_active() if(!module_state_1) module_state_1 = O O.layer = 20 @@ -68,6 +75,8 @@ sight_mode |= module_state_3:sight_mode else src << "You need to disable a module first!" + if (selected) // replaces your selection if you're swapping + select_module(selected) /mob/living/silicon/robot/proc/uneq_active() uneq_module(module_active) @@ -174,6 +183,11 @@ return return + +/mob/living/silicon/robot/proc/deselect_current_module() //deselect current module + deselect_module(get_selected_module()) + + //toggle_module(module) - Toggles the selection of the module slot specified by "module". /mob/living/silicon/robot/proc/toggle_module(var/module) //Module is 1-3 if(module < 1 || module > 3) return @@ -187,23 +201,51 @@ deselect_module(get_selected_module()) //If we can't do select anything, at least deselect the current module. return +/mob/living/silicon/robot/proc/first_active_module() + for (var/slot=0,slot<=3,slot++) + if (module_active(slot)) + return slot + return 0 + +/mob/living/silicon/robot/proc/next_slot(var/slot) + if (slot >= 3) + return 1 + return slot+1 + //cycle_modules() - Cycles through the list of selected modules. /mob/living/silicon/robot/proc/cycle_modules() var/slot_start = get_selected_module() - if(slot_start) deselect_module(slot_start) //Only deselect if we have a selected slot. - - var/slot_num - if(slot_start == 0) - slot_num = 1 - slot_start = 2 + if(slot_start) + deselect_module(slot_start) //Only deselect if we have a selected slot. + if(!slot_start) // we did not find a module + select_module(first_active_module()) // try to select the first active module else - slot_num = slot_start + 1 - - while(slot_start != slot_num) //If we wrap around without finding any free slots, just give up. - if(module_active(slot_num)) - select_module(slot_num) - return - slot_num++ - if(slot_num > 3) slot_num = 1 //Wrap around. - + var/slot_num = next_slot(slot_start) + while(slot_start != slot_num) //If we wrap around without finding any free slots, just give up. + if(module_active(slot_num)) + select_module(slot_num) + return + slot_num=next_slot(slot_num) return + + +/mob/living/silicon/robot/key_pressed_v() + uneq_active() + +/mob/living/silicon/robot/key_pressed_c() + deselect_current_module() + +/mob/living/silicon/robot/key_pressed_q() + hud_used.toggle_show_robot_modules() + +/mob/living/silicon/robot/key_pressed_1() + return select_module(1) + +/mob/living/silicon/robot/key_pressed_2() + return select_module(2) + +/mob/living/silicon/robot/key_pressed_3() + return select_module(3) + +/mob/living/silicon/robot/key_pressed_4() + return \ No newline at end of file diff --git a/code/modules/mob/mob_helpers.dm b/code/modules/mob/mob_helpers.dm index 5e183dcc..27ac10e4 100644 --- a/code/modules/mob/mob_helpers.dm +++ b/code/modules/mob/mob_helpers.dm @@ -394,6 +394,65 @@ var/list/intents = list("help","disarm","grab","hurt") if(2) return "grab" else return "hurt" +/mob/proc/key_pressed_c() + return +/mob/proc/key_pressed_q() + return +/mob/proc/key_pressed_v() + return + +/client/verb/key_pressed_c() + set hidden = 1 + set name = "key-pressed-c" + if (mob) + mob:key_pressed_c() + +/client/verb/key_pressed_q() + set hidden = 1 + set name = "key-pressed-q" + if (mob) + mob:key_pressed_q() + +/client/verb/key_pressed_v() + set hidden = 1 + set name = "key-pressed-v" + if (mob) + mob:key_pressed_v() + +/mob/proc/key_pressed_1() + return a_intent_change("help") +/mob/proc/key_pressed_2() + return a_intent_change("disarm") +/mob/proc/key_pressed_3() + return a_intent_change("grab") +/mob/proc/key_pressed_4() + return a_intent_change("hurt") + +/client/verb/key_pressed_1() + set hidden = 1 + set name = "key-pressed-1" + if (mob) + mob:key_pressed_1() + +/client/verb/key_pressed_2() + set hidden = 1 + set name = "key-pressed-2" + if (mob) + mob:key_pressed_2() + +/client/verb/key_pressed_3() + set hidden = 1 + set name = "key-pressed-3" + if (mob) + mob:key_pressed_3() + +/client/verb/key_pressed_4() + set hidden = 1 + set name = "key-pressed-4" + if (mob) + mob:key_pressed_4() + + //change a mob's act-intent. Input the intent as a string such as "help" or use "right"/"left /mob/verb/a_intent_change(input as text) set name = "a-intent" diff --git a/interface/skin.dmf b/interface/skin.dmf index d0a59f86..b71f4dc6 100644 --- a/interface/skin.dmf +++ b/interface/skin.dmf @@ -243,31 +243,43 @@ macro "hotkeymode" is-disabled = false elem name = "1" - command = "a-intent help" + command = "key-pressed-1" is-disabled = false elem name = "CTRL+1" command = "a-intent help" is-disabled = false + elem + name = "SHIFT+1" + command = "shift-1-key-pressed" + is-disabled = false elem name = "2" - command = "a-intent disarm" + command = "key-pressed-2" is-disabled = false elem name = "CTRL+2" command = "a-intent disarm" is-disabled = false + elem + name = "SHIFT+2" + command = "shift-2-key-pressed" + is-disabled = false elem name = "3" - command = "a-intent grab" + command = "key-pressed-3" is-disabled = false elem name = "CTRL+3" command = "a-intent grab" is-disabled = false + elem + name = "SHIFT+3" + command = "shift-3-key-pressed" + is-disabled = false elem name = "4" - command = "a-intent hurt" + command = "key-pressed-4" is-disabled = false elem name = "CTRL+4" @@ -281,6 +293,10 @@ macro "hotkeymode" name = "CTRL+A+REP" command = ".west" is-disabled = false + elem + name = "C" + command = "key-pressed-c" + is-disabled = false elem name = "D+REP" command = ".east" @@ -323,11 +339,11 @@ macro "hotkeymode" is-disabled = false elem name = "Q" - command = ".northwest" + command = "key-pressed-q" is-disabled = false elem name = "CTRL+Q" - command = ".northwest" + command = "key-pressed-q" is-disabled = false elem name = "R" @@ -349,6 +365,10 @@ macro "hotkeymode" name = "T" command = "say" is-disabled = false + elem "Toggle Module" + name = "V" + command = "key-pressed-v" + is-disabled = false elem "w_key" name = "W+REP" command = ".north"