mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 02:09:41 +00:00
Co-authored-by: Heroman3003 <31296024+Heroman3003@users.noreply.github.com> Co-authored-by: Kashargul <144968721+Kashargul@users.noreply.github.com>
149 lines
4.5 KiB
Plaintext
149 lines
4.5 KiB
Plaintext
/obj/item/mecha_parts/mecha_equipment/generator
|
|
name = "phoron generator"
|
|
desc = "Generates power using solid phoron as fuel. Pollutes the environment."
|
|
icon_state = "tesla"
|
|
origin_tech = list(TECH_PHORON = 2, TECH_POWER = 2, TECH_ENGINEERING = 1)
|
|
equip_cooldown = 10
|
|
energy_drain = 0
|
|
range = MELEE
|
|
var/coeff = 100
|
|
var/obj/item/stack/material/fuel
|
|
var/fuel_type = /obj/item/stack/material/phoron
|
|
var/fuel_amount = 0
|
|
var/max_fuel = 150000
|
|
var/fuel_per_cycle_idle = 100
|
|
var/fuel_per_cycle_active = 500
|
|
var/power_per_cycle = 20
|
|
|
|
equip_type = EQUIP_UTILITY
|
|
|
|
/obj/item/mecha_parts/mecha_equipment/generator/Initialize()
|
|
. = ..()
|
|
fuel = new fuel_type(src)
|
|
|
|
/obj/item/mecha_parts/mecha_equipment/generator/Destroy()
|
|
qdel(fuel)
|
|
return ..()
|
|
|
|
/obj/item/mecha_parts/mecha_equipment/generator/process()
|
|
if(!chassis)
|
|
set_ready_state(TRUE)
|
|
return PROCESS_KILL
|
|
if(fuel_amount <= 0)
|
|
log_message("Deactivated - no fuel.")
|
|
set_ready_state(TRUE)
|
|
return PROCESS_KILL
|
|
var/cur_charge = chassis.get_charge()
|
|
if(isnull(cur_charge))
|
|
set_ready_state(TRUE)
|
|
occupant_message("No powercell detected.")
|
|
log_message("Deactivated.")
|
|
return PROCESS_KILL
|
|
var/use_fuel = fuel_per_cycle_idle
|
|
if(cur_charge<chassis.cell.maxcharge)
|
|
use_fuel = fuel_per_cycle_active
|
|
chassis.give_power(power_per_cycle)
|
|
fuel_amount -= min(use_fuel, fuel_amount) // allows fuel to get to 0
|
|
update_equip_info()
|
|
|
|
/obj/item/mecha_parts/mecha_equipment/generator/detach()
|
|
STOP_PROCESSING(SSfastprocess, src)
|
|
..()
|
|
return
|
|
|
|
|
|
/obj/item/mecha_parts/mecha_equipment/generator/Topic(href, href_list)
|
|
..()
|
|
if(href_list["toggle"])
|
|
if(datum_flags & DF_ISPROCESSING)
|
|
STOP_PROCESSING(SSfastprocess, src)
|
|
set_ready_state(TRUE)
|
|
log_message("Deactivated.")
|
|
else
|
|
START_PROCESSING(SSfastprocess, src)
|
|
set_ready_state(FALSE)
|
|
log_message("Activated.")
|
|
return
|
|
|
|
/obj/item/mecha_parts/mecha_equipment/generator/get_equip_info()
|
|
var/output = ..()
|
|
if(output)
|
|
return "[output] \[[fuel]: [fuel_amount] cm<sup>3</sup>\] - <a href='?src=\ref[src];toggle=1'>[(datum_flags & DF_ISPROCESSING)?"Dea":"A"]ctivate</a>"
|
|
return
|
|
|
|
/obj/item/mecha_parts/mecha_equipment/generator/action(target)
|
|
if(chassis)
|
|
var/result = load_fuel(target)
|
|
var/message
|
|
if(isnull(result))
|
|
message = span_warning("[fuel] traces in target minimal. [target] cannot be used as fuel.")
|
|
else if(!result)
|
|
message = "Unit is full."
|
|
else
|
|
message = "[result] unit\s of [fuel] successfully loaded."
|
|
send_byjax(chassis.occupant,"exosuit.browser","\ref[src]",src.get_equip_info())
|
|
occupant_message(message)
|
|
return
|
|
|
|
/obj/item/mecha_parts/mecha_equipment/generator/proc/load_fuel(var/obj/item/stack/material/P)
|
|
if(P.type == fuel_type && P.get_amount())
|
|
var/to_load = max(max_fuel - fuel_amount,0)
|
|
if(to_load >= 2000)
|
|
if(to_load > P.get_amount() * 2000)
|
|
to_load = P.get_amount() * 2000
|
|
var/sheets = round(to_load / 2000, 1)
|
|
if(P.get_amount() >= sheets)
|
|
fuel_amount += sheets * 2000
|
|
P.use(sheets)
|
|
return sheets * 2000
|
|
else
|
|
return 0
|
|
return
|
|
|
|
/obj/item/mecha_parts/mecha_equipment/generator/attackby(weapon,mob/user)
|
|
var/result = load_fuel(weapon)
|
|
if(isnull(result))
|
|
user.visible_message("[user] tries to shove [weapon] into [src]. What a dumb-ass.",span_warning("[fuel] traces minimal. [weapon] cannot be used as fuel."))
|
|
else if(!result)
|
|
to_chat(user, "Unit is full.")
|
|
else
|
|
user.visible_message("[user] loads [src] with [fuel].","[result] unit\s of [fuel] successfully loaded.")
|
|
return
|
|
|
|
/obj/item/mecha_parts/mecha_equipment/generator/critfail()
|
|
..()
|
|
var/turf/simulated/T = get_turf(src)
|
|
if(!T)
|
|
return
|
|
var/datum/gas_mixture/GM = new
|
|
if(prob(10))
|
|
T.assume_gas(GAS_PHORON, 100, 1500+T0C)
|
|
T.visible_message("The [src] suddenly disgorges a cloud of heated phoron.")
|
|
destroy()
|
|
else
|
|
T.assume_gas(GAS_PHORON, 5, istype(T) ? T.air.temperature : T20C)
|
|
T.visible_message("The [src] suddenly disgorges a cloud of phoron.")
|
|
T.assume_air(GM)
|
|
return
|
|
|
|
|
|
/obj/item/mecha_parts/mecha_equipment/generator/nuclear
|
|
name = "\improper ExoNuclear reactor"
|
|
desc = "Generates power using uranium. Pollutes the environment."
|
|
icon_state = "tesla"
|
|
origin_tech = list(TECH_POWER = 3, TECH_ENGINEERING = 3)
|
|
max_fuel = 50000
|
|
fuel_per_cycle_idle = 10
|
|
fuel_per_cycle_active = 30
|
|
power_per_cycle = 50
|
|
fuel_type = /obj/item/stack/material/uranium
|
|
var/rad_per_cycle = 0.3
|
|
|
|
/obj/item/mecha_parts/mecha_equipment/generator/nuclear/process()
|
|
if(..())
|
|
SSradiation.radiate(src, (rad_per_cycle * 3))
|
|
return
|
|
|
|
/obj/item/mecha_parts/mecha_equipment/generator/nuclear/critfail()
|
|
return
|