Skip to content

Commit

Permalink
Some LWAP (and other scoped weapons) fixes (ParadiseSS13#25775)
Browse files Browse the repository at this point in the history
* can't use lwap from lockers

* active hand flag

* rename SCOPE_CLICK_MIDDLE
  • Loading branch information
larentoun authored Jun 25, 2024
1 parent 1166c3d commit 6b70c59
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 15 deletions.
10 changes: 10 additions & 0 deletions code/__DEFINES/flags.dm
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,13 @@ GLOBAL_LIST_INIT(bitflags, list(1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 204
#define MOBILITY_PULL (1<<4)

#define MOBILITY_FLAGS_DEFAULT (MOBILITY_MOVE | MOBILITY_STAND | MOBILITY_PICKUP | MOBILITY_USE | MOBILITY_PULL)

// Scope component flags
/// Do we have the scope cancel on move?
#define SCOPE_MOVEMENT_CANCELS (1<<0)
/// Can we use scope from mechs, lockers, etc?
#define SCOPE_TURF_ONLY (1<<1)
/// Do we let the user scope and click on the middle of their screen?
#define SCOPE_CLICK_MIDDLE (1<<2)
/// Should the user hold the item in active hand to use it?
#define SCOPE_NEED_ACTIVE_HAND (1<<3)
21 changes: 12 additions & 9 deletions code/datums/components/scope.dm
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,17 @@
var/item_action_type
/// Time to scope up, if you want the scope to take time to boot up. Used by the LWAP
var/time_to_scope
/// Do we let the user scope and click on the middle of their screen?
var/allow_middle_click = FALSE
/// Do we have the scope cancel on move?
var/movement_cancels_scope = FALSE
/// Flags for scoping. Check `code\__DEFINES\flags.dm`
var/flags

/datum/component/scope/Initialize(range_modifier = 1, zoom_method = ZOOM_METHOD_ITEM_ACTION, item_action_type = /datum/action/zoom, time_to_scope = 0, allow_middle_click = FALSE, movement_cancels_scope = FALSE)
/datum/component/scope/Initialize(range_modifier = 1, zoom_method = ZOOM_METHOD_ITEM_ACTION, item_action_type = /datum/action/zoom, time_to_scope = 0, flags)
if(!isitem(parent))
return COMPONENT_INCOMPATIBLE
src.range_modifier = range_modifier
src.zoom_method = zoom_method
src.item_action_type = item_action_type
src.time_to_scope = time_to_scope
src.allow_middle_click = allow_middle_click
src.movement_cancels_scope = movement_cancels_scope
src.flags = flags


/datum/component/scope/Destroy(force)
Expand Down Expand Up @@ -156,15 +153,21 @@
if(HAS_TRAIT(user, TRAIT_SCOPED))
to_chat(user, "<span class='warning'>You are already zoomed in!</span>")
return
if((flags & SCOPE_TURF_ONLY) && !isturf(user.loc))
to_chat(user, "<span class='warning'>There is not enough space to zoom in!</span>")
return
if((flags & SCOPE_NEED_ACTIVE_HAND) && user.get_active_hand() != parent)
to_chat(user, "<span class='warning'>You need to hold [parent] in your active hand to zoom in!</span>")
return
if(time_to_scope)
if(!do_after_once(user, time_to_scope, target = parent))
return
user.playsound_local(parent, 'sound/weapons/scope.ogg', 75, TRUE)
tracker = user.overlay_fullscreen("scope", /atom/movable/screen/fullscreen/stretch/cursor_catcher/scope, istype(parent, /obj/item/gun))
tracker.assign_to_mob(user, range_modifier)
if(movement_cancels_scope)
if(flags & SCOPE_MOVEMENT_CANCELS)
RegisterSignal(user, COMSIG_MOVABLE_MOVED, PROC_REF(on_move))
if(allow_middle_click)
if(flags & SCOPE_CLICK_MIDDLE)
RegisterSignal(tracker, COMSIG_CLICK, PROC_REF(generic_click))
tracker_owner_ckey = user.ckey
if(user.is_holding(parent))
Expand Down
6 changes: 3 additions & 3 deletions code/modules/projectiles/guns/energy/laser.dm
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@

/obj/item/gun/energy/lwap/Initialize(mapload)
. = ..()
AddComponent(/datum/component/scope, range_modifier = 2, time_to_scope = 3 SECONDS, movement_cancels_scope = TRUE)
AddComponent(/datum/component/scope, range_modifier = 2, time_to_scope = 3 SECONDS, flags = SCOPE_MOVEMENT_CANCELS | SCOPE_TURF_ONLY | SCOPE_NEED_ACTIVE_HAND)

/obj/item/gun/energy/lwap/on_scope_success(mob/living/user)
to_chat(user, "<b><span class='robot'>SCOPE_CREEPER_[rand(1, 9999)] Online.</span></b>")
Expand Down Expand Up @@ -368,7 +368,7 @@
allowing entire rooms to be quickly peppered with incendiary laser fire."
. += ""
. += "Few weapons inspire quite the same fear and loathing as this. Nanotrasen reserves this weapon for its elite combat operatives and cyborgs. If you're holding it, be glad you're not the one on the other end."

/obj/item/gun/energy/immolator/multi/update_overlays()
. = ..()
var/obj/item/ammo_casing/energy/shot = ammo_type[select]
Expand Down Expand Up @@ -416,7 +416,7 @@
return

// Special version given by the Safety Override upgrade and as a standard module for ERT engiborgs.
/obj/item/gun/energy/emitter/cyborg/proto
/obj/item/gun/energy/emitter/cyborg/proto
name = "mounted prototype laser emitter"
desc = "A modified mobile laser emitter that draws power directly from your internal energy cell. This one operates on unoptimised software, reducing its effectiveness."
ammo_type = list(/obj/item/ammo_casing/energy/emitter/cyborg/proto)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/projectiles/guns/projectile/sniper.dm
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
/obj/item/gun/projectile/automatic/sniper_rifle/Initialize(mapload)
. = ..()
if(zoomable)
AddComponent(/datum/component/scope, range_modifier = 2)
AddComponent(/datum/component/scope, range_modifier = 2, flags = SCOPE_TURF_ONLY | SCOPE_NEED_ACTIVE_HAND)

/obj/item/gun/projectile/automatic/sniper_rifle/process_fire(atom/target, mob/living/user, message = TRUE, params, zone_override, bonus_spread = 0)
if(istype(chambered.BB, /obj/item/projectile/bullet/sniper) && !HAS_TRAIT(user, TRAIT_SCOPED))
Expand Down
2 changes: 1 addition & 1 deletion code/modules/projectiles/guns/rocket.dm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

/obj/item/gun/rocketlauncher/Initialize(mapload)
. = ..()
AddComponent(/datum/component/scope, range_modifier = 2)
AddComponent(/datum/component/scope, range_modifier = 2, flags = SCOPE_TURF_ONLY | SCOPE_NEED_ACTIVE_HAND)

/obj/item/gun/rocketlauncher/examine(mob/user)
. = ..()
Expand Down
2 changes: 1 addition & 1 deletion code/modules/surgery/organs/eyes.dm
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@

/obj/item/organ/internal/eyes/cybernetic/scope/Initialize(mapload)
. = ..()
AddComponent(/datum/component/scope, range_modifier = scope_range, item_action_type = /datum/action/item_action/organ_action/toggle, allow_middle_click = TRUE)
AddComponent(/datum/component/scope, range_modifier = scope_range, item_action_type = /datum/action/item_action/organ_action/toggle, flags = SCOPE_CLICK_MIDDLE)

/obj/item/organ/internal/eyes/cybernetic/scope/insert(mob/living/carbon/human/M, special)
. = ..()
Expand Down

0 comments on commit 6b70c59

Please sign in to comment.