diff --git a/code/__DEFINES/misc_defines.dm b/code/__DEFINES/misc_defines.dm index 76e30a539b9..a5e9e129d50 100644 --- a/code/__DEFINES/misc_defines.dm +++ b/code/__DEFINES/misc_defines.dm @@ -605,3 +605,5 @@ #define TS_INFESTATION_WHITE_SPIDER 3 #define TS_INFESTATION_PRINCESS_SPIDER 4 #define TS_INFESTATION_QUEEN_SPIDER 5 + +#define MAX_ALLOWED_TELEPORTS_PER_PROCESS 20 diff --git a/code/game/machinery/teleporter.dm b/code/game/machinery/teleporter.dm index 66e3fefedcc..d29651d6385 100644 --- a/code/game/machinery/teleporter.dm +++ b/code/game/machinery/teleporter.dm @@ -307,9 +307,10 @@ /obj/machinery/teleport name = "teleport" - icon = 'icons/obj/stationobjs.dmi' density = TRUE anchored = TRUE + ///Used by the teleporter hub and permament teleporter to track how many teleports have been done this cycle. + var/teleports_this_cycle = 0 /** Internal helper function @@ -363,6 +364,9 @@ component_parts += new /obj/item/stock_parts/matter_bin/super(null) RefreshParts() +/obj/machinery/teleport/hub/process() + teleports_this_cycle = 0 + /obj/machinery/teleport/hub/Destroy() if(power_station) power_station.teleporter_hub = null @@ -418,6 +422,8 @@ var/obj/machinery/computer/teleporter/com = power_station.teleporter_console if(!com) return + if(MAX_ALLOWED_TELEPORTS_PER_PROCESS <= teleports_this_cycle) + return if(!com.target) visible_message("Cannot authenticate locked on coordinates. Please reinstate coordinate matrix.") return @@ -432,6 +438,7 @@ . = do_teleport(M, com.target, bypass_area_flag = com.area_bypass) if(accurate < 3) calibrated = FALSE + teleports_this_cycle++ /obj/machinery/teleport/hub/update_icon_state() if(panel_open) @@ -472,13 +479,16 @@ . = ..() update_lighting() +/obj/machinery/teleport/perma/process() + teleports_this_cycle = 0 + /obj/machinery/teleport/perma/RefreshParts() for(var/obj/item/circuitboard/teleporter_perma/C in component_parts) target = C.target var/A = 40 for(var/obj/item/stock_parts/matter_bin/M in component_parts) A -= M.rating * 10 - tele_delay = max(A, 1) // prevents you from teleporting 50000 times in a single tick + tele_delay = max(A, 0) update_icon(UPDATE_ICON_STATE) /obj/machinery/teleport/perma/Crossed(atom/movable/AM, oldloc) @@ -488,13 +498,15 @@ to_chat(AM, "You can't use this here.") return - if(target && !recalibrating && !panel_open && !blockAI(AM)) + if(target && !recalibrating && !panel_open && !blockAI(AM) && (teleports_this_cycle <= MAX_ALLOWED_TELEPORTS_PER_PROCESS)) do_teleport(AM, target) use_power(5000) - recalibrating = TRUE - update_icon(UPDATE_ICON_STATE | UPDATE_OVERLAYS) - update_lighting() - addtimer(CALLBACK(src, PROC_REF(CrossedCallback)), max(tele_delay, 1)) + teleports_this_cycle++ + if(tele_delay) + recalibrating = TRUE + update_icon(UPDATE_ICON_STATE | UPDATE_OVERLAYS) + update_lighting() + addtimer(CALLBACK(src, PROC_REF(CrossedCallback)), tele_delay) /obj/machinery/teleport/perma/proc/CrossedCallback() recalibrating = FALSE diff --git a/code/game/objects/effects/portals.dm b/code/game/objects/effects/portals.dm index bc80f56dbbb..e669ab95d37 100644 --- a/code/game/objects/effects/portals.dm +++ b/code/game/objects/effects/portals.dm @@ -24,6 +24,7 @@ var/effect_cooldown = 0 ///Whether or not portal use will cause sparks var/create_sparks = TRUE + var/teleports_this_cycle = 0 /obj/effect/portal/New(loc, turf/_target, obj/creation_object = null, lifespan = 300, mob/creation_mob = null, create_sparks = TRUE) ..() @@ -36,6 +37,7 @@ else creation_obj_data = list(null, null) creation_mob_ckey = creation_mob?.ckey + START_PROCESSING(SSobj, src) if(lifespan > 0) QDEL_IN(src, lifespan) @@ -48,8 +50,12 @@ target = null if(create_sparks) do_sparks(5, 0, loc) + STOP_PROCESSING(SSobj, src) return ..() +/obj/effect/portal/process() + teleports_this_cycle = 0 + /obj/effect/portal/singularity_pull() return @@ -132,6 +138,8 @@ return TRUE /obj/effect/portal/proc/attempt_teleport(atom/movable/victim, turf/destination, variance = 0, force_teleport = TRUE) + if(teleports_this_cycle >= MAX_ALLOWED_TELEPORTS_PER_PROCESS) + return var/use_effects = world.time >= effect_cooldown var/effect = null // Will result in the default effect being used if(!use_effects) @@ -141,6 +149,7 @@ invalid_teleport() return FALSE effect_cooldown = world.time + EFFECT_COOLDOWN + teleports_this_cycle++ return TRUE /obj/effect/portal/proc/invalid_teleport()