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

M344 belt and pistol belt buff #660

Merged
merged 8 commits into from
Nov 15, 2024
Merged
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
2 changes: 2 additions & 0 deletions code/__DEFINES/dcs/signals.dm
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,8 @@
#define COMSIG_MOB_GUN_AUTOFIRED "mob_gun_autofired"
#define COMSIG_MOB_GUN_COOLDOWN "mob_gun_cooldown"

#define COMSIG_MAGAZINE_DROP "magazine_drop"

#define COMSIG_XENO_FIRE "xeno_fire"
#define COMSIG_XENO_STOP_FIRE "xeno_stop_fire"
#define COMSIG_XENO_AUTOFIREDELAY_MODIFIED "xeno_firedelay_modified"
Expand Down
4 changes: 4 additions & 0 deletions code/__DEFINES/loadout.dm
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ GLOBAL_LIST_INIT(marine_selector_cats, list(

GLOBAL_LIST_INIT(marine_gear_listed_products, list(
/obj/item/storage/backpack/marine/radiopack = list(CAT_MARINE, "Radio Pack", 5, "orange"),
/obj/item/storage/belt/marine/auto_catch = list(CAT_MARINE, "M344 pattern ammo load rig", 10, "orange"),
/obj/item/stack/sandbags_empty/half = list(CAT_MARINE, "Sandbags x25", SANDBAG_PRICE_IN_GEAR_VENDOR, "orange"),
/obj/item/fulton_extraction_pack = list(CAT_MARINE, "Fulton Extraction Pack", 5, "orange"),
/obj/item/explosive/grenade = list(CAT_MARINE, "M40 HEDP grenade", 2, "orange3"),
Expand Down Expand Up @@ -206,6 +207,7 @@ GLOBAL_LIST_INIT(leader_gear_listed_products, list(
/obj/item/jetpack_marine = list(CAT_LEDSUP, "Jetpack", 5, "yellow"),
/obj/item/storage/belt/grenade/b17 = list(CAT_LEDSUP, "High Capacity Grenade Belt", 5, "yellow"),
/obj/structure/closet/bodybag/tarp = list(CAT_LEDSUP, "V1 thermal-dampening tarp", 2, "yellow"),
/obj/item/storage/belt/marine/auto_catch = list(CAT_LEDSUP, "M344 pattern ammo load rig", 10, "orange"),
/obj/item/weapon/gun/flamer/big_flamer/marinestandard = list(CAT_LEDSUP, "FL-84 flamethrower", 6, "red"),
/obj/item/ammo_magazine/flamer_tank/large = list(CAT_LEDSUP, "Flamethrower tank", 2, "orange2"),
/obj/item/storage/holster/belt/revolver/mateba/full = list(CAT_LEDSUP, "Mateba Autorevolver belt", 10, "red"),
Expand Down Expand Up @@ -247,6 +249,7 @@ GLOBAL_LIST_INIT(commander_gear_listed_products, list(
/obj/item/armor_module/module/night_vision = list(CAT_FCSUP, "BE-35 night vision kit", 18, "blue"),
/obj/item/clothing/glasses/night_vision = list(CAT_FCSUP, "BE-47 night vision goggles", 26, "blue"),
/obj/item/cell/night_vision_battery = list(CAT_FCSUP, "night vision battery", 4, "blue"),
/obj/item/storage/belt/marine/auto_catch = list(CAT_FCSUP, "M344 pattern ammo load rig", 10, "orange"),
/obj/item/explosive/plastique = list(CAT_FCSUP, "Plastique explosive", 2, "orange3"),
/obj/item/detpack = list(CAT_FCSUP, "Detonation pack", 2, "orange3"),
/obj/item/storage/box/visual/grenade/sticky = list(CAT_FCSUP, "M40 adhesive charge grenade box", 15, "blue"),
Expand Down Expand Up @@ -340,6 +343,7 @@ GLOBAL_LIST_INIT(smartgunner_gear_listed_products, list(
/obj/item/ammo_magazine/rifle/sg153/plasmaloss = list(CAT_SGSUP, "SG-153 Spotting Rifle Tanglefoot Magazine", 3, "orange2"),
/obj/item/ammo_magazine/rifle/sg153/incendiary = list(CAT_SGSUP, "SG-153 Spotting Rifle Incendiary Magazine", 3, "orange2"),
/obj/item/ammo_magazine/pistol/p14/smart_pistol = list(CAT_SGSUP, "SP-13 smart pistol ammo", 2, "orange2"),
/obj/item/storage/belt/marine/auto_catch = list(CAT_SGSUP, "M344 pattern ammo load rig", 10, "orange"),
))

GLOBAL_LIST_INIT(synthetic_gear_listed_products, list(
Expand Down
51 changes: 51 additions & 0 deletions code/datums/components/easy_restock.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/datum/component/easy_restock
///Parent storage. Use this over checking the item directly.
var/obj/item/storage/reloading_storage

/datum/component/easy_restock/Initialize()
. = ..()
if(!isstorage(parent))
return COMPONENT_INCOMPATIBLE

/datum/component/easy_restock/Destroy(force, silent)
reloading_storage = null
return ..()

/datum/component/easy_restock/RegisterWithParent()
reloading_storage = parent
RegisterSignal(parent, COMSIG_ATOM_ATTACKBY_ALTERNATE, PROC_REF(on_parent_attackby_alternate))
RegisterSignal(parent, COMSIG_ATOM_EXAMINE, PROC_REF(on_examine))

/datum/component/easy_restock/UnregisterFromParent()
UnregisterSignal(parent, list(
COMSIG_ATOM_ATTACKBY_ALTERNATE,
COMSIG_ATOM_EXAMINE,
))

/datum/component/easy_restock/proc/on_examine(datum/source, mob/user, list/details)
SIGNAL_HANDLER
details += span_notice("You can easily restock magazines inside, right click on the belt with any ammo box.")

/datum/component/easy_restock/proc/on_parent_attackby_alternate(datum/source, obj/item/ammo_magazine/ammo_box, mob/user, params)
SIGNAL_HANDLER
if(!istype(ammo_box))
return
if(!reloading_storage)
CRASH("[user] attempted to reload [ammo_box] on [source], but it has no storage attached!")
INVOKE_ASYNC(src, PROC_REF(do_tac_reload), ammo_box, user, params)

/datum/component/easy_restock/proc/do_tac_reload(obj/item/ammo_magazine/ammo_box, mob/user, params)
for(var/obj/item/ammo_magazine/item_to_restock in reloading_storage.contents)
var/amount_to_transfer = ammo_box.current_rounds

if(!item_to_restock.can_transfer_ammo(ammo_box, user, amount_to_transfer, TRUE))
continue

if(item_to_restock.default_ammo != ammo_box.default_ammo)
if(item_to_restock.current_rounds == 0)
item_to_restock.transfer_ammo(ammo_box, user, amount_to_transfer, TRUE)
return COMPONENT_NO_AFTERATTACK
continue

item_to_restock.transfer_ammo(ammo_box, user, amount_to_transfer)
return COMPONENT_NO_AFTERATTACK
46 changes: 46 additions & 0 deletions code/datums/components/magazine_catcher.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/datum/component/magazine_catcher
var/mob/living/carbon/human/wearer
///Parent storage in which we want to collect magazines
var/obj/item/storage/storage

/datum/component/magazine_catcher/Initialize()
. = ..()
if(!isstorage(parent))
return COMPONENT_INCOMPATIBLE

/datum/component/magazine_catcher/Destroy(force, silent)
storage = null
wearer = null
return ..()

/datum/component/magazine_catcher/RegisterWithParent()
. = ..()
RegisterSignal(parent, COMSIG_ITEM_EQUIPPED_TO_SLOT, PROC_REF(equipped_to_slot))
RegisterSignals(parent, list(COMSIG_ITEM_EQUIPPED_NOT_IN_SLOT, COMSIG_ITEM_DROPPED), PROC_REF(removed_from_slot))
storage = parent

/datum/component/magazine_catcher/UnregisterFromParent()
. = ..()
UnregisterSignal(parent, list(COMSIG_ITEM_EQUIPPED_TO_SLOT, COMSIG_ITEM_EQUIPPED_NOT_IN_SLOT, COMSIG_ITEM_DROPPED))
Helg2 marked this conversation as resolved.
Show resolved Hide resolved

/datum/component/magazine_catcher/proc/equipped_to_slot(datum/source, mob/user, slot)
SIGNAL_HANDLER
wearer = user
RegisterSignal(user, COMSIG_MAGAZINE_DROP, PROC_REF(try_to_catch_magazine))

/datum/component/magazine_catcher/proc/removed_from_slot(datum/source, mob/user)
SIGNAL_HANDLER

if(!iscarbon(user))
return

if(!wearer)
return

wearer = null
UnregisterSignal(user, COMSIG_MAGAZINE_DROP)

/datum/component/magazine_catcher/proc/try_to_catch_magazine(datum/source, obj/item/mag)
if(!storage.can_be_inserted(mag, FALSE))
return FALSE
return storage.handle_item_insertion(mag, TRUE)
11 changes: 11 additions & 0 deletions code/game/objects/items/storage/belt.dm
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,17 @@
/obj/item/reagent_containers/food/snacks,
)

/obj/item/storage/belt/marine/auto_catch
name = "\improper M344 pattern ammo load rig"
icon_state = "autocathbelt"
desc = "The M344 is the modern load-bearing equipment of the TGMC. It consists of a modular belt with various clips. Allows you to quickly obtain and use equipment during combat operations."
storage_slots = 4

/obj/item/storage/belt/marine/auto_catch/Initialize(mapload, ...)
. = ..()
AddComponent(/datum/component/magazine_catcher)
AddComponent(/datum/component/easy_restock)

/obj/item/storage/belt/marine/ar18/Initialize(mapload)
. = ..()
new /obj/item/ammo_magazine/rifle/ar18(src)
Expand Down
3 changes: 3 additions & 0 deletions code/game/objects/items/storage/holsters.dm
Original file line number Diff line number Diff line change
Expand Up @@ -578,10 +578,13 @@
/obj/item/storage/holster/belt/pistol
name = "generic pistol belt"
desc = "A pistol belt that is not a revolver belt"
flags_equip_slot = ITEM_SLOT_BELT|ITEM_SLOT_SUITSTORE

/obj/item/storage/holster/belt/pistol/Initialize(mapload, ...)
. = ..()
AddComponent(/datum/component/tac_reload_storage)
AddComponent(/datum/component/magazine_catcher)
AddComponent(/datum/component/easy_restock)

/obj/item/storage/holster/belt/pistol/m4a3
name = "\improper M4A3 holster rig"
Expand Down
30 changes: 20 additions & 10 deletions code/modules/projectiles/ammunition.dm
Original file line number Diff line number Diff line change
Expand Up @@ -142,25 +142,35 @@
master_gun.aim_slowdown -= aim_speed_mod
master_gun.wield_delay -= wield_delay_mod

//Generic proc to transfer ammo between ammo mags. Can work for anything, mags, handfuls, etc.
/obj/item/ammo_magazine/proc/transfer_ammo(obj/item/ammo_magazine/source, mob/user, transfer_amount = 1, is_new_ammo_type = FALSE)
///Сan the magazine be refilled, mainly used in transfer_ammo proc
/obj/item/ammo_magazine/proc/can_transfer_ammo(obj/item/ammo_magazine/source, mob/user, transfer_amount = 1, silent = FALSE)
Helg2 marked this conversation as resolved.
Show resolved Hide resolved
if(current_rounds >= max_rounds) //Does the mag actually need reloading?
to_chat(user, span_notice("[src] is already full."))
return
if(!silent)
to_chat(user, span_notice("[src] is already full."))
return FALSE

if(source.caliber != caliber) //Are they the same caliber?
to_chat(user, span_notice("The rounds don't match up. Better not mix them up."))
return
if(!silent)
to_chat(user, span_notice("The rounds don't match up. Better not mix them up."))
return FALSE

if(!source.current_rounds)
to_chat(user, span_warning("\The [source] is empty."))
return
if(!silent)
to_chat(user, span_warning("\The [source] is empty."))
return FALSE

//using handfuls; and filling internal mags has no delay.
if(fill_delay)
to_chat(user, span_notice("You start refilling [src] with [source]."))
if(!silent)
to_chat(user, span_notice("You start refilling [src] with [source]."))
if(!do_after(user, fill_delay, NONE, src, BUSY_ICON_GENERIC))
return
return FALSE
return TRUE

///Generic proc to transfer ammo between ammo mags. Can work for anything, mags, handfuls, etc.
/obj/item/ammo_magazine/proc/transfer_ammo(obj/item/ammo_magazine/source, mob/user, transfer_amount = 1, is_new_ammo_type = FALSE)
if(!can_transfer_ammo(source, user, transfer_amount))
return

to_chat(user, span_notice("You refill [src] with [source]."))

Expand Down
1 change: 1 addition & 0 deletions code/modules/projectiles/gun_system.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1416,6 +1416,7 @@
user.put_in_hands(mag)
else
mag.forceMove(get_turf(src))
SEND_SIGNAL(gun_user, COMSIG_MAGAZINE_DROP, mag)
if(CHECK_BITFIELD(reciever_flags, AMMO_RECIEVER_ROTATES_CHAMBER))
chamber_items[chamber_items.Find(mag)] = null
else
Expand Down
2 changes: 1 addition & 1 deletion code/modules/projectiles/guns/pistols.dm
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@
default_ammo_type = /obj/item/ammo_magazine/pistol/m1911
allowed_ammo_types = list(/obj/item/ammo_magazine/pistol/m1911)
attachable_offset = list("muzzle_x" = 30, "muzzle_y" = 21,"rail_x" = 17, "rail_y" = 22, "under_x" = 21, "under_y" = 15, "stock_x" = 21, "stock_y" = 17)
reciever_flags = AMMO_RECIEVER_MAGAZINES|AMMO_RECIEVER_AUTO_EJECT_LOCKED
reciever_flags = AMMO_RECIEVER_MAGAZINES
fire_delay = 0.2 SECONDS
accuracy_mult = 1.05
accuracy_mult_unwielded = 0.85
Expand Down
5 changes: 5 additions & 0 deletions code/modules/reqs/clothing.dm
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
contains = list(/obj/item/storage/backpack/marine/radiopack)
cost = 20

/datum/supply_packs/clothing/auto_catch_belt
name = "M344 pattern ammo load rig"
contains = list(/obj/item/storage/belt/marine/auto_catch)
cost = 50

/datum/supply_packs/clothing/technician_pack
name = "Engineering Technician Pack"
contains = list(/obj/item/storage/backpack/marine/tech)
Expand Down
Binary file modified icons/obj/clothing/belts.dmi
Binary file not shown.
2 changes: 2 additions & 0 deletions tgmc.dme
Original file line number Diff line number Diff line change
Expand Up @@ -411,12 +411,14 @@
#include "code\datums\components\connect_mob_behalf.dm"
#include "code\datums\components\deployable_item.dm"
#include "code\datums\components\dripping.dm"
#include "code\datums\components\easy_restock.dm"
#include "code\datums\components\grillable.dm"
#include "code\datums\components\harvester.dm"
#include "code\datums\components\health_stealth.dm"
#include "code\datums\components\jump.dm"
#include "code\datums\components\largeobjecttransparency.dm"
#include "code\datums\components\larva_queue.dm"
#include "code\datums\components\magazine_catcher.dm"
#include "code\datums\components\mobile_power.dm"
#include "code\datums\components\orbiter.dm"
#include "code\datums\components\overlay_lighting.dm"
Expand Down
Loading