mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-26 06:29:23 +01:00
[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>
This commit is contained in:
co-authored by
Ghom
Jolly-66
parent
56dcf6636f
commit
a1ea7f13db
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* 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)
|
||||
@@ -0,0 +1,20 @@
|
||||
///A simple element that spawns an atom when the bullet hits an object or reaches the end of its range
|
||||
/datum/element/projectile_drop
|
||||
element_flags = ELEMENT_BESPOKE
|
||||
argument_hash_start_idx = 2
|
||||
var/drop_type
|
||||
|
||||
/datum/element/projectile_drop/Attach(datum/target, drop_type)
|
||||
. = ..()
|
||||
if(!isprojectile(target))
|
||||
return ELEMENT_INCOMPATIBLE
|
||||
src.drop_type = drop_type
|
||||
RegisterSignals(target, list(COMSIG_PROJECTILE_RANGE_OUT, COMSIG_PROJECTILE_SELF_ON_HIT), PROC_REF(spawn_drop))
|
||||
|
||||
/datum/element/projectile_drop/proc/spawn_drop(obj/projectile/source)
|
||||
SIGNAL_HANDLER
|
||||
var/turf/turf = get_turf(source)
|
||||
var/atom/new_drop = new drop_type(turf)
|
||||
SEND_SIGNAL(source, COMSIG_PROJECTILE_ON_SPAWN_DROP, new_drop)
|
||||
//Just to be safe, knowing it won't be spawned multiple times.
|
||||
UnregisterSignal(source, list(COMSIG_PROJECTILE_RANGE_OUT, COMSIG_PROJECTILE_SELF_ON_HIT, COMSIG_QDELETING))
|
||||
Reference in New Issue
Block a user