|
102 | 102 | cell = locate(/obj/item/stock_parts/cell) in contents
|
103 | 103 | update_power()
|
104 | 104 |
|
105 |
| -/obj/item/defibrillator/ui_action_click() |
106 |
| - INVOKE_ASYNC(src, PROC_REF(toggle_paddles)) |
| 105 | +/obj/item/defibrillator/ui_action_click(mob/user, actiontype) |
| 106 | + INVOKE_ASYNC(src, PROC_REF(toggle_paddles), user) |
107 | 107 |
|
108 | 108 | //ATTACK HAND IGNORING PARENT RETURN VALUE
|
109 | 109 | /obj/item/defibrillator/attack_hand(mob/user, list/modifiers)
|
110 |
| - if(loc == user) |
111 |
| - if(slot_flags == ITEM_SLOT_BACK) |
112 |
| - if(user.get_item_by_slot(ITEM_SLOT_BACK) == src) |
113 |
| - ui_action_click() |
114 |
| - else |
115 |
| - to_chat(user, span_warning("Put the defibrillator on your back first!")) |
116 |
| - |
117 |
| - else if(slot_flags == ITEM_SLOT_BELT) |
118 |
| - if(user.get_item_by_slot(ITEM_SLOT_BELT) == src) |
119 |
| - ui_action_click() |
120 |
| - else |
121 |
| - to_chat(user, span_warning("Strap the defibrillator's belt on first!")) |
122 |
| - return |
123 |
| - else if(istype(loc, /obj/machinery/defibrillator_mount)) |
124 |
| - ui_action_click() //checks for this are handled in defibrillator.mount.dm |
| 110 | + if(equipped_to == user || istype(loc, /obj/machinery/defibrillator_mount)) |
| 111 | + toggle_paddles(user) |
125 | 112 | return ..()
|
126 | 113 |
|
127 | 114 | /obj/item/defibrillator/screwdriver_act(mob/living/user, obj/item/tool)
|
|
135 | 122 |
|
136 | 123 | /obj/item/defibrillator/attackby(obj/item/W, mob/user, params)
|
137 | 124 | if(W == paddles)
|
138 |
| - toggle_paddles() |
| 125 | + toggle_paddles(user) |
| 126 | + |
139 | 127 | else if(istype(W, /obj/item/stock_parts/cell))
|
140 | 128 | var/obj/item/stock_parts/cell/C = W
|
141 | 129 | if(cell)
|
|
152 | 140 | else
|
153 | 141 | return ..()
|
154 | 142 |
|
| 143 | +/obj/item/defibrillator/AltClick(mob/user) |
| 144 | + . = ..() |
| 145 | + if(on || !user.canUseTopic(src, USE_CLOSE|USE_NEED_HANDS)) |
| 146 | + return |
| 147 | + |
| 148 | + toggle_paddles(user) |
| 149 | + |
155 | 150 | /obj/item/defibrillator/emag_act(mob/user)
|
156 | 151 | if(safety)
|
157 | 152 | safety = FALSE
|
|
180 | 175 | playsound(src, 'sound/machines/defib_saftyOn.ogg', 50, FALSE)
|
181 | 176 | update_power()
|
182 | 177 |
|
183 |
| -/obj/item/defibrillator/proc/toggle_paddles() |
| 178 | +/obj/item/defibrillator/verb/toggle_paddles_verb() |
184 | 179 | set name = "Toggle Paddles"
|
185 | 180 | set category = "Object"
|
| 181 | + set src in view(1) |
| 182 | + |
| 183 | + var/mob/living/user = usr |
| 184 | + if(!istype(user) || !user.canUseTopic(src, USE_CLOSE|USE_NEED_HANDS)) |
| 185 | + return |
| 186 | + |
| 187 | + toggle_paddles(user) |
| 188 | + |
| 189 | +/// Equips or unequips paddles. Overloaded AF. |
| 190 | +/obj/item/defibrillator/proc/toggle_paddles(mob/living/user) |
186 | 191 | on = !on
|
187 | 192 |
|
188 |
| - var/mob/living/carbon/user = usr |
189 | 193 | if(on)
|
190 | 194 | //Detach the paddles into the user's hands
|
191 |
| - if(!usr.put_in_hands(paddles)) |
| 195 | + if(!user.put_in_hands(paddles)) |
192 | 196 | on = FALSE
|
193 | 197 | to_chat(user, span_warning("You need a free hand to hold the paddles!"))
|
194 | 198 | update_power()
|
195 |
| - return |
| 199 | + return FALSE |
196 | 200 | else
|
197 | 201 | //Remove from their hands and back onto the defib unit
|
198 |
| - remove_paddles(user) |
| 202 | + remove_paddles() |
199 | 203 |
|
200 | 204 | update_power()
|
201 | 205 | update_action_buttons()
|
202 |
| - |
| 206 | + return TRUE |
203 | 207 |
|
204 | 208 | /obj/item/defibrillator/equipped(mob/user, slot)
|
205 | 209 | ..()
|
206 | 210 | if((slot_flags == ITEM_SLOT_BACK && slot != ITEM_SLOT_BACK) || (slot_flags == ITEM_SLOT_BELT && slot != ITEM_SLOT_BELT))
|
207 |
| - remove_paddles(user) |
| 211 | + remove_paddles() |
208 | 212 | update_power()
|
209 | 213 |
|
210 | 214 | /obj/item/defibrillator/item_action_slot_check(slot, mob/user)
|
211 | 215 | if(slot == user.getBackSlot())
|
212 | 216 | return 1
|
213 | 217 |
|
214 |
| -/obj/item/defibrillator/proc/remove_paddles(mob/user) //this fox the bug with the paddles when other player stole you the defib when you have the paddles equiped |
215 |
| - if(ismob(paddles.loc)) |
216 |
| - var/mob/M = paddles.loc |
217 |
| - M.dropItemToGround(paddles, TRUE) |
218 |
| - return |
| 218 | +/obj/item/defibrillator/proc/remove_paddles() //this fox the bug with the paddles when other player stole you the defib when you have the paddles equiped |
| 219 | + paddles.equipped_to?.dropItemToGround(paddles, TRUE) |
219 | 220 |
|
220 | 221 | /obj/item/defibrillator/Destroy()
|
221 | 222 | if(on)
|
222 |
| - var/M = get(paddles, /mob) |
223 |
| - remove_paddles(M) |
| 223 | + remove_paddles() |
224 | 224 | QDEL_NULL(paddles)
|
225 | 225 | QDEL_NULL(cell)
|
226 | 226 | return ..()
|
|
336 | 336 |
|
337 | 337 | /obj/item/shockpaddles/Initialize(mapload)
|
338 | 338 | . = ..()
|
| 339 | + ADD_TRAIT(src, TRAIT_NO_STORAGE_INSERT, TRAIT_GENERIC) //stops shockpaddles from being inserted in BoH |
339 | 340 | AddElement(/datum/element/update_icon_updates_onmob, ITEM_SLOT_HANDS|ITEM_SLOT_BACK)
|
| 341 | + if(!req_defib) |
| 342 | + return |
| 343 | + |
| 344 | + if (!loc || !istype(loc, /obj/item/defibrillator)) //To avoid weird issues from admin spawns |
| 345 | + return INITIALIZE_HINT_QDEL |
| 346 | + |
| 347 | + defib = loc |
| 348 | + busy = FALSE |
| 349 | + update_appearance() |
340 | 350 |
|
341 | 351 | /obj/item/shockpaddles/Destroy()
|
342 | 352 | defib = null
|
|
348 | 358 | return
|
349 | 359 | RegisterSignal(user, COMSIG_MOVABLE_MOVED, PROC_REF(check_range))
|
350 | 360 |
|
| 361 | +/obj/item/shockpaddles/attack_self(mob/user, modifiers) |
| 362 | + . = ..() |
| 363 | + if(.) |
| 364 | + return |
| 365 | + |
| 366 | + if(wielded) |
| 367 | + unwield(user) |
| 368 | + else |
| 369 | + wield(user) |
| 370 | + return TRUE |
| 371 | + |
351 | 372 | /obj/item/shockpaddles/Moved(atom/old_loc, movement_dir, forced, list/old_locs, momentum_change = TRUE)
|
352 | 373 | . = ..()
|
353 | 374 | check_range()
|
|
382 | 403 | cooldown = FALSE
|
383 | 404 | update_appearance()
|
384 | 405 |
|
385 |
| -/obj/item/shockpaddles/Initialize(mapload) |
386 |
| - . = ..() |
387 |
| - ADD_TRAIT(src, TRAIT_NO_STORAGE_INSERT, TRAIT_GENERIC) //stops shockpaddles from being inserted in BoH |
388 |
| - if(!req_defib) |
389 |
| - return //If it doesn't need a defib, just say it exists |
390 |
| - if (!loc || !istype(loc, /obj/item/defibrillator)) //To avoid weird issues from admin spawns |
391 |
| - return INITIALIZE_HINT_QDEL |
392 |
| - defib = loc |
393 |
| - busy = FALSE |
394 |
| - update_appearance() |
395 |
| - |
396 | 406 | /obj/item/shockpaddles/suicide_act(mob/user)
|
397 | 407 | user.visible_message(span_danger("[user] is putting the live paddles on [user.p_their()] chest! It looks like [user.p_theyre()] trying to commit suicide!"))
|
398 | 408 | if(req_defib)
|
|
0 commit comments