Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Singulo and tesla comes back to SkyRat #30

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion code/__DEFINES/_flags.dm
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ GLOBAL_LIST_INIT(bitflags, list(1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 204
/// Zaps with this flag will generate less power through tesla coils
#define ZAP_LOW_POWER_GEN (1<<6)

#define ZAP_DEFAULT_FLAGS ZAP_MOB_STUN | ZAP_MOB_DAMAGE | ZAP_OBJ_DAMAGE
#define ZAP_DEFAULT_FLAGS ZAP_MOB_STUN | ZAP_MOB_DAMAGE | ZAP_OBJ_DAMAGE | ZAP_GENERATES_POWER
#define ZAP_FUSION_FLAGS ZAP_OBJ_DAMAGE | ZAP_MOB_DAMAGE | ZAP_MOB_STUN
#define ZAP_SUPERMATTER_FLAGS ZAP_GENERATES_POWER

Expand Down
15 changes: 15 additions & 0 deletions code/__DEFINES/~skyrat_defines/particle_accelerator.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// CONSTRUCTION STATES
#define PA_CONSTRUCTION_UNSECURED 0
#define PA_CONSTRUCTION_UNWIRED 1
#define PA_CONSTRUCTION_PANEL_OPEN 2
#define PA_CONSTRUCTION_COMPLETE 3

// POWER STATES
#define PARTICLE_STRENGTH_WEAK 0
#define PARTICLE_STRENGTH_NORMAL 1
#define PARTICLE_STRENGTH_STRONG 2
#define PARTICLE_STRENGTH_MAX 3

#define ENERGY_REQ_SINGULARITY_CREATION 200

#define SINGULARITY_EFFECT_ANIM_TIME 62
2 changes: 1 addition & 1 deletion code/datums/components/singularity.dm
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@
if (STAGE_ONE)
steps = 1
if (STAGE_TWO)
steps = 3//Yes this is right
steps = 2//Yes this is right
if (STAGE_THREE)
steps = 3
if (STAGE_FOUR)
Expand Down
4 changes: 3 additions & 1 deletion code/modules/power/singularity/field_generator.dm
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ no power level overlay is currently in the overlays list.
///Check for asynk cleanups for this and the connected gens
var/clean_up = FALSE

var/shield_floor = TRUE
/datum/armor/field_generator
melee = 25
bullet = 10
Expand Down Expand Up @@ -337,7 +338,8 @@ no power level overlay is currently in the overlays list.

connected_gens |= found_generator
found_generator.connected_gens |= src
shield_floor(TRUE)
if(shield_floor)
shield_floor(TRUE)
update_appearance()


Expand Down
11 changes: 9 additions & 2 deletions code/modules/power/singularity/singularity.dm
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
/// What the game tells ghosts when you make one
var/ghost_notification_message = "IT'S LOOSE"

invisibility = INVISIBILITY_MAXIMUM

pass_flags = PASSTABLE | PASSGLASS | PASSGRILLE | PASSCLOSEDTURF | PASSMACHINE | PASSSTRUCTURE | PASSDOORS
flags_1 = SUPERMATTER_IGNORES_1
resistance_flags = INDESTRUCTIBLE | LAVA_PROOF | FIRE_PROOF | UNACIDABLE | ACID_PROOF | FREEZE_PROOF
Expand All @@ -56,6 +58,10 @@
/obj/singularity/Initialize(mapload, starting_energy = 50)
. = ..()

new /obj/effect/singularity_creation(loc)

addtimer(CALLBACK(src, PROC_REF(make_visible)), SINGULARITY_EFFECT_ANIM_TIME)

energy = starting_energy

START_PROCESSING(SSsinguloprocess, src)
Expand Down Expand Up @@ -165,13 +171,14 @@
if(prob(event_chance))
event()
dissipate(seconds_per_tick)
hawking_pulse(seconds_per_tick)
check_energy()

/obj/singularity/proc/dissipate(seconds_per_tick)
if (!dissipate)
return

time_since_last_dissipiation += seconds_per_tick
time_since_last_dissipiation += seconds_per_tick SECONDS

// Uses a while in case of especially long delta times
while (time_since_last_dissipiation >= dissipate_delay)
Expand Down Expand Up @@ -449,7 +456,7 @@
)

/obj/singularity/proc/emp_area()
empulse(src, 8, 10)
empulse(src, 5, 8)

/obj/singularity/singularity_act()
var/gain = (energy/2)
Expand Down
11 changes: 9 additions & 2 deletions code/modules/power/tesla/energy_ball.dm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#define TESLA_DEFAULT_POWER 6.95304e8
#define TESLA_MINI_POWER 3.47652e8
#define TESLA_DEFAULT_POWER 5214780
#define TESLA_MINI_POWER 1738260
//Zap constants, speeds up targeting
#define BIKE (COIL + 1)
#define COIL (ROD + 1)
Expand Down Expand Up @@ -236,6 +236,13 @@
/obj/structure/lattice = FALSE,
/obj/structure/grille = FALSE,
/obj/structure/frame/machine = FALSE,
/obj/machinery/particle_accelerator/control_box = FALSE,
/obj/structure/particle_accelerator/fuel_chamber = FALSE,
/obj/structure/particle_accelerator/particle_emitter/center = FALSE,
/obj/structure/particle_accelerator/particle_emitter/left = FALSE,
/obj/structure/particle_accelerator/particle_emitter/right = FALSE,
/obj/structure/particle_accelerator/power_box = FALSE,
/obj/structure/particle_accelerator/end_cap = FALSE,
))

//Ok so we are making an assumption here. We assume that view() still calculates from the center out.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,3 +258,9 @@
"borg_upgrade_welding",
)
return ..()
// ENGINEERING
/datum/techweb_node/engineering/New()
design_ids += list(
"rad_collector",
)
return ..()
5 changes: 0 additions & 5 deletions modular_skyrat/modules/aesthetics/emitter/code/emitter.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,3 @@

/obj/machinery/field/generator
icon = 'modular_skyrat/modules/aesthetics/emitter/icons/field_generator.dmi'


/obj/machinery/power/rad_collector
icon = 'modular_skyrat/modules/aesthetics/emitter/icons/emitter.dmi'

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/datum/export/large/collector
cost = CARGO_CRATE_VALUE * 2
unit_name = "radiation collector"
export_types = list(/obj/machinery/power/energy_accumulator/rad_collector)
37 changes: 37 additions & 0 deletions modular_skyrat/modules/singularity_engine/code/cargo/packs.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/datum/supply_pack/engine/collector
name = "Radiation Collector Crate"
desc = "Contains three radiation collectors. Useful for collecting energy off nearby Supermatter Crystals, Singularities or Teslas!"
cost = CARGO_CRATE_VALUE * 8
contains = list(
/obj/machinery/power/energy_accumulator/rad_collector,
/obj/machinery/power/energy_accumulator/rad_collector,
/obj/machinery/power/energy_accumulator/rad_collector,
)
crate_name = "collector crate"

/datum/supply_pack/engine/particle_accelerator
name = "Particle Accelerator Crate"
desc = "A supermassive black hole or hyper-powered teslaball are the perfect way to spice up any party! This \"My First Apocalypse\" kit contains everything you need to build your own Particle Accelerator! Ages 10 and up."
cost = 10000
contains = list(/obj/structure/particle_accelerator/fuel_chamber,
/obj/machinery/particle_accelerator/control_box,
/obj/structure/particle_accelerator/particle_emitter/center,
/obj/structure/particle_accelerator/particle_emitter/left,
/obj/structure/particle_accelerator/particle_emitter/right,
/obj/structure/particle_accelerator/power_box,
/obj/structure/particle_accelerator/end_cap)
crate_name = "particle accelerator crate"

/datum/supply_pack/engine/sing_gen
name = "Singularity Generator Crate"
desc = "The key to unlocking the power of Lord Singuloth. Particle Accelerator not included."
cost = 25000
contains = list(/obj/machinery/singularity_generator)
crate_name = "singularity generator crate"

/datum/supply_pack/engine/tesla_gen
name = "Tesla Generator Crate"
desc = "The key to unlocking the power of the Tesla energy ball. Particle Accelerator not included."
cost = 25000 // bullshit 25k
contains = list(/obj/machinery/singularity_generator/tesla)
crate_name = "tesla generator crate"
204 changes: 204 additions & 0 deletions modular_skyrat/modules/singularity_engine/code/collector.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
//radiation needs to be over this amount to get power
#define RAD_COLLECTOR_THRESHOLD 80
//amount of joules created for each rad point over RAD_COLLECTOR_THRESHOLD
#define RAD_COLLECTOR_COEFFICIENT 200

/obj/machinery/power/energy_accumulator/rad_collector
name = "Hawking Radiation Collector Array"
desc = "A device which uses hawking radiation generated from singularities and plasma to produce power."
icon = 'modular_skyrat/modules/aesthetics/emitter/icons/emitter.dmi'
icon_state = "ca"
req_access = list(ACCESS_ENGINE_EQUIP, ACCESS_ATMOSPHERICS)
max_integrity = 350
integrity_failure = 0.2
rad_insulation = RAD_EXTREME_INSULATION
circuit = /obj/item/circuitboard/machine/rad_collector
/// Stores the loaded tank instance
var/obj/item/tank/internals/plasma/loaded_tank = null
/// Is the collector working?
var/active = FALSE
/// Is the collector locked with an id?
var/locked = FALSE
/// Amount of gas removed per tick
var/drain_ratio = 0.5
/// Multiplier for the amount of gas removed per tick
var/power_production_drain = 0.001
/// Base efficiency
var/efficiency_multiplier = 1.0

/obj/machinery/power/energy_accumulator/rad_collector/anchored
anchored = TRUE

/obj/machinery/power/energy_accumulator/rad_collector/process(delta_time)
if(!loaded_tank)
return
var/datum/gas_mixture/tank_mix = loaded_tank.return_air()
if(!tank_mix.gases[/datum/gas/plasma])
investigate_log("<font color='red'>out of fuel</font>.", INVESTIGATE_ENGINE)
playsound(src, 'sound/machines/ding.ogg', 50, TRUE)
eject()
return
var/gasdrained = min(power_production_drain * drain_ratio * delta_time, tank_mix.gases[/datum/gas/plasma][MOLES])
tank_mix.gases[/datum/gas/plasma][MOLES] -= gasdrained
tank_mix.assert_gas(/datum/gas/tritium)
tank_mix.gases[/datum/gas/tritium][MOLES] += gasdrained
tank_mix.garbage_collect()

. = ..()

/obj/machinery/power/energy_accumulator/rad_collector/interact(mob/user)
if(!anchored)
return
if(locked)
to_chat(user, span_warning("The controls are locked!"))
return
toggle_power()
user.visible_message(span_notice("[user.name] turns the [src.name] [active? "on":"off"]."), \
span_notice("You turn the [src.name] [active? "on":"off"]."))
var/datum/gas_mixture/tank_mix = loaded_tank?.return_air()
var/fuel
if(loaded_tank)
fuel = tank_mix.gases[/datum/gas/plasma]
fuel = fuel ? fuel[MOLES] : 0
investigate_log("turned [active?"<font color='green'>on</font>":"<font color='red'>off</font>"] by [key_name(user)]. [loaded_tank?"Fuel: [round(fuel/0.29)]%":"<font color='red'>It is empty</font>"].", INVESTIGATE_ENGINE)

/obj/machinery/power/energy_accumulator/rad_collector/can_be_unfasten_wrench(mob/user, silent)
if(!loaded_tank)
return ..()
if(!silent)
to_chat(user, span_warning("Remove the plasma tank first!"))
return FAILED_UNFASTEN

/obj/machinery/power/energy_accumulator/rad_collector/attackby(obj/item/item, mob/user, params)
if(istype(item, /obj/item/tank/internals/plasma))
if(!anchored)
to_chat(user, span_warning("[src] needs to be secured to the floor first!"))
return TRUE
if(loaded_tank)
to_chat(user, span_warning("There's already a plasma tank loaded!"))
return TRUE
if(panel_open)
to_chat(user, span_warning("Close the maintenance panel first!"))
return TRUE
if(!user.transferItemToLoc(item, src))
return
loaded_tank = item
update_appearance()
else if(item.GetID())
if(!allowed(user))
to_chat(user, span_danger("Access denied."))
return TRUE
if(!active)
to_chat(user, span_warning("The controls can only be locked when \the [src] is active!"))
return TRUE
locked = !locked
to_chat(user, span_notice("You [locked ? "lock" : "unlock"] the controls."))
return TRUE
else
return ..()

/obj/machinery/power/energy_accumulator/rad_collector/wrench_act(mob/living/user, obj/item/item)
. = ..()
default_unfasten_wrench(user, item)
return TRUE

/obj/machinery/power/energy_accumulator/rad_collector/screwdriver_act(mob/living/user, obj/item/item)
if(..())
return TRUE
if(!loaded_tank)
default_deconstruction_screwdriver(user, icon_state, icon_state, item)
return TRUE
to_chat(user, span_warning("Remove the plasma tank first!"))
return TRUE

/obj/machinery/power/energy_accumulator/rad_collector/crowbar_act(mob/living/user, obj/item/I)
if(loaded_tank)
if(!locked)
eject()
return TRUE
to_chat(user, span_warning("The controls are locked!"))
return TRUE
if(default_deconstruction_crowbar(I))
return TRUE
to_chat(user, span_warning("There isn't a tank loaded!"))
return TRUE

/obj/machinery/power/energy_accumulator/rad_collector/return_analyzable_air()
if(!loaded_tank)
return null
return loaded_tank.return_analyzable_air()

/obj/machinery/power/energy_accumulator/rad_collector/examine(mob/user)
. = ..()
if(!active)
. += span_notice("<b>[src]'s display displays the words:</b> \"Power production mode. Please insert <b>Plasma</b>.\"")
. += span_notice("[src]'s display states that it has stored <b>[display_joules(get_stored_joules())]</b>, and is processing <b>[display_power(get_power_output())]</b>.")

/obj/machinery/power/energy_accumulator/rad_collector/atom_break(damage_flag)
. = ..()
if(.)
eject()

/obj/machinery/power/energy_accumulator/rad_collector/RefreshParts()
. = ..()

// Reset the upgrades to base values
efficiency_multiplier = 1.0

// Calculate efficiency based on micro-laser parts
for(var/datum/stock_part/micro_laser/laser in component_parts)
efficiency_multiplier += (laser.tier - 1) * 0.2 // Each tier above 1 increases efficiency by 20%

/obj/machinery/power/energy_accumulator/rad_collector/proc/eject()
locked = FALSE
var/obj/item/tank/internals/plasma/tank = loaded_tank
if (!tank)
return
tank.forceMove(drop_location())
tank.layer = initial(tank.layer)
tank.plane = initial(tank.plane)
loaded_tank = null
if(active)
toggle_power()
else
update_appearance()

/obj/machinery/power/energy_accumulator/rad_collector/proc/hawking_pulse(atom/source, pulse_strength)
if(loaded_tank && active && pulse_strength > RAD_COLLECTOR_THRESHOLD)
// Adjust energy calculation based on efficiency multiplier
stored_energy += joules_to_energy((pulse_strength - RAD_COLLECTOR_THRESHOLD) * RAD_COLLECTOR_COEFFICIENT * efficiency_multiplier)
new /obj/effect/temp_visual/hawking_radiation(get_turf(src))

/obj/machinery/power/energy_accumulator/rad_collector/update_overlays()
. = ..()
if(loaded_tank)
. += "ptank"
if(machine_stat & (NOPOWER|BROKEN))
return
if(active)
. += "on" // SKYRAT EDIT CHANGE - ORIGINAL. += loaded_tank ? "on" : "error"

/obj/machinery/power/energy_accumulator/rad_collector/proc/toggle_power()
active = !active
if(active)
icon_state = "ca_on"
flick("ca_active", src)
else
icon_state = "ca"
flick("ca_deactive", src)
update_appearance()
return

#undef RAD_COLLECTOR_THRESHOLD
#undef RAD_COLLECTOR_COEFFICIENT


/obj/item/circuitboard/machine/rad_collector
name = "Radiation Collector(hawking)"
greyscale_colors = CIRCUIT_COLOR_ENGINEERING
build_path = /obj/machinery/power/energy_accumulator/rad_collector
req_components = list(
/datum/stock_part/micro_laser = 1,
/obj/item/stack/cable_coil = 2,
/obj/item/stack/sheet/glass = 2)
needs_anchored = FALSE
13 changes: 13 additions & 0 deletions modular_skyrat/modules/singularity_engine/code/emp_proof_door.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/obj/machinery/door/airlock/external/glass/emp_proof
name = "emp proof airlock"

/obj/machinery/door/airlock/external/glass/emp_proof/emp_act(severity)
return

/obj/machinery/power/apc/auto_name/emp_proof
name = "emp proof apc"

/obj/machinery/power/apc/auto_name/emp_proof/emp_act(severity)
return

MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/power/apc/auto_name/emp_proof, APC_PIXEL_OFFSET)
Loading
Loading