Files
Paradise/code/modules/reagents/reagent_containers/borghydro.dm
T
Tigercat2000 d20298e996 -tg- atom pooling system, qdel changes
This commit first and foremost ports the -tg- atom pooling system, and
removes the old experimental system entirely.

Secondly, this PR modifies the qdel system to use a -tg- lookalike
"destroy hint" system, which means that individual objects can tell qdel
what to do with them beyond taking care of things they need to delete.
This ties into the atom pooling system via a new hint define,
QDEL_HINT_PUTINPOOL, which will place the atom in the pool instead of
deleting it as per standard.

Emitter beams are now fully pooled.

Qdel now has semi-compatibility with all datum types, however it is not
the same as -tg-'s "Queue everything!" system. It simply passes it through
the GC immediately and adds it to the "hard del" lists. This means that
reagents can be qdel'ed, but there is no purpose as of yet, as it is more
or less the same as just deleting them, with the added effect of adding
logs of them being deleted to the garbage collector.
2015-06-21 15:47:57 -07:00

113 lines
3.7 KiB
Plaintext

/obj/item/weapon/reagent_containers/borghypo
name = "Cyborg Hypospray"
desc = "An advanced chemical synthesizer and injection system, designed for heavy-duty medical equipment."
icon = 'icons/obj/syringe.dmi'
item_state = "hypo"
icon_state = "borghypo"
amount_per_transfer_from_this = 5
volume = 30
possible_transfer_amounts = null
var/mode = 1
var/charge_cost = 50
var/charge_tick = 0
var/recharge_time = 5 //Time it takes for shots to recharge (in seconds)
var/list/datum/reagents/reagent_list = list()
var/list/reagent_ids = list("salglu_solution", "epinephrine", "spaceacillin", "charcoal")
//var/list/reagent_ids = list("salbutamol", "silver_sulfadiazine", "styptic_powder", "charcoal", "epinephrine", "spaceacillin")
/obj/item/weapon/reagent_containers/borghypo/surgeon
reagent_ids = list("styptic_powder", "epinephrine", "salbutamol")
/obj/item/weapon/reagent_containers/borghypo/crisis
reagent_ids = list("salglu_solution", "epinephrine", "sal_acid")
/obj/item/weapon/reagent_containers/borghypo/New()
..()
for(var/R in reagent_ids)
add_reagent(R)
processing_objects.Add(src)
/obj/item/weapon/reagent_containers/borghypo/Destroy()
processing_objects.Remove(src)
return ..()
/obj/item/weapon/reagent_containers/borghypo/process() //Every [recharge_time] seconds, recharge some reagents for the cyborg
charge_tick++
if(charge_tick < recharge_time) return 0
charge_tick = 0
if(isrobot(src.loc))
var/mob/living/silicon/robot/R = src.loc
if(R && R.cell)
var/datum/reagents/RG = reagent_list[mode]
if(RG.total_volume < RG.maximum_volume) //Don't recharge reagents and drain power if the storage is full.
R.cell.use(charge_cost) //Take power from borg...
RG.add_reagent(reagent_ids[mode], 5) //And fill hypo with reagent.
//update_icon()
return 1
// Purely for testing purposes I swear~
/*
/obj/item/weapon/reagent_containers/borghypo/verb/add_cyanide()
set src in world
add_reagent("cyanide")
*/
// Use this to add more chemicals for the borghypo to produce.
/obj/item/weapon/reagent_containers/borghypo/proc/add_reagent(var/reagent)
reagent_ids |= reagent
var/datum/reagents/RG = new(30)
RG.my_atom = src
reagent_list += RG
var/datum/reagents/R = reagent_list[reagent_list.len]
R.add_reagent(reagent, 30)
/obj/item/weapon/reagent_containers/borghypo/attack(mob/living/M as mob, mob/user as mob)
var/datum/reagents/R = reagent_list[mode]
if(!R.total_volume)
user << "\red The injector is empty."
return
if (!(istype(M)))
return
if (R.total_volume && M.can_inject(user,1))
user << "\blue You inject [M] with the injector."
M << "\red You feel a tiny prick!"
R.add_reagent(M)
if(M.reagents)
var/trans = R.trans_to(M, amount_per_transfer_from_this)
user << "\blue [trans] units injected. [R.total_volume] units remaining."
return
/obj/item/weapon/reagent_containers/borghypo/attack_self(mob/user as mob)
playsound(src.loc, 'sound/effects/pop.ogg', 50, 0) //Change the mode
mode++
if(mode > reagent_list.len)
mode = 1
charge_tick = 0 //Prevents wasted chems/cell charge if you're cycling through modes.
var/datum/reagent/R = chemical_reagents_list[reagent_ids[mode]]
user << "\blue Synthesizer is now producing '[R.name]'."
return
/obj/item/weapon/reagent_containers/borghypo/examine()
set src in view()
..()
if (!(usr in view(2)) && usr!=src.loc) return
var/empty = 1
for(var/datum/reagents/RS in reagent_list)
var/datum/reagent/R = locate() in RS.reagent_list
if(R)
usr << "\blue It currently has [R.volume] units of [R.name] stored."
empty = 0
if(empty)
usr << "\blue It is currently empty. Allow some time for the internal syntheszier to produce more."