Skip to content

Commit

Permalink
Fix Detach and on_detach parameter oversights (#5470)
Browse files Browse the repository at this point in the history
# About the pull request

This PR fixes some confusion with Detatch logic for gun attachments. The
base implementation didn't seem to originally have a user variable but
all other implementations did.

# Explain why it's good for the game

Less pitfalls for coders.

# Testing Photographs and Procedure
<details>
<summary>Screenshots & Videos</summary>

Put screenshots and videos here with an empty line between the
screenshots and the `<details>` tags.

</details>


# Changelog
:cl: Drathek
code: Cleaned up some oversights in attachment Detatch logic
/:cl:
  • Loading branch information
Drulikar committed Jan 17, 2024
1 parent a822700 commit 70851f8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion code/modules/projectiles/gun_attachables.dm
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ Defined in conflicts.dm of the #defines folder.
/obj/item/attachable/proc/Detach(mob/user, obj/item/weapon/gun/detaching_gub)
if(!istype(detaching_gub)) return //Guns only

detaching_gub.on_detach(user)
if(user)
detaching_gub.on_detach(user, src)

if(flags_attach_features & ATTACH_ACTIVATION)
activate_attachment(detaching_gub, null, TRUE)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/projectiles/gun_helpers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ DEFINES in setup.dm, referenced here.
playsound(user, 'sound/handling/attachment_add.ogg', 15, 1, 4)
return TRUE

/obj/item/weapon/gun/proc/on_detach(obj/item/attachable/attachment)
/obj/item/weapon/gun/proc/on_detach(mob/user, obj/item/attachable/attachment)
return

/obj/item/weapon/gun/proc/update_attachables() //Updates everything. You generally don't need to use this.
Expand Down

0 comments on commit 70851f8

Please sign in to comment.