-
-
Notifications
You must be signed in to change notification settings - Fork 444
/
Copy pathholotool.dm
147 lines (132 loc) · 5.1 KB
/
holotool.dm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/obj/item/holotool
name = "experimental holotool"
desc = "A highly experimental holographic tool projector."
icon = 'yogstation/icons/obj/holotool.dmi'
icon_state = "holotool"
slot_flags = ITEM_SLOT_BELT
w_class = WEIGHT_CLASS_SMALL
usesound = 'sound/items/pshoom.ogg'
lefthand_file = 'yogstation/icons/mob/inhands/lefthand.dmi'
righthand_file = 'yogstation/icons/mob/inhands/righthand.dmi'
actions_types = list(/datum/action/item_action/change_tool, /datum/action/item_action/change_ht_color)
resistance_flags = FIRE_PROOF | ACID_PROOF
light_system = MOVABLE_LIGHT
light_range = 3
light_on = FALSE
/// Buffer used by the multitool mode
var/buffer
/// The current mode
var/datum/holotool_mode/current_tool
// to be retained until we have the hubris to abstract all multitool functionality into some /datum/component, and break modularity in a hundred ways
var/list/available_modes
var/list/mode_names
var/list/radial_modes
var/current_color = "#48D1CC" //mediumturquoise
/obj/item/holotool/examine(mob/user)
. = ..()
. += span_notice("It is currently set to [current_tool ? current_tool.name : "'off'"] mode.")
. += span_notice("Ctrl+Click it to open the radial menu!")
/obj/item/holotool/attack(mob/living/M, mob/living/user, params)
if(tool_behaviour == TOOL_WELDER && !user.combat_mode && ishuman(M))
var/mob/living/carbon/human/H = M
var/obj/item/bodypart/affecting = H.get_bodypart(check_zone(user.zone_selected))
if(affecting?.status == BODYPART_ROBOTIC)
if(affecting.brute_dam <= 0)
to_chat(user, span_warning("[affecting] is already in good condition!"))
return FALSE
if(DOING_INTERACTION(user, H))
return FALSE
user.changeNext_move(CLICK_CD_MELEE)
user.visible_message(span_notice("[user] starts to fix some of the dents on [M]'s [affecting.name]."), span_notice("You start fixing some of the dents on [M == user ? "your" : "[M]'s"] [affecting.name]."))
heal_robo_limb(src, H, user, 10, 0, 0, 50)
user.visible_message(span_notice("[user] fixes some of the dents on [M]'s [affecting.name]."), span_notice("You fix some of the dents on [M == user ? "your" : "[M]'s"] [affecting.name]."))
return TRUE
return ..()
/obj/item/holotool/use(used)
return TRUE //it just always works, capiche!?
/obj/item/holotool/tool_use_check(mob/living/user, amount)
return TRUE //always has enough "fuel"
/obj/item/holotool/ui_action_click(mob/user, datum/action/action)
if(istype(action, /datum/action/item_action/change_tool))
update_listing()
var/datum/holotool_mode/chosen = input("Choose tool settings", "Tool", null, null) as null|anything in available_modes
switch_tool(user, chosen)
else
var/C = input(user, "Select Color", "Select color", "#48D1CC") as null|color
if(!C || QDELETED(src))
return
current_color = C
set_light_color(current_color)
update_appearance(UPDATE_ICON)
action.build_all_button_icons()
user.regenerate_icons()
/obj/item/holotool/proc/switch_tool(mob/user, datum/holotool_mode/mode)
if(!mode || !istype(mode))
return
if(current_tool)
current_tool.on_unset(src)
current_tool = mode
current_tool.on_set(src)
playsound(loc, 'yogstation/sound/items/holotool.ogg', get_clamped_volume(), 1, -1)
update_appearance(UPDATE_ICON)
user.regenerate_icons()
/obj/item/holotool/proc/update_listing()
LAZYCLEARLIST(available_modes)
LAZYCLEARLIST(radial_modes)
LAZYCLEARLIST(mode_names)
for(var/A in subtypesof(/datum/holotool_mode))
var/datum/holotool_mode/M = new A
if(M.can_be_used(src))
LAZYADD(available_modes, M)
LAZYSET(mode_names, M.name, M)
var/image/holotool_img = image(icon = icon, icon_state = icon_state)
var/image/tool_img = image(icon = icon, icon_state = M.name)
tool_img.color = current_color
holotool_img.overlays += tool_img
LAZYSET(radial_modes, M.name, holotool_img)
else
qdel(M)
/obj/item/holotool/update_icon(updates=ALL)
. = ..()
cut_overlays()
if(current_tool)
var/mutable_appearance/holo_item = mutable_appearance(icon, current_tool.name)
holo_item.color = current_color
item_state = current_tool.name
add_overlay(holo_item)
if(current_tool.name == "off")
set_light_on(FALSE)
else
set_light_on(TRUE)
else
item_state = "holotool"
icon_state = "holotool"
set_light_on(FALSE)
for(var/datum/action/A as anything in actions)
A.build_all_button_icons()
/obj/item/holotool/proc/check_menu(mob/living/user)
if(!istype(user))
return FALSE
if(user.incapacitated() || !user.Adjacent(src))
return FALSE
return TRUE
/obj/item/holotool/attack_self(mob/user)
update_listing()
var/chosen = show_radial_menu(user, src, radial_modes, custom_check = CALLBACK(src, PROC_REF(check_menu),user))
if(!check_menu(user))
return
if(chosen)
var/new_tool = LAZYACCESS(mode_names, chosen)
if(new_tool)
switch_tool(user, new_tool)
/obj/item/holotool/emag_act(mob/user, obj/item/card/emag/emag_card)
if(obj_flags & EMAGGED)
return FALSE
to_chat(user, span_danger("ZZT- ILLEGAL BLUEPRINT UNLOCKED- CONTACT !#$@^%$# NANOTRASEN SUPPORT-@*%$^%!"))
do_sparks(5, 0, src)
obj_flags |= EMAGGED
return TRUE
// Spawn in RD closet
/obj/structure/closet/secure_closet/RD/PopulateContents()
. = ..()
new /obj/item/holotool(src)