diff --git a/code/_onclick/hud/action.dm b/code/_onclick/hud/action.dm deleted file mode 100644 index f7408e3ff8f..00000000000 --- a/code/_onclick/hud/action.dm +++ /dev/null @@ -1,310 +0,0 @@ -#define AB_CHECK_RESTRAINED 1 -#define AB_CHECK_STUNNED 2 -#define AB_CHECK_LYING 4 -#define AB_CHECK_CONSCIOUS 8 - - -/datum/action - var/name = "Generic Action" - var/obj/item/target = null - var/check_flags = 0 - var/processing = 0 - var/obj/screen/movable/action_button/button = null - var/button_icon = 'icons/mob/actions.dmi' - var/button_icon_state = "default" - var/background_icon_state = "bg_default" - var/mob/living/owner - -/datum/action/New(var/Target) - target = Target - -/datum/action/Destroy() - if(owner) - Remove(owner) - return ..() - -/datum/action/proc/Grant(mob/living/T) - if(owner) - if(owner == T) - return - Remove(owner) - owner = T - T.actions += src - - if(!button) - button = new - button.linked_action = src - button.name = UpdateName() - if(T.client) - T.client.screen += button - T.update_action_buttons() - -/datum/action/proc/Remove(mob/living/T) - if(button) - if(T.client) - T.client.screen -= button - qdel(button) - button = null - T.actions -= src - T.update_action_buttons() - owner = null - -/datum/action/proc/Trigger() - if(!IsAvailable()) - return 0 - return 1 - -/datum/action/proc/Process() - return - -/datum/action/proc/IsAvailable() - if(!owner) - return 0 - if(check_flags & AB_CHECK_RESTRAINED) - if(owner.restrained()) - return 0 - if(check_flags & AB_CHECK_STUNNED) - if(owner.stunned || owner.weakened) - return 0 - if(check_flags & AB_CHECK_LYING) - if(owner.lying) - return 0 - if(check_flags & AB_CHECK_CONSCIOUS) - if(owner.stat) - return 0 - return 1 - -/datum/action/proc/UpdateName() - return name - -/datum/action/proc/ApplyIcon(obj/screen/movable/action_button/current_button) - current_button.overlays.Cut() - if(button_icon && button_icon_state) - var/image/img - img = image(button_icon, current_button, button_icon_state) - img.pixel_x = 0 - img.pixel_y = 0 - current_button.overlays += img - -/obj/screen/movable/action_button - var/datum/action/linked_action - screen_loc = null - -/obj/screen/movable/action_button/Click(location,control,params) - var/list/modifiers = params2list(params) - if(modifiers["shift"]) - moved = 0 - return 1 - if(usr.next_move >= world.time) // Is this needed ? - return - linked_action.Trigger() - return 1 - -/obj/screen/movable/action_button/proc/UpdateIcon() - if(!linked_action) - return - icon = linked_action.button_icon - icon_state = linked_action.background_icon_state - - linked_action.ApplyIcon(src) - - if(!linked_action.IsAvailable()) - color = rgb(128,0,0,128) - else - color = rgb(255,255,255,255) - -//Hide/Show Action Buttons ... Button -/obj/screen/movable/action_button/hide_toggle - name = "Hide Buttons" - icon = 'icons/mob/actions.dmi' - icon_state = "bg_default" - var/hidden = 0 - -/obj/screen/movable/action_button/hide_toggle/Click(location,control,params) - var/list/modifiers = params2list(params) - if(modifiers["shift"]) - moved = 0 - return 1 - usr.hud_used.action_buttons_hidden = !usr.hud_used.action_buttons_hidden - - hidden = usr.hud_used.action_buttons_hidden - if(hidden) - name = "Show Buttons" - else - name = "Hide Buttons" - UpdateIcon() - usr.update_action_buttons() - - -/obj/screen/movable/action_button/hide_toggle/proc/InitialiseIcon(mob/living/user) - if(isalien(user)) - icon_state = "bg_alien" - else - icon_state = "bg_default" - UpdateIcon() - return - -/obj/screen/movable/action_button/hide_toggle/UpdateIcon() - overlays.Cut() - var/image/img = image(icon, src, hidden ? "show" : "hide") - overlays += img - return - - -/obj/screen/movable/action_button/MouseEntered(location,control,params) - openToolTip(usr,src,params,title = name,content = desc) - - -/obj/screen/movable/action_button/MouseExited() - closeToolTip(usr) - - -//This is the proc used to update all the action buttons. Properly defined in /mob/living/ -/mob/proc/update_action_buttons(reload_screen) - return - -//used to update the buttons icon. -/mob/proc/update_action_buttons_icon() - return - -#define AB_MAX_COLUMNS 10 - -/datum/hud/proc/ButtonNumberToScreenCoords(number) // TODO : Make this zero-indexed for readabilty - var/row = round((number - 1)/AB_MAX_COLUMNS) - var/col = ((number - 1)%(AB_MAX_COLUMNS)) + 1 - - var/coord_col = "+[col-1]" - var/coord_col_offset = 4 + 2 * col - - var/coord_row = "[row ? -row : "+0"]" - - return "WEST[coord_col]:[coord_col_offset],NORTH[coord_row]:-6" - -/datum/hud/proc/SetButtonCoords(obj/screen/button,number) - var/row = round((number-1)/AB_MAX_COLUMNS) - var/col = ((number - 1)%(AB_MAX_COLUMNS)) + 1 - var/x_offset = 32*(col-1) + 4 + 2*col - var/y_offset = -32*(row+1) + 26 - - var/matrix/M = matrix() - M.Translate(x_offset,y_offset) - button.transform = M - -//Presets for item actions -/datum/action/item_action - check_flags = AB_CHECK_RESTRAINED|AB_CHECK_STUNNED|AB_CHECK_LYING|AB_CHECK_CONSCIOUS - -/datum/action/item_action/Trigger() - if(!..()) - return 0 - if(target) - var/obj/item/item = target - item.ui_action_click() - return 1 - -/datum/action/item_action/ApplyIcon(obj/screen/movable/action_button/current_button) - current_button.overlays.Cut() - if(target) - var/obj/item/I = target - var/old = I.layer - I.layer = FLOAT_LAYER //AAAH - current_button.overlays += I - I.layer = old - -/datum/action/item_action/hands_free - check_flags = AB_CHECK_CONSCIOUS - -/datum/action/item_action/organ_action - check_flags = AB_CHECK_CONSCIOUS - -/datum/action/item_action/organ_action/IsAvailable() - var/obj/item/organ/internal/I = target - if(!I.owner) - return 0 - return ..() - -//Preset for spells -/datum/action/spell_action - check_flags = 0 - background_icon_state = "bg_spell" - -/datum/action/spell_action/Trigger() - if(!..()) - return 0 - if(target) - var/obj/effect/proc_holder/spell = target - spell.Click() - return 1 - -/datum/action/spell_action/UpdateName() - return target.name - -/datum/action/spell_action/IsAvailable() - if(!target) - return 0 - var/obj/effect/proc_holder/spell/spell = target - - if(usr) - return spell.can_cast(usr) - else - if(owner) - return spell.can_cast(owner) - return 1 - -//Preset for general and toggled actions -/datum/action/innate - check_flags = 0 - var/active = 0 - -/datum/action/innate/Trigger() - if(!..()) - return 0 - if(!active) - Activate() - else - Deactivate() - return 1 - -/datum/action/innate/proc/Activate() - return - -/datum/action/innate/proc/Deactivate() - return - -//Preset for action that call specific procs (consider innate). -/datum/action/generic - check_flags = 0 - var/procname - -/datum/action/generic/Trigger() - if(!..()) - return 0 - if(target && procname) - call(target, procname)(usr) - return 1 - - -//Action button controlling a mob's research examine ability. -/datum/action/innate/scan_mode - name = "Toggle Research Scanner" - button_icon_state = "scan_mode" - check_flags = AB_CHECK_RESTRAINED|AB_CHECK_STUNNED|AB_CHECK_CONSCIOUS - var/devices = 0 //How may enabled scanners the mob has - -/datum/action/innate/scan_mode/Activate() - active = 1 - owner.research_scanner = 1 - owner << "Research analyzer is now active." - -/datum/action/innate/scan_mode/Deactivate() - active = 0 - owner.research_scanner = 0 - owner << "Research analyzer deactivated." - -/datum/action/innate/scan_mode/Grant(mob/living/T) - ..(T) - -/datum/action/innate/scan_mode/Remove(mob/living/T) - owner.research_scanner = 0 - active = 0 - ..(T) \ No newline at end of file diff --git a/code/_onclick/hud/action_button.dm b/code/_onclick/hud/action_button.dm new file mode 100644 index 00000000000..e24462f6493 --- /dev/null +++ b/code/_onclick/hud/action_button.dm @@ -0,0 +1,136 @@ + +/obj/screen/movable/action_button + var/datum/action/linked_action + screen_loc = null + +/obj/screen/movable/action_button/Click(location,control,params) + var/list/modifiers = params2list(params) + if(modifiers["shift"]) + moved = 0 + return 1 + if(usr.next_move >= world.time) // Is this needed ? + return + linked_action.Trigger() + return 1 + +//Hide/Show Action Buttons ... Button +/obj/screen/movable/action_button/hide_toggle + name = "Hide Buttons" + icon = 'icons/mob/actions.dmi' + icon_state = "bg_default" + var/hidden = 0 + +/obj/screen/movable/action_button/hide_toggle/Click(location,control,params) + var/list/modifiers = params2list(params) + if(modifiers["shift"]) + moved = 0 + return 1 + usr.hud_used.action_buttons_hidden = !usr.hud_used.action_buttons_hidden + + hidden = usr.hud_used.action_buttons_hidden + if(hidden) + name = "Show Buttons" + else + name = "Hide Buttons" + UpdateIcon() + usr.update_action_buttons() + + +/obj/screen/movable/action_button/hide_toggle/proc/InitialiseIcon(mob/living/user) + if(isalien(user)) + icon_state = "bg_alien" + else + icon_state = "bg_default" + UpdateIcon() + return + +/obj/screen/movable/action_button/hide_toggle/proc/UpdateIcon() + overlays.Cut() + var/image/img = image(icon, src, hidden ? "show" : "hide") + overlays += img + return + + +/obj/screen/movable/action_button/MouseEntered(location,control,params) + openToolTip(usr,src,params,title = name,content = desc) + + +/obj/screen/movable/action_button/MouseExited() + closeToolTip(usr) + + + +//used to update the buttons icon. +/mob/proc/update_action_buttons_icon() + return + +/mob/living/update_action_buttons_icon() + for(var/X in actions) + var/datum/action/A = X + A.UpdateButtonIcon() + +//This is the proc used to update all the action buttons. +/mob/proc/update_action_buttons(reload_screen) + return + +/mob/living/update_action_buttons(reload_screen) + if(!hud_used || !client) + return + + if(hud_used.hud_shown != HUD_STYLE_STANDARD) + return + + var/button_number = 0 + + if(hud_used.action_buttons_hidden) + for(var/datum/action/A in actions) + A.button.screen_loc = null + if(reload_screen) + client.screen += A.button + else + for(var/datum/action/A in actions) + button_number++ + A.UpdateButtonIcon() + var/obj/screen/movable/action_button/B = A.button + if(!B.moved) + B.screen_loc = hud_used.ButtonNumberToScreenCoords(button_number) + else + B.screen_loc = B.moved + if(reload_screen) + client.screen += B + + if(!button_number) + hud_used.hide_actions_toggle.screen_loc = null + return + + if(!hud_used.hide_actions_toggle.moved) + hud_used.hide_actions_toggle.screen_loc = hud_used.ButtonNumberToScreenCoords(button_number+1) + else + hud_used.hide_actions_toggle.screen_loc = hud_used.hide_actions_toggle.moved + if(reload_screen) + client.screen += hud_used.hide_actions_toggle + + + +#define AB_MAX_COLUMNS 10 + +/datum/hud/proc/ButtonNumberToScreenCoords(number) // TODO : Make this zero-indexed for readabilty + var/row = round((number - 1)/AB_MAX_COLUMNS) + var/col = ((number - 1)%(AB_MAX_COLUMNS)) + 1 + + var/coord_col = "+[col-1]" + var/coord_col_offset = 4 + 2 * col + + var/coord_row = "[row ? -row : "+0"]" + + return "WEST[coord_col]:[coord_col_offset],NORTH[coord_row]:-6" + +/datum/hud/proc/SetButtonCoords(obj/screen/button,number) + var/row = round((number-1)/AB_MAX_COLUMNS) + var/col = ((number - 1)%(AB_MAX_COLUMNS)) + 1 + var/x_offset = 32*(col-1) + 4 + 2*col + var/y_offset = -32*(row+1) + 26 + + var/matrix/M = matrix() + M.Translate(x_offset,y_offset) + button.transform = M diff --git a/code/_onclick/hud/screen_objects.dm b/code/_onclick/hud/screen_objects.dm index 33137e1954c..797f0d1ff67 100644 --- a/code/_onclick/hud/screen_objects.dm +++ b/code/_onclick/hud/screen_objects.dm @@ -106,54 +106,59 @@ screen_loc = ui_internal /obj/screen/internals/Click() - if(iscarbon(usr)) - var/mob/living/carbon/C = usr - if(!C.incapacitated()) + if(!iscarbon(usr)) + return + var/mob/living/carbon/C = usr + if(C.incapacitated()) + return + + if(C.internal) + C.internal = null + C << "You are no longer running on internals." + icon_state = "internal0" + else + if(!istype(C.wear_mask, /obj/item/clothing/mask)) + C << "You are not wearing an internals mask!" + return 1 + else + var/obj/item/clothing/mask/M = C.wear_mask + if(M.mask_adjusted) // if mask on face but pushed down + M.adjustmask(C) // adjust it back + if( !(M.flags & MASKINTERNALS) ) + C << "You are not wearing an internals mask!" + return + if(istype(C.l_hand, /obj/item/weapon/tank)) + C << "You are now running on internals from the [C.l_hand] on your left hand." + C.internal = C.l_hand + else if(istype(C.r_hand, /obj/item/weapon/tank)) + C << "You are now running on internals from the [C.r_hand] on your right hand." + C.internal = C.r_hand + else if(ishuman(C)) + var/mob/living/carbon/human/H = C + if(istype(H.s_store, /obj/item/weapon/tank)) + H << "You are now running on internals from the [H.s_store] on your [H.wear_suit]." + H.internal = H.s_store + else if(istype(H.belt, /obj/item/weapon/tank)) + H << "You are now running on internals from the [H.belt] on your belt." + H.internal = H.belt + else if(istype(H.l_store, /obj/item/weapon/tank)) + H << "You are now running on internals from the [H.l_store] in your left pocket." + H.internal = H.l_store + else if(istype(H.r_store, /obj/item/weapon/tank)) + H << "You are now running on internals from the [H.r_store] in your right pocket." + H.internal = H.r_store + + //Seperate so CO2 jetpacks are a little less cumbersome. + if(!C.internal && istype(C.back, /obj/item/weapon/tank)) + C << "You are now running on internals from the [C.back] on your back." + C.internal = C.back + if(C.internal) - C.internal = null - C << "You are no longer running on internals." - icon_state = "internal0" + icon_state = "internal1" else - if(!istype(C.wear_mask, /obj/item/clothing/mask)) - C << "You are not wearing an internals mask!" - return 1 - else - var/obj/item/clothing/mask/M = C.wear_mask - if(M.mask_adjusted) // if mask on face but pushed down - M.adjustmask(C) // adjust it back - if( !(M.flags & MASKINTERNALS) ) - C << "You are not wearing an internals mask!" - return - if(istype(C.l_hand, /obj/item/weapon/tank)) - C << "You are now running on internals from the [C.l_hand] on your left hand." - C.internal = C.l_hand - else if(istype(C.r_hand, /obj/item/weapon/tank)) - C << "You are now running on internals from the [C.r_hand] on your right hand." - C.internal = C.r_hand - else if(ishuman(C)) - var/mob/living/carbon/human/H = C - if(istype(H.s_store, /obj/item/weapon/tank)) - H << "You are now running on internals from the [H.s_store] on your [H.wear_suit]." - H.internal = H.s_store - else if(istype(H.belt, /obj/item/weapon/tank)) - H << "You are now running on internals from the [H.belt] on your belt." - H.internal = H.belt - else if(istype(H.l_store, /obj/item/weapon/tank)) - H << "You are now running on internals from the [H.l_store] in your left pocket." - H.internal = H.l_store - else if(istype(H.r_store, /obj/item/weapon/tank)) - H << "You are now running on internals from the [H.r_store] in your right pocket." - H.internal = H.r_store - - //Seperate so CO2 jetpacks are a little less cumbersome. - if(!C.internal && istype(C.back, /obj/item/weapon/tank)) - C << "You are now running on internals from the [C.back] on your back." - C.internal = C.back - - if(C.internal) - icon_state = "internal1" - else - C << "You don't have an oxygen tank!" + C << "You don't have an oxygen tank!" + return + C.update_action_buttons_icon() /obj/screen/mov_intent name = "run/walk toggle" diff --git a/code/datums/action.dm b/code/datums/action.dm new file mode 100644 index 00000000000..2743fd5f0fb --- /dev/null +++ b/code/datums/action.dm @@ -0,0 +1,357 @@ +#define AB_CHECK_RESTRAINED 1 +#define AB_CHECK_STUNNED 2 +#define AB_CHECK_LYING 4 +#define AB_CHECK_CONSCIOUS 8 + + +/datum/action + var/name = "Generic Action" + var/obj/target = null + var/check_flags = 0 + var/processing = 0 + var/obj/screen/movable/action_button/button = null + var/button_icon = 'icons/mob/actions.dmi' + var/button_icon_state = "default" + var/background_icon_state = "bg_default" + var/mob/living/owner + +/datum/action/New(Target) + target = Target + button = new + button.linked_action = src + button.name = name + +/datum/action/Destroy() + if(owner) + Remove(owner) + target = null + qdel(button) + button = null + return ..() + +/datum/action/proc/Grant(mob/living/L) + if(owner) + if(owner == L) + return + Remove(owner) + owner = L + L.actions += src + if(L.client) + L.client.screen += button + L.update_action_buttons() + +/datum/action/proc/Remove(mob/living/L) + if(L.client) + L.client.screen -= button + button.moved = FALSE //so the button appears in its normal position when given to another owner. + L.actions -= src + L.update_action_buttons() + owner = null + +/datum/action/proc/Trigger() + if(!IsAvailable()) + return 0 + return 1 + +/datum/action/proc/Process() + return + +/datum/action/proc/IsAvailable() + if(!owner) + return 0 + if(check_flags & AB_CHECK_RESTRAINED) + if(owner.restrained()) + return 0 + if(check_flags & AB_CHECK_STUNNED) + if(owner.stunned || owner.weakened) + return 0 + if(check_flags & AB_CHECK_LYING) + if(owner.lying) + return 0 + if(check_flags & AB_CHECK_CONSCIOUS) + if(owner.stat) + return 0 + return 1 + +/datum/action/proc/UpdateButtonIcon() + if(button) + button.icon = button_icon + button.icon_state = background_icon_state + + ApplyIcon(button) + + if(!IsAvailable()) + button.color = rgb(128,0,0,128) + else + button.color = rgb(255,255,255,255) + return 1 + +/datum/action/proc/ApplyIcon(obj/screen/movable/action_button/current_button) + current_button.overlays.Cut() + if(button_icon && button_icon_state) + var/image/img + img = image(button_icon, current_button, button_icon_state) + img.pixel_x = 0 + img.pixel_y = 0 + current_button.overlays += img + + + +//Presets for item actions +/datum/action/item_action + check_flags = AB_CHECK_RESTRAINED|AB_CHECK_STUNNED|AB_CHECK_LYING|AB_CHECK_CONSCIOUS + +/datum/action/item_action/New(Target) + ..() + var/obj/item/I = target + I.actions += src + +/datum/action/item_action/Destroy() + var/obj/item/I = target + I.actions -= src + return ..() + +/datum/action/item_action/Trigger() + if(!..()) + return 0 + if(target) + var/obj/item/I = target + I.ui_action_click(owner, src.type) + return 1 + +/datum/action/item_action/ApplyIcon(obj/screen/movable/action_button/current_button) + current_button.overlays.Cut() + if(target) + var/obj/item/I = target + var/old = I.layer + I.layer = FLOAT_LAYER //AAAH + current_button.overlays += I + I.layer = old + +/datum/action/item_action/toggle_light + name = "Toggle Light" + +/datum/action/item_action/toggle_hood + name = "Toggle Hood" + +/datum/action/item_action/toggle_firemode + name = "Toggle Firemode" + +/datum/action/item_action/startchainsaw + name = "Pull The Starting Cord" + +/datum/action/item_action/toggle_gunlight + name = "Toggle Gunlight" + +/datum/action/item_action/toggle_mode + name = "Toggle Mode" + +/datum/action/item_action/toggle_barrier_spread + name = "Toggle Barrier Spread" + +/datum/action/item_action/equip_unequip_TED_Gun + name = "Equip/Unequip TED Gun" + +/datum/action/item_action/toggle_paddles + name = "Toggle Paddles" + +/datum/action/item_action/set_internals + name = "Set Internals" + +/datum/action/item_action/set_internals/UpdateButtonIcon() + if(..()) //button available + if(iscarbon(owner)) + var/mob/living/carbon/C = owner + if(target == C.internal) + button.icon_state = "bg_internals_on" + +/datum/action/item_action/toggle_mister + name = "Toggle Mister" + +/datum/action/item_action/activate_injector + name = "Activate Injector" + +/datum/action/item_action/toggle_helmet_light + name = "Toggle Helmet Light" + +/datum/action/item_action/toggle_helmet_flashlight + name = "Toggle Helmet Flashlight" + +/datum/action/item_action/toggle_helmet_mode + name = "Toggle Helmet Mode" + +/datum/action/item_action/toggle + +/datum/action/item_action/toggle/New(Target) + ..() + name = "Toggle [target.name]" + button.name = name + +/datum/action/item_action/halt + name = "HALT!" + +/datum/action/item_action/toggle_voice_box + name = "Toggle Voice Box" + +/datum/action/item_action/change + name = "Change" + +/datum/action/item_action/adjust + +/datum/action/item_action/adjust/New(Target) + ..() + name = "Adjust [target.name]" + button.name = name + +/datum/action/item_action/switch_hud + name = "Switch HUD" + +/datum/action/item_action/toggle_wings + name = "Toggle Wings" + +/datum/action/item_action/toggle_human_head + name = "Toggle Human Head" + +/datum/action/item_action/toggle_helmet + name = "Toggle Helmet" + +/datum/action/item_action/jetpack_mode + name = "Jetpack Mode" + +/datum/action/item_action/hands_free + check_flags = AB_CHECK_CONSCIOUS + +/datum/action/item_action/hands_free/activate + name = "Activate" + + +/datum/action/item_action/hands_free/shift_nerves + name = "Shift Nerves" + + +/datum/action/item_action/toggle_research_scanner + name = "Toggle Research Scanner" + button_icon_state = "scan_mode" + +/datum/action/item_action/toggle_research_scanner/Trigger() + if(IsAvailable()) + owner.research_scanner = !owner.research_scanner + owner << "Research analyzer is now [owner.research_scanner ? "active" : "deactivated"]." + return 1 + +/datum/action/item_action/toggle_research_scanner/Remove(mob/living/L) + if(owner) + owner.research_scanner = 0 + ..() + +/datum/action/item_action/toggle_research_scanner/ApplyIcon(obj/screen/movable/action_button/current_button) + if(button_icon && button_icon_state) + var/image/img = image(button_icon, current_button, "scan_mode") + current_button.overlays += img + +/datum/action/item_action/organ_action + check_flags = AB_CHECK_CONSCIOUS + +/datum/action/item_action/organ_action/New(Target) + ..() + name = "Toggle [target.name]" + button.name = name + +/datum/action/item_action/organ_action/IsAvailable() + var/obj/item/organ/internal/I = target + if(!I.owner) + return 0 + return ..() + + + +//Preset for spells +/datum/action/spell_action + check_flags = 0 + background_icon_state = "bg_spell" + +/datum/action/spell_action/New(Target) + ..() + var/obj/effect/proc_holder/spell/S = target + S.action = src + name = S.name + button_icon = S.action_icon + button_icon_state = S.action_icon_state + background_icon_state = S.action_background_icon_state + button.name = name + +/datum/action/spell_action/Destroy() + var/obj/effect/proc_holder/spell/S = target + S.action = null + return ..() + +/datum/action/spell_action/Trigger() + if(!..()) + return 0 + if(target) + var/obj/effect/proc_holder/spell = target + spell.Click() + return 1 + +/datum/action/spell_action/IsAvailable() + if(!target) + return 0 + var/obj/effect/proc_holder/spell/spell = target + + if(usr) + return spell.can_cast(usr) + else + if(owner) + return spell.can_cast(owner) + return 1 + + +/datum/action/spell_action/alien + +/datum/action/spell_action/alien/IsAvailable() + if(!target) + return 0 + var/obj/effect/proc_holder/alien/ab = target + + if(usr) + return ab.cost_check(ab.check_turf,usr,1) + else + if(owner) + return ab.cost_check(ab.check_turf,owner,1) + return 1 + + + +//Preset for general and toggled actions +/datum/action/innate + check_flags = 0 + var/active = 0 + +/datum/action/innate/Trigger() + if(!..()) + return 0 + if(!active) + Activate() + else + Deactivate() + return 1 + +/datum/action/innate/proc/Activate() + return + +/datum/action/innate/proc/Deactivate() + return + + + +//Preset for action that call specific procs (consider innate). +/datum/action/generic + check_flags = 0 + var/procname + +/datum/action/generic/Trigger() + if(!..()) + return 0 + if(target && procname) + call(target, procname)(usr) + return 1 diff --git a/code/datums/mind.dm b/code/datums/mind.dm index ab14f6575c9..7fc41c16e58 100644 --- a/code/datums/mind.dm +++ b/code/datums/mind.dm @@ -1549,34 +1549,20 @@ return 1 -/datum/mind/proc/AddSpell(obj/effect/proc_holder/spell/spell) - spell_list += spell - if(!spell.action) - spell.action = new/datum/action/spell_action - spell.action.target = spell - spell.action.name = spell.name - spell.action.button_icon = spell.action_icon - spell.action.button_icon_state = spell.action_icon_state - spell.action.background_icon_state = spell.action_background_icon_state - spell.action.Grant(current) - return +/datum/mind/proc/AddSpell(obj/effect/proc_holder/spell/S) + spell_list += S + S.action.Grant(current) + /datum/mind/proc/transfer_actions(mob/living/new_character) if(current && current.actions) for(var/datum/action/A in current.actions) A.Grant(new_character) transfer_mindbound_actions(new_character) -/datum/mind/proc/transfer_mindbound_actions(var/mob/living/new_character) - for(var/obj/effect/proc_holder/spell/spell in spell_list) - if(!spell.action) // Unlikely but whatever - spell.action = new/datum/action/spell_action - spell.action.target = spell - spell.action.name = spell.name - spell.action.button_icon = spell.action_icon - spell.action.button_icon_state = spell.action_icon_state - spell.action.background_icon_state = spell.action_background_icon_state - spell.action.Grant(new_character) - return +/datum/mind/proc/transfer_mindbound_actions(mob/living/new_character) + for(var/X in spell_list) + var/obj/effect/proc_holder/spell/S = X + S.action.Grant(new_character) /mob/proc/sync_mind() mind_initialize() //updates the mind (or creates and initializes one if one doesn't exist) diff --git a/code/game/gamemodes/miniantags/abduction/abduction_gear.dm b/code/game/gamemodes/miniantags/abduction/abduction_gear.dm index 707df3c16f0..41b35e2f108 100644 --- a/code/game/gamemodes/miniantags/abduction/abduction_gear.dm +++ b/code/game/gamemodes/miniantags/abduction/abduction_gear.dm @@ -13,8 +13,7 @@ blood_overlay_type = "armor" origin_tech = "materials=5;biotech=4;powerstorage=5" armor = list(melee = 15, bullet = 15, laser = 15, energy = 15, bomb = 15, bio = 15, rad = 15) - action_button_name = "Activate" - action_button_type = /datum/action/item_action/hands_free + actions_types = list(/datum/action/item_action/hands_free/activate) var/mode = VEST_STEALTH var/stealth_active = 0 var/combat_cooldown = 10 @@ -36,8 +35,9 @@ if(istype(loc, /mob/living/carbon/human)) var/mob/living/carbon/human/H = loc H.update_inv_wear_suit() - if(action && action.button) - action.button.UpdateIcon() + for(var/X in actions) + var/datum/action/A = X + A.UpdateButtonIcon() /obj/item/clothing/suit/armor/abductor/vest/item_action_slot_check(slot, mob/user) if(slot == slot_wear_suit) //we only give the mob the ability to activate the vest if he's actually wearing it. @@ -365,7 +365,7 @@ Congratulations! You are now trained for xenobiology research!"} origin_tech = "materials=6;combat=5;biotech=7" force = 7 w_class = 3 - action_button_name = "Toggle Mode" + actions_types = list(/datum/action/item_action/toggle_mode) /obj/item/weapon/abductor_baton/proc/toggle(mob/living/user=usr) mode = (mode+1)%BATON_MODES diff --git a/code/game/gamemodes/miniantags/revenant/revenant_abilities.dm b/code/game/gamemodes/miniantags/revenant/revenant_abilities.dm index f61cf1c8a6e..b6d9281ab40 100644 --- a/code/game/gamemodes/miniantags/revenant/revenant_abilities.dm +++ b/code/game/gamemodes/miniantags/revenant/revenant_abilities.dm @@ -79,8 +79,8 @@ name = "[initial(name)] ([cast_amount]E)" user.reveal(reveal) user.stun(stun) - if(action && action.button) - action.button.UpdateIcon() + if(action) + action.UpdateButtonIcon() return 1 //Overload Light: Breaks a light that's online and sends out lightning bolts to all nearby people. diff --git a/code/game/gamemodes/shadowling/shadowling_items.dm b/code/game/gamemodes/shadowling/shadowling_items.dm index 7be25cd4722..0284386cde5 100644 --- a/code/game/gamemodes/shadowling/shadowling_items.dm +++ b/code/game/gamemodes/shadowling/shadowling_items.dm @@ -83,8 +83,7 @@ invis_view = 2 flash_protect = -1 unacidable = 1 - action_button_name = "Shift Nerves" - action_button_type = /datum/action/item_action/hands_free + actions_types = list(/datum/action/item_action/hands_free/shift_nerves) var/max_darkness_view = 8 var/min_darkness_view = 0 flags = ABSTRACT | NODROP diff --git a/code/game/machinery/deployable.dm b/code/game/machinery/deployable.dm index d56706d2e09..40a9a5f4641 100644 --- a/code/game/machinery/deployable.dm +++ b/code/game/machinery/deployable.dm @@ -134,7 +134,7 @@ icon = 'icons/obj/grenade.dmi' icon_state = "flashbang" item_state = "flashbang" - action_button_name = "Toggle Barrier Spread" + actions_types = list(/datum/action/item_action/toggle_barrier_spread) var/mode = SINGLE /obj/item/weapon/grenade/barrier/AltClick(mob/user) @@ -172,8 +172,8 @@ new /obj/structure/barricade/security(target_turf2) qdel(src) -/obj/item/weapon/grenade/barrier/ui_action_click() - toggle_mode(usr) +/obj/item/weapon/grenade/barrier/ui_action_click(mob/user) + toggle_mode(user) #undef SINGLE diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm index c520f594834..7d9eddc24a4 100644 --- a/code/game/objects/items.dm +++ b/code/game/objects/items.dm @@ -33,10 +33,8 @@ var/global/image/fire_overlay = image("icon" = 'icons/effects/fire.dmi', "icon_s var/max_heat_protection_temperature //Set this variable to determine up to which temperature (IN KELVIN) the item protects against heat damage. Keep at null to disable protection. Only protects areas set by heat_protection flags var/min_cold_protection_temperature //Set this variable to determine down to which temperature (IN KELVIN) the item protects against cold damage. 0 is NOT an acceptable number due to if(varname) tests!! Keep at null to disable protection. Only protects areas set by cold_protection flags - //If this is set, The item will make an action button on the player's HUD when picked up. - var/action_button_name //It is also the text which gets displayed on the action button. If not set it defaults to 'Use [name]'. If it's not set, there'll be no button. - var/action_button_type = null //if we want a special type of item action, not the standard one. - var/datum/action/item_action/action = null + var/list/actions = list() //list of /datum/action's that this item has. + var/list/actions_types = list() //list of paths of action datums to give to the item on New(). //Since any item can now be a piece of clothing, this has to be put here so all items share it. var/flags_inv //This flag is used to determine when items in someone's inventory cover others. IE helmets making it so you can't see glasses, etc. @@ -130,10 +128,17 @@ var/global/image/fire_overlay = image("icon" = 'icons/effects/fire.dmi', "icon_s /obj/item/device icon = 'icons/obj/device.dmi' +/obj/item/New() + ..() + for(var/path in actions_types) + new path(src) + /obj/item/Destroy() if(ismob(loc)) var/mob/m = loc m.unEquip(src, 1) + for(var/X in actions) + qdel(X) return ..() /obj/item/blob_act() @@ -362,8 +367,9 @@ var/global/image/fire_overlay = image("icon" = 'icons/effects/fire.dmi', "icon_s return /obj/item/proc/dropped(mob/user) - if(action) - action.Remove(user) + for(var/X in actions) + var/datum/action/A = X + A.Remove(user) // called just as an item is picked up (loc is not yet changed) /obj/item/proc/pickup(mob/user) @@ -388,16 +394,10 @@ var/global/image/fire_overlay = image("icon" = 'icons/effects/fire.dmi', "icon_s // for items that can be placed in multiple slots // note this isn't called during the initial dressing of a player /obj/item/proc/equipped(mob/user, slot) - if(action_button_name) - if(!action) - if(action_button_type) - action = new action_button_type - else - action = new/datum/action/item_action - action.name = action_button_name - action.target = src - if(item_action_slot_check(slot, user)) //some items only give their action button when in a specific slot. - action.Grant(user) + for(var/X in actions) + var/datum/action/A = X + if(item_action_slot_check(slot, user)) //some items only give their actions buttons when in a specific slot. + A.Grant(user) //sometimes we only want to grant the item's action if it's equipped in a specific slot. obj/item/proc/item_action_slot_check(slot, mob/user) @@ -423,11 +423,11 @@ obj/item/proc/item_action_slot_check(slot, mob/user) if(usr.get_active_hand() == null) // Let me know if this has any problems -Yota usr.UnarmedAttack(src) -//This proc is executed when someone clicks the on-screen UI button. To make the UI button show, set the 'action_button_name'. +//This proc is executed when someone clicks the on-screen UI button. //The default action is attack_self(). //Checks before we get to here are: mob is alive, mob is not restrained, paralyzed, asleep, resting, laying, item is on the mob. -/obj/item/proc/ui_action_click() - attack_self(usr) +/obj/item/proc/ui_action_click(mob/user, actiontype) + attack_self(user) /obj/item/proc/IsReflect(var/def_zone) //This proc determines if and at what% an object will reflect energy projectiles if it's in l_hand,r_hand or wear_suit return 0 diff --git a/code/game/objects/items/devices/flashlight.dm b/code/game/objects/items/devices/flashlight.dm index 8e136bbb682..94a556d9b2e 100644 --- a/code/game/objects/items/devices/flashlight.dm +++ b/code/game/objects/items/devices/flashlight.dm @@ -8,7 +8,7 @@ flags = CONDUCT slot_flags = SLOT_BELT materials = list(MAT_METAL=50, MAT_GLASS=20) - action_button_name = "Toggle Light" + actions_types = list(/datum/action/item_action/toggle_light) var/on = 0 var/brightness_on = 4 //luminosity when on @@ -41,8 +41,9 @@ return 0 on = !on update_brightness(user) - if(action && action.button) - action.button.UpdateIcon() + for(var/X in actions) + var/datum/action/A = X + A.UpdateButtonIcon() return 1 @@ -195,7 +196,7 @@ obj/item/device/flashlight/lamp/bananalamp brightness_on = 7 // Pretty bright. icon_state = "flare" item_state = "flare" - action_button_name = null //just pull it manually, neckbeard. + actions_types = list() var/fuel = 0 var/on_damage = 7 var/produce_heat = 1500 diff --git a/code/game/objects/items/devices/traitordevices.dm b/code/game/objects/items/devices/traitordevices.dm index 5ef14db2bdc..43864b56684 100644 --- a/code/game/objects/items/devices/traitordevices.dm +++ b/code/game/objects/items/devices/traitordevices.dm @@ -158,10 +158,10 @@ effective or pretty fucking useless. var/max_charge = 300 var/on = 0 var/old_alpha = 0 - action_button_name = "Toggle Cloaker" + actions_types = list(/datum/action/item_action/toggle) -/obj/item/device/shadowcloak/ui_action_click() - if(usr.get_item_by_slot(slot_belt) == src) +/obj/item/device/shadowcloak/ui_action_click(mob/user) + if(user.get_item_by_slot(slot_belt) == src) if(!on) Activate(usr) else diff --git a/code/game/objects/items/robot/robot_upgrades.dm b/code/game/objects/items/robot/robot_upgrades.dm index 278156bb3ce..7cd44cecb81 100644 --- a/code/game/objects/items/robot/robot_upgrades.dm +++ b/code/game/objects/items/robot/robot_upgrades.dm @@ -235,12 +235,8 @@ cyborg = R icon_state = "selfrepair_off" - action_button_name = "Toggle Self-Repair" - if(!action) - action = new - action.name = action_button_name - action.target = src - action.Grant(R) + var/datum/action/A = new /datum/action/item_action/toggle(src) + A.Grant(R) return 1 /obj/item/borg/upgrade/selfrepair/ui_action_click() @@ -256,8 +252,9 @@ /obj/item/borg/upgrade/selfrepair/update_icon() if(cyborg) icon_state = "selfrepair_[on ? "on" : "off"]" - if(action && action.button) - action.button.UpdateIcon() + for(var/X in actions) + var/datum/action/A = X + A.UpdateButtonIcon() else icon_state = "cyborg_upgrade5" diff --git a/code/game/objects/items/weapons/chrono_eraser.dm b/code/game/objects/items/weapons/chrono_eraser.dm index f89da1dcc97..b325e95844f 100644 --- a/code/game/objects/items/weapons/chrono_eraser.dm +++ b/code/game/objects/items/weapons/chrono_eraser.dm @@ -9,7 +9,7 @@ w_class = 4 slot_flags = SLOT_BACK slowdown = 1 - action_button_name = "Equip/Unequip TED Gun" + actions_types = list(/datum/action/item_action/equip_unequip_TED_Gun) var/obj/item/weapon/gun/energy/chrono_gun/PA = null var/list/erased_minds = list() //a collection of minds from the dead @@ -25,14 +25,15 @@ dropped() return ..() -/obj/item/weapon/chrono_eraser/ui_action_click() - var/mob/living/carbon/user = src.loc - if(iscarbon(user) && (user.back == src)) - if(PA) - qdel(PA) - else - PA = new(src) - user.put_in_hands(PA) +/obj/item/weapon/chrono_eraser/ui_action_click(mob/user) + if(iscarbon(user)) + var/mob/living/carbon/C = user + if(C.back == src) + if(PA) + qdel(PA) + else + PA = new(src) + user.put_in_hands(PA) /obj/item/weapon/chrono_eraser/item_action_slot_check(slot, mob/user) if(slot == slot_back) diff --git a/code/game/objects/items/weapons/defib.dm b/code/game/objects/items/weapons/defib.dm index 6a7476b4c94..78cd7163026 100644 --- a/code/game/objects/items/weapons/defib.dm +++ b/code/game/objects/items/weapons/defib.dm @@ -11,7 +11,7 @@ throwforce = 6 w_class = 4 origin_tech = "biotech=4" - action_button_name = "Toggle Paddles" + actions_types = list(/datum/action/item_action/toggle_paddles) var/on = 0 //if the paddles are equipped (1) or on the defib (0) var/safety = 1 //if you can zap people with the defibs on harm mode @@ -177,8 +177,9 @@ remove_paddles(user) update_icon() - if(action && action.button) - action.button.UpdateIcon() + for(var/X in actions) + var/datum/action/A = X + A.UpdateButtonIcon() /obj/item/weapon/defibrillator/proc/make_paddles() return new /obj/item/weapon/twohanded/shockpaddles(src) diff --git a/code/game/objects/items/weapons/implants/implant.dm b/code/game/objects/items/weapons/implants/implant.dm index 13a9a9f4c73..a19a828d64e 100644 --- a/code/game/objects/items/weapons/implants/implant.dm +++ b/code/game/objects/items/weapons/implants/implant.dm @@ -3,7 +3,7 @@ icon = 'icons/obj/implants.dmi' icon_state = "generic" //Shows up as the action button icon origin_tech = "materials=2;biotech=3;programming=2" - + actions_types = list(/datum/action/item_action/hands_free/activate) var/activated = 1 //1 for implant types that can be activated, 0 for ones that are "always on" like loyalty implants var/implanted = null var/mob/living/imp_in = null @@ -43,12 +43,9 @@ imp_in = source implanted = 1 if(activated) - action_button_name = "Activate [src.name]" - if(!action) - action = new /datum/action/item_action/hands_free - action.name = action_button_name - action.target = src - action.Grant(source) + for(var/X in actions) + var/datum/action/A = X + A.Grant(source) if(istype(source, /mob/living/carbon/human)) var/mob/living/carbon/human/H = source H.sec_hud_set_implants() @@ -62,8 +59,9 @@ src.loc = null imp_in = null implanted = 0 - if(action) - action.Remove(source) + for(var/X in actions) + var/datum/action/A = X + A.Grant(source) if(istype(source, /mob/living/carbon/human)) var/mob/living/carbon/human/H = source H.sec_hud_set_implants() diff --git a/code/game/objects/items/weapons/tanks/jetpack.dm b/code/game/objects/items/weapons/tanks/jetpack.dm index fad276107cf..02b89d5cd51 100644 --- a/code/game/objects/items/weapons/tanks/jetpack.dm +++ b/code/game/objects/items/weapons/tanks/jetpack.dm @@ -1,17 +1,3 @@ -/datum/action/item_action/jetpack/cycle - name = "Jetpack Mode" - -/datum/action/item_action/jetpack/cycle/Trigger() - if(!IsAvailable()) - return - - var/obj/item/weapon/tank/jetpack/J = target - J.cycle(owner) - return 1 - -/datum/action/item_action/jetpack/cycle/suit - name = "Internal Jetpack Mode" - /obj/item/weapon/tank/jetpack name = "jetpack (empty)" desc = "A tank of compressed gas for use as propulsion in zero-gravity areas. Use with caution." @@ -19,15 +5,12 @@ item_state = "jetpack" w_class = 4 distribute_pressure = ONE_ATMOSPHERE * O2STANDARD + actions_types = list(/datum/action/item_action/set_internals, /datum/action/item_action/jetpack_mode) var/gas_type = "o2" var/on = FALSE var/turbo = FALSE - var/datum/effect_system/trail_follow/ion/ion_trail - var/datum/action/item_action/jetpack/cycle/cycle_action - var/cycle_action_type = /datum/action/item_action/jetpack/cycle - /obj/item/weapon/tank/jetpack/New() ..() air_contents.assert_gas(gas_type) @@ -36,15 +19,12 @@ ion_trail = new ion_trail.set_up(src) - cycle_action = new cycle_action_type(src) +/obj/item/weapon/tank/jetpack/ui_action_click(mob/user, actiontype) + if(actiontype == /datum/action/item_action/jetpack_mode) + cycle(user) + else + toggle_internals(user) -/obj/item/weapon/tank/jetpack/pickup(mob/user) - ..() - cycle_action.Grant(user) - -/obj/item/weapon/tank/jetpack/dropped(mob/user) - ..() - cycle_action.Remove(user) /obj/item/weapon/tank/jetpack/proc/cycle(mob/user) if(user.incapacitated()) @@ -60,6 +40,10 @@ turn_off() turbo = FALSE user << "You turn jetpack off." + for(var/X in actions) + var/datum/action/A = X + A.UpdateButtonIcon() + /obj/item/weapon/tank/jetpack/proc/turn_on() on = TRUE @@ -130,8 +114,8 @@ desc = "A device that will use your internals tank as a gas source for propulsion." icon_state = "jetpack-void" item_state = "jetpack-void" + actions_types = list(/datum/action/item_action/jetpack_mode) var/obj/item/weapon/tank/internals/tank = null - cycle_action_type = /datum/action/item_action/jetpack/cycle/suit /obj/item/weapon/tank/jetpack/suit/New() ..() diff --git a/code/game/objects/items/weapons/tanks/tanks.dm b/code/game/objects/items/weapons/tanks/tanks.dm index 9130d3c75f8..58b230917d2 100644 --- a/code/game/objects/items/weapons/tanks/tanks.dm +++ b/code/game/objects/items/weapons/tanks/tanks.dm @@ -9,33 +9,42 @@ throwforce = 10 throw_speed = 1 throw_range = 4 - action_button_name = "Set Internals" + actions_types = list(/datum/action/item_action/set_internals) var/datum/gas_mixture/air_contents = null var/distribute_pressure = ONE_ATMOSPHERE var/integrity = 3 var/volume = 70 -/obj/item/weapon/tank/ui_action_click() - var/mob/living/carbon/human/H = action.owner +/obj/item/weapon/tank/ui_action_click(mob/user) + toggle_internals(user) + +/obj/item/weapon/tank/proc/toggle_internals(mob/user) + var/mob/living/carbon/human/H = user if(!istype(H)) return - if(!H.wear_mask) - H << "You need a mask!" - return - if(H.wear_mask.mask_adjusted) - H.wear_mask.adjustmask(H) - if(!(H.wear_mask.flags & MASKINTERNALS)) - H << "[H.wear_mask] can't use [src]!" - return if(H.internal == src) + H << "You close [src] valve." H.internal = null - H << "You close \the [src] valve." H.update_internals_hud_icon(0) - else if(H.wear_mask && (H.wear_mask.flags & MASKINTERNALS)) + else + if(!H.wear_mask) + H << "You need a mask!" + return + if(H.wear_mask.mask_adjusted) + H.wear_mask.adjustmask(H) + if(!(H.wear_mask.flags & MASKINTERNALS)) + H << "[H.wear_mask] can't use [src]!" + return + + if(H.internal) + H << "You switch your internals to [src]." + else + H << "You open [src] valve." H.internal = src - H << "You open \the [src] valve." H.update_internals_hud_icon(1) + H.update_action_buttons_icon() + /obj/item/weapon/tank/New() ..() diff --git a/code/game/objects/items/weapons/tanks/watertank.dm b/code/game/objects/items/weapons/tanks/watertank.dm index 33a83cbd03e..fdb0cdf157d 100644 --- a/code/game/objects/items/weapons/tanks/watertank.dm +++ b/code/game/objects/items/weapons/tanks/watertank.dm @@ -8,7 +8,7 @@ w_class = 4 slot_flags = SLOT_BACK slowdown = 1 - action_button_name = "Toggle Mister" + actions_types = list(/datum/action/item_action/toggle_mister) var/obj/item/weapon/noz var/on = 0 @@ -341,7 +341,7 @@ w_class = 4 slot_flags = SLOT_BACK slowdown = 1 - action_button_name = "Activate Injector" + actions_types = list(/datum/action/item_action/activate_injector) var/on = 0 volume = 300 diff --git a/code/game/objects/items/weapons/twohanded.dm b/code/game/objects/items/weapons/twohanded.dm index 03556edae0e..1e4cc29fb10 100644 --- a/code/game/objects/items/weapons/twohanded.dm +++ b/code/game/objects/items/weapons/twohanded.dm @@ -394,7 +394,7 @@ attack_verb = list("sawed", "torn", "cut", "chopped", "diced") hitsound = "swing_hit" sharpness = IS_SHARP - action_button_name = "Pull the starting cord" + actions_types = list(/datum/action/item_action/startchainsaw) var/on = 0 /obj/item/weapon/twohanded/required/chainsaw/attack_self(mob/user) @@ -412,8 +412,9 @@ if(src == user.get_active_hand()) //update inhands user.update_inv_l_hand() user.update_inv_r_hand() - if(action && action.button) - action.button.UpdateIcon() + for(var/X in actions) + var/datum/action/A = X + A.UpdateButtonIcon() //GREY TIDE diff --git a/code/modules/clothing/clothing.dm b/code/modules/clothing/clothing.dm index f1ce059d3ae..9cd995349a6 100644 --- a/code/modules/clothing/clothing.dm +++ b/code/modules/clothing/clothing.dm @@ -116,7 +116,6 @@ BLIND // can't see anything strip_delay = 40 put_on_delay = 40 var/mask_adjusted = 0 - var/ignore_maskadjust = 1 var/adjusted_flags = null @@ -132,31 +131,32 @@ BLIND // can't see anything //Proc that moves gas/breath masks out of the way, disabling them and allowing pill/food consumption /obj/item/clothing/mask/proc/adjustmask(mob/living/user) - if(!ignore_maskadjust) - if(user.incapacitated()) - return - if(mask_adjusted == 1) - src.icon_state = initial(icon_state) - gas_transfer_coefficient = initial(gas_transfer_coefficient) - permeability_coefficient = initial(permeability_coefficient) - flags |= visor_flags - flags_inv |= visor_flags_inv - flags_cover = initial(flags_cover) - user << "You push \the [src] back into place." - src.mask_adjusted = 0 - slot_flags = initial(slot_flags) - else - icon_state += "_up" - user << "You push \the [src] out of the way." - gas_transfer_coefficient = null - permeability_coefficient = null - flags &= ~visor_flags - flags_inv &= ~visor_flags_inv - flags_cover &= 0 - src.mask_adjusted = 1 - if(adjusted_flags) - slot_flags = adjusted_flags - user.wear_mask_update(src, unequip = 0) + if(user.incapacitated()) + return + mask_adjusted = !mask_adjusted + if(!mask_adjusted) + src.icon_state = initial(icon_state) + gas_transfer_coefficient = initial(gas_transfer_coefficient) + permeability_coefficient = initial(permeability_coefficient) + flags |= visor_flags + flags_inv |= visor_flags_inv + flags_cover = initial(flags_cover) + user << "You push \the [src] back into place." + slot_flags = initial(slot_flags) + else + icon_state += "_up" + user << "You push \the [src] out of the way." + gas_transfer_coefficient = null + permeability_coefficient = null + flags &= ~visor_flags + flags_inv &= ~visor_flags_inv + flags_cover &= 0 + if(adjusted_flags) + slot_flags = adjusted_flags + user.wear_mask_update(src, toggle_off = mask_adjusted) + for(var/X in actions) + var/datum/action/A = X + A.UpdateButtonIcon() @@ -516,8 +516,9 @@ BLIND // can't see anything if(istype(usr, /mob/living/carbon)) var/mob/living/carbon/C = usr C.head_update(src, forced = 1) - if(action && action.button) - action.button.UpdateIcon() + for(var/X in actions) + var/datum/action/A = X + A.UpdateButtonIcon() /obj/item/clothing/proc/can_use(mob/user) if(user && ismob(user)) diff --git a/code/modules/clothing/glasses/engine_goggles.dm b/code/modules/clothing/glasses/engine_goggles.dm index 4194f474fc0..c5e4954152c 100644 --- a/code/modules/clothing/glasses/engine_goggles.dm +++ b/code/modules/clothing/glasses/engine_goggles.dm @@ -4,7 +4,7 @@ name = "Engineering Scanner Goggles" desc = "Goggles used by engineers. The Meson Scanner mode lets you see basic structural and terrain layouts through walls, regardless of lighting condition. The T-ray Scanner mode lets you see underfloor objects such as cables and pipes." icon_state = "trayson-meson" - action_button_name = "Change Scanning Mode" + actions_types = list(/datum/action/item_action/toggle_mode) var/mode = 0 //0 - regular mesons mode 1 - t-ray mode var/invis_objects = list() @@ -33,8 +33,9 @@ H.update_sight() update_icon() - if(action && action.button) - action.button.UpdateIcon() + for(var/X in actions) + var/datum/action/A = X + A.UpdateButtonIcon() /obj/item/clothing/glasses/meson/engine/process() if(!mode) @@ -94,7 +95,6 @@ name = "Optical T-Ray Scanner" desc = "Used by engineering staff to see underfloor objects such as cables and pipes." icon_state = "trayson-tray_off" - action_button_name = "Toggle Scanner Power" mode = 1 var/on = 0 @@ -127,8 +127,9 @@ invis_update() update_icon() - if(action && action.button) - action.button.UpdateIcon() + for(var/X in actions) + var/datum/action/A = X + A.UpdateButtonIcon() /obj/item/clothing/glasses/meson/engine/tray/t_ray_on() return on && ..() \ No newline at end of file diff --git a/code/modules/clothing/glasses/glasses.dm b/code/modules/clothing/glasses/glasses.dm index 31f9e2aefae..df0f18f5405 100644 --- a/code/modules/clothing/glasses/glasses.dm +++ b/code/modules/clothing/glasses/glasses.dm @@ -50,16 +50,11 @@ item_state = "glasses" origin_tech = "magnets=2;engineering=2" scan_reagents = 1 //You can see reagents while wearing science goggles + actions_types = list(/datum/action/item_action/toggle_research_scanner) -/obj/item/clothing/glasses/science/equipped(mob/user, slot) +/obj/item/clothing/glasses/science/item_action_slot_check(slot) if(slot == slot_glasses) - user.scanner.devices += 1 - user.scanner.Grant(user) - ..(user, slot) - -/obj/item/clothing/glasses/science/dropped(mob/user) - user.scanner.devices = max(0, user.scanner.devices - 1) - ..() + return 1 /obj/item/clothing/glasses/night name = "Night Vision Goggles" @@ -170,7 +165,7 @@ desc = "Protects the eyes from welders; approved by the mad scientist association." icon_state = "welding-g" item_state = "welding-g" - action_button_name = "Toggle Welding Goggles" + actions_types = list(/datum/action/item_action/toggle) materials = list(MAT_METAL = 250) flash_protect = 2 tint = 2 diff --git a/code/modules/clothing/glasses/hud.dm b/code/modules/clothing/glasses/hud.dm index 55b4786b813..7ab535c4d9d 100644 --- a/code/modules/clothing/glasses/hud.dm +++ b/code/modules/clothing/glasses/hud.dm @@ -114,7 +114,7 @@ /obj/item/clothing/glasses/hud/toggle name = "Toggle Hud" desc = "A hud with multiple functions." - action_button_name = "Switch HUD" + actions_types = list(/datum/action/item_action/switch_hud) /obj/item/clothing/glasses/hud/toggle/attack_self(mob/user) if(!ishuman(user)) diff --git a/code/modules/clothing/head/hardhat.dm b/code/modules/clothing/head/hardhat.dm index 756732dbabe..1c0e4b04794 100644 --- a/code/modules/clothing/head/hardhat.dm +++ b/code/modules/clothing/head/hardhat.dm @@ -8,7 +8,7 @@ item_color = "yellow" //Determines used sprites: hardhat[on]_[item_color] and hardhat[on]_[item_color]2 (lying down sprite) armor = list(melee = 15, bullet = 5, laser = 20,energy = 10, bomb = 20, bio = 10, rad = 20) flags_inv = 0 - action_button_name = "Toggle Helmet Light" + actions_types = list(/datum/action/item_action/toggle_helmet_light) burn_state = FIRE_PROOF /obj/item/clothing/head/hardhat/attack_self(mob/user) @@ -24,8 +24,9 @@ turn_on(user) else turn_off(user) - if(action && action.button) - action.button.UpdateIcon() + for(var/X in actions) + var/datum/action/A = X + A.UpdateButtonIcon() /obj/item/clothing/head/hardhat/pickup(mob/user) ..() diff --git a/code/modules/clothing/head/helmet.dm b/code/modules/clothing/head/helmet.dm index 5592732ca14..543f765addb 100644 --- a/code/modules/clothing/head/helmet.dm +++ b/code/modules/clothing/head/helmet.dm @@ -43,7 +43,7 @@ armor = list(melee = 41, bullet = 15, laser = 5,energy = 5, bomb = 5, bio = 2, rad = 0) flags_inv = HIDEMASK|HIDEEARS|HIDEFACE strip_delay = 80 - action_button_name = "Toggle Helmet Visor" + actions_types = list(/datum/action/item_action/toggle) visor_flags_inv = HIDEMASK|HIDEFACE toggle_cooldown = 0 flags_cover = HEADCOVERSEYES | HEADCOVERSMOUTH @@ -75,7 +75,7 @@ icon_state = "justice" toggle_message = "You turn off the lights on" alt_toggle_message = "You turn on the lights on" - action_button_name = "Toggle Justice Lights" + actions_types = list(/datum/action/item_action/toggle_helmet_light) can_toggle = 1 toggle_cooldown = 20 active_sound = 'sound/items/WEEOO1.ogg' @@ -86,7 +86,6 @@ icon_state = "justice2" toggle_message = "You turn off the light on" alt_toggle_message = "You turn on the light on" - action_button_name = "Toggle Alarm Lights" /obj/item/clothing/head/helmet/swat name = "\improper SWAT helmet" @@ -210,35 +209,33 @@ return -/obj/item/clothing/head/helmet/ui_action_click() - toggle_helmlight() - ..() +/obj/item/clothing/head/helmet/ui_action_click(mob/user, actiontype) + if(actiontype == /datum/action/item_action/toggle_helmet_flashlight) + toggle_helmlight() + else + ..() -/obj/item/clothing/head/helmet/attackby(obj/item/A, mob/user, params) - if(istype(A, /obj/item/device/flashlight/seclite)) - var/obj/item/device/flashlight/seclite/S = A +/obj/item/clothing/head/helmet/attackby(obj/item/I, mob/user, params) + if(istype(I, /obj/item/device/flashlight/seclite)) + var/obj/item/device/flashlight/seclite/S = I if(can_flashlight) if(!F) - if(!user.unEquip(A)) + if(!user.unEquip(S)) return user << "You click [S] into place on [src]." if(S.on) SetLuminosity(0) F = S - A.loc = src + S.loc = src update_icon() update_helmlight(user) verbs += /obj/item/clothing/head/helmet/proc/toggle_helmlight - action_button_name = "Toggle Helmetlight" + var/datum/action/A = new /datum/action/item_action/toggle_helmet_flashlight(src) if(loc == user) - if(!action) - action = new - action.name = action_button_name - action.target = src - action.Grant(user) + A.Grant(user) return - if(istype(A, /obj/item/weapon/screwdriver)) + if(istype(I, /obj/item/weapon/screwdriver)) if(F) for(var/obj/item/device/flashlight/seclite/S in src) user << "You unscrew the seclite from [src]." @@ -249,9 +246,8 @@ update_icon() usr.update_inv_head() verbs -= /obj/item/clothing/head/helmet/proc/toggle_helmlight - action_button_name = null - if(action && loc == user) - action.Remove(user) + for(var/datum/action/item_action/toggle_helmet_flashlight/THL in actions) + qdel(THL) return ..() @@ -295,9 +291,9 @@ user.AddLuminosity(-5) else if(isturf(loc)) SetLuminosity(0) - action_button_name = null - if(action && action.button) - action.button.UpdateIcon() + for(var/X in actions) + var/datum/action/A = X + A.UpdateButtonIcon() /obj/item/clothing/head/helmet/pickup(mob/user) ..() diff --git a/code/modules/clothing/head/misc_special.dm b/code/modules/clothing/head/misc_special.dm index 91265c6cd01..9b660fb015c 100644 --- a/code/modules/clothing/head/misc_special.dm +++ b/code/modules/clothing/head/misc_special.dm @@ -23,7 +23,7 @@ tint = 2 armor = list(melee = 10, bullet = 0, laser = 0,energy = 0, bomb = 0, bio = 0, rad = 0) flags_inv = HIDEMASK|HIDEEARS|HIDEEYES|HIDEFACE - action_button_name = "Toggle Welding Helmet" + actions_types = list(/datum/action/item_action/toggle) visor_flags_inv = HIDEMASK|HIDEEARS|HIDEEYES|HIDEFACE burn_state = FIRE_PROOF @@ -49,7 +49,6 @@ item_state = "hardhat0_cakehat" item_color = "cakehat" flags_inv = HIDEEARS|HIDEHAIR - action_button_name = "Toggle Candle" armor = list(melee = 0, bullet = 0, laser = 0,energy = 0, bomb = 0, bio = 0, rad = 0) brightness_on = 2 //luminosity when on flags_cover = HEADCOVERSEYES @@ -116,7 +115,6 @@ item_state = "hardhat0_pumpkin" item_color = "pumpkin" flags_inv = HIDEMASK|HIDEEARS|HIDEEYES|HIDEFACE|HIDEHAIR|HIDEFACIALHAIR - action_button_name = "Toggle Pumpkin Light" armor = list(melee = 0, bullet = 0, laser = 0,energy = 0, bomb = 0, bio = 0, rad = 0) brightness_on = 2 //luminosity when on flags_cover = HEADCOVERSEYES @@ -147,6 +145,5 @@ item_state = "hardhat0_reindeer" item_color = "reindeer" flags_inv = 0 - action_button_name = "Toggle Nose Light" armor = list(melee = 0, bullet = 0, laser = 0,energy = 0, bomb = 0, bio = 0, rad = 0) brightness_on = 1 //luminosity when on diff --git a/code/modules/clothing/masks/boxing.dm b/code/modules/clothing/masks/boxing.dm index 8b537b722f6..2c9fa24c27f 100644 --- a/code/modules/clothing/masks/boxing.dm +++ b/code/modules/clothing/masks/boxing.dm @@ -6,8 +6,7 @@ flags_inv = HIDEFACE|HIDEHAIR|HIDEFACIALHAIR visor_flags_inv = HIDEFACE|HIDEFACIALHAIR w_class = 2 - action_button_name = "Adjust Balaclava" - ignore_maskadjust = 0 + actions_types = list(/datum/action/item_action/adjust) /obj/item/clothing/mask/balaclava/attack_self(mob/user) adjustmask(user) diff --git a/code/modules/clothing/masks/breath.dm b/code/modules/clothing/masks/breath.dm index ef684dac5f7..2ac22361d26 100644 --- a/code/modules/clothing/masks/breath.dm +++ b/code/modules/clothing/masks/breath.dm @@ -9,8 +9,7 @@ w_class = 2 gas_transfer_coefficient = 0.10 permeability_coefficient = 0.50 - action_button_name = "Adjust Breath Mask" - ignore_maskadjust = 0 + actions_types = list(/datum/action/item_action/adjust) flags_cover = MASKCOVERSMOUTH burn_state = FIRE_PROOF diff --git a/code/modules/clothing/masks/gasmask.dm b/code/modules/clothing/masks/gasmask.dm index 07a038729a2..99eb30afe61 100644 --- a/code/modules/clothing/masks/gasmask.dm +++ b/code/modules/clothing/masks/gasmask.dm @@ -22,7 +22,7 @@ tint = 2 armor = list(melee = 10, bullet = 0, laser = 0,energy = 0, bomb = 0, bio = 0, rad = 0) origin_tech = "materials=2;engineering=2" - action_button_name = "Toggle Welding Mask" + actions_types = list(/datum/action/item_action/toggle) flags_inv = HIDEEARS|HIDEEYES|HIDEFACE flags_cover = MASKCOVERSEYES visor_flags_inv = HIDEEYES @@ -60,7 +60,7 @@ var/voice = "Unknown" var/vchange = 0//This didn't do anything before. It now checks if the mask has special functions/N origin_tech = "syndicate=4" - action_button_name = "Toggle mask" + actions_types = list(/datum/action/item_action/toggle) /obj/item/clothing/mask/gas/voice/attack_self(mob/user) vchange = !vchange @@ -109,7 +109,7 @@ item_state = "mime" flags_cover = MASKCOVERSEYES burn_state = FLAMMABLE - action_button_name = "Adjust Mask" + actions_types = list(/datum/action/item_action/adjust) /obj/item/clothing/mask/gas/mime/attack_self(mob/user) cycle_mask(usr) diff --git a/code/modules/clothing/masks/hailer.dm b/code/modules/clothing/masks/hailer.dm index d35e67bde87..040ef0bab42 100644 --- a/code/modules/clothing/masks/hailer.dm +++ b/code/modules/clothing/masks/hailer.dm @@ -4,9 +4,8 @@ /obj/item/clothing/mask/gas/sechailer name = "security gas mask" desc = "A standard issue Security gas mask with integrated 'Compli-o-nator 3000' device. Plays over a dozen pre-recorded compliance phrases designed to get scumbags to stand still whilst you taze them. Do not tamper with the device." - action_button_name = "HALT!" + actions_types = list(/datum/action/item_action/halt, /datum/action/item_action/adjust) icon_state = "sechailer" - ignore_maskadjust = 0 flags = BLOCK_GAS_SMOKE_EFFECT | MASKINTERNALS flags_inv = HIDEFACIALHAIR|HIDEFACE w_class = 2 @@ -21,10 +20,9 @@ /obj/item/clothing/mask/gas/sechailer/swat name = "\improper SWAT mask" desc = "A close-fitting tactical mask with an especially aggressive Compli-o-nator 3000." - action_button_name = "HALT!" + actions_types = list(/datum/action/item_action/halt) icon_state = "swat" aggressiveness = 3 - ignore_maskadjust = 1 flags_inv = HIDEFACIALHAIR|HIDEFACE|HIDEEYES|HIDEEARS visor_flags_inv = 0 @@ -34,11 +32,7 @@ icon = 'icons/obj/device.dmi' icon_state = "taperecorder_idle" aggressiveness = 1 //Borgs are nicecurity! - ignore_maskadjust = 1 - -/obj/item/clothing/mask/gas/sechailer/cyborg/New() - ..() - verbs -= /obj/item/clothing/mask/gas/sechailer/verb/adjust + actions_types = list(/datum/action/item_action/halt) /obj/item/clothing/mask/gas/sechailer/attackby(obj/item/weapon/W, mob/user, params) if(istype(W, /obj/item/weapon/screwdriver)) @@ -61,10 +55,11 @@ else ..() -/obj/item/clothing/mask/gas/sechailer/verb/adjust() - set category = "Object" - set name = "Adjust Mask" - adjustmask(usr) +/obj/item/clothing/mask/gas/sechailer/ui_action_click(mob/user, actiontype) + if(actiontype == /datum/action/item_action/halt) + halt() + else + adjustmask(user) /obj/item/clothing/mask/gas/sechailer/attack_self() halt() diff --git a/code/modules/clothing/masks/miscellaneous.dm b/code/modules/clothing/masks/miscellaneous.dm index 1a6a0f006ea..669c5467606 100644 --- a/code/modules/clothing/masks/miscellaneous.dm +++ b/code/modules/clothing/masks/miscellaneous.dm @@ -28,8 +28,7 @@ gas_transfer_coefficient = 0.90 permeability_coefficient = 0.01 armor = list(melee = 0, bullet = 0, laser = 0,energy = 0, bomb = 0, bio = 25, rad = 0) - action_button_name = "Adjust Sterile Mask" - ignore_maskadjust = 0 + actions_types = list(/datum/action/item_action/adjust) /obj/item/clothing/mask/surgical/attack_self(mob/user) adjustmask(user) @@ -47,7 +46,7 @@ item_state = "pig" flags_inv = HIDEFACE|HIDEHAIR|HIDEFACIALHAIR w_class = 2 - action_button_name = "Toggle Voice Box" + actions_types = list(/datum/action/item_action/toggle_voice_box) var/voicechange = 0 /obj/item/clothing/mask/pig/attack_self(mob/user) @@ -110,7 +109,6 @@ flags_inv = HIDEFACE|HIDEFACIALHAIR visor_flags_inv = HIDEFACE|HIDEFACIALHAIR slot_flags = SLOT_MASK - ignore_maskadjust = 0 adjusted_flags = SLOT_HEAD icon_state = "bandbotany" diff --git a/code/modules/clothing/shoes/bananashoes.dm b/code/modules/clothing/shoes/bananashoes.dm index dea88acaef8..0f7accc2e5d 100644 --- a/code/modules/clothing/shoes/bananashoes.dm +++ b/code/modules/clothing/shoes/bananashoes.dm @@ -6,7 +6,7 @@ icon_state = "clown_prototype_off" var/on = 0 var/datum/material_container/bananium - action_button_name = "Toggle Shoes" + actions_types = list(/datum/action/item_action/toggle) /obj/item/clothing/shoes/clown_shoes/banana_shoes/New() ..() @@ -58,13 +58,13 @@ var/ban_amt = bananium.amount(MAT_BANANIUM) user << "The shoes are [on ? "enabled" : "disabled"]. There is [ban_amt ? ban_amt : "no"] bananium left." -/obj/item/clothing/shoes/clown_shoes/banana_shoes/ui_action_click() +/obj/item/clothing/shoes/clown_shoes/banana_shoes/ui_action_click(mob/user) if(bananium.amount(MAT_BANANIUM)) on = !on update_icon() - loc << "You [on ? "activate" : "deactivate"] the prototype shoes." + user << "You [on ? "activate" : "deactivate"] the prototype shoes." else - loc << "You need bananium to turn the prototype shoes on!" + user << "You need bananium to turn the prototype shoes on!" /obj/item/clothing/shoes/clown_shoes/banana_shoes/update_icon() if(on) @@ -72,5 +72,6 @@ else icon_state = "clown_prototype_off" usr.update_inv_shoes() - if(action && action.button) - action.button.UpdateIcon() + for(var/X in actions) + var/datum/action/A = X + A.UpdateButtonIcon() diff --git a/code/modules/clothing/shoes/magboots.dm b/code/modules/clothing/shoes/magboots.dm index ed673d40c50..bc4c31f0aa3 100644 --- a/code/modules/clothing/shoes/magboots.dm +++ b/code/modules/clothing/shoes/magboots.dm @@ -5,7 +5,7 @@ var/magboot_state = "magboots" var/magpulse = 0 var/slowdown_active = 2 - action_button_name = "Toggle Magboots" + actions_types = list(/datum/action/item_action/toggle) strip_delay = 70 put_on_delay = 70 burn_state = FIRE_PROOF diff --git a/code/modules/clothing/spacesuits/chronosuit.dm b/code/modules/clothing/spacesuits/chronosuit.dm index ec6fdaa65fd..de2d07a8e87 100644 --- a/code/modules/clothing/spacesuits/chronosuit.dm +++ b/code/modules/clothing/spacesuits/chronosuit.dm @@ -22,7 +22,7 @@ desc = "An advanced spacesuit equipped with teleportation and anti-compression technology" icon_state = "chronosuit" item_state = "chronosuit" - action_button_name = "Toggle Chronosuit" + actions_types = list(/datum/action/item_action/toggle) armor = list(melee = 60, bullet = 60, laser = 60, energy = 60, bomb = 30, bio = 90, rad = 90) var/list/chronosafe_items = list(/obj/item/weapon/chrono_eraser, /obj/item/weapon/gun/energy/chrono_gun) var/hands_nodrop_states @@ -93,8 +93,7 @@ if(camera) camera.remove_target_ui() camera.loc = user - if(teleport_now.button) - teleport_now.button.UpdateIcon() + teleport_now.UpdateButtonIcon() /obj/item/clothing/suit/space/chronos/proc/chronowalk(atom/location) var/mob/living/carbon/human/user = src.loc @@ -108,8 +107,7 @@ if(camera) camera.remove_target_ui() - if(teleport_now.button) - teleport_now.button.UpdateIcon() + teleport_now.UpdateButtonIcon() var/list/nonsafe_slots = list(slot_belt, slot_back, slot_l_hand, slot_r_hand) for(var/slot in nonsafe_slots) diff --git a/code/modules/clothing/spacesuits/hardsuit.dm b/code/modules/clothing/spacesuits/hardsuit.dm index 7e586e890c5..8117736920a 100644 --- a/code/modules/clothing/spacesuits/hardsuit.dm +++ b/code/modules/clothing/spacesuits/hardsuit.dm @@ -10,7 +10,7 @@ var/on = 0 var/obj/item/clothing/suit/space/hardsuit/suit item_color = "engineering" //Determines used sprites: hardsuit[on]-[color] and hardsuit[on]-[color]2 (lying down sprite) - action_button_name = "Toggle Helmet Light" + actions_types = list(/datum/action/item_action/toggle_helmet_light) /obj/item/clothing/head/helmet/space/hardsuit/attack_self(mob/user) @@ -25,8 +25,9 @@ user.AddLuminosity(brightness_on) else user.AddLuminosity(-brightness_on) - if(action && action.button) - action.button.UpdateIcon() + for(var/X in actions) + var/datum/action/A = X + A.UpdateButtonIcon() /obj/item/clothing/head/helmet/space/hardsuit/pickup(mob/user) @@ -78,7 +79,7 @@ allowed = list(/obj/item/device/flashlight,/obj/item/weapon/tank/internals,/obj/item/device/t_scanner, /obj/item/weapon/rcd, /obj/item/weapon/pipe_dispenser) siemens_coefficient = 0 var/obj/item/clothing/head/helmet/space/hardsuit/helmet - action_button_name = "Toggle Helmet" + actions_types = list(/datum/action/item_action/toggle_helmet) var/helmettype = /obj/item/clothing/head/helmet/space/hardsuit var/obj/item/weapon/tank/jetpack/suit/jetpack = null @@ -86,12 +87,16 @@ ..() if(jetpack) if(slot == slot_wear_suit) - jetpack.cycle_action.Grant(user) + for(var/X in jetpack.actions) + var/datum/action/A = X + A.Grant(user) /obj/item/clothing/suit/space/hardsuit/dropped(mob/user) ..() if(jetpack) - jetpack.cycle_action.Remove(user) + for(var/X in jetpack.actions) + var/datum/action/A = X + A.Remove(user) /obj/item/clothing/suit/space/hardsuit/item_action_slot_check(slot) if(slot == slot_wear_suit) //we only give the mob the ability to toggle the helmet if he's wearing the hardsuit. @@ -198,7 +203,7 @@ armor = list(melee = 40, bullet = 50, laser = 30, energy = 15, bomb = 35, bio = 100, rad = 50) on = 1 var/obj/item/clothing/suit/space/hardsuit/syndi/linkedsuit = null - action_button_name = "Toggle Helmet Mode" + actions_types = list(/datum/action/item_action/toggle_helmet_mode) visor_flags_inv = HIDEMASK|HIDEEYES|HIDEFACE|HIDEFACIALHAIR visor_flags = STOPSPRESSUREDMAGE @@ -240,6 +245,9 @@ if(istype(user, /mob/living/carbon)) var/mob/living/carbon/C = user C.head_update(src, forced = 1) + for(var/X in actions) + var/datum/action/A = X + A.UpdateButtonIcon() /obj/item/clothing/head/helmet/space/hardsuit/syndi/proc/toggle_hardsuit_mode(mob/user) //Helmet Toggles Suit Mode if(linkedsuit) @@ -270,7 +278,6 @@ item_state = "syndie_hardsuit" item_color = "syndi" w_class = 3 - action_button_name = "Toggle Helmet" armor = list(melee = 40, bullet = 50, laser = 30, energy = 15, bomb = 35, bio = 100, rad = 50) allowed = list(/obj/item/weapon/gun,/obj/item/ammo_box,/obj/item/ammo_casing,/obj/item/weapon/melee/baton,/obj/item/weapon/melee/energy/sword/saber,/obj/item/weapon/restraints/handcuffs,/obj/item/weapon/tank/internals) helmettype = /obj/item/clothing/head/helmet/space/hardsuit/syndi @@ -387,15 +394,14 @@ armor = list(melee = 30, bullet = 5, laser = 10, energy = 5, bomb = 100, bio = 100, rad = 60) var/obj/machinery/doppler_array/integrated/bomb_radar scan_reagents = 1 + actions_types = list(/datum/action/item_action/toggle_helmet_light, /datum/action/item_action/toggle_research_scanner) /obj/item/clothing/head/helmet/space/hardsuit/rd/New() ..() bomb_radar = new /obj/machinery/doppler_array/integrated(src) /obj/item/clothing/head/helmet/space/hardsuit/rd/equipped(mob/living/carbon/human/user, slot) - ..(user, slot) - user.scanner.Grant(user) - user.scanner.devices += 1 + ..() if(user.glasses && istype(user.glasses, /obj/item/clothing/glasses/hud/diagnostic)) user << ("Your [user.glasses] prevents you using [src]'s diagnostic visor HUD.") else @@ -404,8 +410,7 @@ DHUD.add_hud_to(user) /obj/item/clothing/head/helmet/space/hardsuit/rd/dropped(mob/living/carbon/human/user) - ..(user) - user.scanner.devices = max(0, user.scanner.devices - 1) + ..() if(onboard_hud_enabled && !(user.glasses && istype(user.glasses, /obj/item/clothing/glasses/hud/diagnostic))) var/datum/atom_hud/DHUD = huds[DATA_HUD_DIAGNOSTIC] DHUD.remove_hud_from(user) diff --git a/code/modules/clothing/spacesuits/miscellaneous.dm b/code/modules/clothing/spacesuits/miscellaneous.dm index dbce102f077..e89458f6da9 100644 --- a/code/modules/clothing/spacesuits/miscellaneous.dm +++ b/code/modules/clothing/spacesuits/miscellaneous.dm @@ -44,7 +44,7 @@ Contains: strip_delay = 130 max_heat_protection_temperature = FIRE_IMMUNITY_HELM_MAX_TEMP_PROTECT unacidable = 1 - action_button_name = null + actions_types = list() /obj/item/clothing/head/helmet/space/hardsuit/deathsquad/attack_self(mob/user) return @@ -262,7 +262,7 @@ Contains: item_state = "syndicate" armor = list(melee = -20, bullet = 0, laser = 0, energy = 0, bomb = 0, bio = 100, rad = 75) //As whimpy as a space carp brightness_on = 0 //luminosity when on - action_button_name = "" + actions_types = list() flags = STOPSPRESSUREDMAGE | THICKMATERIAL | NODROP @@ -284,7 +284,7 @@ Contains: item_state = "hardsuit0-prt" item_color = "knight_grey" max_heat_protection_temperature = FIRE_IMMUNITY_HELM_MAX_TEMP_PROTECT - action_button_name = null + actions_types = list() /obj/item/clothing/suit/space/hardsuit/ert/paranormal name = "paranormal response team suit" diff --git a/code/modules/clothing/suits/armor.dm b/code/modules/clothing/suits/armor.dm index 83d21d2117a..1cd1b4616a5 100644 --- a/code/modules/clothing/suits/armor.dm +++ b/code/modules/clothing/suits/armor.dm @@ -131,7 +131,7 @@ item_state = "reactiveoff" blood_overlay_type = "armor" armor = list(melee = 0, bullet = 0, laser = 0, energy = 0, bomb = 0, bio = 0, rad = 0) - action_button_name = "Toggle Armor" + actions_types = list(/datum/action/item_action/toggle) unacidable = 1 hit_reaction_chance = 50 diff --git a/code/modules/clothing/suits/jobs.dm b/code/modules/clothing/suits/jobs.dm index b4444726662..b1386ed9eea 100644 --- a/code/modules/clothing/suits/jobs.dm +++ b/code/modules/clothing/suits/jobs.dm @@ -31,7 +31,6 @@ body_parts_covered = CHEST|GROIN|LEGS|ARMS allowed = list(/obj/item/weapon/storage/book/bible, /obj/item/weapon/nullrod, /obj/item/weapon/reagent_containers/food/drinks/bottle/holywater, /obj/item/weapon/storage/fancy/candle_box, /obj/item/candle, /obj/item/weapon/tank/internals/emergency_oxygen) hooded = 1 - action_button_name = "Toggle Chaplain Hoodie" hoodtype = /obj/item/clothing/head/chaplain_hood /obj/item/clothing/head/chaplain_hood diff --git a/code/modules/clothing/suits/miscellaneous.dm b/code/modules/clothing/suits/miscellaneous.dm index d0c8e507ab9..f565dd1d316 100644 --- a/code/modules/clothing/suits/miscellaneous.dm +++ b/code/modules/clothing/suits/miscellaneous.dm @@ -136,7 +136,7 @@ togglename = "wings" body_parts_covered = ARMS|CHEST allowed = list(/obj/item/weapon/gun/energy,/obj/item/weapon/reagent_containers/spray/pepper,/obj/item/weapon/gun/projectile,/obj/item/ammo_box,/obj/item/ammo_casing,/obj/item/weapon/melee/baton,/obj/item/weapon/restraints/handcuffs,/obj/item/device/flashlight/seclite,/obj/item/weapon/melee/classic_baton/telescopic) - action_button_name = "Toggle Owl Wings" + actions_types = list(/datum/action/item_action/toggle_wings) /obj/item/clothing/suit/toggle/owlwings/griffinwings name = "griffon cloak" @@ -215,7 +215,6 @@ min_cold_protection_temperature = FIRE_SUIT_MIN_TEMP_PROTECT //Space carp like space, so you should too allowed = list(/obj/item/weapon/tank/internals/emergency_oxygen, /obj/item/weapon/gun/projectile/automatic/speargun) hooded = 1 - action_button_name = "Toggle Carp Hood" hoodtype = /obj/item/clothing/head/carp_hood /obj/item/clothing/head/carp_hood @@ -238,7 +237,6 @@ //min_cold_protection_temperature = FIRE_SUIT_MIN_TEMP_PROTECT allowed = list(,) hooded = 1 - action_button_name = "Toggle Ian Hood" hoodtype = /obj/item/clothing/head/ian_hood /obj/item/clothing/head/ian_hood @@ -259,7 +257,7 @@ body_parts_covered = CHEST|GROIN|ARMS allowed = list(,) hooded = 1 - action_button_name = "Toggle Human Head" + actions_types = list(/datum/action/item_action/toggle_human_head) hoodtype = /obj/item/clothing/head/human_head /obj/item/clothing/head/human_head @@ -374,7 +372,6 @@ armor = list(melee = 0, bullet = 0, laser = 0,energy = 0, bomb = 0, bio = 10, rad = 0) allowed = list(/obj/item/device/flashlight,/obj/item/weapon/tank/internals/emergency_oxygen,/obj/item/toy,/obj/item/weapon/storage/fancy/cigarettes,/obj/item/weapon/lighter) hooded = 1 - action_button_name = "Toggle Winter Hood" /obj/item/clothing/head/winterhood name = "winter hood" diff --git a/code/modules/clothing/suits/toggles.dm b/code/modules/clothing/suits/toggles.dm index dbbfc5dbb00..fc8d0cf89ac 100644 --- a/code/modules/clothing/suits/toggles.dm +++ b/code/modules/clothing/suits/toggles.dm @@ -37,8 +37,9 @@ H.unEquip(hood, 1) H.update_inv_wear_suit() hood.loc = src - if(action && action.button) - action.button.UpdateIcon() + for(var/X in actions) + var/datum/action/A = X + A.UpdateButtonIcon() /obj/item/clothing/suit/hooded/dropped() ..() @@ -59,8 +60,9 @@ suittoggled = 1 src.icon_state = "[initial(icon_state)]_t" H.update_inv_wear_suit() - if(action && action.button) - action.button.UpdateIcon() + for(var/X in actions) + var/datum/action/A = X + A.UpdateButtonIcon() else RemoveHood() @@ -93,8 +95,9 @@ src.icon_state = "[initial(icon_state)]_t" src.suittoggled = 1 usr.update_inv_wear_suit() - if(action && action.button) - action.button.UpdateIcon() + for(var/X in actions) + var/datum/action/A = X + A.UpdateButtonIcon() /obj/item/clothing/suit/toggle/examine(mob/user) ..() diff --git a/code/modules/clothing/under/chameleon.dm b/code/modules/clothing/under/chameleon.dm index f38708348bb..a72f6ea4539 100644 --- a/code/modules/clothing/under/chameleon.dm +++ b/code/modules/clothing/under/chameleon.dm @@ -5,7 +5,7 @@ item_state = "bl_suit" item_color = "black" desc = "It's a plain jumpsuit. It has a small dial on the wrist." - action_button_name = "Change" + actions_types = list(/datum/action/item_action/change) origin_tech = "syndicate=3" sensor_mode = 0 //Hey who's this guy on the Syndicate Shuttle?? random_sensor = 0 diff --git a/code/modules/mob/living/carbon/alien/humanoid/alien_powers.dm b/code/modules/mob/living/carbon/alien/humanoid/alien_powers.dm index de750a6d833..3d7c28a98c4 100644 --- a/code/modules/mob/living/carbon/alien/humanoid/alien_powers.dm +++ b/code/modules/mob/living/carbon/alien/humanoid/alien_powers.dm @@ -5,20 +5,6 @@ These are general powers. Specific powers are stored under the appropriate alien /*Alien spit now works like a taser shot. It won't home in on the target but will act the same once it does hit. Doesn't work on other aliens/AI.*/ -/datum/action/spell_action/alien - -/datum/action/spell_action/alien/IsAvailable() - if(!target) - return 0 - var/obj/effect/proc_holder/alien/ab = target - - if(usr) - return ab.cost_check(ab.check_turf,usr,1) - else - if(owner) - return ab.cost_check(ab.check_turf,owner,1) - return 1 - /obj/effect/proc_holder/alien name = "Alien Power" @@ -32,6 +18,10 @@ Doesn't work on other aliens/AI.*/ var/action_icon_state = "spell_default" var/action_background_icon_state = "bg_alien" +/obj/effect/proc_holder/alien/New() + ..() + action = new(src) + /obj/effect/proc_holder/alien/Click() if(!istype(usr,/mob/living/carbon)) return 1 @@ -307,9 +297,8 @@ Doesn't work on other aliens/AI.*/ vessel.storedPlasma = min(vessel.storedPlasma, vessel.max_plasma) //upper limit of max_plasma, lower limit of 0 for(var/X in abilities) var/obj/effect/proc_holder/alien/APH = X - if(APH.action && APH.action.button) - var/obj/screen/movable/action_button/AB = APH.action.button - AB.UpdateIcon() + if(APH.has_action) + APH.action.UpdateButtonIcon() return 1 /mob/living/carbon/alien/adjustPlasma(amount) diff --git a/code/modules/mob/living/carbon/carbon.dm b/code/modules/mob/living/carbon/carbon.dm index cb6a42efb16..b6b13b41669 100644 --- a/code/modules/mob/living/carbon/carbon.dm +++ b/code/modules/mob/living/carbon/carbon.dm @@ -555,13 +555,6 @@ var/const/GALOSHES_DONT_HELP = 4 abilities.Add(A) A.on_gain(src) if(A.has_action) - if(!A.action) - A.action = new/datum/action/spell_action/alien - A.action.target = A - A.action.name = A.name - A.action.button_icon = A.action_icon - A.action.button_icon_state = A.action_icon_state - A.action.background_icon_state = A.action_background_icon_state A.action.Grant(src) sortInsert(abilities, /proc/cmp_abilities_cost, 0) diff --git a/code/modules/mob/living/carbon/human/inventory.dm b/code/modules/mob/living/carbon/human/inventory.dm index 6bde0e6fc25..c7e5f8174fe 100644 --- a/code/modules/mob/living/carbon/human/inventory.dm +++ b/code/modules/mob/living/carbon/human/inventory.dm @@ -170,10 +170,10 @@ s_store = null update_inv_s_store() -/mob/living/carbon/human/wear_mask_update(obj/item/clothing/C, unequip = 1) +/mob/living/carbon/human/wear_mask_update(obj/item/clothing/C, toggle_off = 1) if((C.flags_inv & (HIDEHAIR|HIDEFACIALHAIR)) || (initial(C.flags_inv) & (HIDEHAIR|HIDEFACIALHAIR))) update_hair() - if(unequip && internal) + if(toggle_off && internal) update_internals_hud_icon(0) internal = null if(C.flags_inv & HIDEEYES) diff --git a/code/modules/mob/living/carbon/inventory.dm b/code/modules/mob/living/carbon/inventory.dm index d32dc722d84..910cbf3c338 100644 --- a/code/modules/mob/living/carbon/inventory.dm +++ b/code/modules/mob/living/carbon/inventory.dm @@ -40,7 +40,7 @@ update_inv_back() if(slot_wear_mask) wear_mask = I - wear_mask_update(I, unequip=0) + wear_mask_update(I, toggle_off = 0) if(slot_head) head = I head_update(I) @@ -77,7 +77,7 @@ update_inv_back() else if(I == wear_mask) wear_mask = null - wear_mask_update(I, unequip=1) + wear_mask_update(I, toggle_off = 1) else if(I == handcuffed) handcuffed = null if(buckled && buckled.buckle_requires_restraints) @@ -88,10 +88,10 @@ update_inv_legcuffed() //handle stuff to update when a mob equips/unequips a mask. -/mob/living/proc/wear_mask_update(obj/item/clothing/C, unequip = 1) +/mob/living/proc/wear_mask_update(obj/item/clothing/C, toggle_off = 1) update_inv_wear_mask() -/mob/living/carbon/wear_mask_update(obj/item/clothing/C, unequip = 1) +/mob/living/carbon/wear_mask_update(obj/item/clothing/C, toggle_off = 1) if(C.tint || initial(C.tint)) update_tint() update_inv_wear_mask() diff --git a/code/modules/mob/living/carbon/life.dm b/code/modules/mob/living/carbon/life.dm index 6b90a274f3d..29873a676fe 100644 --- a/code/modules/mob/living/carbon/life.dm +++ b/code/modules/mob/living/carbon/life.dm @@ -196,16 +196,12 @@ /mob/living/carbon/proc/get_breath_from_internal(volume_needed) if(internal) - if (!contents.Find(internal)) + if(internal.loc != src) internal = null - if (!wear_mask || !(wear_mask.flags & MASKINTERNALS) ) - internal = null - if(internal) + update_internals_hud_icon(0) + else update_internals_hud_icon(1) return internal.remove_air_volume(volume_needed) - else - update_internals_hud_icon(0) - return /mob/living/carbon/proc/handle_changeling() diff --git a/code/modules/mob/living/life.dm b/code/modules/mob/living/life.dm index 190ad0dfc10..be63fc849a6 100644 --- a/code/modules/mob/living/life.dm +++ b/code/modules/mob/living/life.dm @@ -116,47 +116,4 @@ /mob/living/proc/update_damage_hud() return -/mob/living/update_action_buttons_icon() - for(var/X in actions) - var/datum/action/A = X - if(A.button) - A.button.UpdateIcon() - -/mob/living/update_action_buttons(reload_screen) - if(!hud_used || !client) - return - - if(hud_used.hud_shown != HUD_STYLE_STANDARD) - return - - var/button_number = 0 - - if(hud_used.action_buttons_hidden) - for(var/datum/action/A in actions) - A.button.screen_loc = null - if(reload_screen) - client.screen += A.button - else - for(var/datum/action/A in actions) - button_number++ - var/obj/screen/movable/action_button/B = A.button - B.UpdateIcon() - if(!B.moved) - B.screen_loc = hud_used.ButtonNumberToScreenCoords(button_number) - else - B.screen_loc = B.moved - if(reload_screen) - client.screen += B - - if(!button_number) - hud_used.hide_actions_toggle.screen_loc = null - return - - if(!hud_used.hide_actions_toggle.moved) - hud_used.hide_actions_toggle.screen_loc = hud_used.ButtonNumberToScreenCoords(button_number+1) - else - hud_used.hide_actions_toggle.screen_loc = hud_used.hide_actions_toggle.moved - if(reload_screen) - client.screen += hud_used.hide_actions_toggle - diff --git a/code/modules/mob/living/simple_animal/friendly/drone/_drone.dm b/code/modules/mob/living/simple_animal/friendly/drone/_drone.dm index 58c5c241ccd..b86e8f7ca21 100644 --- a/code/modules/mob/living/simple_animal/friendly/drone/_drone.dm +++ b/code/modules/mob/living/simple_animal/friendly/drone/_drone.dm @@ -80,7 +80,6 @@ equip_to_slot_or_del(I, slot_head) access_card.flags |= NODROP - scanner.Grant(src) alert_drones(DRONE_NET_CONNECT) diff --git a/code/modules/mob/living/simple_animal/slime/death.dm b/code/modules/mob/living/simple_animal/slime/death.dm index cbb93197426..fb9d09c1565 100644 --- a/code/modules/mob/living/simple_animal/slime/death.dm +++ b/code/modules/mob/living/simple_animal/slime/death.dm @@ -9,6 +9,10 @@ M.regenerate_icons() is_adult = 0 maxHealth = 150 + for(var/datum/action/innate/slime/reproduce/R in actions) + R.Remove(src) + var/datum/action/innate/slime/evolve/E = new + E.Grant(src) revive(full_heal = 1) regenerate_icons() number = rand(1, 1000) diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index 7f908f28430..9068660597e 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -888,18 +888,9 @@ var/next_mob_id = 0 /mob/proc/setEarDamage() return -/mob/proc/AddSpell(obj/effect/proc_holder/spell/spell) - mob_spell_list += spell - if(!spell.action) - spell.action = new/datum/action/spell_action - spell.action.target = spell - spell.action.name = spell.name - spell.action.button_icon = spell.action_icon - spell.action.button_icon_state = spell.action_icon_state - spell.action.background_icon_state = spell.action_background_icon_state - if(isliving(src)) - spell.action.Grant(src) - return +/mob/proc/AddSpell(obj/effect/proc_holder/spell/S) + mob_spell_list += S + S.action.Grant(src) //override to avoid rotating pixel_xy on mobs /mob/shuttleRotate(rotation) diff --git a/code/modules/mob/mob_defines.dm b/code/modules/mob/mob_defines.dm index 017c9a0369b..5be8673a352 100644 --- a/code/modules/mob/mob_defines.dm +++ b/code/modules/mob/mob_defines.dm @@ -84,7 +84,6 @@ var/datum/hud/hud_used = null var/research_scanner = 0 //For research scanner equipped mobs. Enable to show research data when examining. - var/datum/action/innate/scan_mode/scanner = new var/list/grabbed_by = list( ) var/list/requests = list( ) diff --git a/code/modules/projectiles/gun.dm b/code/modules/projectiles/gun.dm index 85063e88e10..e749d430867 100644 --- a/code/modules/projectiles/gun.dm +++ b/code/modules/projectiles/gun.dm @@ -257,30 +257,26 @@ obj/item/weapon/gun/proc/newshot() else return -/obj/item/weapon/gun/attackby(obj/item/A, mob/user, params) - if(istype(A, /obj/item/device/flashlight/seclite)) - var/obj/item/device/flashlight/seclite/S = A +/obj/item/weapon/gun/attackby(obj/item/I, mob/user, params) + if(istype(I, /obj/item/device/flashlight/seclite)) + var/obj/item/device/flashlight/seclite/S = I if(can_flashlight) if(!F) - if(!user.unEquip(A)) + if(!user.unEquip(I)) return user << "You click [S] into place on [src]." if(S.on) SetLuminosity(0) F = S - A.loc = src + I.loc = src update_icon() update_gunlight(user) verbs += /obj/item/weapon/gun/proc/toggle_gunlight - action_button_name = "Toggle Gunlight" + var/datum/action/A = new /datum/action/item_action/toggle_gunlight(src) if(loc == user) - if(!action) - action = new - action.name = action_button_name - action.target = src - action.Grant(user) + A.Grant(user) - if(istype(A, /obj/item/weapon/screwdriver)) + if(istype(I, /obj/item/weapon/screwdriver)) if(F) for(var/obj/item/device/flashlight/seclite/S in src) user << "You unscrew the seclite from [src]." @@ -290,16 +286,13 @@ obj/item/weapon/gun/proc/newshot() S.update_brightness(user) update_icon() verbs -= /obj/item/weapon/gun/proc/toggle_gunlight - action_button_name = null - if(action && loc == user) - action.Remove(user) + for(var/datum/action/item_action/toggle_gunlight/TGL in actions) + qdel(TGL) if(unique_rename) - if(istype(A, /obj/item/weapon/pen)) + if(istype(I, /obj/item/weapon/pen)) rename_gun(user) - ..() - return /obj/item/weapon/gun/proc/toggle_gunlight() set name = "Toggle Gunlight" @@ -337,8 +330,9 @@ obj/item/weapon/gun/proc/newshot() user.AddLuminosity(-5) else if(isturf(loc)) SetLuminosity(0) - if(action && action.button) - action.button.UpdateIcon() + for(var/X in actions) + var/datum/action/A = X + A.UpdateButtonIcon() /obj/item/weapon/gun/pickup(mob/user) diff --git a/code/modules/projectiles/guns/projectile/automatic.dm b/code/modules/projectiles/guns/projectile/automatic.dm index 4bd3852b935..54313c7f174 100644 --- a/code/modules/projectiles/guns/projectile/automatic.dm +++ b/code/modules/projectiles/guns/projectile/automatic.dm @@ -6,7 +6,7 @@ can_suppress = 1 burst_size = 3 fire_delay = 2 - action_button_name = "Toggle Firemode" + actions_types = list(/datum/action/item_action/toggle_firemode) /obj/item/weapon/gun/projectile/automatic/proto name = "\improper NanoTrasen Saber SMG" @@ -67,8 +67,9 @@ playsound(user, 'sound/weapons/empty.ogg', 100, 1) update_icon() - if(action && action.button) - action.button.UpdateIcon() + for(var/X in actions) + var/datum/action/A = X + A.UpdateButtonIcon() /obj/item/weapon/gun/projectile/automatic/can_shoot() return get_ammo() @@ -119,7 +120,7 @@ fire_delay = 2 can_suppress = 0 burst_size = 0 - action_button_name = null + actions_types = list() /obj/item/weapon/gun/projectile/automatic/wt550/update_icon() ..() diff --git a/code/modules/projectiles/guns/projectile/launchers.dm b/code/modules/projectiles/guns/projectile/launchers.dm index ed5c2f204e9..e7d55f30c16 100644 --- a/code/modules/projectiles/guns/projectile/launchers.dm +++ b/code/modules/projectiles/guns/projectile/launchers.dm @@ -39,7 +39,7 @@ mag_type = /obj/item/ammo_box/magazine/m75 burst_size = 1 fire_delay = 0 - action_button_name = null + actions_types = list() /obj/item/weapon/gun/projectile/automatic/gyropistol/process_chamber(eject_casing = 0, empty_chamber = 1) ..() @@ -62,7 +62,7 @@ burst_size = 1 fire_delay = 0 select = 0 - action_button_name = null + actions_types = list() /obj/item/weapon/gun/projectile/automatic/speargun/update_icon() return diff --git a/code/modules/projectiles/guns/projectile/pistol.dm b/code/modules/projectiles/guns/projectile/pistol.dm index 6df4c8eb333..5c45df2cb17 100644 --- a/code/modules/projectiles/guns/projectile/pistol.dm +++ b/code/modules/projectiles/guns/projectile/pistol.dm @@ -8,7 +8,7 @@ can_suppress = 1 burst_size = 1 fire_delay = 0 - action_button_name = null + actions_types = list() /obj/item/weapon/gun/projectile/automatic/pistol/update_icon() ..() @@ -55,4 +55,4 @@ can_suppress = 0 burst_size = 3 fire_delay = 2 - action_button_name = "Toggle Firemode" + actions_types = list(/datum/action/item_action/toggle_firemode) \ No newline at end of file diff --git a/code/modules/projectiles/guns/projectile/rechargable_magazine.dm b/code/modules/projectiles/guns/projectile/rechargable_magazine.dm index d24dd02c71b..2ae94e94355 100644 --- a/code/modules/projectiles/guns/projectile/rechargable_magazine.dm +++ b/code/modules/projectiles/guns/projectile/rechargable_magazine.dm @@ -36,7 +36,7 @@ fire_delay = 2 can_suppress = 0 burst_size = 0 - action_button_name = null + actions_types = list() fire_sound = 'sound/weapons/Laser.ogg' /obj/item/weapon/gun/projectile/automatic/laser/process_chamber(eject_casing = 0, empty_chamber = 1) diff --git a/code/modules/projectiles/guns/projectile/shotgun.dm b/code/modules/projectiles/guns/projectile/shotgun.dm index 72a3631cb3f..76f18ad2a36 100644 --- a/code/modules/projectiles/guns/projectile/shotgun.dm +++ b/code/modules/projectiles/guns/projectile/shotgun.dm @@ -312,7 +312,7 @@ burst_size = 1 fire_delay = 0 pin = /obj/item/device/firing_pin/implant/pindicate - action_button_name = null + actions_types = list() /obj/item/weapon/gun/projectile/automatic/shotgun/bulldog/unrestricted pin = /obj/item/device/firing_pin diff --git a/code/modules/projectiles/guns/projectile/toy.dm b/code/modules/projectiles/guns/projectile/toy.dm index 2555a8ac16a..417f13ea9b5 100644 --- a/code/modules/projectiles/guns/projectile/toy.dm +++ b/code/modules/projectiles/guns/projectile/toy.dm @@ -29,7 +29,7 @@ can_suppress = 0 burst_size = 1 fire_delay = 0 - action_button_name = null + actions_types = list() /obj/item/weapon/gun/projectile/automatic/toy/pistol/update_icon() ..() diff --git a/code/modules/spells/spell.dm b/code/modules/spells/spell.dm index 5b26cc14c33..b46d9f4a49c 100644 --- a/code/modules/spells/spell.dm +++ b/code/modules/spells/spell.dm @@ -156,6 +156,7 @@ var/list/spells = typesof(/obj/effect/proc_holder/spell) //needed for the badmin /obj/effect/proc_holder/spell/New() ..() + action = new(src) still_recharging_msg = "[name] is still recharging." charge_counter = charge_max @@ -169,13 +170,13 @@ var/list/spells = typesof(/obj/effect/proc_holder/spell) //needed for the badmin return /obj/effect/proc_holder/spell/proc/start_recharge() - if(action && action.button) - action.button.UpdateIcon() + if(action) + action.UpdateButtonIcon() while(charge_counter < charge_max && isnull(gc_destroyed)) sleep(1) charge_counter++ - if(action && action.button) - action.button.UpdateIcon() + if(action) + action.UpdateButtonIcon() /obj/effect/proc_holder/spell/proc/perform(list/targets, recharge = 1, mob/user = usr) //if recharge is started is important for the trigger spells before_cast(targets) diff --git a/code/modules/surgery/organs/augments_internal.dm b/code/modules/surgery/organs/augments_internal.dm index 6fd62d8c645..8a6634f35c1 100644 --- a/code/modules/surgery/organs/augments_internal.dm +++ b/code/modules/surgery/organs/augments_internal.dm @@ -47,7 +47,7 @@ implant_color = "#DE7E00" slot = "brain_antidrop" origin_tech = "materials=5;programming=4;biotech=4" - organ_action_name = "Toggle Anti-Drop" + actions_types = list(/datum/action/item_action/organ_action) /obj/item/organ/internal/cyberimp/brain/anti_drop/ui_action_click() active = !active @@ -260,7 +260,7 @@ implant_color = "#007ACC" slot = "shoulders" origin_tech = "materials=5;biotech=4;powerstorage=4" - organ_action_name = "Toggle Arm Mod" + actions_types = list(/datum/action/item_action/organ_action) var/obj/holder//is defined as the retractable item itself. ensure this is defined somewhere! var/out = 0//determines if the item is in the owner's hand or not var/overloaded = 0//is set to 1 when owner gets EMPed. if set to 1, implant doesn't work. @@ -309,7 +309,7 @@ desc = "A variant of the arm cannon implant that fires electrodes and disabler shots. The cannon emerges from the subject's arms and remains in the shoulders when not in use." icon_state = "armcannon_tase_implant" origin_tech = "materials=5;combat=5;biotech=4;powerstorage=4" - organ_action_name = "Toggle Arm Cannon Taser" + actions_types = list(/datum/action/item_action/organ_action) /obj/item/organ/internal/cyberimp/chest/arm_mod/tase/New()//when the implant is created... holder = new /obj/item/weapon/gun/energy/gun/advtaser/mounted(src)//assign a brand new item to it. (in this case, a gun) @@ -319,7 +319,7 @@ desc = "A variant of the arm cannon implant that fires lethal laser beams. The cannon emerges from the subject's arms and remains in the shoulders when not in use." icon_state = "armcannon_lase_implant" origin_tech = "materials=5;combat=5;biotech=4;powerstorage=4;syndicate=5"//this is kinda nutty and i might lower it - organ_action_name = "Toggle Arm Cannon Laser" + actions_types = list(/datum/action/item_action/organ_action) /obj/item/organ/internal/cyberimp/chest/arm_mod/lase/New() holder = new /obj/item/weapon/gun/energy/laser/mounted(src) diff --git a/code/modules/surgery/organs/organ_internal.dm b/code/modules/surgery/organs/organ_internal.dm index 93ef30267ae..5501ac870ed 100644 --- a/code/modules/surgery/organs/organ_internal.dm +++ b/code/modules/surgery/organs/organ_internal.dm @@ -6,7 +6,6 @@ var/zone = "chest" var/slot var/vital = 0 - var/organ_action_name = null /obj/item/organ/internal/proc/Insert(mob/living/carbon/M, special = 0) if(!iscarbon(M) || owner == M) @@ -19,12 +18,9 @@ owner = M M.internal_organs |= src loc = null - if(organ_action_name) - if(!action) - action = new/datum/action/item_action/organ_action - action.name = organ_action_name - action.target = src - action.Grant(src) + for(var/X in actions) + var/datum/action/A = X + A.Grant(src) /obj/item/organ/internal/proc/Remove(mob/living/carbon/M, special = 0) owner = null @@ -32,9 +28,9 @@ M.internal_organs -= src if(vital && !special) M.death() - if(organ_action_name) - if(action) - action.Remove(M) + for(var/X in actions) + var/datum/action/A = X + A.Remove(M) /obj/item/organ/internal/proc/on_find(mob/living/finder) return @@ -79,6 +75,9 @@ else ..() +/obj/item/organ/internal/item_action_slot_check(slot,mob/user) + return //so we don't grant the organ's action to mobs who pick up the organ. + //Looking for brains? //Try code/modules/mob/living/carbon/brain/brain_item.dm diff --git a/icons/mob/actions.dmi b/icons/mob/actions.dmi index 8c1c3f5e685..caeb4fc5671 100644 Binary files a/icons/mob/actions.dmi and b/icons/mob/actions.dmi differ diff --git a/tgstation.dme b/tgstation.dme index cd0d0a2c446..64f9d22adb8 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -96,7 +96,7 @@ #include "code\_onclick\overmind.dm" #include "code\_onclick\telekinesis.dm" #include "code\_onclick\hud\_defines.dm" -#include "code\_onclick\hud\action.dm" +#include "code\_onclick\hud\action_button.dm" #include "code\_onclick\hud\ai.dm" #include "code\_onclick\hud\alert.dm" #include "code\_onclick\hud\alien.dm" @@ -141,6 +141,7 @@ #include "code\controllers\subsystem\ticker.dm" #include "code\controllers\subsystem\timer.dm" #include "code\controllers\subsystem\voting.dm" +#include "code\datums\action.dm" #include "code\datums\ai_laws.dm" #include "code\datums\beam.dm" #include "code\datums\browser.dm"