diff --git a/code/game/objects/items/weapons/inducer_vr.dm b/code/game/objects/items/weapons/inducer_vr.dm new file mode 100644 index 0000000000..8ca20c049b --- /dev/null +++ b/code/game/objects/items/weapons/inducer_vr.dm @@ -0,0 +1,270 @@ +/obj/item/weapon/inducer + name = "industrial inducer" + desc = "A tool for inductively charging internal power cells." + icon = 'icons/obj/tools_vr.dmi' + icon_state = "inducer-engi" + item_state = "inducer-engi" + item_icons = list( + slot_l_hand_str = 'icons/mob/items/lefthand_vr.dmi', + slot_r_hand_str = 'icons/mob/items/righthand_vr.dmi', + ) + force = 7 + + var/powertransfer = 1000 //Transfer per time when charging something + var/cell_type = /obj/item/weapon/cell/high //Type of cell to spawn in it + var/charge_guns = FALSE //Can it charge guns? + + var/datum/effect/effect/system/spark_spread/spark_system + var/obj/item/weapon/cell/cell + var/recharging = FALSE + var/opened = FALSE + +/obj/item/weapon/inducer/unloaded + cell_type = null + opened = TRUE + +/obj/item/weapon/inducer/Initialize() + . = ..() + if(!cell && cell_type) + cell = new cell_type + +/obj/item/weapon/inducer/proc/induce(var/obj/item/weapon/cell/target, coefficient) + var/totransfer = min(cell.charge,(powertransfer * coefficient)) + var/transferred = target.give(totransfer) + cell.use(transferred) + cell.update_icon() + target.update_icon() + +/obj/item/weapon/inducer/get_cell() + return cell + +/obj/item/weapon/inducer/emp_act(severity) + . = ..() + if(cell) + cell.emp_act(severity) + +/obj/item/weapon/inducer/afterattack(atom/A, mob/living/carbon/user, proximity) + if(user.a_intent == I_HURT) + return ..() + + if(cantbeused(user)) + return + + if(recharge(A, user)) + return + + return ..() + +/obj/item/weapon/inducer/proc/cantbeused(mob/user) + if(!user.IsAdvancedToolUser()) + to_chat(user, "You don't have the dexterity to use [src]!") + return TRUE + + if(!cell) + to_chat(user, "[src] doesn't have a power cell installed!") + return TRUE + + if(!cell.charge) + to_chat(user, "[src]'s battery is dead!") + return TRUE + return FALSE + + +/obj/item/weapon/inducer/attackby(obj/item/W, mob/user) + if(W.is_screwdriver()) + playsound(src, W.usesound, 50, 1) + if(!opened) + to_chat(user, "You open the battery compartment.") + opened = TRUE + update_icon() + return + else + to_chat(user, "You close the battery compartment.") + opened = FALSE + update_icon() + return + if(istype(W, /obj/item/weapon/cell)) + if(opened) + if(!cell) + user.drop_from_inventory(W) + W.forceMove(src) + to_chat(user, "You insert [W] into [src].") + cell = W + update_icon() + return + else + to_chat(user, "[src] already has \a [cell] installed!") + return + + if(cantbeused(user)) + return + + if(recharge(W, user)) + return + + return ..() + +/obj/item/weapon/inducer/proc/recharge(atom/movable/A, mob/user) + if(!isturf(A) && user.loc == A) + return FALSE + if(recharging) + return TRUE + else + recharging = TRUE + + if(istype(A, /obj/item/weapon/gun/energy) && !charge_guns) + to_chat(user, "Error unable to interface with device.") + return FALSE + + //The cell we hopefully eventually find + var/obj/item/weapon/cell/C + + //Synthetic humanoids + if(ishuman(A)) + var/mob/living/carbon/human/H = A + if(H.isSynthetic()) + C = new /obj/item/weapon/cell/standin(null, H) // o o f + + //Borg frienbs + else if(isrobot(A)) + var/mob/living/silicon/robot/R = A + C = R.cell + + //Can set different coefficients per item if you want + var/coefficient = 1 + + //Last ditch effort + var/obj/O //For updating icons, just in case they have a battery meter icon + if(!C && isobj(A)) + O = A + C = O.get_cell() + + if(C) + var/done_any = FALSE + + if(C.charge >= C.maxcharge) + to_chat(user, "[A] is fully charged ([round(C.charge)] / [C.maxcharge])!") + recharging = FALSE + return TRUE + user.visible_message("[user] starts recharging [A] with [src].", "You start recharging [A] with [src].") + + var/datum/beam/charge_beam = user.Beam(A, icon_state = "rped_upgrade", time = 20 SECONDS) + var/filter = filter(type = "outline", size = 1, color = "#22AAFF") + A.filters += filter + + spark_system = new /datum/effect/effect/system/spark_spread + spark_system.set_up(5, 0, get_turf(A)) + spark_system.attach(A) + + while(C.charge < C.maxcharge) + if(do_after(user, 2 SECONDS, target = user) && cell.charge) + done_any = TRUE + induce(C, coefficient) + spark_system.start() + if(O) + O.update_icon() + else + break + + QDEL_NULL(charge_beam) + QDEL_NULL(spark_system) + if(A) + A.filters -= filter + + if(done_any) // Only show a message if we succeeded at least once + user.visible_message("[user] recharged [A]!", "You recharged [A]!") + + recharging = FALSE + return TRUE + else //Couldn't find a cell + to_chat(user, "Error unable to interface with device.") + + recharging = FALSE + +/obj/item/weapon/inducer/attack_self(mob/user) + if(opened && cell) + user.visible_message("[user] removes [cell] from [src]!", "You remove [cell].") + cell.update_icon() + user.put_in_hands(cell) + cell = null + update_icon() + +/obj/item/weapon/inducer/examine(mob/living/M) + . = ..() + var/dat = "" + if(cell) + dat += "
Its display shows: [round(cell.charge)] / [cell.maxcharge]." + else + dat += "
Its display is dark." + if(opened) + dat += "
Its battery compartment is open." + to_chat(M, dat) + +/obj/item/weapon/inducer/update_icon() + ..() + cut_overlays() + if(opened) + if(!cell) + add_overlay("inducer-nobat") + else + add_overlay("inducer-bat") + +//////// Variants +/obj/item/weapon/inducer/sci + name = "inducer" + desc = "A tool for inductively charging internal power cells. This one has a science color scheme, and is less potent than its engineering counterpart." + icon_state = "inducer-sci" + item_state = "inducer-sci" + cell_type = null + powertransfer = 500 + opened = TRUE + +/obj/item/weapon/inducer/sci/Initialize() + . = ..() + update_icon() //To get the 'open' state applied + +/obj/item/weapon/inducer/syndicate + name = "suspicious inducer" + desc = "A tool for inductively charging internal power cells. This one has a suspicious colour scheme, and seems to be rigged to transfer charge at a much faster rate." + icon_state = "inducer-syndi" + item_state = "inducer-syndi" + powertransfer = 2000 + cell_type = /obj/item/weapon/cell/super + charge_guns = TRUE + +/obj/item/weapon/inducer/hybrid + name = "hybrid-tech inducer" + desc = "A tool for inductively charging internal power cells. This one has some flashy bits and recharges devices slower, but seems to recharge itself between uses." + icon_state = "inducer-hybrid" + item_state = "inducer-hybrid" + powertransfer = 250 + cell_type = /obj/item/weapon/cell/void + charge_guns = TRUE + +// A 'human stand-in' cell for recharging 'nutrition' on synthetic humans (wow this is terrible! \o/) +/obj/item/weapon/cell/standin + name = "don't spawn this" + desc = "this is for weird code use, don't spawn it!!!" + + charge = 100 + maxcharge = 100 + + var/mob/living/carbon/human/hume + +/obj/item/weapon/cell/standin/New(newloc, var/mob/living/carbon/human/H) + ..() + hume = H + charge = H.nutrition + maxcharge = initial(H.nutrition) + + QDEL_IN(src, 10 SECONDS) + +/obj/item/weapon/cell/standin/give(var/amount) + amount *= 0.05 // So 1000 becomes 50 + ..(amount) + hume.nutrition += amount + +// Various sideways-defined get_cells +/obj/mecha/get_cell() + return cell + diff --git a/icons/mob/items/lefthand_vr.dmi b/icons/mob/items/lefthand_vr.dmi index c419b6f075..c033b49117 100644 Binary files a/icons/mob/items/lefthand_vr.dmi and b/icons/mob/items/lefthand_vr.dmi differ diff --git a/icons/mob/items/righthand_vr.dmi b/icons/mob/items/righthand_vr.dmi index 53abebcd3f..9a136dc19d 100644 Binary files a/icons/mob/items/righthand_vr.dmi and b/icons/mob/items/righthand_vr.dmi differ diff --git a/icons/obj/tools_vr.dmi b/icons/obj/tools_vr.dmi index b6fb6487c7..0b8f5f0490 100644 Binary files a/icons/obj/tools_vr.dmi and b/icons/obj/tools_vr.dmi differ diff --git a/vorestation.dme b/vorestation.dme index a453552ef0..7a1b7c71fe 100644 --- a/vorestation.dme +++ b/vorestation.dme @@ -1166,6 +1166,7 @@ #include "code\game\objects\items\weapons\handcuffs.dm" #include "code\game\objects\items\weapons\handcuffs_vr.dm" #include "code\game\objects\items\weapons\improvised_components.dm" +#include "code\game\objects\items\weapons\inducer_vr.dm" #include "code\game\objects\items\weapons\manuals.dm" #include "code\game\objects\items\weapons\manuals_vr.dm" #include "code\game\objects\items\weapons\mop.dm"