mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-08-29 16:10:02 +01:00
RnD Inductive Chargers (#12199)
This commit is contained in:
@@ -3,8 +3,11 @@
|
||||
desc = "A phoron-enhanced induction charger hooked up to its attached stationbound's internal cell."
|
||||
desc_fluff = "Harnessing the energy potential found in phoron structures, Nanotrasen engineers have created a portable device capable of highly efficient wireless charging. The expense and limit of energy output of using this method of charging prevents it from being used on a large scale, being far outclassed by Phoron-Supermatter charging systems."
|
||||
desc_info = "Click on an adjacent object that contains or is a power cell to attempt to find and charge it. After a successful charge, the inductive charger recharge in a few minutes. The amount transfered can be adjusted by alt clicking it."
|
||||
icon = 'icons/obj/robot_items.dmi'
|
||||
icon = 'icons/obj/contained_items/tools/inductive_charger.dmi'
|
||||
icon_state = "inductive_charger"
|
||||
item_state = "inductive_charger"
|
||||
flags = HELDMAPTEXT
|
||||
contained_sprite = TRUE
|
||||
var/ready_to_use = TRUE
|
||||
var/recharge_time = 300
|
||||
var/transfer_rate = 5000
|
||||
@@ -12,9 +15,8 @@
|
||||
maptext_x = 3
|
||||
maptext_y = 2
|
||||
|
||||
/obj/item/inductive_charger/Initialize()
|
||||
. = ..()
|
||||
maptext = "<span style=\"font-family: 'Small Fonts'; -dm-text-outline: 1 black; font-size: 7px;\">Ready</span>"
|
||||
/obj/item/inductive_charger/set_initial_maptext()
|
||||
held_maptext = SMALL_FONTS(7, "Ready")
|
||||
|
||||
/obj/item/inductive_charger/AltClick(mob/user)
|
||||
. = ..()
|
||||
@@ -26,14 +28,25 @@
|
||||
transfer_rate = set_rate
|
||||
to_chat(user, SPAN_NOTICE("You set the transfer rate of \the [src] to [transfer_rate]."))
|
||||
|
||||
/obj/item/inductive_charger/get_cell()
|
||||
if(isrobot(loc))
|
||||
var/mob/living/silicon/robot/R = loc
|
||||
return R.get_cell()
|
||||
return null
|
||||
|
||||
/obj/item/inductive_charger/attack(mob/living/M, mob/living/user, target_zone)
|
||||
return
|
||||
|
||||
/obj/item/inductive_charger/afterattack(atom/target, mob/user, proximity_flag, click_parameters)
|
||||
var/mob/living/silicon/robot/R = user
|
||||
if(!istype(R))
|
||||
to_chat(user, SPAN_WARNING("Only cyborgs can use this!"))
|
||||
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)
|
||||
to_chat(user, SPAN_WARNING("\The [src] doesn't have a cell connected to it!"))
|
||||
return
|
||||
|
||||
if(!ready_to_use)
|
||||
to_chat(user, SPAN_WARNING("\The [src] is still gathering charge!"))
|
||||
return
|
||||
@@ -41,7 +54,7 @@
|
||||
user.visible_message("<b>[user]</b> 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))
|
||||
return
|
||||
if(R.cell.charge < 1000)
|
||||
if(C.charge < 1000)
|
||||
to_chat(user, SPAN_WARNING("You have no spare charge in your internal cell to give!"))
|
||||
return
|
||||
|
||||
@@ -51,25 +64,21 @@
|
||||
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 = R.cell.use(charge_amount / efficiency_mod) * efficiency_mod
|
||||
var/charge_value = C.use(charge_amount / efficiency_mod) * efficiency_mod
|
||||
IPC.nutrition = min(IPC.max_nutrition, charge_value)
|
||||
message_and_use(user, "<b>[user]</b> 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] of internal cell power."))
|
||||
message_and_use(user, "<b>[user]</b> 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))
|
||||
var/obj/item/cell/C
|
||||
if(istype(target, /obj/item/cell))
|
||||
C = target
|
||||
else
|
||||
C = locate() in target
|
||||
if(!C)
|
||||
to_chat(user, SPAN_WARNING("\The [target] doesn't contain a cell, or it's buried too deep for you to reach!"))
|
||||
var/obj/item/cell/obj_cell = target.get_cell()
|
||||
if(!obj_cell)
|
||||
to_chat(user, SPAN_WARNING("\The [target] doesn't contain a cell!"))
|
||||
return
|
||||
if(C.fully_charged())
|
||||
to_chat(user, SPAN_WARNING("\The [C] is already fully charged!"))
|
||||
if(obj_cell.fully_charged())
|
||||
to_chat(user, SPAN_WARNING("\The [obj_cell] is already fully charged!"))
|
||||
return
|
||||
var/charge_amount = min(C.maxcharge - C.charge, transfer_rate)
|
||||
var/charge_value = R.cell.use(charge_amount / efficiency_mod) * efficiency_mod
|
||||
C.give(charge_value)
|
||||
message_and_use(user, "<b>[user]</b> 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] of internal cell power."))
|
||||
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, "<b>[user]</b> 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."))
|
||||
else
|
||||
to_chat(user, SPAN_WARNING("\The [src] cannot be used on \the [target]!"))
|
||||
|
||||
@@ -77,8 +86,52 @@
|
||||
user.visible_message(others_message, self_message, range = 3)
|
||||
addtimer(CALLBACK(src, .proc/recharge), recharge_time)
|
||||
ready_to_use = FALSE
|
||||
maptext = "<span style=\"font-family: 'Small Fonts'; -dm-text-outline: 1 black; font-size: 6px;\">Charge</span>"
|
||||
check_maptext(SMALL_FONTS(6, "Charge"))
|
||||
|
||||
/obj/item/inductive_charger/proc/recharge()
|
||||
ready_to_use = TRUE
|
||||
maptext = "<span style=\"font-family: 'Small Fonts'; -dm-text-outline: 1 black; font-size: 7px;\">Ready</span>"
|
||||
check_maptext(SMALL_FONTS(7, "Ready"))
|
||||
|
||||
/obj/item/inductive_charger/handheld
|
||||
desc = "A handheld phoron-enhanced induction charger, capable of wirelessly charging cells at a reduced efficiency. This one is painted in science colors."
|
||||
icon_state = "inductive_charger_sci"
|
||||
item_state = "inductive_charger_sci"
|
||||
efficiency_mod = 0.8 // less efficient than the stationbound version
|
||||
var/obj/item/cell/cell = /obj/item/cell/high/empty
|
||||
|
||||
/obj/item/inductive_charger/handheld/Initialize()
|
||||
. = ..()
|
||||
if(ispath(cell))
|
||||
cell = new cell(src)
|
||||
|
||||
/obj/item/inductive_charger/handheld/examine(mob/user, distance)
|
||||
. = ..()
|
||||
if(cell)
|
||||
to_chat(user, SPAN_NOTICE("Cell Charge: [cell.percent()]%"))
|
||||
|
||||
/obj/item/inductive_charger/handheld/get_cell()
|
||||
return cell
|
||||
|
||||
/obj/item/inductive_charger/handheld/attackby(obj/item/I, mob/user)
|
||||
if(istype(I, /obj/item/cell))
|
||||
if(cell)
|
||||
to_chat(user, SPAN_WARNING("\The [src] already has a cell inserted."))
|
||||
return
|
||||
user.drop_from_inventory(I, src)
|
||||
to_chat(user, SPAN_NOTICE("You put \the [I] into \the [src]."))
|
||||
cell = I
|
||||
return
|
||||
if(I.isscrewdriver())
|
||||
if(!cell)
|
||||
to_chat(user, SPAN_WARNING("\The [src] doesn't have a cell inserted."))
|
||||
return
|
||||
user.put_in_hands(cell)
|
||||
to_chat(user, SPAN_NOTICE("You remove \the [cell] from \the [src]."))
|
||||
cell = null
|
||||
return
|
||||
return ..()
|
||||
|
||||
/obj/item/inductive_charger/handheld/engineering
|
||||
desc = "A handheld phoron-enhanced induction charger, capable of wirelessly charging cells at a reduced efficiency. This one is painted in engineering colors."
|
||||
icon_state = "inductive_charger_eng"
|
||||
item_state = "inductive_charger_eng"
|
||||
Reference in New Issue
Block a user