Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attachment Update + A few new attachments #4040

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion code/__DEFINES/dcs/signals/signals.dm
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,10 @@
#define COMSIG_CLICK_CTRL_SHIFT_RIGHT "ctrl_shift_right_click"
/// from mob/ver/do_unique_action
#define COMSIG_CLICK_UNIQUE_ACTION "unique_action"
#define OVERIDE_UNIQUE_ACTION 1
#define OVERRIDE_UNIQUE_ACTION 1
/// from mob/ver/do_unique_action
#define COMSIG_CLICK_SECONDARY_ACTION "secondary_action"
#define OVERRIDE_SECONDARY_ACTION 1
//from base of atom/MouseDrop(): (/atom/over, /mob/user)
#define COMSIG_MOUSEDROP_ONTO "mousedrop_onto"
#define COMPONENT_NO_MOUSEDROP 1
Expand Down
1 change: 1 addition & 0 deletions code/__DEFINES/guns.dm
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
#define COMSIG_ATTACHMENT_UNIQUE_ACTION "attach-unique-action"
#define COMSIG_ATTACHMENT_CTRL_CLICK "attach-ctrl-click"
#define COMSIG_ATTACHMENT_ALT_CLICK "attach-alt-click"
#define COMSIG_ATTACHMENT_ATTACK_HAND "attach-attack-hand"

#define COMSIG_ATTACHMENT_TOGGLE "attach-toggle"

Expand Down
1 change: 1 addition & 0 deletions code/__DEFINES/keybinding.dm
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#define COMSIG_KB_HUMAN_QUICKEQUIP_DOWN "keybinding_human_quickequip_down"
#define COMSIG_KB_HUMAN_QUICKEQUIPBELT_DOWN "keybinding_human_quickequipbelt_down"
#define COMSIG_KB_HUMAN_UNIQUEACTION "keybinding_uniqueaction"
#define COMSIG_KB_HUMAN_SECONDARYACTION "keybinding_secondaryaction"
#define COMSIG_KB_HUMAN_BAGEQUIP_DOWN "keybinding_human_bagequip_down"
#define COMSIG_KB_HUMAN_EQUIPMENTSWAP_DOWN "keybinding_human_equipmentswap_down"
#define COMSIG_KB_HUMAN_SUITEQUIP_DOWN "keybinding_human_suitequip_down"
Expand Down
10 changes: 10 additions & 0 deletions code/datums/components/attachment.dm
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
var/datum/callback/on_ctrl_click
var/datum/callback/on_alt_click
var/datum/callback/on_examine
var/datum/callback/on_attack_hand
///Called on the parents preattack
var/datum/callback/on_preattack
///Called on the parents wield
Expand All @@ -39,6 +40,7 @@
datum/callback/on_unwield = null,
datum/callback/on_examine = null,
datum/callback/on_alt_click = null,
datum/callback/on_attack_hand = null,
list/signals = null
)

Expand All @@ -59,6 +61,7 @@
src.on_unwield = on_unwield
src.on_examine = on_examine
src.on_alt_click = on_alt_click
src.on_attack_hand = on_attack_hand

ADD_TRAIT(parent, TRAIT_ATTACHABLE, "attachable")
RegisterSignal(parent, COMSIG_ATTACHMENT_ATTACH, PROC_REF(try_attach))
Expand All @@ -77,6 +80,7 @@
RegisterSignal(parent, COMSIG_ATTACHMENT_UNIQUE_ACTION, PROC_REF(relay_unique_action))
RegisterSignal(parent, COMSIG_ATTACHMENT_CTRL_CLICK, PROC_REF(relay_ctrl_click))
RegisterSignal(parent, COMSIG_ATTACHMENT_ALT_CLICK, PROC_REF(relay_alt_click))
RegisterSignal(parent, COMSIG_ATTACHMENT_ATTACK_HAND, PROC_REF(relay_attack_hand))

for(var/signal in signals)
RegisterSignal(parent, signal, signals[signal])
Expand Down Expand Up @@ -206,6 +210,12 @@
if(on_alt_click)
return on_alt_click.Invoke(gun, user, params)

/datum/component/attachment/proc/relay_attack_hand(obj/item/parent, obj/item/gun, mob/user, params)
SIGNAL_HANDLER_DOES_SLEEP

if(on_attack_hand)
return on_attack_hand.Invoke(gun, user, params)

/datum/component/attachment/proc/send_slot(obj/item/parent)
SIGNAL_HANDLER
return attachment_slot_to_bflag(slot)
Expand Down
8 changes: 8 additions & 0 deletions code/datums/components/attachment_holder.dm
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
RegisterSignal(parent, COMSIG_ITEM_PRE_ATTACK, PROC_REF(handle_item_pre_attack))
RegisterSignal(parent, COMSIG_TWOHANDED_WIELD, PROC_REF(handle_item_wield))
RegisterSignal(parent, COMSIG_TWOHANDED_UNWIELD, PROC_REF(handle_item_unwield))
RegisterSignal(parent, COMSIG_ATOM_ATTACK_HAND, PROC_REF(handle_hand_attack))
RegisterSignal(parent, COMSIG_CLICK_CTRL_SHIFT, PROC_REF(handle_ctrl_shift_click))
RegisterSignal(parent, COMSIG_CLICK_CTRL, PROC_REF(handle_ctrl_click))
RegisterSignal(parent, COMSIG_CLICK_ALT, PROC_REF(handle_alt_click))
Expand Down Expand Up @@ -221,6 +222,13 @@
if(SEND_SIGNAL(attach, COMSIG_ATTACHMENT_UNWIELD, parent, user, params))
return TRUE

/datum/component/attachment_holder/proc/handle_hand_attack(obj/item/parent, mob/user, params)
SIGNAL_HANDLER

for(var/obj/item/attach as anything in attachments)
if(SEND_SIGNAL(attach, COMSIG_ATTACHMENT_ATTACK_HAND, parent, user, params))
return TRUE

/datum/component/attachment_holder/proc/handle_unique_action(obj/item/parent, mob/user, params)
SIGNAL_HANDLER

Expand Down
17 changes: 17 additions & 0 deletions code/datums/keybinding/human.dm
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,23 @@
current_human.do_unique_action()
return TRUE

/datum/keybinding/human/secondary_action
hotkey_keys = list("ShiftSpace")
name = "secondary_action"
full_name = "Perform secondary action"
description = ""
keybind_signal = COMSIG_KB_HUMAN_SECONDARYACTION


/datum/keybinding/human/secondary_action/down(client/user)
. = ..()
if(.)
return
var/mob/living/carbon/human/current_human = user.mob
current_human.do_secondary_action()
return TRUE


/datum/keybinding/human/quick_equip_belt
hotkey_keys = list("ShiftE")
name = "quick_equip_belt"
Expand Down
11 changes: 10 additions & 1 deletion code/game/objects/items.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1213,7 +1213,16 @@ GLOBAL_VAR_INIT(embedpocalypse, FALSE) // if true, all items will be able to emb

///Called before unique action, if any other associated items should do a unique action or override it.
/obj/item/proc/pre_unique_action(mob/living/user)
if(SEND_SIGNAL(src,COMSIG_CLICK_UNIQUE_ACTION,user) & OVERIDE_UNIQUE_ACTION)
if(SEND_SIGNAL(src,COMSIG_CLICK_UNIQUE_ACTION,user) & OVERRIDE_UNIQUE_ACTION)
return TRUE
return FALSE //return true if the proc should end here

///Intended for interactions with guns, like swapping firemodes
/obj/item/proc/secondary_action(mob/living/user)

///Called before unique action, if any other associated items should do a secondary action or override it.
/obj/item/proc/pre_secondary_action(mob/living/user)
if(SEND_SIGNAL(src,COMSIG_CLICK_SECONDARY_ACTION,user) & OVERRIDE_SECONDARY_ACTION)
return TRUE
return FALSE //return true if the proc should end here
/**
Expand Down
10 changes: 10 additions & 0 deletions code/game/objects/items/attachments/_attachment.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
///Component that handles most of the logic of attachments
var/datum/component/attachment/attachment_comp


/// the cell in the gun, if any
var/obj/item/stock_parts/cell/gun/gun_cell

///If the attachment is on or off
var/toggled = FALSE
var/toggle_on_sound = 'sound/items/flashlight_on.ogg'
Expand Down Expand Up @@ -57,6 +61,7 @@
CALLBACK(src, PROC_REF(on_unwield)), \
CALLBACK(src, PROC_REF(on_examine)), \
CALLBACK(src, PROC_REF(on_alt_click)), \
CALLBACK(src, PROC_REF(on_attack_hand)), \
signals)

/obj/item/attachment/Destroy()
Expand All @@ -80,6 +85,7 @@
return FALSE

apply_modifiers(gun, user, TRUE)
gun_cell = gun.cell
playsound(src.loc, 'sound/weapons/gun/pistol/mag_insert_alt.ogg', 75, 1)
return TRUE

Expand All @@ -91,6 +97,7 @@

apply_modifiers(gun, user, FALSE)
playsound(src.loc, 'sound/weapons/gun/pistol/mag_release_alt.ogg', 75, 1)
gun_cell = null
return TRUE

/obj/item/attachment/proc/on_preattack(obj/item/gun/gun, atom/target, mob/user, list/params)
Expand All @@ -114,6 +121,9 @@
/obj/item/attachment/proc/on_examine(obj/item/gun/gun, mob/user, list/examine_list)
return

/obj/item/attachment/proc/on_attack_hand(obj/item/gun/gun, mob/user, list/examine_list)
return FALSE

/obj/item/attachment/proc/on_alt_click(obj/item/gun/gun, mob/user, list/examine_list)
AltClick(user)
return TRUE
Expand Down
23 changes: 20 additions & 3 deletions code/game/objects/items/attachments/_gun_attachment.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
wield_delay = 0.1 SECONDS
var/weapon_type = /obj/item/gun/ballistic/shotgun/automatic
var/obj/item/gun/attached_gun
var/allow_hand_interaction = FALSE
//basically so the fire select shows the right icon
var/underbarrel_prefix = ""

/obj/item/attachment/gun/Initialize()
/obj/item/attachment/gun/Initialize(mapload, spawn_empty = FALSE)
. = ..()
if(weapon_type)
attached_gun = new weapon_type(src)
attached_gun = new weapon_type(src,spawn_empty)
attached_gun.interaction_flags_item = NONE

/obj/item/attachment/gun/Destroy()
. = ..()
Expand Down Expand Up @@ -64,10 +66,25 @@
/obj/item/attachment/gun/unique_action(mob/living/user)
attached_gun.unique_action(user)

/obj/item/attachment/gun/on_attack_hand(obj/item/gun/gun, mob/user, list/examine_list)
if(gun.gun_firemodes[gun.firemode_index] == FIREMODE_UNDERBARREL && gun.loc == user && user.is_holding(gun) && allow_hand_interaction)
hand_attack_interaction(user)
return COMPONENT_NO_ATTACK_HAND
return

/obj/item/attachment/gun/attack_hand(mob/user)
if(loc == user && user.is_holding(src) && allow_hand_interaction)
if(hand_attack_interaction(user))
return COMPONENT_NO_ATTACK_HAND
return ..()

/obj/item/attachment/gun/proc/hand_attack_interaction(mob/user)
return COMPONENT_NO_ATTACK_HAND

/obj/item/attachment/gun/on_unique_action(obj/item/gun/gun, mob/user)
if(gun.gun_firemodes[gun.firemode_index] == FIREMODE_UNDERBARREL)
attached_gun.unique_action(user)
return OVERIDE_UNIQUE_ACTION
return OVERRIDE_UNIQUE_ACTION

/obj/item/attachment/gun/on_ctrl_click(obj/item/gun/gun, mob/user)
attached_gun.toggle_safety(user,TRUE)
Expand Down
47 changes: 47 additions & 0 deletions code/game/objects/items/attachments/alof.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/obj/item/attachment/alof
name = "alof tube"
desc = "An antiquated spring operated magazine attachment for the HP Beacon. Has a capacity of three rounds."
icon_state = "alof"

attach_features_flags = ATTACH_REMOVABLE_HAND
pixel_shift_x = 10
pixel_shift_y = 0
wield_delay = 0.1 SECONDS
var/obj/item/ammo_box/magazine/internal/shot/alof/mag

/obj/item/attachment/alof/Initialize()
. = ..()
mag = new /obj/item/ammo_box/magazine/internal/shot/alof(src)

/obj/item/attachment/alof/Destroy()
. = ..()
QDEL_NULL(mag)

/obj/item/attachment/alof/on_attacked(obj/item/gun/gun, mob/user, obj/item)
. = ..()
if(istype(item,/obj/item/ammo_casing) || istype(item, /obj/item/ammo_box))
attackby(item,user)

/obj/item/attachment/alof/attackby(obj/item/I, mob/living/user, params)
if(istype(I,/obj/item/ammo_casing) || istype(I, /obj/item/ammo_box))
mag.attackby(I,user)
else
return ..()
/obj/item/attachment/alof/attack_self(mob/user)
. = ..()
mag.attack_self(user)

/obj/item/attachment/alof/on_unique_action(obj/item/gun/gun, mob/user, obj/item)
. = ..()
if(gun.bolt_locked)
var/obj/item/ammo_casing/casing_to_insert = mag.get_round(TRUE)
if(gun.magazine.give_round(casing_to_insert,TRUE))
mag.stored_ammo -= casing_to_insert
to_chat(user,span_notice("\The [src] automatically loads another round into \the [gun]!"))

/obj/item/ammo_box/magazine/internal/shot/alof
name = "alof tube internal magazine"
ammo_type = /obj/item/ammo_casing/a4570
caliber = ".45-70"
max_ammo = 3
instant_load = TRUE
35 changes: 32 additions & 3 deletions code/game/objects/items/attachments/gun_attachments/ballistic.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
else
return ..()

/obj/item/attachment/gun/ballistic/hand_attack_interaction(mob/user)
var/obj/item/gun/ballistic/ballistic_gun = attached_gun
if(ballistic_gun.magazine)
ballistic_gun.eject_magazine(user)
return ..()

/obj/item/attachment/gun/ballistic/on_examine(obj/item/gun/gun, mob/user, list/examine_list)
var/obj/item/gun/ballistic/ballistic_gun = attached_gun
var/gun_bolt = ballistic_gun.bolt_type
Expand All @@ -24,8 +30,7 @@
/obj/item/gun/ballistic/shotgun/underbarrel
name = "underbarrel ballistic gun"
desc = "You shouldnt be seeing this."
semi_auto = TRUE
always_chambers = TRUE
semi_auto = FALSE
casing_ejector = TRUE
gunslinger_recoil_bonus = 0
default_ammo_type = /obj/item/ammo_box/magazine/internal/shot/underbarrel
Expand All @@ -35,7 +40,7 @@

/obj/item/attachment/gun/ballistic/shotgun
name = "underbarrel shotgun"
desc = "A single shot underbarrel shotgun for warding off anyone who gets too close for comfort."
desc = "A two shot pump underbarrel shotgun for warding off anyone who gets too close for comfort."
underbarrel_prefix = "sg_"
weapon_type = /obj/item/gun/ballistic/shotgun/underbarrel

Expand All @@ -49,9 +54,33 @@
/obj/item/gun/ballistic/shotgun/underbarrel/grenadelauncher
name = "underbarrel grenade launcher"
fire_sound = 'sound/weapons/gun/general/grenade_launch.ogg'
always_chambers = TRUE
default_ammo_type = /obj/item/ammo_box/magazine/internal/grenadelauncher
allowed_ammo_types = list(
/obj/item/ammo_box/magazine/internal/grenadelauncher
)

/obj/item/attachment/gun/ballistic/hognose
name = "PC-22 \"Hognose\""
desc = "A compact underbarrel pistol chambered in 22lr. Holds eight rounds."
icon_state = "hognose"
weapon_type = /obj/item/gun/ballistic/automatic/pistol/himehabu/underbarrel
allow_hand_interaction = TRUE

/obj/item/gun/ballistic/automatic/pistol/himehabu/underbarrel
name = "PC-22 \"Hognose\""
desc = "You shouldn't be seeing this."
default_ammo_type = /obj/item/ammo_box/magazine/m22lr_himehabu/hognose
allowed_ammo_types = list(
/obj/item/ammo_box/magazine/m22lr_himehabu/hognose,
)

/obj/item/ammo_box/magazine/m22lr_himehabu/hognose
name = "Hognose magazine (.22 LR)"
max_ammo = 8

/obj/item/ammo_box/magazine/m22lr_himehabu/hognose/empty
start_empty = TRUE



41 changes: 41 additions & 0 deletions code/game/objects/items/attachments/gun_attachments/energy.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
icon_state = "energy"
weapon_type = /obj/item/gun/energy/e_gun
var/automatic_charge_overlays = TRUE
allow_hand_interaction = TRUE

/obj/item/attachment/gun/energy/attackby(obj/item/I, mob/living/user, params)
if(istype(I, /obj/item/stock_parts/cell/gun))
Expand All @@ -13,6 +14,12 @@
else
return ..()

/obj/item/attachment/gun/energy/hand_attack_interaction(mob/user)
var/obj/item/gun/energy/e_gun = attached_gun
if(e_gun.tac_reloads && e_gun.cell)
e_gun.eject_cell(user)
return ..()

/obj/item/attachment/gun/energy/on_examine(obj/item/gun/gun, mob/user, list/examine_list)
var/obj/item/gun/energy/e_gun = attached_gun
var/obj/item/ammo_casing/energy/shot = e_gun.ammo_type[e_gun.select]
Expand Down Expand Up @@ -45,3 +52,37 @@
ammo_type = list(/obj/item/ammo_casing/energy/disabler/underbarrel, /obj/item/ammo_casing/energy/laser/underbarrel)
spawn_no_ammo = TRUE

/obj/item/attachment/gun/energy/e50
name = "underbarrel energy cannon"
desc = "An aftermarket conversion of Eoehoma Firearms' E-50 emitter cannon stripped down in order to fit on the rail mounts on other weapons. This less than orthodox conversion strips out most of the E-50's safety mechanisms to cut down on weight and size, making it dangerously prone to overheating even at its reduced power. Heat insulated gloves are reccomended."
weapon_type = /obj/item/gun/energy/laser/e50/clip/underbarrel
icon_state = "e50"

/obj/item/gun/energy/laser/e50/clip/underbarrel
name = "underbarrel energy cannon"
desc = "Watch out, its hot."
default_ammo_type = /obj/item/stock_parts/cell/gun
allowed_ammo_types = list(
/obj/item/stock_parts/cell/gun,
/obj/item/stock_parts/cell/gun/upgraded,
/obj/item/stock_parts/cell/gun/empty,
/obj/item/stock_parts/cell/gun/upgraded/empty,
)

// turns out shrinking an industrial laser to this size is kinda dangerous
/obj/item/gun/energy/laser/e50/clip/underbarrel/process_fire(atom/target, mob/living/user, message, params, zone_override, bonus_spread)
if(..())
var/prot = FALSE
var/mob/living/carbon/human/shooter = user
if(shooter.gloves)
var/obj/item/clothing/gloves/shooter_glove = shooter.gloves
if(shooter_glove.max_heat_protection_temperature)
prot = (shooter_glove.max_heat_protection_temperature > 360)
if(HAS_TRAIT(user, TRAIT_RESISTHEAT) || HAS_TRAIT(user, TRAIT_RESISTHEATHANDS))
prot = TRUE
var/obj/item/bodypart/affected_hand = shooter.get_bodypart("[(user.active_hand_index % 2 == 0) ? "r" : "l" ]_arm")
if(prot == FALSE)
if(affected_hand && affected_hand.receive_damage(0, 25))
shooter.drop_all_held_items()
to_chat(shooter,span_danger("The [src] violently heats up as it fires, burning your hand!"))

Loading
Loading