diff --git a/code/__DEFINES/dcs/signals.dm b/code/__DEFINES/dcs/signals.dm index 8307cd89419..b7d54f04bbb 100644 --- a/code/__DEFINES/dcs/signals.dm +++ b/code/__DEFINES/dcs/signals.dm @@ -991,6 +991,8 @@ #define COMSIG_MOB_FIRED_GUN "mob_fired_gun" ///called in /obj/item/gun/process_fire (user, target, params, zone_override) #define COMSIG_GUN_FIRED "gun_fired" +///called in /obj/item/gun/process_chamber (src) +#define COMSIG_GUN_CHAMBER_PROCESSED "gun_chamber_processed" ///called in /obj/item/gun/ballistic/process_chamber (casing) #define COMSIG_CASING_EJECTED "casing_ejected" diff --git a/code/modules/projectiles/gun.dm b/code/modules/projectiles/gun.dm index ab4d7cccdbc..018a53d10c3 100644 --- a/code/modules/projectiles/gun.dm +++ b/code/modules/projectiles/gun.dm @@ -152,8 +152,12 @@ zoom(user, user.dir, FALSE) //we can only stay zoomed in if it's in our hands //yeah and we only unzoom if we're actually zoomed using the gun!! //called after the gun has successfully fired its chambered ammo. -/obj/item/gun/proc/process_chamber() - return FALSE +/obj/item/gun/proc/process_chamber(empty_chamber = TRUE, from_firing = TRUE, chamber_next_round = TRUE) + handle_chamber(empty_chamber, from_firing, chamber_next_round) + SEND_SIGNAL(src, COMSIG_GUN_CHAMBER_PROCESSED) + +/obj/item/gun/proc/handle_chamber(empty_chamber = TRUE, from_firing = TRUE, chamber_next_round = TRUE) + return //check if there's enough ammo/energy/whatever to shoot one time //i.e if clicking would make it shoot diff --git a/code/modules/projectiles/guns/ballistic.dm b/code/modules/projectiles/guns/ballistic.dm index 068325f9995..fed2f497c33 100644 --- a/code/modules/projectiles/guns/ballistic.dm +++ b/code/modules/projectiles/guns/ballistic.dm @@ -210,7 +210,7 @@ . += "[icon_state]_mag_[capacity_number]" -/obj/item/gun/ballistic/process_chamber(empty_chamber = TRUE, from_firing = TRUE, chamber_next_round = TRUE) +/obj/item/gun/ballistic/handle_chamber(empty_chamber = TRUE, from_firing = TRUE, chamber_next_round = TRUE) if(!semi_auto && from_firing) return var/obj/item/ammo_casing/AC = chambered //Find chambered round diff --git a/code/modules/projectiles/guns/ballistic/rifle.dm b/code/modules/projectiles/guns/ballistic/rifle.dm index c6128ad7630..9e25dde3b04 100644 --- a/code/modules/projectiles/guns/ballistic/rifle.dm +++ b/code/modules/projectiles/guns/ballistic/rifle.dm @@ -148,7 +148,7 @@ can_be_sawn_off = FALSE projectile_damage_multiplier = 0.75 -/obj/item/gun/ballistic/rifle/boltaction/pipegun/process_chamber(empty_chamber, from_firing, chamber_next_round) +/obj/item/gun/ballistic/rifle/boltaction/pipegun/handle_chamber() . = ..() do_sparks(1, TRUE, src) diff --git a/code/modules/projectiles/guns/ballistic/toy.dm b/code/modules/projectiles/guns/ballistic/toy.dm index 48fd614fe49..9aa48ecbfd5 100644 --- a/code/modules/projectiles/guns/ballistic/toy.dm +++ b/code/modules/projectiles/guns/ballistic/toy.dm @@ -46,8 +46,8 @@ pb_knockback = 0 gun_flags = TOY_FIREARM_OVERLAY -/obj/item/gun/ballistic/shotgun/toy/process_chamber(empty_chamber = 0) - ..() +/obj/item/gun/ballistic/shotgun/toy/handle_chamber() + . = ..() if(chambered && !chambered.loaded_projectile) qdel(chambered) diff --git a/code/modules/projectiles/guns/energy.dm b/code/modules/projectiles/guns/energy.dm index a2320ae59f1..a57516285cf 100644 --- a/code/modules/projectiles/guns/energy.dm +++ b/code/modules/projectiles/guns/energy.dm @@ -155,7 +155,7 @@ if(!chambered.loaded_projectile) chambered.newshot() -/obj/item/gun/energy/process_chamber() +/obj/item/gun/energy/handle_chamber() if(chambered && !chambered.loaded_projectile) //if loaded_projectile is null, i.e the shot has been fired... var/obj/item/ammo_casing/energy/shot = chambered cell.use(shot.e_cost)//... drain the cell cell diff --git a/code/modules/projectiles/guns/magic.dm b/code/modules/projectiles/guns/magic.dm index 77f8a121b31..ebbbc009646 100644 --- a/code/modules/projectiles/guns/magic.dm +++ b/code/modules/projectiles/guns/magic.dm @@ -45,7 +45,7 @@ if (charges && chambered && !chambered.loaded_projectile) chambered.newshot() -/obj/item/gun/magic/process_chamber() +/obj/item/gun/magic/handle_chamber() if(chambered && !chambered.loaded_projectile) //if BB is null, i.e the shot has been fired... charges--//... drain a charge recharge_newshot() diff --git a/code/modules/projectiles/guns/special/chem_gun.dm b/code/modules/projectiles/guns/special/chem_gun.dm index 5d30449188f..ae3e62081c9 100644 --- a/code/modules/projectiles/guns/special/chem_gun.dm +++ b/code/modules/projectiles/guns/special/chem_gun.dm @@ -30,7 +30,7 @@ /obj/item/gun/chem/can_shoot() return syringes_left -/obj/item/gun/chem/process_chamber() +/obj/item/gun/chem/handle_chamber() if(chambered && !chambered.loaded_projectile && syringes_left) chambered.newshot() diff --git a/code/modules/projectiles/guns/special/syringe_gun.dm b/code/modules/projectiles/guns/special/syringe_gun.dm index e04e7cd85c9..e0b18c8b9c2 100644 --- a/code/modules/projectiles/guns/special/syringe_gun.dm +++ b/code/modules/projectiles/guns/special/syringe_gun.dm @@ -33,7 +33,7 @@ /obj/item/gun/syringe/can_shoot() return syringes.len -/obj/item/gun/syringe/process_chamber() +/obj/item/gun/syringe/handle_chamber() if(chambered && !chambered.loaded_projectile) //we just fired recharge_newshot() update_appearance() diff --git a/code/modules/research/designs/wiremod_designs.dm b/code/modules/research/designs/wiremod_designs.dm index 41a49c6ea58..7c0f7033d25 100644 --- a/code/modules/research/designs/wiremod_designs.dm +++ b/code/modules/research/designs/wiremod_designs.dm @@ -308,6 +308,15 @@ materials = list(/datum/material/glass = 2000, /datum/material/iron = 7000) category = list("Circuitry", "Shells") +/datum/design/gun_shell + name = "Gun Shell" + desc = "A handheld shell that can fire projectiles to output entities." + id = "gun_shell" + build_path = /obj/item/gun/energy/wiremod_gun + build_type = PROTOLATHE | COMPONENT_PRINTER + materials = list(/datum/material/glass = 2000, /datum/material/iron = 10000, /datum/material/plasma = 100) + category = list("Circuitry", "Shells") + /datum/design/bot_shell name = "Bot Shell" desc = "An immobile shell that can store more components. Has a USB port to be able to connect to computers and machines." diff --git a/code/modules/research/techweb/all_nodes.dm b/code/modules/research/techweb/all_nodes.dm index 1fd4dff93ee..004c64f79dd 100644 --- a/code/modules/research/techweb/all_nodes.dm +++ b/code/modules/research/techweb/all_nodes.dm @@ -700,8 +700,9 @@ prereq_ids = list("basic_circuitry", "engineering") design_ids = list( "bot_shell", - "door_shell", "controller_shell", + "door_shell", + "gun_shell", "money_bot_shell", "scanner_gate_shell", "scanner_shell", diff --git a/code/modules/wiremod/components/string/tostring.dm b/code/modules/wiremod/components/string/tostring.dm index bc044f157a7..f7dbea77960 100644 --- a/code/modules/wiremod/components/string/tostring.dm +++ b/code/modules/wiremod/components/string/tostring.dm @@ -15,7 +15,7 @@ circuit_flags = CIRCUIT_FLAG_INPUT_SIGNAL|CIRCUIT_FLAG_OUTPUT_SIGNAL - var/max_range = 5 + var/max_range = 7 /obj/item/circuit_component/tostring/Initialize() . = ..() diff --git a/code/modules/wiremod/shell/gun.dm b/code/modules/wiremod/shell/gun.dm new file mode 100644 index 00000000000..619e666282b --- /dev/null +++ b/code/modules/wiremod/shell/gun.dm @@ -0,0 +1,86 @@ +/** + * # Circuit Gun + * + * A gun that lets you fire projectiles to enact circuitry. + */ +/obj/item/gun/energy/wiremod_gun + name = "circuit gun" + desc = "A gun that fires projectiles able to control circuitry. It can recharge using power from an attached circuit." + icon = 'icons/obj/wiremod.dmi' + icon_state = "setup_gun" + ammo_type = list(/obj/item/ammo_casing/energy/wiremod_gun) + cell_type = /obj/item/stock_parts/cell/emproof/wiremod_gun + item_flags = NONE + light_system = MOVABLE_LIGHT_DIRECTIONAL + light_on = FALSE + automatic_charge_overlays = FALSE + trigger_guard = TRIGGER_GUARD_ALLOW_ALL + +/obj/item/ammo_casing/energy/wiremod_gun + projectile_type = /obj/projectile/energy/wiremod_gun + select_name = "circuit" + fire_sound = 'sound/weapons/blaster.ogg' + +/obj/projectile/energy/wiremod_gun + name = "scanning beam" + icon_state = "energy" + nodamage = TRUE + damage = 0 + range = 7 + +/obj/item/stock_parts/cell/emproof/wiremod_gun + maxcharge = 100 + +/obj/item/gun/energy/wiremod_gun/Initialize() + . = ..() + AddComponent(/datum/component/shell, list( + new /obj/item/circuit_component/wiremod_gun() + ), SHELL_CAPACITY_MEDIUM) + +/obj/item/circuit_component/wiremod_gun + display_name = "Gun" + desc = "Used to receive entities hit by projectiles from a gun." + /// Called when a projectile hits + var/datum/port/output/signal + /// The shooter + var/datum/port/output/shooter + /// The entity being shot + var/datum/port/output/shot + +/obj/item/circuit_component/wiremod_gun/Initialize() + . = ..() + shooter = add_output_port("Shooter", PORT_TYPE_ATOM) + shot = add_output_port("Shot Entity", PORT_TYPE_ATOM) + signal = add_output_port("Shot", PORT_TYPE_SIGNAL) + +/obj/item/circuit_component/wiremod_gun/register_shell(atom/movable/shell) + RegisterSignal(shell, COMSIG_PROJECTILE_ON_HIT, .proc/handle_shot) + if(istype(shell, /obj/item/gun/energy)) + RegisterSignal(shell, COMSIG_GUN_CHAMBER_PROCESSED, .proc/handle_chamber) + +/obj/item/circuit_component/wiremod_gun/unregister_shell(atom/movable/shell) + UnregisterSignal(shell, list(COMSIG_PROJECTILE_ON_HIT, COMSIG_GUN_CHAMBER_PROCESSED)) + +/** + * Called when the shell item shoots something + */ +/obj/item/circuit_component/wiremod_gun/proc/handle_shot(atom/source, mob/firer, atom/target, angle) + SIGNAL_HANDLER + + playsound(source, get_sfx("terminal_type"), 25, FALSE) + shooter.set_output(firer) + shot.set_output(target) + signal.set_output(COMPONENT_SIGNAL) + +/** + * Called when the shell item processes a new chamber + */ +/obj/item/circuit_component/wiremod_gun/proc/handle_chamber(atom/source) + SIGNAL_HANDLER + + if(!parent?.cell) + return + var/obj/item/gun/energy/fired_gun = source + var/totransfer = min(100, parent.cell.charge) + var/transferred = fired_gun.cell.give(totransfer) + parent.cell.use(transferred) diff --git a/icons/obj/wiremod.dmi b/icons/obj/wiremod.dmi index 81bda323d66..0feb8b9c9a3 100644 Binary files a/icons/obj/wiremod.dmi and b/icons/obj/wiremod.dmi differ diff --git a/modular_skyrat/master_files/code/modules/projectiles/guns/gun.dm b/modular_skyrat/master_files/code/modules/projectiles/guns/gun.dm index 0b20fff9437..0d19b9d630b 100644 --- a/modular_skyrat/master_files/code/modules/projectiles/guns/gun.dm +++ b/modular_skyrat/master_files/code/modules/projectiles/guns/gun.dm @@ -246,8 +246,13 @@ return TRUE //called after the gun has successfully fired its chambered ammo. -/obj/item/gun/proc/process_chamber() - return FALSE +/obj/item/gun/proc/process_chamber(empty_chamber = TRUE, from_firing = TRUE, chamber_next_round = TRUE) + handle_chamber(empty_chamber, from_firing, chamber_next_round) + SEND_SIGNAL(src, COMSIG_GUN_CHAMBER_PROCESSED) + +/obj/item/gun/proc/handle_chamber(empty_chamber = TRUE, from_firing = TRUE, chamber_next_round = TRUE) + return + //check if there's enough ammo/energy/whatever to shoot one time //i.e if clicking would make it shoot diff --git a/tgstation.dme b/tgstation.dme index 328e593ee42..5df5b3cc09e 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -3848,6 +3848,7 @@ #include "code\modules\wiremod\shell\compact_remote.dm" #include "code\modules\wiremod\shell\controller.dm" #include "code\modules\wiremod\shell\drone.dm" +#include "code\modules\wiremod\shell\gun.dm" #include "code\modules\wiremod\shell\moneybot.dm" #include "code\modules\wiremod\shell\scanner.dm" #include "code\modules\wiremod\shell\scanner_gate.dm"