Files
Bubberstation/code/datums/elements/caseless.dm
SkyratBot a1ea7f13db [MIRROR] Replaces ammo_casing/caseless and bullet/reusable with elements. [MDB IGNORE] (#22102)
* Replaces ammo_casing/caseless and bullet/reusable with elements.

* stupid

---------

Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>
Co-authored-by: Jolly-66 <70232195+Jolly-66@users.noreply.github.com>
2023-07-04 13:06:52 +00:00

31 lines
1.1 KiB
Plaintext

/**
* An element that deletes the casing when fired and, if reusable is true, adds the projectile_drop element to the bullet.
* Just make sure to not add components or elements that also use COMSIG_FIRE_CASING after this one.
* Not compatible with pellets (how the eff would that work in a senible way tho?).
*/
/datum/element/caseless
element_flags = ELEMENT_BESPOKE
argument_hash_start_idx = 2
var/reusable = FALSE
/datum/element/caseless/Attach(datum/target, reusable)
. = ..()
if(!isammocasing(target))
return ELEMENT_INCOMPATIBLE
src.reusable = reusable
RegisterSignal(target, COMSIG_FIRE_CASING, PROC_REF(on_fired_casing))
/datum/element/caseless/proc/on_fired_casing(obj/item/ammo_casing/shell, atom/target, mob/living/user, fired_from, randomspread, spread, zone_override, params, distro, obj/projectile/proj)
SIGNAL_HANDLER
if(!proj)
return
if(reusable)
proj.AddElement(/datum/element/projectile_drop, shell.type)
if(isgun(fired_from))
var/obj/item/gun/shot_from = fired_from
if(shot_from.chambered == shell)
shot_from.chambered = null //Nuke it. Nuke it now.
qdel(shell)