Skip to content

Commit

Permalink
gun freedom
Browse files Browse the repository at this point in the history
  • Loading branch information
harryob committed Aug 28, 2023
1 parent 649661c commit 9eabccc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions code/__DEFINES/traits.dm
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@

// GUN TRAITS
#define TRAIT_GUN_SILENCED "t_gun_silenced"
#define TRAIT_GUN_LIGHT_DEACTIVATED "t_gun_light_deactivated"

// Miscellaneous item traits.
// Do NOT bloat this category, if needed make a new category (like shoe traits, xeno item traits...)
Expand Down
6 changes: 5 additions & 1 deletion code/modules/projectiles/gun.dm
Original file line number Diff line number Diff line change
Expand Up @@ -506,9 +506,13 @@ As sniper rifles have both and weapon mods can change them as well. ..() deals w

if(slot in list(WEAR_L_HAND, WEAR_R_HAND))
set_gun_user(user)
if(HAS_TRAIT_FROM_ONLY(src, TRAIT_GUN_LIGHT_DEACTIVATED, user))
force_light(on = TRUE)
REMOVE_TRAIT(src, TRAIT_GUN_LIGHT_DEACTIVATED, user)
else
set_gun_user(null)
force_light_off()
force_light(on = FALSE)
ADD_TRAIT(src, TRAIT_GUN_LIGHT_DEACTIVATED, user)

return ..()

Expand Down
6 changes: 3 additions & 3 deletions code/modules/projectiles/gun_helpers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -938,14 +938,14 @@ DEFINES in setup.dm, referenced here.
return null
return params2turf(modifiers["screen-loc"], get_turf(user), user.client)

/// If this gun has a relevant flashlight attachable attached, deactivate it
/obj/item/weapon/gun/proc/force_light_off()
/// If this gun has a relevant flashlight attachable attached, (de)activate it
/obj/item/weapon/gun/proc/force_light(on)
var/obj/item/attachable/flashlight/torch
for(var/slot in attachments)
torch = attachments[slot]
if(istype(torch))
break
if(!torch)
return FALSE
torch.turn_light(toggle_on = FALSE, forced = TRUE)
torch.turn_light(toggle_on = on, forced = TRUE)
return TRUE

0 comments on commit 9eabccc

Please sign in to comment.