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

Fixes gun light attachment issues #3696

Merged
merged 1 commit into from
Jun 23, 2023
Merged
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
18 changes: 15 additions & 3 deletions code/modules/projectiles/gun_helpers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ As sniper rifles have both and weapon mods can change them as well. ..() deals w
/obj/item/weapon/gun/dropped(mob/user)
. = ..()

turn_off_light(user)
disconnect_light_from_mob(user)

var/delay_left = (last_fired + fire_delay + additional_fire_group_delay) - world.time
if(fire_delay_group && delay_left > 0)
Expand All @@ -160,16 +160,28 @@ As sniper rifles have both and weapon mods can change them as well. ..() deals w
for(var/group in fire_delay_group)
LAZYSET(user.fire_delay_next_fire, group, world.time + delay_left)

/obj/item/weapon/gun/proc/turn_off_light(mob/bearer)
/// This function disconnects the luminosity from the mob and back to the gun
/obj/item/weapon/gun/proc/disconnect_light_from_mob(mob/bearer)
if (!(flags_gun_features & GUN_FLASHLIGHT_ON))
return FALSE
for (var/slot in attachments)
var/obj/item/attachable/attachment = attachments[slot]
if (!attachment || !attachment.light_mod)
continue
bearer.SetLuminosity(0, FALSE, src)
SetLuminosity(attachment.light_mod)
return TRUE
return FALSE

/// This function actually turns the lights on the gun off
/obj/item/weapon/gun/proc/turn_off_light(mob/bearer)
if (!(flags_gun_features & GUN_FLASHLIGHT_ON))
return FALSE
for (var/slot in attachments)
var/obj/item/attachable/attachment = attachments[slot]
if (!attachment || !attachment.light_mod)
continue
attachment.activate_attachment(src, bearer)

return TRUE
return FALSE

Expand Down