Skip to content

Commit

Permalink
[PORT] New bluespace harvester sprite from paradise and tweak (yogsta…
Browse files Browse the repository at this point in the history
…tion13#21250)

* ha

* a

* fix

* oh god

* fix 2

* ge
  • Loading branch information
warface1234455 authored Jan 20, 2024
1 parent 7e2e1f6 commit 2913aae
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 15 deletions.
122 changes: 107 additions & 15 deletions code/modules/goals/station_goals/bluespace_tap.dm
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,11 @@
/obj/machinery/power/bluespace_tap
name = "Bluespace harvester"
icon = 'icons/obj/machines/bluespace_tap.dmi'
icon_state = "bluespace_tap" //sprites by Ionward
icon_state = "bluespace_tap"
base_icon_state = "bluespace_tap"
max_integrity = 300
pixel_x = -32 //shamelessly stolen from dna vault
pixel_y = -64
pixel_y = -32
/// For faking having a big machine, dummy 'machines' that are hidden inside the large sprite and make certain tiles dense. See new and destroy.
var/list/obj/structure/fillers = list()
use_power = NO_POWER_USE // power usage is handelled manually
Expand Down Expand Up @@ -251,6 +252,8 @@
var/base_points = 100
/// How high the machine can be run before it starts having a chance for dimension breaches.
var/safe_levels = 10
/// When event triggers this will hold references to all portals so we can fix the sprite after they're broken
var/list/active_nether_portals = list()
var/emagged = FALSE

/// Cooldown to prevent spamming portal spawns without an emag
Expand All @@ -261,10 +264,8 @@
//more code stolen from dna vault, inculding comment below. Taking bets on that datum being made ever.
//TODO: Replace this,bsa and gravgen with some big machinery datum
var/list/occupied = list()
for(var/direct in list(EAST, WEST, SOUTHEAST, SOUTHWEST))
for(var/direct in list(NORTH, NORTHEAST, NORTHWEST, EAST, WEST, SOUTHEAST, SOUTHWEST))
occupied += get_step(src, direct)
occupied += locate(x + 1, y - 2, z)
occupied += locate(x - 1, y - 2, z)

for(var/T in occupied)
var/obj/structure/filler/F = new(T)
Expand All @@ -278,6 +279,72 @@
if(!powernet)
connect_to_network()

/obj/machinery/power/bluespace_tap/update_icon_state()
. = ..()

if(length(active_nether_portals))
icon_state = "redspace_tap"
return

if(avail() <= 0)
icon_state = base_icon_state
else
icon_state = "[base_icon_state][get_icon_state_number()]"


/obj/machinery/power/bluespace_tap/update_overlays()
. = ..()

underlays.Cut()

if(length(active_nether_portals))
. += "redspace"
. += "redspace_flash"
set_light(15, 5, "#ff0000")
return

if(stat & (BROKEN|NOPOWER))
set_light(0)
else
set_light(1, 1, "#353535")

if(avail())
. += "screen"
if(light)
underlays += mutable_appearance(icon, "light_mask")


/obj/machinery/power/bluespace_tap/proc/get_icon_state_number()
switch(input_level)
if(0)
return 0
if(1 to 2)
return 1
if(3 to 5)
return 2
if(6 to 7)
return 3
if(8 to 10)
return 4
if(11 to INFINITY)
return 5

/obj/machinery/power/bluespace_tap/power_change()
. = ..()
if(stat & (BROKEN|NOPOWER))
set_light(0)
else
set_light(1, 1, "#353535")


/obj/machinery/power/bluespace_tap/connect_to_network()
. = ..()
update_appearance(UPDATE_ICON)

/obj/machinery/power/bluespace_tap/disconnect_from_network()
. = ..()
update_appearance(UPDATE_ICON)

/obj/machinery/power/bluespace_tap/Destroy()
QDEL_LIST(fillers)
return ..()
Expand Down Expand Up @@ -322,9 +389,6 @@
* * t_level - The level we try to set it at, between 0 and max_level
*/
/obj/machinery/power/bluespace_tap/proc/set_level(t_level)
if(!COOLDOWN_FINISHED(src, emergency_shutdown))
desired_level = 0
return
if(t_level < 0)
return
if(t_level > max_level)
Expand All @@ -344,9 +408,14 @@
return power_needs[i_level]

/obj/machinery/power/bluespace_tap/process()
if(avail() && icon_state == "bluespace_tap")
update_appearance(UPDATE_ICON)
else if(!avail() && icon_state == "bluespace_tap0")
update_appearance(UPDATE_ICON)
actual_power_usage = get_power_use(input_level)
if(surplus() < actual_power_usage) //not enough power, so turn down a level
input_level--
update_appearance(UPDATE_ICON)
return // and no mining gets done
if(actual_power_usage)
add_load(actual_power_usage)
Expand All @@ -356,17 +425,26 @@
// actual input level changes slowly
if(input_level < desired_level && (surplus() >= get_power_use(input_level + 1)))
input_level++
update_appearance(UPDATE_ICON)
else if(input_level > desired_level)
input_level--
update_appearance(UPDATE_ICON)
if(prob(input_level - safe_levels + (emagged * 5))) //at dangerous levels, start doing freaky shit. prob with values less than 0 treat it as 0
priority_announce("Unexpected power spike during Bluespace Harvester Operation. Extra-dimensional intruder alert. Expected location: [get_area_name(src)]. [emagged ? "DANGER: Emergency shutdown failed! Please proceed with manual shutdown." : "Emergency shutdown initiated."]", "Bluespace Harvester Malfunction",sound = SSstation.announcer.get_rand_report_sound())
if(!emagged)
input_level = 0 //emergency shutdown unless we're sabotaged
desired_level = 0
COOLDOWN_START(src, emergency_shutdown, 10 MINUTES)
for(var/i in 1 to rand(1, 3))
var/turf/location = locate(x + rand(-5, 5), y + rand(-5, 5), z)
new /obj/structure/spawner/nether/bluespace_tap(location)
start_nether_portaling(rand(3,5))

/obj/machinery/power/bluespace_tap/proc/start_nether_portaling(amount)
var/turf/location = locate(x + rand(-5, -2) || rand(2, 5), y + rand(-5, -2) || rand(2, 5), z)
var/obj/structure/spawner/nether/bluespace_tap/P = new /obj/structure/spawner/nether/bluespace_tap(location)
amount--
active_nether_portals += P
P.linked_source_object = src
update_appearance(UPDATE_ICON)
if(amount)
addtimer(CALLBACK(src, PROC_REF(start_nether_portaling), amount), rand(3,5) SECONDS)



Expand Down Expand Up @@ -398,12 +476,18 @@

/obj/machinery/power/bluespace_tap/attack_hand(mob/user)
add_fingerprint(user)
if(length(active_nether_portals)) //this would be cool if we made unique TGUI for this
to_chat(user, span_warning("UNKNOWN INTERFERENCE ... UNRESPONSIVE"))
return
ui_interact(user)

/obj/machinery/power/bluespace_tap/attack_ghost(mob/user)
ui_interact(user)

/obj/machinery/power/bluespace_tap/attack_ai(mob/user)
if(length(active_nether_portals)) //this would be cool if we made unique TGUI for this
to_chat(user, span_warning("UNKNOWN INTERFERENCE ... UNRESPONSIVE"))
return
ui_interact(user)

/**
Expand All @@ -419,8 +503,9 @@
return
points -= A.product_cost
playsound(src, 'sound/magic/blink.ogg', 50)
flick_overlay_view(image(icon, src, "flash", layer+1), src, 6)
do_sparks(2, FALSE, src)
new A.product_path(get_step(src,(dir)))
new A.product_path(get_turf(src))



Expand Down Expand Up @@ -454,19 +539,26 @@
emagged = TRUE
do_sparks(5, FALSE, src)
if(user)
user.visible_message("<span class='warning'>[user] overrides the safety protocols of [src].</span>", "<span class='warning'>You override the safety protocols.</span>")
COOLDOWN_RESET(src, emergency_shutdown)
user.visible_message(span_warning("[user] overrides the safety protocols of [src]."), span_warning("You override the safety protocols."))
return TRUE

/obj/structure/spawner/nether/bluespace_tap
spawn_time = 30 SECONDS
max_mobs = 5 //Dont' want them overrunning the station
max_integrity = 250
/// the BSH that spawned this portal
var/obj/machinery/power/bluespace_tap/linked_source_object

/obj/structure/spawner/nether/bluespace_tap/deconstruct(disassembled)
new /obj/item/stack/ore/bluespace_crystal(loc) //have a reward
return ..()

/obj/structure/spawner/nether/bluespace_tap/Destroy()
. = ..()
if(linked_source_object)
linked_source_object.active_nether_portals -= src
linked_source_object.update_appearance(UPDATE_ICON)

/obj/item/paper/bluespace_tap
name = "paper- 'The Experimental NT Bluespace Harvester - Mining other universes for science and profit!'"
info = "<h1>Important Instructions!</h1>Please follow all setup instructions to ensure proper operation. <br>\
Expand Down
Binary file modified icons/obj/machines/bluespace_tap.dmi
Binary file not shown.

0 comments on commit 2913aae

Please sign in to comment.