diff --git a/code/modules/antagonists/clockcult/clock_effects/spatial_gateway.dm b/code/modules/antagonists/clockcult/clock_effects/spatial_gateway.dm index 36aaa27716..293625d9a7 100644 --- a/code/modules/antagonists/clockcult/clock_effects/spatial_gateway.dm +++ b/code/modules/antagonists/clockcult/clock_effects/spatial_gateway.dm @@ -14,6 +14,8 @@ var/uses = 1 //How many objects or mobs can go through the portal var/obj/effect/clockwork/spatial_gateway/linked_gateway //The gateway linked to this one var/timerid + var/is_stable = FALSE + var/busy = FALSE //If someone is already working on closing the gateway, only needed for stable gateways but in the parent to not need typecasting /obj/effect/clockwork/spatial_gateway/Initialize() . = ..() @@ -31,11 +33,16 @@ clockwork_desc = "A gateway in reality. It can both send and receive objects." else clockwork_desc = "A gateway in reality. It can only [sender ? "send" : "receive"] objects." - timerid = QDEL_IN(src, lifetime) + if(is_stable) + return + timerid = QDEL_IN(src, lifetime) //We only need this if the gateway is not stable //set up a gateway with another gateway /obj/effect/clockwork/spatial_gateway/proc/setup_gateway(obj/effect/clockwork/spatial_gateway/gatewayB, set_duration, set_uses, two_way) - if(!gatewayB || !set_duration || !uses) + if(!gatewayB) + return FALSE + + if((!set_duration || !uses) && !is_stable) return FALSE linked_gateway = gatewayB gatewayB.linked_gateway = src @@ -55,7 +62,7 @@ /obj/effect/clockwork/spatial_gateway/examine(mob/user) . = ..() if(is_servant_of_ratvar(user) || isobserver(user)) - . += "It has [uses] use\s remaining." + . += " [is_stable ? "It is stabilised and can be used as much as is neccessary." : "It has [uses] use\s remaining."]" //ATTACK GHOST IGNORING PARENT RETURN VALUE /obj/effect/clockwork/spatial_gateway/attack_ghost(mob/user) @@ -122,9 +129,9 @@ /obj/effect/clockwork/spatial_gateway/Bumped(atom/movable/AM) ..() if(!QDELETED(AM)) - pass_through_gateway(AM, FALSE) + pass_through_gateway(AM) -/obj/effect/clockwork/spatial_gateway/proc/pass_through_gateway(atom/movable/A, no_cost) +/obj/effect/clockwork/spatial_gateway/proc/pass_through_gateway(atom/movable/A, no_cost = FALSE) if(!linked_gateway) qdel(src) return FALSE @@ -198,6 +205,10 @@ return procure_gateway(invoker, time_duration, gateway_uses, two_way) var/istargetobelisk = istype(target, /obj/structure/destructible/clockwork/powered/clockwork_obelisk) var/issrcobelisk = istype(src, /obj/structure/destructible/clockwork/powered/clockwork_obelisk) + if(!issrcobelisk && target.z != invoker.z && (is_reebe(invoker.z) || is_reebe(target.z)) && !GLOB.ratvar_awakens) //You need obilisks to get from and to reebe. Costs alot of power, unless you use stable gateways. + to_chat(invoker, "The distance between reebe and the mortal realm is far too vast to bridge with a gateway your slab can create, my child. \ + Use an obilisk instead!") + return procure_gateway(invoker, time_duration, gateway_uses, two_way) if(issrcobelisk) if(!anchored) to_chat(invoker, "[src] is no longer secured!") @@ -218,12 +229,64 @@ gateway_uses = round(gateway_uses * (2 * efficiency), 1) time_duration = round(time_duration * (2 * efficiency), 1) CO.active = TRUE //you'd be active in a second but you should update immediately - invoker.visible_message("The air in front of [invoker] ripples before suddenly tearing open!", \ - "With a word, you rip open a [two_way ? "two-way":"one-way"] rift to [input_target_key]. It will last for [DisplayTimeText(time_duration)] and has [gateway_uses] use[gateway_uses > 1 ? "s" : ""].") - var/obj/effect/clockwork/spatial_gateway/S1 = new(issrcobelisk ? get_turf(src) : get_step(get_turf(invoker), invoker.dir)) - var/obj/effect/clockwork/spatial_gateway/S2 = new(istargetobelisk ? get_turf(target) : get_step(get_turf(target), target.dir)) + if(issrcobelisk && istargetobelisk && src.z != target.z && (is_reebe(src.z) || is_reebe(target.z))) + invoker.visible_message("The air in front of [invoker] ripples before suddenly tearing open!", \ + "With a word, you rip open a stable two-way rift between reebe and the mortal realm.") + var/obj/effect/clockwork/spatial_gateway/stable/stable_S1 = new(get_turf(src)) + var/obj/effect/clockwork/spatial_gateway/stable/stable_S2 = new(get_turf(target)) + stable_S1.setup_gateway(stable_S2) + stable_S2.visible_message("The air in front of [target] ripples before suddenly tearing open!") + else + invoker.visible_message("The air in front of [invoker] ripples before suddenly tearing open!", \ + "With a word, you rip open a [two_way ? "two-way":"one-way"] rift to [input_target_key]. It will last for [DisplayTimeText(time_duration)] and has [gateway_uses] use[gateway_uses > 1 ? "s" : ""].") + var/obj/effect/clockwork/spatial_gateway/S1 = new(issrcobelisk ? get_turf(src) : get_step(get_turf(invoker), invoker.dir)) + var/obj/effect/clockwork/spatial_gateway/S2 = new(istargetobelisk ? get_turf(target) : get_step(get_turf(target), target.dir)) - //Set up the portals now that they've spawned - S1.setup_gateway(S2, time_duration, gateway_uses, two_way) - S2.visible_message("The air in front of [target] ripples before suddenly tearing open!") + //Set up the portals now that they've spawned + S1.setup_gateway(S2, time_duration, gateway_uses, two_way) + S2.visible_message("The air in front of [target] ripples before suddenly tearing open!") return TRUE + +//Stable Gateway: Used to travel to and from reebe without any further powercost. Needs a clockwork obilisk to keep active, but stays active as long as it is not deactivated via an null rod or a slab, or the obilisk is destroyed +/obj/effect/clockwork/spatial_gateway/stable + name = "stable gateway" + is_stable = TRUE + //TODO: Icon for the gateway that looks a bit different + +/obj/effect/clockwork/spatial_gateway/stable/ex_act(severity) + if(severity == 1) + start_shutdown() //Yes, you can chain devastation-level explosions to delay a gateway shutdown, if you somehow manage to do it without breaking the obelisk. Is it worth it? Probably not. + return TRUE + return FALSE + +/obj/effect/clockwork/spatial_gateway/stable/setup_gateway(obj/effect/clockwork/spatial_gateway/stable/gatewayB) //Reduced setup call due to some things being irrelevant for stable gateways + return ..(gatewayB, 1, 1, TRUE) //Uses and time irrelevant due to is_stable + +/obj/effect/clockwork/spatial_gateway/stable/attackby(obj/item/I, mob/living/user, params) + if(!istype(I, /obj/item/clockwork/slab) || !is_servant_of_ratvar(user) || busy) + return ..() + user.visible_message("The rift begins to ripple as [user] points [user.p_their()] slab at it!", " You begin to shutdown the stabilised gateway with your slab.") + linked_gateway.visible_message("") + busy = TRUE + linked_gateway.busy = TRUE + if(do_after(user, 80, target = src)) //Eight seconds to initiate the closing, then another two before is closes. + to_chat(user, "You successfully set the gateway to shutdown in another two seconds.") + start_shutdown() + busy = FALSE + linked_gateway.busy = FALSE + return TRUE + //TODO: Add effect for this, maybe reuse the void blaster one from that PR? + + +/obj/effect/clockwork/spatial_gateway/stable/proc/start_shutdown() + deltimer(timerid) + deltimer(linked_gateway.timerid) + timerid = QDEL_IN(src, 20) + linked_gateway.timerid = QDEL_IN(linked_gateway, 20) + animate(src, alpha = 0, transform = matrix()*2, time = 20, flags = ANIMATION_END_NOW) + animate(linked_gateway, alpha = 0, transform = matrix()*2, time = 20, flags = ANIMATION_END_NOW) + src.visible_message("[src] begins to destabilise!") + linked_gateway.visible_message("[linked_gateway] begins to destabilise!") + +/obj/effect/clockwork/spatial_gateway/stable/pass_through_gateway(atom/movable/A, no_cost = TRUE) + return ..() \ No newline at end of file diff --git a/code/modules/antagonists/clockcult/clock_items/integration_cog.dm b/code/modules/antagonists/clockcult/clock_items/integration_cog.dm index 0ce70336fe..ab8e30c8bb 100644 --- a/code/modules/antagonists/clockcult/clock_items/integration_cog.dm +++ b/code/modules/antagonists/clockcult/clock_items/integration_cog.dm @@ -30,6 +30,7 @@ var/obj/item/stock_parts/cell/cell = apc.cell if(cell && (cell.charge / cell.maxcharge > COG_MAX_SIPHON_THRESHOLD)) cell.use(1) + apc.cog_drained++ adjust_clockwork_power(2) //Power is shared, so only do it once; this runs very quickly so it's about 10 W/second else adjust_clockwork_power(1) //Continue generating power when the cell has run dry; 5 W/second diff --git a/code/modules/antagonists/clockcult/clock_structures/clockwork_obelisk.dm b/code/modules/antagonists/clockcult/clock_structures/clockwork_obelisk.dm index 058bd9d24e..d9c3b047ca 100644 --- a/code/modules/antagonists/clockcult/clock_structures/clockwork_obelisk.dm +++ b/code/modules/antagonists/clockcult/clock_structures/clockwork_obelisk.dm @@ -41,6 +41,11 @@ affected += try_use_power(MIN_CLOCKCULT_POWER*4) return affected +/obj/structure/destructible/clockwork/powered/clockwork_obelisk/Destroy() + for(var/obj/effect/clockwork/spatial_gateway/SG in loc) + SG.ex_act(EXPLODE_DEVASTATE) + return ..() + /obj/structure/destructible/clockwork/powered/clockwork_obelisk/attack_hand(mob/living/user) . = ..() if(.) @@ -48,7 +53,7 @@ if(!is_servant_of_ratvar(user) || !can_access_clockwork_power(src, hierophant_cost) || !anchored) to_chat(user, "You place your hand on [src], but it doesn't react.") return - var/choice = alert(user,"You place your hand on [src]...",,"Hierophant Broadcast","Spatial Gateway","Cancel") + var/choice = alert(user,"You place your hand on [src]...",,"Hierophant Broadcast","Spatial Gateway","Cancel") //TODO: Find a good way to do this because choice / alert does only support up to six args, not seven as needed switch(choice) if("Hierophant Broadcast") if(active) @@ -96,7 +101,7 @@ if(!anchored) return var/obj/effect/clockwork/spatial_gateway/SG = locate(/obj/effect/clockwork/spatial_gateway) in loc - if(SG && SG.timerid) //it's a valid gateway, we're active + if(SG && (SG.timerid || SG.is_stable)) //it's a valid gateway, we're active icon_state = active_icon density = FALSE active = TRUE diff --git a/code/modules/power/apc.dm b/code/modules/power/apc.dm index 6772fe3cf1..3d6fde64dc 100644 --- a/code/modules/power/apc.dm +++ b/code/modules/power/apc.dm @@ -38,6 +38,8 @@ #define APC_CHARGING 1 #define APC_FULLY_CHARGED 2 +#define MAXIMUM_COG_REGAIN 100 //How much charge drained by an integration cog can be priority-recharged in one processing-tick + // the Area Power Controller (APC), formerly Power Distribution Unit (PDU) // one per area, needs wire connection to power network through a terminal @@ -94,6 +96,7 @@ var/mob/living/silicon/ai/occupier = null var/transfer_in_progress = FALSE //Is there an AI being transferred out of us? var/obj/item/clockwork/integration_cog/integration_cog //Is there a cog siphoning power? + var/cog_drained = 0 //How much of the cell's charge was drained by an integration cog, recovering this amount takes priority over the normal APC cell recharge calculations, but comes after powering Essentials. var/longtermpower = 10 var/auto_name = 0 var/failure_timer = 0 @@ -499,6 +502,7 @@ cell.forceMove(T) cell.update_icon() cell = null + cog_drained = 0 //No more cell means no more averting celldrain charging = APC_NOT_CHARGING update_icon() return @@ -701,7 +705,7 @@ START_PROCESSING(SSfastprocess, W) playsound(src, 'sound/machines/clockcult/steam_whoosh.ogg', 50, FALSE) opened = APC_COVER_CLOSED - locked = FALSE + locked = TRUE //Clockies get full APC access on cogged APCs, but they can't lock or unlock em unless they steal some ID to give all of them APC access, soo this is pretty much just QoL for them and makes cogs a tiny bit more stealthy update_icon() return else if(panel_open && !opened && is_wire_tool(W)) @@ -1314,6 +1318,11 @@ cur_used -= lastused_light lighting_satisfied = TRUE + //If drained by an integration cog: Forcefully avert as much of the powerdrain as possible, though a maximum of MAXIMUM_COG_REGAIN + if(cur_excess && cog_drained && cell) + var/cog_regain = cell.give(min(min(cog_drained, cur_excess), MAXIMUM_COG_REGAIN)) + cur_excess -= cog_regain + cog_drained = max(0, cog_drained - cog_regain) // next: take from or charge to the cell, depending on how much is left if(cell && !shorted) @@ -1576,6 +1585,8 @@ #undef APC_UPOVERLAY_LOCKED #undef APC_UPOVERLAY_OPERATING +#undef MAXIMUM_COG_REGAIN + /*Power module, used for APC construction*/ /obj/item/electronics/apc name = "power control module"