diff --git a/code/modules/mob/living/silicon/robot/items/inductive_charger.dm b/code/modules/mob/living/silicon/robot/items/inductive_charger.dm index 10a034ba912..707df9b31d2 100644 --- a/code/modules/mob/living/silicon/robot/items/inductive_charger.dm +++ b/code/modules/mob/living/silicon/robot/items/inductive_charger.dm @@ -8,6 +8,7 @@ item_state = "inductive_charger" flags = HELDMAPTEXT contained_sprite = TRUE + var/is_in_use = FALSE var/ready_to_use = TRUE var/recharge_time = 300 var/transfer_rate = 5000 @@ -38,12 +39,16 @@ return /obj/item/inductive_charger/afterattack(atom/target, mob/user, proximity_flag, click_parameters) + if(is_in_use) + to_chat(user, SPAN_WARNING("You're already using \the [src]!")) + return + if(!proximity_flag) to_chat(user, SPAN_WARNING("You need to be adjacent to the target to charge it!")) return var/obj/item/cell/C = get_cell() - if(!C) + if(!istype(C)) to_chat(user, SPAN_WARNING("\The [src] doesn't have a cell connected to it!")) return @@ -51,25 +56,19 @@ to_chat(user, SPAN_WARNING("\The [src] is still gathering charge!")) return + is_in_use = TRUE user.visible_message("[user] begins waving \the [src] around \the [target]...", SPAN_NOTICE("You prepare to wirelessly charge \the [target]..."), range = 3) if(!do_after(user, 50, TRUE, target)) + is_in_use = FALSE return + is_in_use = FALSE if(C.charge < 1000) to_chat(user, SPAN_WARNING("You have no spare charge in your internal cell to give!")) return - if(isipc(target)) - var/mob/living/carbon/human/IPC = target - if(IPC.nutrition == IPC.max_nutrition) - to_chat(user, SPAN_WARNING("\The [IPC] is already fully charged!")) - return - var/charge_amount = min(IPC.max_nutrition - IPC.nutrition, transfer_rate) - var/charge_value = C.use(charge_amount / efficiency_mod) * efficiency_mod - IPC.nutrition = min(IPC.max_nutrition, charge_value) - message_and_use(user, "[user] holds \the [src] over \the [IPC], topping up their battery.", SPAN_NOTICE("You wirelessly transmit [charge_value] units of power to \the [IPC], using [charge_value / efficiency_mod] units of internal cell power.")) - else if(isobj(target)) + if(isobj(target) || isliving(target)) var/obj/item/cell/obj_cell = target.get_cell() - if(!obj_cell) + if(!istype(obj_cell)) to_chat(user, SPAN_WARNING("\The [target] doesn't contain a cell!")) return if(obj_cell.fully_charged()) @@ -78,7 +77,7 @@ var/charge_amount = min(obj_cell.maxcharge - obj_cell.charge, transfer_rate) var/charge_value = C.use(charge_amount / efficiency_mod) * efficiency_mod obj_cell.give(charge_value) - message_and_use(user, "[user] holds \the [src] over \the [target], topping up its battery.", SPAN_NOTICE("You wirelessly transmit [charge_value] units of power to \the [target], using [charge_value / efficiency_mod] units of internal cell power.")) + message_and_use(user, "[user] holds \the [src] over \the [target], topping up [target.get_pronoun("his")] battery.", SPAN_NOTICE("You wirelessly transmit [charge_value] units of power to \the [target], using [charge_value / efficiency_mod] units of internal cell power.")) else to_chat(user, SPAN_WARNING("\The [src] cannot be used on \the [target]!")) diff --git a/code/modules/power/apc.dm b/code/modules/power/apc.dm index f477d195233..74245922dc2 100644 --- a/code/modules/power/apc.dm +++ b/code/modules/power/apc.dm @@ -477,6 +477,9 @@ results += 2 return results +/obj/machinery/power/apc/get_cell() + return cell + //attack with an item - open/close cover, insert cell, or (un)lock interface /obj/machinery/power/apc/attackby(obj/item/W, mob/user) diff --git a/code/modules/power/cell.dm b/code/modules/power/cell.dm index 05768fe3c32..26202ac2e8e 100644 --- a/code/modules/power/cell.dm +++ b/code/modules/power/cell.dm @@ -12,6 +12,9 @@ charge = 0 update_icon() +/obj/item/cell/get_cell() + return src + /obj/item/cell/drain_power(var/drain_check, var/surge, var/power = 0) if(drain_check) diff --git a/html/changelogs/geeves-inducer_fix.yml b/html/changelogs/geeves-inducer_fix.yml new file mode 100644 index 00000000000..342395bcaf9 --- /dev/null +++ b/html/changelogs/geeves-inducer_fix.yml @@ -0,0 +1,8 @@ +author: Geeves + +delete-after: True + +changes: + - bugfix: "Inductive chargers now properly report when they don't find a cell to charge." + - rscadd: "Using an inductive charger on a power cell or an APC will now properly charge it." + - bugfix: "You can no longer line up multiple inductive chargers by spamclicking the target." \ No newline at end of file