Skip to content

Commit

Permalink
Shoulder Sling attachment (#3860)
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

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

Adds the shoulder sling attachment to cargo for 500 credits.

The shoulder sling can be attached any long arm gun with a weight class
of bulky or up. The sling allows for the gun to be carried in your suit
storage slot without an armor holster.

Adds support for attachment overlays to render under the attached gun.

Shoulder sling sprites by Moffball.


![image](https://github.com/user-attachments/assets/f6b9910f-b42b-4e38-87fa-a146061c05d5)

## Why It's Good For The Game

<!-- 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. -->
This gives players more options for fashion and accessorizing. You're no
longer stuck with wearing a boring armor vest to hold your bulky
weapons, and the other option of carrying your gun everywhere in your
hands makes you look like a maniac. Balance wise this should be fine,
since you can buy armor from the outpost anyways, which provides the
same benefit with it's holster while being objectively better because
well. It's armored.


## Changelog

:cl:
add: Shoulder slings to outpost cargo for 500 credits.
/: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
Gristlebee authored Dec 4, 2024
1 parent acd54fd commit 8dd6c6c
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 4 deletions.
1 change: 1 addition & 0 deletions code/__DEFINES/traits.dm
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai
/// A transforming item that is actively extended / transformed
#define TRAIT_TRANSFORM_ACTIVE "active_transform"
#define TRAIT_WIELDED "wielded" //The item is currently being wielded
#define TRAIT_FORCE_SUIT_STORAGE "force_suit_storage" // the item can be worn in suit storage without an outerclothing

//quirk traits
#define TRAIT_ALCOHOL_TOLERANCE "alcohol_tolerance"
Expand Down
10 changes: 8 additions & 2 deletions code/datums/components/attachment.dm
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,15 @@
parent.attack_self(user)
return TRUE

/datum/component/attachment/proc/update_overlays(obj/item/parent, list/overlays, list/offset)
/datum/component/attachment/proc/update_overlays(obj/item/attachment/parent, list/overlays, list/offset)
if(!(attach_features_flags & ATTACH_NO_SPRITE))
overlays += mutable_appearance(parent.icon, "[parent.icon_state]-attached")
var/overlay_layer = FLOAT_LAYER
var/overlay_plane = FLOAT_PLANE
if(parent.render_layer)
overlay_layer = parent.render_layer
if(parent.render_plane)
overlay_layer = parent.render_plane
overlays += mutable_appearance(parent.icon, "[parent.icon_state]-attached",overlay_layer,overlay_plane)

/datum/component/attachment/proc/try_attach(obj/item/parent, obj/item/holder, mob/user, bypass_checks)
SIGNAL_HANDLER
Expand Down
3 changes: 3 additions & 0 deletions code/game/objects/items/attachments/_attachment.dm
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
var/pixel_shift_x = 16
///Determines the amount of pixels to move the icon state for the overlay. in the y direction
var/pixel_shift_y = 16
/// Determines what layer the icon state for the overlay renders on.
var/render_layer = FLOAT_LAYER //inhands
var/render_plane = FLOAT_PLANE //world

//Toggle modifers are handled seperatly
///Modifier applied to the parent
Expand Down
31 changes: 31 additions & 0 deletions code/game/objects/items/attachments/shoulder_sling.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/obj/item/attachment/sling
name = "shoulder sling"
desc = "A leather shoulder sling for longarms to allow for easy carrying on the shoulder without the need for traditional armor holsters."
icon_state = "sling"

attach_features_flags = ATTACH_REMOVABLE_HAND
pixel_shift_x = 14
pixel_shift_y = 15
render_layer = BELOW_OBJ_LAYER
render_plane = BELOW_OBJ_LAYER
wield_delay = 0.2 SECONDS

var/check_size = TRUE

/obj/item/attachment/sling/apply_attachment(obj/item/gun/gun, mob/user)
. = ..()
if(initial(gun.w_class) < WEIGHT_CLASS_BULKY && check_size)
to_chat(user,span_warning("The frame of the \the [gun] isn't large enough to support \the [src]!"))
return FALSE
if(!(gun.slot_flags | ITEM_SLOT_SUITSTORE))
gun.slot_flags = gun.slot_flags | ITEM_SLOT_SUITSTORE
ADD_TRAIT(gun,TRAIT_FORCE_SUIT_STORAGE,REF(src))

/obj/item/attachment/sling/remove_attachment(obj/item/gun/gun, mob/user)
. = ..()
gun.slot_flags = initial(gun.slot_flags)
REMOVE_TRAIT(gun,TRAIT_FORCE_SUIT_STORAGE, REF(src))

/obj/item/attachment/sling/examine(mob/user)
. = ..()
. += span_notice("The shoulder sling can only be attached to bulky or heavier guns.")
7 changes: 7 additions & 0 deletions code/modules/cargo/packs/gun.dm
Original file line number Diff line number Diff line change
Expand Up @@ -684,3 +684,10 @@
cost = 250
contains = list(/obj/item/attachment/silencer)
crate_name = "suppressor crate"

/datum/supply_pack/gun/attachment/sling
name = "Shoulder Sling Crate"
desc = "Contains a single shoulder sling to be mounted on a firearm for easy carrying without armor holsters. Only compatible with longarms."
cost = 250
contains = list(/obj/item/attachment/sling)
crate_name = "shoulder sling crate"
2 changes: 2 additions & 0 deletions code/modules/mob/living/carbon/human/species.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1238,6 +1238,8 @@ GLOBAL_LIST_EMPTY(roundstart_races)
return FALSE
if(H.s_store && !swap)
return FALSE
if(HAS_TRAIT(I, TRAIT_FORCE_SUIT_STORAGE))
return TRUE
if(!H.wear_suit)
if(!disable_warning)
to_chat(H, "<span class='warning'>You need a suit before you can attach this [I.name]!</span>")
Expand Down
3 changes: 2 additions & 1 deletion code/modules/projectiles/guns/ballistic.dm
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
/obj/item/attachment/silencer,
/obj/item/attachment/laser_sight,
/obj/item/attachment/rail_light,
/obj/item/attachment/bayonet
/obj/item/attachment/bayonet,
/obj/item/attachment/sling
)
slot_available = list(
ATTACHMENT_SLOT_MUZZLE = 1,
Expand Down
3 changes: 2 additions & 1 deletion code/modules/projectiles/guns/energy.dm
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
valid_attachments = list(
/obj/item/attachment/laser_sight,
/obj/item/attachment/rail_light,
/obj/item/attachment/bayonet
/obj/item/attachment/bayonet,
/obj/item/attachment/sling
)
slot_available = list(
ATTACHMENT_SLOT_RAIL = 1
Expand Down
Binary file modified icons/obj/guns/attachments.dmi
Binary file not shown.
1 change: 1 addition & 0 deletions shiptest.dme
Original file line number Diff line number Diff line change
Expand Up @@ -1254,6 +1254,7 @@
#include "code\game\objects\items\attachments\laser_sight.dm"
#include "code\game\objects\items\attachments\m17_barrel.dm"
#include "code\game\objects\items\attachments\rail_light.dm"
#include "code\game\objects\items\attachments\shoulder_sling.dm"
#include "code\game\objects\items\attachments\silencer.dm"
#include "code\game\objects\items\attachments\stock.dm"
#include "code\game\objects\items\circuitboards\circuitboard.dm"
Expand Down

0 comments on commit 8dd6c6c

Please sign in to comment.