Skip to content

Commit

Permalink
adds starting attachment functionality to guns (#6852)
Browse files Browse the repository at this point in the history
yeaaah i'm a little silly i forgot this
this lets you have guns start with attachments.
kinda important, innit.
  • Loading branch information
silicons authored Nov 10, 2024
1 parent 2e46afe commit 0b0ffb3
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions code/modules/projectiles/gun.dm
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@
//* Attachments *//

/// Installed attachments
///
/// * Set to list of typepaths to immediately install them on init.
/// * Do not set this.
var/list/obj/item/gun_attachment/attachments
/// Attachment alignments.
///
Expand Down Expand Up @@ -232,6 +235,23 @@
if(attachment_alignment)
attachment_alignment = typelist(NAMEOF(src, attachment_alignment), attachment_alignment)

//* handle attachments *//
if(length(attachments))
var/list/translating_attachments = attachments
attachments = list()
for(var/obj/item/gun_attachment/casted as anything in translating_attachments)
var/obj/item/gun_attachment/actual
if(IS_ANONYMOUS_TYPEPATH(casted))
actual = new casted
else if(ispath(casted, /obj/item/gun_attachment))
actual = new casted
else if(istype(casted))
actual = casted
if(actual.attached != src)
if(!install_attachment(actual))
stack_trace("[actual] ([actual.type]) couldn't be auto-installed on initialize despite being in list.")
qdel(actual)

//! LEGACY: firemodes
for(var/i in 1 to firemodes.len)
var/key = firemodes[i]
Expand Down

0 comments on commit 0b0ffb3

Please sign in to comment.