diff --git a/code/__DEFINES/guns.dm b/code/__DEFINES/guns.dm index ba5c94562f82..c2296a53834e 100644 --- a/code/__DEFINES/guns.dm +++ b/code/__DEFINES/guns.dm @@ -156,6 +156,7 @@ DEFINE_BITFIELD(attach_slots, list( #define ATTACH_REMOVABLE_HAND (1<<0) #define ATTACH_REMOVABLE_TOOL (1<<1) #define ATTACH_TOGGLE (1<<2) +#define ATTACH_NO_SPRITE (1<<3) ///////////////// // PROJECTILES // diff --git a/code/datums/components/attachment.dm b/code/datums/components/attachment.dm index 34f053e4d601..219e48670bfa 100644 --- a/code/datums/components/attachment.dm +++ b/code/datums/components/attachment.dm @@ -72,13 +72,15 @@ return TRUE /datum/component/attachment/proc/update_overlays(obj/item/parent, list/overlays, list/offset) - overlays += mutable_appearance(parent.icon, "[parent.icon_state]-attached") + if(!(attach_features_flags & ATTACH_NO_SPRITE)) + overlays += mutable_appearance(parent.icon, "[parent.icon_state]-attached") -/datum/component/attachment/proc/try_attach(obj/item/parent, obj/item/holder, mob/user) +/datum/component/attachment/proc/try_attach(obj/item/parent, obj/item/holder, mob/user, bypass_checks) SIGNAL_HANDLER - if(!parent.Adjacent(user) || (length(valid_parent_types) && (holder.type in valid_parent_types))) - return FALSE + if(!bypass_checks) + if(!parent.Adjacent(user) || (length(valid_parent_types) && (holder.type in valid_parent_types))) + return FALSE if(on_attach && !on_attach.Invoke(holder, user)) return FALSE diff --git a/code/datums/components/attachment_holder.dm b/code/datums/components/attachment_holder.dm index 9edae8c8063b..6b57447f40b8 100644 --- a/code/datums/components/attachment_holder.dm +++ b/code/datums/components/attachment_holder.dm @@ -15,6 +15,7 @@ if(!isgun(parent)) return COMPONENT_INCOMPATIBLE + var/obj/item/gun/parent_gun = parent src.slot_room = slot_room src.valid_types = valid_types @@ -30,9 +31,9 @@ RegisterSignal(parent, COMSIG_ATOM_UPDATE_OVERLAYS, PROC_REF(handle_overlays)) if(length(default_attachments)) - for(var/obj/item/attachment/attachment in default_attachments) - var/obj/item/attachment/new_attachment = new(attachment) - INVOKE_ASYNC(src, PROC_REF(do_attach), new_attachment, null) + for(var/attachment in default_attachments) + var/obj/item/attachment/new_attachment = new attachment(parent_gun.loc) + INVOKE_ASYNC(src, PROC_REF(do_attach), new_attachment, null, TRUE) /datum/component/attachment_holder/proc/handle_overlays(obj/item/parent, list/overlays) SIGNAL_HANDLER @@ -104,7 +105,7 @@ for(var/obj/item/attach as anything in attachments) SEND_SIGNAL(attach, COMSIG_ATTACHMENT_EXAMINE_MORE, user, examine_list) -/datum/component/attachment_holder/proc/do_attach(obj/item/attachment, mob/user) +/datum/component/attachment_holder/proc/do_attach(obj/item/attachment, mob/user, bypass_checks) var/slot = SEND_SIGNAL(attachment, COMSIG_ATTACHMENT_GET_SLOT) slot = attachment_slot_from_bflag(slot) if(!(attachment.type in valid_types)) @@ -114,7 +115,7 @@ to_chat(user, span_notice("[parent] does not contain room for [attachment]!")) return slot_room[slot]-- - . = SEND_SIGNAL(attachment, COMSIG_ATTACHMENT_ATTACH, parent, user) + . = SEND_SIGNAL(attachment, COMSIG_ATTACHMENT_ATTACH, parent, user, bypass_checks) if(.) attachments += attachment var/atom/parent = src.parent diff --git a/code/game/objects/items/attachments/_attachment.dm b/code/game/objects/items/attachments/_attachment.dm index a78fc06d299d..48a17c15af03 100644 --- a/code/game/objects/items/attachments/_attachment.dm +++ b/code/game/objects/items/attachments/_attachment.dm @@ -20,6 +20,9 @@ var/pixel_shift_y = 16 var/spread_mod = 0 + var/spread_unwielded_mod = 0 + var/wield_delay = 0 + var/size_mod = 0 /obj/item/attachment/Initialize() . = ..() @@ -75,8 +78,11 @@ /obj/item/attachment/proc/apply_modifiers(obj/item/gun/gun, mob/user, attaching) if(attaching) gun.spread += spread_mod - gun.spread_unwielded += spread_mod + gun.spread_unwielded += spread_unwielded_mod + gun.wield_delay += wield_delay + gun.w_class += size_mod else gun.spread -= spread_mod - gun.spread_unwielded -= spread_mod - + gun.spread_unwielded -= spread_unwielded_mod + gun.wield_delay -= wield_delay + gun.w_class -= size_mod diff --git a/code/game/objects/items/attachments/bayonet.dm b/code/game/objects/items/attachments/bayonet.dm index 0bfac65b33c9..06fbb7982293 100644 --- a/code/game/objects/items/attachments/bayonet.dm +++ b/code/game/objects/items/attachments/bayonet.dm @@ -4,15 +4,16 @@ icon_state = "bayonet" force = 15 throwforce = 10 - pixel_shift_x = 1 - pixel_shift_y = 4 pickup_sound = 'sound/items/handling/knife1_pickup.ogg' drop_sound = 'sound/items/handling/knife3_drop.ogg' hitsound = 'sound/weapons/bladeslice.ogg' attack_verb = list("slashed", "stabbed", "sliced", "torn", "ripped", "diced", "cut") sharpness = IS_SHARP_ACCURATE + pixel_shift_x = 1 + pixel_shift_y = 4 spread_mod = 1 + wield_delay = 0.1 SECONDS /obj/item/attachment/bayonet/PreAttack(obj/item/gun/gun, atom/target, mob/living/user, list/params) if(user.a_intent == INTENT_HARM && user.CanReach(target, src, TRUE)) diff --git a/code/game/objects/items/attachments/laser_sight.dm b/code/game/objects/items/attachments/laser_sight.dm index 8f76ec51339f..8d493d2b86c8 100644 --- a/code/game/objects/items/attachments/laser_sight.dm +++ b/code/game/objects/items/attachments/laser_sight.dm @@ -2,13 +2,22 @@ name = "laser sight" desc = "This laser sight is designed to be rail-mounted on a compatible firearm to provide increased accuracy." icon_state = "laserpointer" + attach_features_flags = ATTACH_REMOVABLE_HAND|ATTACH_TOGGLE pixel_shift_x = 1 pixel_shift_y = 4 - - spread_mod = -1 + wield_delay = 0.1 SECONDS /obj/item/attachment/laser_sight/Toggle(obj/item/gun/gun, mob/user) . = ..() + if(toggled) + gun.spread -= 3 + gun.spread_unwielded -= 3 + gun.wield_delay -= 0.3 SECONDS + else + gun.spread += 3 + gun.spread_unwielded += 3 + gun.wield_delay += 0.3 SECONDS + playsound(user, toggled ? 'sound/weapons/magin.ogg' : 'sound/weapons/magout.ogg', 40, TRUE) diff --git a/code/game/objects/items/attachments/rail_light.dm b/code/game/objects/items/attachments/rail_light.dm index 9850a9f94ea6..155c6d485873 100644 --- a/code/game/objects/items/attachments/rail_light.dm +++ b/code/game/objects/items/attachments/rail_light.dm @@ -2,16 +2,17 @@ name = "rail light" desc = "Rail mounted gun light for better visibility down range." icon_state = "raillight" - attach_features_flags = ATTACH_REMOVABLE_HAND|ATTACH_TOGGLE - pixel_shift_x = 1 - pixel_shift_y = 4 - light_color = "#FFCC66" light_system = MOVABLE_LIGHT_DIRECTIONAL light_range = 4 light_power = 0.8 light_on = FALSE + attach_features_flags = ATTACH_REMOVABLE_HAND|ATTACH_TOGGLE + pixel_shift_x = 1 + pixel_shift_y = 4 + wield_delay = 0.1 SECONDS + /obj/item/attachment/rail_light/Toggle(obj/item/gun/gun, mob/user) . = ..() set_light_on(toggled) diff --git a/code/game/objects/items/attachments/silencer.dm b/code/game/objects/items/attachments/silencer.dm index a97ba1ea0375..ff601407632d 100644 --- a/code/game/objects/items/attachments/silencer.dm +++ b/code/game/objects/items/attachments/silencer.dm @@ -2,11 +2,12 @@ name = "silencer" desc = "For when you need to kill someone but not be seen killing someone!" icon_state = "silencer" + slot = ATTACHMENT_SLOT_MUZZLE pixel_shift_x = 1 pixel_shift_y = 2 - spread_mod = -1 + size_mod = 1 /obj/item/attachment/silencer/Attach(obj/item/gun/gun, mob/user) . = ..()