Migrate laser pointer to the new attack chain. (#32256)

* Migrate laser pointer to the new attack chain.

* Apply suggestions from CRUNCH review

Co-authored-by: CRUNCH <143041327+CRUNCH-Borg@users.noreply.github.com>
Signed-off-by: Alan <alfalfascout@users.noreply.github.com>

---------

Signed-off-by: Alan <alfalfascout@users.noreply.github.com>
Co-authored-by: CRUNCH <143041327+CRUNCH-Borg@users.noreply.github.com>
This commit is contained in:
Alan
2026-07-24 19:41:42 +00:00
committed by GitHub
co-authored by CRUNCH
parent 7526673692
commit 9348ca5885
2 changed files with 44 additions and 28 deletions
+41 -27
View File
@@ -8,7 +8,7 @@
flags = CONDUCT
slot_flags = ITEM_SLOT_BELT
materials = list(MAT_METAL=500, MAT_GLASS=500)
w_class = WEIGHT_CLASS_SMALL //Increased to 2, because diodes are w_class 2. Conservation of matter.
w_class = WEIGHT_CLASS_SMALL
origin_tech = "combat=1;magnets=2"
var/pointer_icon_state
var/energy = 5
@@ -16,14 +16,18 @@
var/effectchance = 33
var/recharging = 0
var/recharge_locked = 0
var/obj/item/stock_parts/micro_laser/diode //used for upgrading!
var/obj/item/stock_parts/micro_laser/diode // Used for upgrading!
new_attack_chain = TRUE
/obj/item/laser_pointer/red
pointer_icon_state = "red_laser"
/obj/item/laser_pointer/green
pointer_icon_state = "green_laser"
/obj/item/laser_pointer/blue
pointer_icon_state = "blue_laser"
/obj/item/laser_pointer/purple
pointer_icon_state = "purple_laser"
@@ -43,18 +47,34 @@
/obj/item/laser_pointer/upgraded/create_diode()
diode = new /obj/item/stock_parts/micro_laser/ultra(src)
/obj/item/laser_pointer/attack__legacy__attackchain(mob/living/M, mob/user)
laser_act(M, user)
/obj/item/laser_pointer/interact_with_atom(atom/target, mob/living/user, list/modifiers)
laser_act(target, user, modifiers)
add_fingerprint(user)
return ITEM_INTERACT_COMPLETE
/obj/item/laser_pointer/attackby__legacy__attackchain(obj/item/W, mob/user, params)
if(istype(W, /obj/item/stock_parts/micro_laser))
if(!diode)
user.drop_item()
W.loc = src
diode = W
to_chat(user, SPAN_NOTICE("You install [diode] in [src]."))
else
to_chat(user, SPAN_NOTICE("[src] already has a cell."))
/obj/item/laser_pointer/ranged_interact_with_atom(atom/target, mob/living/user, list/modifiers)
if(get_dist(src, target) >= (user.client.maxview() + 2)) // To prevent people from using it over cameras.
return ITEM_INTERACT_COMPLETE
laser_act(target, user, modifiers)
add_fingerprint(user)
return ITEM_INTERACT_COMPLETE
/obj/item/laser_pointer/item_interaction(mob/user, obj/item/used, list/modifiers)
if(!istype(used, /obj/item/stock_parts/micro_laser))
return ..()
if(diode)
to_chat(user, SPAN_WARNING("There's already a [diode.name] inside [src]!"))
return ITEM_INTERACT_COMPLETE
if(!user.drop_item())
to_chat(user, SPAN_WARNING("[used] is stuck to your hand!"))
return ITEM_INTERACT_COMPLETE
used.forceMove(src)
diode = used
to_chat(user, SPAN_NOTICE("You install [diode] in [src]."))
return ITEM_INTERACT_COMPLETE
/obj/item/laser_pointer/screwdriver_act(mob/living/user, obj/item/I)
if(!diode)
@@ -65,12 +85,7 @@
diode = null
return TRUE
/obj/item/laser_pointer/afterattack__legacy__attackchain(atom/target, mob/living/user, flag, params)
if(flag) //we're placing the object on a table or in backpack
return
laser_act(target, user, params)
/obj/item/laser_pointer/proc/laser_act(atom/target, mob/living/user, params)
/obj/item/laser_pointer/proc/laser_act(atom/target, mob/living/user, list/modifiers)
if(!diode)
to_chat(user, SPAN_NOTICE("You point [src] at [target], but nothing happens!"))
return
@@ -123,7 +138,7 @@
add_attack_logs(user, S, "shone [src] in their eyes")
else
outmsg = SPAN_NOTICE("You fail to overload [S] by shining [src] at [S.p_their()] sensors.")
outmsg = SPAN_WARNING("You fail to overload [S] by shining [src] at [S.p_their()] sensors!")
//cameras
else if(istype(target, /obj/machinery/camera))
@@ -136,7 +151,7 @@
user.create_attack_log("[key_name(user)] EMPd a camera with a laser pointer")
add_attack_logs(user, C, "EMPd with [src]", ATKLOG_ALL)
else
outmsg = SPAN_NOTICE("You missed the lens of [C] with [src].")
outmsg = SPAN_WARNING("You missed the lens of [C] with [src]!")
//laser pointer image
icon_state = "pointer_[pointer_icon_state]"
@@ -145,12 +160,11 @@
if(M.client)
showto.Add(M.client)
var/image/I = image('icons/obj/projectiles.dmi',targloc,pointer_icon_state,10)
var/list/click_params = params2list(params)
if(click_params)
if(click_params["icon-x"])
I.pixel_x = (text2num(click_params["icon-x"]) - 16)
if(click_params["icon-y"])
I.pixel_y = (text2num(click_params["icon-y"]) - 16)
if(length(modifiers))
if(modifiers["icon-x"])
I.pixel_x = (text2num(modifiers["icon-x"]) - 16)
if(modifiers["icon-y"])
I.pixel_y = (text2num(modifiers["icon-y"]) - 16)
else
I.pixel_x = target.pixel_x + rand(-5,5)
I.pixel_y = target.pixel_y + rand(-5,5)