Skip to content

Commit

Permalink
Improved weapon menus (#2506)
Browse files Browse the repository at this point in the history
<!-- Write **BELOW** The Headers and **ABOVE** The comments else it may
not be viewable. -->
<!-- You can view Contributing.MD for a detailed description of the pull
request process. -->

## About The Pull Request

Uses radial menus to let you better pick what
attachments/modkits/trophies you want to remove

![image](https://github.com/shiptest-ss13/Shiptest/assets/86381784/89214d04-fa56-4c46-a697-0ee470604164)

![image](https://github.com/shiptest-ss13/Shiptest/assets/86381784/a67cd03f-bad6-45ce-8e08-785d8121d233)


https://github.com/shiptest-ss13/Shiptest/assets/86381784/cc0d7d4b-0c40-4c8e-bb30-debc15b422fb

<!-- Describe The Pull Request. Please be sure every change is
documented or this can delay review and even discourage maintainers from
merging your PR! -->

## Why It's Good For The Game

I have always hated when I want to remove a trophies and it dumps
everything onto the floor. Input menus are also unappealing to look at
and it will make it easier to add other removable attachments

<!-- Please add a short description of why you think these changes would
benefit the game. If you can't justify it in words, it might not be
worth adding. -->

## Changelog

:cl:
add: improved radial menu for mining tools
tweak: menus for removing attachments
/:cl:

<!-- Both :cl:'s are required for the changelog to work! You can put
your name to the right of the first :cl: if you want to overwrite your
GitHub username as author ingame. -->
<!-- You can use multiple of the same prefix (they're only used for the
icon ingame) and delete the unneeded ones. Despite some of the tags,
changelogs should generally represent how a player might be affected by
the changes rather than a summary of the PR's contents. -->
  • Loading branch information
FalloutFalcon authored Dec 6, 2023
1 parent a873243 commit 563a7d4
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 55 deletions.
15 changes: 10 additions & 5 deletions code/modules/mining/equipment/kinetic_crusher.dm
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,16 @@
/obj/item/kinetic_crusher/attackby(obj/item/I, mob/living/user)
if(I.tool_behaviour == TOOL_CROWBAR)
if(LAZYLEN(trophies))
to_chat(user, "<span class='notice'>You remove [src]'s trophies.</span>")
I.play_tool_sound(src)
for(var/t in trophies)
var/obj/item/crusher_trophy/T = t
T.remove_from(src, user)
var/list/choose_options = list()
for(var/obj/item/crusher_trophy/T in trophies)
choose_options += list(T.name = image(icon = T.icon, icon_state = T.icon_state))
var/picked_option = show_radial_menu(user, src, choose_options, radius = 38, require_near = TRUE)
if(picked_option)
to_chat(user, "<span class='notice'>You remove [picked_option].</span>")
I.play_tool_sound(src)
for(var/obj/item/crusher_trophy/T in trophies)
if(T.name == picked_option)
T.remove_from(src, user)
else
to_chat(user, "<span class='warning'>There are no trophies on [src].</span>")
else if(istype(I, /obj/item/crusher_trophy))
Expand Down
42 changes: 18 additions & 24 deletions code/modules/projectiles/gun.dm
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
lefthand_file = 'icons/mob/inhands/weapons/guns_lefthand.dmi'
righthand_file = 'icons/mob/inhands/weapons/guns_righthand.dmi'

var/list/attachment_options = list() //This.. works for now.. gun refactor soon
var/obj/item/firing_pin/pin = /obj/item/firing_pin //standard firing pin for most guns

var/can_flashlight = FALSE //if a flashlight can be added or removed if it already has one.
Expand Down Expand Up @@ -545,33 +546,26 @@
return
if(!user.canUseTopic(src, BE_CLOSE, FALSE, NO_TK))
return
if((can_flashlight && gun_light) && (can_bayonet && bayonet)) //give them a choice instead of removing both
var/list/possible_items = list(gun_light, bayonet)
var/obj/item/item_to_remove = input(user, "Select an attachment to remove", "Attachment Removal") as null|obj in sortNames(possible_items)
if(!item_to_remove || !user.canUseTopic(src, BE_CLOSE, FALSE, NO_TK))
return
return remove_gun_attachment(user, I, item_to_remove)

else if(gun_light && can_flashlight) //if it has a gun_light and can_flashlight is false, the flashlight is permanently attached.
attachment_options = list()
get_gun_attachments()
if(LAZYLEN(attachment_options) == 1)
remove_gun_attachments(user, I, attachment_options[1])
else if (LAZYLEN(attachment_options))
var/picked_option = show_radial_menu(user, src, attachment_options, radius = 38, require_near = TRUE)
remove_gun_attachments(user, I, picked_option)

/obj/item/gun/proc/get_gun_attachments()
if(can_flashlight && gun_light)
attachment_options += list("Light" = image(icon = gun_light.icon, icon_state = gun_light.icon_state))
if(can_bayonet && bayonet)
attachment_options += list("Knife" = image(icon = bayonet.icon, icon_state = bayonet.icon_state))

/obj/item/gun/proc/remove_gun_attachments(mob/living/user, obj/item/I, picked_option)
if(picked_option == "Light")
return remove_gun_attachment(user, I, gun_light, "unscrewed")

else if(bayonet && can_bayonet) //if it has a bayonet, and the bayonet can be removed
else if(picked_option == "Knife")
return remove_gun_attachment(user, I, bayonet, "unfix")

/*WS Edit - Fixes Pin Removal
else if(pin && user.is_holding(src))
user.visible_message("<span class='warning'>[user] attempts to remove [pin] from [src] with [I].</span>",
"<span class='notice'>You attempt to remove [pin] from [src]. (It will take [DisplayTimeText(FIRING_PIN_REMOVAL_DELAY)].)</span>", null, 3)
if(I.use_tool(src, user, FIRING_PIN_REMOVAL_DELAY, volume = 50))
if(!pin) //check to see if the pin is still there, or we can spam messages by clicking multiple times during the tool delay
return
user.visible_message("<span class='notice'>[pin] is pried out of [src] by [user], destroying the pin in the process.</span>",
"<span class='warning'>You pry [pin] out with [I], destroying the pin in the process.</span>", null, 3)
QDEL_NULL(pin)
return TRUE
WS End */


/obj/item/gun/welder_act(mob/living/user, obj/item/I)
. = ..()
if(.)
Expand Down
44 changes: 22 additions & 22 deletions code/modules/projectiles/guns/energy.dm
Original file line number Diff line number Diff line change
Expand Up @@ -128,27 +128,29 @@
to_chat(user, "<span class='warning'>You cannot seem to get \the [src] out of your hands!</span>")
return FALSE

/obj/item/gun/energy/proc/eject_cell(mob/user, obj/item/stock_parts/cell/gun/tac_load = null)
playsound(src, load_sound, sound_volume, load_sound_vary)
cell.forceMove(drop_location())
var/obj/item/stock_parts/cell/gun/old_cell = cell
/*if(insert_cell(user, tac_load))
to_chat(user, "<span class='notice'>You perform a tactical reload on \the [src].</span>")
else
to_chat(user, "<span class='warning'>You dropped the old cell, but the new one doesn't fit. How embarassing.</span>")*/
cell = null
user.put_in_hands(old_cell)
old_cell.update_appearance()
to_chat(user, "<span class='notice'>You pull the cell out of \the [src].</span>")
update_appearance()
/obj/item/gun/energy/proc/eject_cell(mob/user, obj/item/I)
to_chat(user, "<span class='notice'>You begin unscrewing and pulling out the cell...</span>")
if(I.use_tool(src, user, unscrewing_time, volume=100))
to_chat(user, "<span class='notice'>You remove the power cell.</span>")
playsound(src, load_sound, sound_volume, load_sound_vary)
cell.forceMove(drop_location())
var/obj/item/stock_parts/cell/gun/old_cell = cell
cell = null
user.put_in_hands(old_cell)
old_cell.update_appearance()
to_chat(user, "<span class='notice'>You pull the cell out of \the [src].</span>")
update_appearance()

/obj/item/gun/energy/screwdriver_act(mob/living/user, obj/item/I)
if(cell && !internal_cell && !bayonet && (!gun_light || !can_flashlight))
to_chat(user, "<span class='notice'>You begin unscrewing and pulling out the cell...</span>")
if(I.use_tool(src, user, unscrewing_time, volume=100))
to_chat(user, "<span class='notice'>You remove the power cell.</span>")
eject_cell(user)
return ..()
/obj/item/gun/energy/get_gun_attachments()
if(cell && !internal_cell)
attachment_options += list("Cell" = image(icon = cell.icon, icon_state = cell.icon_state))
..()

/obj/item/gun/energy/remove_gun_attachments(mob/living/user, obj/item/I, picked_option)
if(picked_option == "Cell")
eject_cell(user, I)
return TRUE
..()

/obj/item/gun/energy/can_shoot(visuals)
if(safety && !visuals)
Expand Down Expand Up @@ -226,8 +228,6 @@
. = ..()
if(!automatic_charge_overlays || QDELETED(src))
return
if(cell)
. += "[icon_state]_cell"
// Every time I see code this "flexible", a kitten fucking dies //it got worse
//todo: refactor this a bit to allow showing of charge on a gun's cell
var/overlay_icon_state = "[icon_state]_charge"
Expand Down
14 changes: 10 additions & 4 deletions code/modules/projectiles/guns/energy/kinetic_accelerator.dm
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,17 @@

/obj/item/gun/energy/kinetic_accelerator/crowbar_act(mob/living/user, obj/item/I)
. = TRUE
if(modkits.len)
to_chat(user, "<span class='notice'>You pry the modifications out.</span>")
I.play_tool_sound(src, 100)
if(LAZYLEN(modkits))
var/list/choose_options = list()
for(var/obj/item/borg/upgrade/modkit/M in modkits)
M.uninstall(src)
choose_options += list(M.name = image(icon = M.icon, icon_state = M.icon_state))
var/picked_option = show_radial_menu(user, src, choose_options, radius = 38, require_near = TRUE)
if(picked_option)
to_chat(user, "<span class='notice'>You remove [picked_option].</span>")
I.play_tool_sound(src, 100)
for(var/obj/item/borg/upgrade/modkit/M in modkits)
if(M.name == picked_option)
M.uninstall(src)
else
to_chat(user, "<span class='notice'>There are no modifications currently installed.</span>")

Expand Down

0 comments on commit 563a7d4

Please sign in to comment.